ls-chl-setup.c 8.3 KB

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