ls_hgl-setup.c 7.1 KB

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