t5325-setup.c 4.6 KB

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