ls-chl-setup.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. /*
  2. * arch/arm/mach-orion5x/ls-chl-setup.c
  3. *
  4. * Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk>
  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/gpio-fan.h>
  18. #include <linux/input.h>
  19. #include <linux/i2c.h>
  20. #include <linux/ata_platform.h>
  21. #include <linux/gpio.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include "common.h"
  25. #include "mpp.h"
  26. #include "orion5x.h"
  27. /*****************************************************************************
  28. * Linkstation LS-CHL Info
  29. ****************************************************************************/
  30. /*
  31. * 256K NOR flash Device bus boot chip select
  32. */
  33. #define LSCHL_NOR_BOOT_BASE 0xf4000000
  34. #define LSCHL_NOR_BOOT_SIZE SZ_256K
  35. /*****************************************************************************
  36. * 256KB NOR Flash on BOOT Device
  37. ****************************************************************************/
  38. static struct physmap_flash_data lschl_nor_flash_data = {
  39. .width = 1,
  40. };
  41. static struct resource lschl_nor_flash_resource = {
  42. .flags = IORESOURCE_MEM,
  43. .start = LSCHL_NOR_BOOT_BASE,
  44. .end = LSCHL_NOR_BOOT_BASE + LSCHL_NOR_BOOT_SIZE - 1,
  45. };
  46. static struct platform_device lschl_nor_flash = {
  47. .name = "physmap-flash",
  48. .id = 0,
  49. .dev = {
  50. .platform_data = &lschl_nor_flash_data,
  51. },
  52. .num_resources = 1,
  53. .resource = &lschl_nor_flash_resource,
  54. };
  55. /*****************************************************************************
  56. * Ethernet
  57. ****************************************************************************/
  58. static struct mv643xx_eth_platform_data lschl_eth_data = {
  59. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  60. };
  61. /*****************************************************************************
  62. * RTC 5C372a on I2C bus
  63. ****************************************************************************/
  64. static struct i2c_board_info __initdata lschl_i2c_rtc = {
  65. I2C_BOARD_INFO("rs5c372a", 0x32),
  66. };
  67. /*****************************************************************************
  68. * LEDs attached to GPIO
  69. ****************************************************************************/
  70. #define LSCHL_GPIO_LED_ALARM 2
  71. #define LSCHL_GPIO_LED_INFO 3
  72. #define LSCHL_GPIO_LED_FUNC 17
  73. #define LSCHL_GPIO_LED_PWR 0
  74. static struct gpio_led lschl_led_pins[] = {
  75. {
  76. .name = "alarm:red",
  77. .gpio = LSCHL_GPIO_LED_ALARM,
  78. .active_low = 1,
  79. }, {
  80. .name = "info:amber",
  81. .gpio = LSCHL_GPIO_LED_INFO,
  82. .active_low = 1,
  83. }, {
  84. .name = "func:blue:top",
  85. .gpio = LSCHL_GPIO_LED_FUNC,
  86. .active_low = 1,
  87. }, {
  88. .name = "power:blue:bottom",
  89. .gpio = LSCHL_GPIO_LED_PWR,
  90. },
  91. };
  92. static struct gpio_led_platform_data lschl_led_data = {
  93. .leds = lschl_led_pins,
  94. .num_leds = ARRAY_SIZE(lschl_led_pins),
  95. };
  96. static struct platform_device lschl_leds = {
  97. .name = "leds-gpio",
  98. .id = -1,
  99. .dev = {
  100. .platform_data = &lschl_led_data,
  101. },
  102. };
  103. /*****************************************************************************
  104. * SATA
  105. ****************************************************************************/
  106. static struct mv_sata_platform_data lschl_sata_data = {
  107. .n_ports = 2,
  108. };
  109. /*****************************************************************************
  110. * LS-CHL specific power off method: reboot
  111. ****************************************************************************/
  112. /*
  113. * On the LS-CHL, the shutdown process is following:
  114. * - Userland monitors key events until the power switch goes to off position
  115. * - The board reboots
  116. * - U-boot starts and goes into an idle mode waiting for the user
  117. * to move the switch to ON position
  118. *
  119. */
  120. static void lschl_power_off(void)
  121. {
  122. orion5x_restart(REBOOT_HARD, NULL);
  123. }
  124. /*****************************************************************************
  125. * General Setup
  126. ****************************************************************************/
  127. #define LSCHL_GPIO_USB_POWER 9
  128. #define LSCHL_GPIO_AUTO_POWER 17
  129. #define LSCHL_GPIO_POWER 18
  130. /****************************************************************************
  131. * GPIO Attached Keys
  132. ****************************************************************************/
  133. #define LSCHL_GPIO_KEY_FUNC 15
  134. #define LSCHL_GPIO_KEY_POWER 8
  135. #define LSCHL_GPIO_KEY_AUTOPOWER 10
  136. #define LSCHL_SW_POWER 0x00
  137. #define LSCHL_SW_AUTOPOWER 0x01
  138. #define LSCHL_SW_FUNC 0x02
  139. static struct gpio_keys_button lschl_buttons[] = {
  140. {
  141. .type = EV_SW,
  142. .code = LSCHL_SW_POWER,
  143. .gpio = LSCHL_GPIO_KEY_POWER,
  144. .desc = "Power-on Switch",
  145. .active_low = 1,
  146. }, {
  147. .type = EV_SW,
  148. .code = LSCHL_SW_AUTOPOWER,
  149. .gpio = LSCHL_GPIO_KEY_AUTOPOWER,
  150. .desc = "Power-auto Switch",
  151. .active_low = 1,
  152. }, {
  153. .type = EV_SW,
  154. .code = LSCHL_SW_FUNC,
  155. .gpio = LSCHL_GPIO_KEY_FUNC,
  156. .desc = "Function Switch",
  157. .active_low = 1,
  158. },
  159. };
  160. static struct gpio_keys_platform_data lschl_button_data = {
  161. .buttons = lschl_buttons,
  162. .nbuttons = ARRAY_SIZE(lschl_buttons),
  163. };
  164. static struct platform_device lschl_button_device = {
  165. .name = "gpio-keys",
  166. .id = -1,
  167. .num_resources = 0,
  168. .dev = {
  169. .platform_data = &lschl_button_data,
  170. },
  171. };
  172. #define LSCHL_GPIO_HDD_POWER 1
  173. /****************************************************************************
  174. * GPIO Fan
  175. ****************************************************************************/
  176. #define LSCHL_GPIO_FAN_LOW 16
  177. #define LSCHL_GPIO_FAN_HIGH 14
  178. #define LSCHL_GPIO_FAN_LOCK 6
  179. static struct gpio_fan_alarm lschl_alarm = {
  180. .gpio = LSCHL_GPIO_FAN_LOCK,
  181. };
  182. static struct gpio_fan_speed lschl_speeds[] = {
  183. {
  184. .rpm = 0,
  185. .ctrl_val = 3,
  186. }, {
  187. .rpm = 1500,
  188. .ctrl_val = 2,
  189. }, {
  190. .rpm = 3250,
  191. .ctrl_val = 1,
  192. }, {
  193. .rpm = 5000,
  194. .ctrl_val = 0,
  195. },
  196. };
  197. static int lschl_gpio_list[] = {
  198. LSCHL_GPIO_FAN_HIGH, LSCHL_GPIO_FAN_LOW,
  199. };
  200. static struct gpio_fan_platform_data lschl_fan_data = {
  201. .num_ctrl = ARRAY_SIZE(lschl_gpio_list),
  202. .ctrl = lschl_gpio_list,
  203. .alarm = &lschl_alarm,
  204. .num_speed = ARRAY_SIZE(lschl_speeds),
  205. .speed = lschl_speeds,
  206. };
  207. static struct platform_device lschl_fan_device = {
  208. .name = "gpio-fan",
  209. .id = -1,
  210. .num_resources = 0,
  211. .dev = {
  212. .platform_data = &lschl_fan_data,
  213. },
  214. };
  215. /****************************************************************************
  216. * GPIO Data
  217. ****************************************************************************/
  218. static unsigned int lschl_mpp_modes[] __initdata = {
  219. MPP0_GPIO, /* LED POWER */
  220. MPP1_GPIO, /* HDD POWER */
  221. MPP2_GPIO, /* LED ALARM */
  222. MPP3_GPIO, /* LED INFO */
  223. MPP4_UNUSED,
  224. MPP5_UNUSED,
  225. MPP6_GPIO, /* FAN LOCK */
  226. MPP7_GPIO, /* SW INIT */
  227. MPP8_GPIO, /* SW POWER */
  228. MPP9_GPIO, /* USB POWER */
  229. MPP10_GPIO, /* SW AUTO POWER */
  230. MPP11_UNUSED,
  231. MPP12_UNUSED,
  232. MPP13_UNUSED,
  233. MPP14_GPIO, /* FAN HIGH */
  234. MPP15_GPIO, /* SW FUNC */
  235. MPP16_GPIO, /* FAN LOW */
  236. MPP17_GPIO, /* LED FUNC */
  237. MPP18_UNUSED,
  238. MPP19_UNUSED,
  239. 0,
  240. };
  241. static void __init lschl_init(void)
  242. {
  243. /*
  244. * Setup basic Orion functions. Needs to be called early.
  245. */
  246. orion5x_init();
  247. orion5x_mpp_conf(lschl_mpp_modes);
  248. /*
  249. * Configure peripherals.
  250. */
  251. orion5x_ehci0_init();
  252. orion5x_ehci1_init();
  253. orion5x_eth_init(&lschl_eth_data);
  254. orion5x_i2c_init();
  255. orion5x_sata_init(&lschl_sata_data);
  256. orion5x_uart0_init();
  257. orion5x_xor_init();
  258. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  259. ORION_MBUS_DEVBUS_BOOT_ATTR,
  260. LSCHL_NOR_BOOT_BASE,
  261. LSCHL_NOR_BOOT_SIZE);
  262. platform_device_register(&lschl_nor_flash);
  263. platform_device_register(&lschl_leds);
  264. platform_device_register(&lschl_button_device);
  265. platform_device_register(&lschl_fan_device);
  266. i2c_register_board_info(0, &lschl_i2c_rtc, 1);
  267. /* usb power on */
  268. gpio_set_value(LSCHL_GPIO_USB_POWER, 1);
  269. /* register power-off method */
  270. pm_power_off = lschl_power_off;
  271. pr_info("%s: finished\n", __func__);
  272. }
  273. MACHINE_START(LINKSTATION_LSCHL, "Buffalo Linkstation LiveV3 (LS-CHL)")
  274. /* Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk> */
  275. .atag_offset = 0x100,
  276. .nr_irqs = ORION5X_NR_IRQS,
  277. .init_machine = lschl_init,
  278. .map_io = orion5x_map_io,
  279. .init_early = orion5x_init_early,
  280. .init_irq = orion5x_init_irq,
  281. .init_time = orion5x_timer_init,
  282. .fixup = tag_fixup_mem32,
  283. .restart = orion5x_restart,
  284. MACHINE_END