ls_hgl-setup.c 7.0 KB

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