lsmini-setup.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /*
  2. * arch/arm/mach-orion5x/lsmini-setup.c
  3. *
  4. * Maintainer: Alexey Kopytko <alexey@kopytko.ru>
  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/pci.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <linux/mv643xx_eth.h>
  16. #include <linux/leds.h>
  17. #include <linux/gpio_keys.h>
  18. #include <linux/input.h>
  19. #include <linux/i2c.h>
  20. #include <linux/ata_platform.h>
  21. #include <asm/mach-types.h>
  22. #include <linux/gpio.h>
  23. #include <asm/mach/arch.h>
  24. #include "common.h"
  25. #include "mpp.h"
  26. #include "include/mach/system.h"
  27. /*****************************************************************************
  28. * Linkstation Mini Info
  29. ****************************************************************************/
  30. /*
  31. * 256K NOR flash Device bus boot chip select
  32. */
  33. #define LSMINI_NOR_BOOT_BASE 0xf4000000
  34. #define LSMINI_NOR_BOOT_SIZE SZ_256K
  35. /*****************************************************************************
  36. * 256KB NOR Flash on BOOT Device
  37. ****************************************************************************/
  38. static struct physmap_flash_data lsmini_nor_flash_data = {
  39. .width = 1,
  40. };
  41. static struct resource lsmini_nor_flash_resource = {
  42. .flags = IORESOURCE_MEM,
  43. .start = LSMINI_NOR_BOOT_BASE,
  44. .end = LSMINI_NOR_BOOT_BASE + LSMINI_NOR_BOOT_SIZE - 1,
  45. };
  46. static struct platform_device lsmini_nor_flash = {
  47. .name = "physmap-flash",
  48. .id = 0,
  49. .dev = {
  50. .platform_data = &lsmini_nor_flash_data,
  51. },
  52. .num_resources = 1,
  53. .resource = &lsmini_nor_flash_resource,
  54. };
  55. /*****************************************************************************
  56. * Ethernet
  57. ****************************************************************************/
  58. static struct mv643xx_eth_platform_data lsmini_eth_data = {
  59. .phy_addr = 8,
  60. };
  61. /*****************************************************************************
  62. * RTC 5C372a on I2C bus
  63. ****************************************************************************/
  64. static struct i2c_board_info __initdata lsmini_i2c_rtc = {
  65. I2C_BOARD_INFO("rs5c372a", 0x32),
  66. };
  67. /*****************************************************************************
  68. * LEDs attached to GPIO
  69. ****************************************************************************/
  70. #define LSMINI_GPIO_LED_ALARM 2
  71. #define LSMINI_GPIO_LED_INFO 3
  72. #define LSMINI_GPIO_LED_FUNC 9
  73. #define LSMINI_GPIO_LED_PWR 14
  74. static struct gpio_led lsmini_led_pins[] = {
  75. {
  76. .name = "alarm:red",
  77. .gpio = LSMINI_GPIO_LED_ALARM,
  78. .active_low = 1,
  79. }, {
  80. .name = "info:amber",
  81. .gpio = LSMINI_GPIO_LED_INFO,
  82. .active_low = 1,
  83. }, {
  84. .name = "func:blue:top",
  85. .gpio = LSMINI_GPIO_LED_FUNC,
  86. .active_low = 1,
  87. }, {
  88. .name = "power:blue:bottom",
  89. .gpio = LSMINI_GPIO_LED_PWR,
  90. },
  91. };
  92. static struct gpio_led_platform_data lsmini_led_data = {
  93. .leds = lsmini_led_pins,
  94. .num_leds = ARRAY_SIZE(lsmini_led_pins),
  95. };
  96. static struct platform_device lsmini_leds = {
  97. .name = "leds-gpio",
  98. .id = -1,
  99. .dev = {
  100. .platform_data = &lsmini_led_data,
  101. },
  102. };
  103. /****************************************************************************
  104. * GPIO Attached Keys
  105. ****************************************************************************/
  106. #define LSMINI_GPIO_KEY_FUNC 15
  107. #define LSMINI_GPIO_KEY_POWER 18
  108. #define LSMINI_GPIO_KEY_AUTOPOWER 17
  109. #define LSMINI_SW_POWER 0x00
  110. #define LSMINI_SW_AUTOPOWER 0x01
  111. static struct gpio_keys_button lsmini_buttons[] = {
  112. {
  113. .code = KEY_OPTION,
  114. .gpio = LSMINI_GPIO_KEY_FUNC,
  115. .desc = "Function Button",
  116. .active_low = 1,
  117. }, {
  118. .type = EV_SW,
  119. .code = LSMINI_SW_POWER,
  120. .gpio = LSMINI_GPIO_KEY_POWER,
  121. .desc = "Power-on Switch",
  122. .active_low = 1,
  123. }, {
  124. .type = EV_SW,
  125. .code = LSMINI_SW_AUTOPOWER,
  126. .gpio = LSMINI_GPIO_KEY_AUTOPOWER,
  127. .desc = "Power-auto Switch",
  128. .active_low = 1,
  129. },
  130. };
  131. static struct gpio_keys_platform_data lsmini_button_data = {
  132. .buttons = lsmini_buttons,
  133. .nbuttons = ARRAY_SIZE(lsmini_buttons),
  134. };
  135. static struct platform_device lsmini_button_device = {
  136. .name = "gpio-keys",
  137. .id = -1,
  138. .num_resources = 0,
  139. .dev = {
  140. .platform_data = &lsmini_button_data,
  141. },
  142. };
  143. /*****************************************************************************
  144. * SATA
  145. ****************************************************************************/
  146. static struct mv_sata_platform_data lsmini_sata_data = {
  147. .n_ports = 2,
  148. };
  149. /*****************************************************************************
  150. * Linkstation Mini specific power off method: reboot
  151. ****************************************************************************/
  152. /*
  153. * On the Linkstation Mini, 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 lsmini_power_off(void)
  160. {
  161. arch_reset(0);
  162. }
  163. /*****************************************************************************
  164. * General Setup
  165. ****************************************************************************/
  166. #define LSMINI_GPIO_USB_POWER 16
  167. #define LSMINI_GPIO_AUTO_POWER 17
  168. #define LSMINI_GPIO_POWER 18
  169. #define LSMINI_GPIO_HDD_POWER0 1
  170. #define LSMINI_GPIO_HDD_POWER1 19
  171. static struct orion5x_mpp_mode lsmini_mpp_modes[] __initdata = {
  172. { 0, MPP_UNUSED }, /* LED_RESERVE1 (unused) */
  173. { 1, MPP_GPIO }, /* HDD_PWR */
  174. { 2, MPP_GPIO }, /* LED_ALARM */
  175. { 3, MPP_GPIO }, /* LED_INFO */
  176. { 4, MPP_UNUSED },
  177. { 5, MPP_UNUSED },
  178. { 6, MPP_UNUSED },
  179. { 7, MPP_UNUSED },
  180. { 8, MPP_UNUSED },
  181. { 9, MPP_GPIO }, /* LED_FUNC */
  182. { 10, MPP_UNUSED },
  183. { 11, MPP_UNUSED }, /* LED_ETH (dummy) */
  184. { 12, MPP_UNUSED },
  185. { 13, MPP_UNUSED },
  186. { 14, MPP_GPIO }, /* LED_PWR */
  187. { 15, MPP_GPIO }, /* FUNC */
  188. { 16, MPP_GPIO }, /* USB_PWR */
  189. { 17, MPP_GPIO }, /* AUTO_POWER */
  190. { 18, MPP_GPIO }, /* POWER */
  191. { 19, MPP_GPIO }, /* HDD_PWR1 */
  192. { -1 },
  193. };
  194. static void __init lsmini_init(void)
  195. {
  196. /*
  197. * Setup basic Orion functions. Need to be called early.
  198. */
  199. orion5x_init();
  200. orion5x_mpp_conf(lsmini_mpp_modes);
  201. /*
  202. * Configure peripherals.
  203. */
  204. orion5x_ehci0_init();
  205. orion5x_ehci1_init();
  206. orion5x_eth_init(&lsmini_eth_data);
  207. orion5x_i2c_init();
  208. orion5x_sata_init(&lsmini_sata_data);
  209. orion5x_uart0_init();
  210. orion5x_xor_init();
  211. orion5x_setup_dev_boot_win(LSMINI_NOR_BOOT_BASE,
  212. LSMINI_NOR_BOOT_SIZE);
  213. platform_device_register(&lsmini_nor_flash);
  214. platform_device_register(&lsmini_button_device);
  215. platform_device_register(&lsmini_leds);
  216. i2c_register_board_info(0, &lsmini_i2c_rtc, 1);
  217. /* enable USB power */
  218. gpio_set_value(LSMINI_GPIO_USB_POWER, 1);
  219. /* register power-off method */
  220. pm_power_off = lsmini_power_off;
  221. pr_info("%s: finished\n", __func__);
  222. }
  223. #ifdef CONFIG_MACH_LINKSTATION_MINI
  224. MACHINE_START(LINKSTATION_MINI, "Buffalo Linkstation Mini")
  225. /* Maintainer: Alexey Kopytko <alexey@kopytko.ru> */
  226. .phys_io = ORION5X_REGS_PHYS_BASE,
  227. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  228. .boot_params = 0x00000100,
  229. .init_machine = lsmini_init,
  230. .map_io = orion5x_map_io,
  231. .init_irq = orion5x_init_irq,
  232. .timer = &orion5x_timer,
  233. .fixup = tag_fixup_mem32,
  234. MACHINE_END
  235. #endif