ls_hgl-setup.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. * arch/arm/mach-orion5x/ls_hgl-setup.c
  3. *
  4. * Maintainer: Zhu Qingsen <zhuqs@cn.fujitsu.com>
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/mv643xx_eth.h>
  15. #include <linux/leds.h>
  16. #include <linux/gpio_keys.h>
  17. #include <linux/input.h>
  18. #include <linux/i2c.h>
  19. #include <linux/ata_platform.h>
  20. #include <linux/gpio.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/system.h>
  24. #include <mach/orion5x.h>
  25. #include "common.h"
  26. #include "mpp.h"
  27. /*****************************************************************************
  28. * Linkstation LS-HGL Info
  29. ****************************************************************************/
  30. /*
  31. * 256K NOR flash Device bus boot chip select
  32. */
  33. #define LS_HGL_NOR_BOOT_BASE 0xf4000000
  34. #define LS_HGL_NOR_BOOT_SIZE SZ_256K
  35. /*****************************************************************************
  36. * 256KB NOR Flash on BOOT Device
  37. ****************************************************************************/
  38. static struct physmap_flash_data ls_hgl_nor_flash_data = {
  39. .width = 1,
  40. };
  41. static struct resource ls_hgl_nor_flash_resource = {
  42. .flags = IORESOURCE_MEM,
  43. .start = LS_HGL_NOR_BOOT_BASE,
  44. .end = LS_HGL_NOR_BOOT_BASE + LS_HGL_NOR_BOOT_SIZE - 1,
  45. };
  46. static struct platform_device ls_hgl_nor_flash = {
  47. .name = "physmap-flash",
  48. .id = 0,
  49. .dev = {
  50. .platform_data = &ls_hgl_nor_flash_data,
  51. },
  52. .num_resources = 1,
  53. .resource = &ls_hgl_nor_flash_resource,
  54. };
  55. /*****************************************************************************
  56. * Ethernet
  57. ****************************************************************************/
  58. static struct mv643xx_eth_platform_data ls_hgl_eth_data = {
  59. .phy_addr = 8,
  60. };
  61. /*****************************************************************************
  62. * RTC 5C372a on I2C bus
  63. ****************************************************************************/
  64. static struct i2c_board_info __initdata ls_hgl_i2c_rtc = {
  65. I2C_BOARD_INFO("rs5c372a", 0x32),
  66. };
  67. /*****************************************************************************
  68. * LEDs attached to GPIO
  69. ****************************************************************************/
  70. #define LS_HGL_GPIO_LED_ALARM 2
  71. #define LS_HGL_GPIO_LED_INFO 3
  72. #define LS_HGL_GPIO_LED_FUNC 17
  73. #define LS_HGL_GPIO_LED_PWR 0
  74. static struct gpio_led ls_hgl_led_pins[] = {
  75. {
  76. .name = "alarm:red",
  77. .gpio = LS_HGL_GPIO_LED_ALARM,
  78. .active_low = 1,
  79. }, {
  80. .name = "info:amber",
  81. .gpio = LS_HGL_GPIO_LED_INFO,
  82. .active_low = 1,
  83. }, {
  84. .name = "func:blue:top",
  85. .gpio = LS_HGL_GPIO_LED_FUNC,
  86. .active_low = 1,
  87. }, {
  88. .name = "power:blue:bottom",
  89. .gpio = LS_HGL_GPIO_LED_PWR,
  90. },
  91. };
  92. static struct gpio_led_platform_data ls_hgl_led_data = {
  93. .leds = ls_hgl_led_pins,
  94. .num_leds = ARRAY_SIZE(ls_hgl_led_pins),
  95. };
  96. static struct platform_device ls_hgl_leds = {
  97. .name = "leds-gpio",
  98. .id = -1,
  99. .dev = {
  100. .platform_data = &ls_hgl_led_data,
  101. },
  102. };
  103. /****************************************************************************
  104. * GPIO Attached Keys
  105. ****************************************************************************/
  106. #define LS_HGL_GPIO_KEY_FUNC 15
  107. #define LS_HGL_GPIO_KEY_POWER 8
  108. #define LS_HGL_GPIO_KEY_AUTOPOWER 10
  109. #define LS_HGL_SW_POWER 0x00
  110. #define LS_HGL_SW_AUTOPOWER 0x01
  111. static struct gpio_keys_button ls_hgl_buttons[] = {
  112. {
  113. .code = KEY_OPTION,
  114. .gpio = LS_HGL_GPIO_KEY_FUNC,
  115. .desc = "Function Button",
  116. .active_low = 1,
  117. }, {
  118. .type = EV_SW,
  119. .code = LS_HGL_SW_POWER,
  120. .gpio = LS_HGL_GPIO_KEY_POWER,
  121. .desc = "Power-on Switch",
  122. .active_low = 1,
  123. }, {
  124. .type = EV_SW,
  125. .code = LS_HGL_SW_AUTOPOWER,
  126. .gpio = LS_HGL_GPIO_KEY_AUTOPOWER,
  127. .desc = "Power-auto Switch",
  128. .active_low = 1,
  129. },
  130. };
  131. static struct gpio_keys_platform_data ls_hgl_button_data = {
  132. .buttons = ls_hgl_buttons,
  133. .nbuttons = ARRAY_SIZE(ls_hgl_buttons),
  134. };
  135. static struct platform_device ls_hgl_button_device = {
  136. .name = "gpio-keys",
  137. .id = -1,
  138. .num_resources = 0,
  139. .dev = {
  140. .platform_data = &ls_hgl_button_data,
  141. },
  142. };
  143. /*****************************************************************************
  144. * SATA
  145. ****************************************************************************/
  146. static struct mv_sata_platform_data ls_hgl_sata_data = {
  147. .n_ports = 2,
  148. };
  149. /*****************************************************************************
  150. * Linkstation LS-HGL specific power off method: reboot
  151. ****************************************************************************/
  152. /*
  153. * On the Linkstation LS-HGL, the shutdown process is following:
  154. * - Userland monitors key events until the power switch goes to off position
  155. * - The board reboots
  156. * - U-boot starts and goes into an idle mode waiting for the user
  157. * to move the switch to ON position
  158. */
  159. static void ls_hgl_power_off(void)
  160. {
  161. arm_machine_restart('h', NULL);
  162. }
  163. /*****************************************************************************
  164. * General Setup
  165. ****************************************************************************/
  166. #define LS_HGL_GPIO_USB_POWER 9
  167. #define LS_HGL_GPIO_AUTO_POWER 10
  168. #define LS_HGL_GPIO_POWER 8
  169. #define LS_HGL_GPIO_HDD_POWER 1
  170. static struct orion5x_mpp_mode ls_hgl_mpp_modes[] __initdata = {
  171. { 0, MPP_GPIO }, /* LED_PWR */
  172. { 1, MPP_GPIO }, /* HDD_PWR */
  173. { 2, MPP_GPIO }, /* LED_ALARM */
  174. { 3, MPP_GPIO }, /* LED_INFO */
  175. { 4, MPP_UNUSED },
  176. { 5, MPP_UNUSED },
  177. { 6, MPP_GPIO }, /* FAN_LCK */
  178. { 7, MPP_GPIO }, /* INIT */
  179. { 8, MPP_GPIO }, /* POWER */
  180. { 9, MPP_GPIO }, /* USB_PWR */
  181. { 10, MPP_GPIO }, /* AUTO_POWER */
  182. { 11, MPP_UNUSED }, /* LED_ETH (dummy) */
  183. { 12, MPP_UNUSED },
  184. { 13, MPP_UNUSED },
  185. { 14, MPP_UNUSED },
  186. { 15, MPP_GPIO }, /* FUNC */
  187. { 16, MPP_UNUSED },
  188. { 17, MPP_GPIO }, /* LED_FUNC */
  189. { 18, MPP_UNUSED },
  190. { 19, MPP_UNUSED },
  191. { -1 },
  192. };
  193. static void __init ls_hgl_init(void)
  194. {
  195. /*
  196. * Setup basic Orion functions. Need to be called early.
  197. */
  198. orion5x_init();
  199. orion5x_mpp_conf(ls_hgl_mpp_modes);
  200. /*
  201. * Configure peripherals.
  202. */
  203. orion5x_ehci0_init();
  204. orion5x_ehci1_init();
  205. orion5x_eth_init(&ls_hgl_eth_data);
  206. orion5x_i2c_init();
  207. orion5x_sata_init(&ls_hgl_sata_data);
  208. orion5x_uart0_init();
  209. orion5x_xor_init();
  210. orion5x_setup_dev_boot_win(LS_HGL_NOR_BOOT_BASE,
  211. LS_HGL_NOR_BOOT_SIZE);
  212. platform_device_register(&ls_hgl_nor_flash);
  213. platform_device_register(&ls_hgl_button_device);
  214. platform_device_register(&ls_hgl_leds);
  215. i2c_register_board_info(0, &ls_hgl_i2c_rtc, 1);
  216. /* enable USB power */
  217. gpio_set_value(LS_HGL_GPIO_USB_POWER, 1);
  218. /* register power-off method */
  219. pm_power_off = ls_hgl_power_off;
  220. pr_info("%s: finished\n", __func__);
  221. }
  222. MACHINE_START(LINKSTATION_LS_HGL, "Buffalo Linkstation LS-HGL")
  223. /* Maintainer: Zhu Qingsen <zhuqs@cn.fujistu.com> */
  224. .boot_params = 0x00000100,
  225. .init_machine = ls_hgl_init,
  226. .map_io = orion5x_map_io,
  227. .init_early = orion5x_init_early,
  228. .init_irq = orion5x_init_irq,
  229. .timer = &orion5x_timer,
  230. .fixup = tag_fixup_mem32,
  231. MACHINE_END