t5325-setup.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. *
  3. * HP t5325 Thin Client setup
  4. *
  5. * Copyright (C) 2010 Martin Michlmayr <tbm@cyrius.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/spi/flash.h>
  17. #include <linux/spi/spi.h>
  18. #include <linux/spi/orion_spi.h>
  19. #include <linux/i2c.h>
  20. #include <linux/mv643xx_eth.h>
  21. #include <linux/ata_platform.h>
  22. #include <linux/gpio.h>
  23. #include <linux/gpio_keys.h>
  24. #include <linux/input.h>
  25. #include <sound/alc5623.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <mach/kirkwood.h>
  29. #include "common.h"
  30. #include "mpp.h"
  31. struct mtd_partition hp_t5325_partitions[] = {
  32. {
  33. .name = "u-boot env",
  34. .size = SZ_64K,
  35. .offset = SZ_512K + SZ_256K,
  36. },
  37. {
  38. .name = "permanent u-boot env",
  39. .size = SZ_64K,
  40. .offset = MTDPART_OFS_APPEND,
  41. .mask_flags = MTD_WRITEABLE,
  42. },
  43. {
  44. .name = "HP env",
  45. .size = SZ_64K,
  46. .offset = MTDPART_OFS_APPEND,
  47. },
  48. {
  49. .name = "u-boot",
  50. .size = SZ_512K,
  51. .offset = 0,
  52. .mask_flags = MTD_WRITEABLE,
  53. },
  54. {
  55. .name = "SSD firmware",
  56. .size = SZ_256K,
  57. .offset = SZ_512K,
  58. },
  59. };
  60. const struct flash_platform_data hp_t5325_flash = {
  61. .type = "mx25l8005",
  62. .name = "spi_flash",
  63. .parts = hp_t5325_partitions,
  64. .nr_parts = ARRAY_SIZE(hp_t5325_partitions),
  65. };
  66. struct spi_board_info __initdata hp_t5325_spi_slave_info[] = {
  67. {
  68. .modalias = "m25p80",
  69. .platform_data = &hp_t5325_flash,
  70. .irq = -1,
  71. },
  72. };
  73. static struct mv643xx_eth_platform_data hp_t5325_ge00_data = {
  74. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  75. };
  76. static struct mv_sata_platform_data hp_t5325_sata_data = {
  77. .n_ports = 2,
  78. };
  79. static struct gpio_keys_button hp_t5325_buttons[] = {
  80. {
  81. .code = KEY_POWER,
  82. .gpio = 45,
  83. .desc = "Power",
  84. .active_low = 1,
  85. },
  86. };
  87. static struct gpio_keys_platform_data hp_t5325_button_data = {
  88. .buttons = hp_t5325_buttons,
  89. .nbuttons = ARRAY_SIZE(hp_t5325_buttons),
  90. };
  91. static struct platform_device hp_t5325_button_device = {
  92. .name = "gpio-keys",
  93. .id = -1,
  94. .num_resources = 0,
  95. .dev = {
  96. .platform_data = &hp_t5325_button_data,
  97. }
  98. };
  99. static struct platform_device hp_t5325_audio_device = {
  100. .name = "t5325-audio",
  101. .id = -1,
  102. };
  103. static unsigned int hp_t5325_mpp_config[] __initdata = {
  104. MPP0_NF_IO2,
  105. MPP1_SPI_MOSI,
  106. MPP2_SPI_SCK,
  107. MPP3_SPI_MISO,
  108. MPP4_NF_IO6,
  109. MPP5_NF_IO7,
  110. MPP6_SYSRST_OUTn,
  111. MPP7_SPI_SCn,
  112. MPP8_TW0_SDA,
  113. MPP9_TW0_SCK,
  114. MPP10_UART0_TXD,
  115. MPP11_UART0_RXD,
  116. MPP12_SD_CLK,
  117. MPP13_GPIO,
  118. MPP14_GPIO,
  119. MPP15_GPIO,
  120. MPP16_GPIO,
  121. MPP17_GPIO,
  122. MPP18_NF_IO0,
  123. MPP19_NF_IO1,
  124. MPP20_GPIO,
  125. MPP21_GPIO,
  126. MPP22_GPIO,
  127. MPP23_GPIO,
  128. MPP32_GPIO,
  129. MPP33_GE1_TXCTL,
  130. MPP39_AU_I2SBCLK,
  131. MPP40_AU_I2SDO,
  132. MPP43_AU_I2SDI,
  133. MPP41_AU_I2SLRCLK,
  134. MPP42_AU_I2SMCLK,
  135. MPP45_GPIO, /* Power button */
  136. MPP48_GPIO, /* Board power off */
  137. 0
  138. };
  139. static struct alc5623_platform_data alc5621_data = {
  140. .add_ctrl = 0x3700,
  141. .jack_det_ctrl = 0x4810,
  142. };
  143. static struct i2c_board_info i2c_board_info[] __initdata = {
  144. {
  145. I2C_BOARD_INFO("alc5621", 0x1a),
  146. .platform_data = &alc5621_data,
  147. },
  148. };
  149. #define HP_T5325_GPIO_POWER_OFF 48
  150. static void hp_t5325_power_off(void)
  151. {
  152. gpio_set_value(HP_T5325_GPIO_POWER_OFF, 1);
  153. }
  154. static void __init hp_t5325_init(void)
  155. {
  156. /*
  157. * Basic setup. Needs to be called early.
  158. */
  159. kirkwood_init();
  160. kirkwood_mpp_conf(hp_t5325_mpp_config);
  161. kirkwood_uart0_init();
  162. spi_register_board_info(hp_t5325_spi_slave_info,
  163. ARRAY_SIZE(hp_t5325_spi_slave_info));
  164. kirkwood_spi_init();
  165. kirkwood_i2c_init();
  166. kirkwood_ge00_init(&hp_t5325_ge00_data);
  167. kirkwood_sata_init(&hp_t5325_sata_data);
  168. kirkwood_ehci_init();
  169. platform_device_register(&hp_t5325_button_device);
  170. platform_device_register(&hp_t5325_audio_device);
  171. i2c_register_board_info(0, i2c_board_info, ARRAY_SIZE(i2c_board_info));
  172. kirkwood_audio_init();
  173. if (gpio_request(HP_T5325_GPIO_POWER_OFF, "power-off") == 0 &&
  174. gpio_direction_output(HP_T5325_GPIO_POWER_OFF, 0) == 0)
  175. pm_power_off = hp_t5325_power_off;
  176. else
  177. pr_err("t5325: failed to configure power-off GPIO\n");
  178. }
  179. static int __init hp_t5325_pci_init(void)
  180. {
  181. if (machine_is_t5325())
  182. kirkwood_pcie_init(KW_PCIE0);
  183. return 0;
  184. }
  185. subsys_initcall(hp_t5325_pci_init);
  186. MACHINE_START(T5325, "HP t5325 Thin Client")
  187. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  188. .atag_offset = 0x100,
  189. .init_machine = hp_t5325_init,
  190. .map_io = kirkwood_map_io,
  191. .init_early = kirkwood_init_early,
  192. .init_irq = kirkwood_init_irq,
  193. .timer = &kirkwood_timer,
  194. .restart = kirkwood_restart,
  195. MACHINE_END