t5325-setup.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <mach/kirkwood.h>
  28. #include "common.h"
  29. #include "mpp.h"
  30. 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. 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. 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 unsigned int hp_t5325_mpp_config[] __initdata = {
  99. MPP0_NF_IO2,
  100. MPP1_SPI_MOSI,
  101. MPP2_SPI_SCK,
  102. MPP3_SPI_MISO,
  103. MPP4_NF_IO6,
  104. MPP5_NF_IO7,
  105. MPP6_SYSRST_OUTn,
  106. MPP7_SPI_SCn,
  107. MPP8_TW0_SDA,
  108. MPP9_TW0_SCK,
  109. MPP10_UART0_TXD,
  110. MPP11_UART0_RXD,
  111. MPP12_SD_CLK,
  112. MPP13_GPIO,
  113. MPP14_GPIO,
  114. MPP15_GPIO,
  115. MPP16_GPIO,
  116. MPP17_GPIO,
  117. MPP18_NF_IO0,
  118. MPP19_NF_IO1,
  119. MPP20_GPIO,
  120. MPP21_GPIO,
  121. MPP22_GPIO,
  122. MPP23_GPIO,
  123. MPP32_GPIO,
  124. MPP33_GE1_TXCTL,
  125. MPP39_AU_I2SBCLK,
  126. MPP40_AU_I2SDO,
  127. MPP41_AU_I2SLRCLK,
  128. MPP42_AU_I2SMCLK,
  129. MPP45_GPIO, /* Power button */
  130. MPP48_GPIO, /* Board power off */
  131. 0
  132. };
  133. #define HP_T5325_GPIO_POWER_OFF 48
  134. static void hp_t5325_power_off(void)
  135. {
  136. gpio_set_value(HP_T5325_GPIO_POWER_OFF, 1);
  137. }
  138. static void __init hp_t5325_init(void)
  139. {
  140. /*
  141. * Basic setup. Needs to be called early.
  142. */
  143. kirkwood_init();
  144. kirkwood_mpp_conf(hp_t5325_mpp_config);
  145. kirkwood_uart0_init();
  146. spi_register_board_info(hp_t5325_spi_slave_info,
  147. ARRAY_SIZE(hp_t5325_spi_slave_info));
  148. kirkwood_spi_init();
  149. kirkwood_i2c_init();
  150. kirkwood_ge00_init(&hp_t5325_ge00_data);
  151. kirkwood_sata_init(&hp_t5325_sata_data);
  152. kirkwood_ehci_init();
  153. platform_device_register(&hp_t5325_button_device);
  154. if (gpio_request(HP_T5325_GPIO_POWER_OFF, "power-off") == 0 &&
  155. gpio_direction_output(HP_T5325_GPIO_POWER_OFF, 0) == 0)
  156. pm_power_off = hp_t5325_power_off;
  157. else
  158. pr_err("t5325: failed to configure power-off GPIO\n");
  159. }
  160. static int __init hp_t5325_pci_init(void)
  161. {
  162. if (machine_is_t5325())
  163. kirkwood_pcie_init(KW_PCIE0);
  164. return 0;
  165. }
  166. subsys_initcall(hp_t5325_pci_init);
  167. MACHINE_START(T5325, "HP t5325 Thin Client")
  168. /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
  169. .phys_io = KIRKWOOD_REGS_PHYS_BASE,
  170. .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
  171. .boot_params = 0x00000100,
  172. .init_machine = hp_t5325_init,
  173. .map_io = kirkwood_map_io,
  174. .init_irq = kirkwood_init_irq,
  175. .timer = &kirkwood_timer,
  176. MACHINE_END