edmini_v2-setup.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * arch/arm/mach-orion5x/edmini_v2-setup.c
  3. *
  4. * LaCie Ethernet Disk mini V2 Setup
  5. *
  6. * Copyright (C) 2008 Christopher Moore <moore@free.fr>
  7. * Copyright (C) 2008 Albert Aribaud <albert.aribaud@free.fr>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. /*
  14. * TODO: add Orion USB device port init when kernel.org support is added.
  15. * TODO: add flash write support: see below.
  16. * TODO: add power-off support.
  17. * TODO: add I2C EEPROM support.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/pci.h>
  23. #include <linux/irq.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/mv643xx_eth.h>
  26. #include <linux/leds.h>
  27. #include <linux/gpio_keys.h>
  28. #include <linux/input.h>
  29. #include <linux/i2c.h>
  30. #include <linux/ata_platform.h>
  31. #include <linux/gpio.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/pci.h>
  35. #include <mach/orion5x.h>
  36. #include "common.h"
  37. #include "mpp.h"
  38. /*****************************************************************************
  39. * EDMINI_V2 Info
  40. ****************************************************************************/
  41. /*
  42. * 512KB NOR flash Device bus boot chip select
  43. */
  44. #define EDMINI_V2_NOR_BOOT_BASE 0xfff80000
  45. #define EDMINI_V2_NOR_BOOT_SIZE SZ_512K
  46. /*****************************************************************************
  47. * 512KB NOR Flash on BOOT Device
  48. ****************************************************************************/
  49. /*
  50. * Currently the MTD code does not recognize the MX29LV400CBCT as a bottom
  51. * -type device. This could cause risks of accidentally erasing critical
  52. * flash sectors. We thus define a single, write-protected partition covering
  53. * the whole flash.
  54. * TODO: once the flash part TOP/BOTTOM detection issue is sorted out in the MTD
  55. * code, break this into at least three partitions: 'u-boot code', 'u-boot
  56. * environment' and 'whatever is left'.
  57. */
  58. static struct mtd_partition edmini_v2_partitions[] = {
  59. {
  60. .name = "Full512kb",
  61. .size = 0x00080000,
  62. .offset = 0x00000000,
  63. .mask_flags = MTD_WRITEABLE,
  64. },
  65. };
  66. static struct physmap_flash_data edmini_v2_nor_flash_data = {
  67. .width = 1,
  68. .parts = edmini_v2_partitions,
  69. .nr_parts = ARRAY_SIZE(edmini_v2_partitions),
  70. };
  71. static struct resource edmini_v2_nor_flash_resource = {
  72. .flags = IORESOURCE_MEM,
  73. .start = EDMINI_V2_NOR_BOOT_BASE,
  74. .end = EDMINI_V2_NOR_BOOT_BASE
  75. + EDMINI_V2_NOR_BOOT_SIZE - 1,
  76. };
  77. static struct platform_device edmini_v2_nor_flash = {
  78. .name = "physmap-flash",
  79. .id = 0,
  80. .dev = {
  81. .platform_data = &edmini_v2_nor_flash_data,
  82. },
  83. .num_resources = 1,
  84. .resource = &edmini_v2_nor_flash_resource,
  85. };
  86. /*****************************************************************************
  87. * Ethernet
  88. ****************************************************************************/
  89. static struct mv643xx_eth_platform_data edmini_v2_eth_data = {
  90. .phy_addr = 8,
  91. };
  92. /*****************************************************************************
  93. * RTC 5C372a on I2C bus
  94. ****************************************************************************/
  95. #define EDMINIV2_RTC_GPIO 3
  96. static struct i2c_board_info __initdata edmini_v2_i2c_rtc = {
  97. I2C_BOARD_INFO("rs5c372a", 0x32),
  98. .irq = 0,
  99. };
  100. /*****************************************************************************
  101. * Sata
  102. ****************************************************************************/
  103. static struct mv_sata_platform_data edmini_v2_sata_data = {
  104. .n_ports = 2,
  105. };
  106. /*****************************************************************************
  107. * GPIO LED (simple - doesn't use hardware blinking support)
  108. ****************************************************************************/
  109. #define EDMINI_V2_GPIO_LED_POWER 16
  110. static struct gpio_led edmini_v2_leds[] = {
  111. {
  112. .name = "power:blue",
  113. .gpio = EDMINI_V2_GPIO_LED_POWER,
  114. .active_low = 1,
  115. },
  116. };
  117. static struct gpio_led_platform_data edmini_v2_led_data = {
  118. .num_leds = ARRAY_SIZE(edmini_v2_leds),
  119. .leds = edmini_v2_leds,
  120. };
  121. static struct platform_device edmini_v2_gpio_leds = {
  122. .name = "leds-gpio",
  123. .id = -1,
  124. .dev = {
  125. .platform_data = &edmini_v2_led_data,
  126. },
  127. };
  128. /****************************************************************************
  129. * GPIO key
  130. ****************************************************************************/
  131. #define EDMINI_V2_GPIO_KEY_POWER 18
  132. static struct gpio_keys_button edmini_v2_buttons[] = {
  133. {
  134. .code = KEY_POWER,
  135. .gpio = EDMINI_V2_GPIO_KEY_POWER,
  136. .desc = "Power Button",
  137. .active_low = 0,
  138. },
  139. };
  140. static struct gpio_keys_platform_data edmini_v2_button_data = {
  141. .buttons = edmini_v2_buttons,
  142. .nbuttons = ARRAY_SIZE(edmini_v2_buttons),
  143. };
  144. static struct platform_device edmini_v2_gpio_buttons = {
  145. .name = "gpio-keys",
  146. .id = -1,
  147. .dev = {
  148. .platform_data = &edmini_v2_button_data,
  149. },
  150. };
  151. /*****************************************************************************
  152. * General Setup
  153. ****************************************************************************/
  154. static struct orion5x_mpp_mode edminiv2_mpp_modes[] __initdata = {
  155. { 0, MPP_UNUSED },
  156. { 1, MPP_UNUSED },
  157. { 2, MPP_UNUSED },
  158. { 3, MPP_GPIO }, /* RTC interrupt */
  159. { 4, MPP_UNUSED },
  160. { 5, MPP_UNUSED },
  161. { 6, MPP_UNUSED },
  162. { 7, MPP_UNUSED },
  163. { 8, MPP_UNUSED },
  164. { 9, MPP_UNUSED },
  165. { 10, MPP_UNUSED },
  166. { 11, MPP_UNUSED },
  167. { 12, MPP_SATA_LED }, /* SATA 0 presence */
  168. { 13, MPP_SATA_LED }, /* SATA 1 presence */
  169. { 14, MPP_SATA_LED }, /* SATA 0 active */
  170. { 15, MPP_SATA_LED }, /* SATA 1 active */
  171. /* 16: Power LED control (0 = On, 1 = Off) */
  172. { 16, MPP_GPIO },
  173. /* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */
  174. { 17, MPP_GPIO },
  175. /* 18: Power button status (0 = Released, 1 = Pressed) */
  176. { 18, MPP_GPIO },
  177. { 19, MPP_UNUSED },
  178. { -1 }
  179. };
  180. static void __init edmini_v2_init(void)
  181. {
  182. /*
  183. * Setup basic Orion functions. Need to be called early.
  184. */
  185. orion5x_init();
  186. orion5x_mpp_conf(edminiv2_mpp_modes);
  187. /*
  188. * Configure peripherals.
  189. */
  190. orion5x_ehci0_init();
  191. orion5x_eth_init(&edmini_v2_eth_data);
  192. orion5x_i2c_init();
  193. orion5x_sata_init(&edmini_v2_sata_data);
  194. orion5x_uart0_init();
  195. orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE,
  196. EDMINI_V2_NOR_BOOT_SIZE);
  197. platform_device_register(&edmini_v2_nor_flash);
  198. platform_device_register(&edmini_v2_gpio_leds);
  199. platform_device_register(&edmini_v2_gpio_buttons);
  200. pr_notice("edmini_v2: USB device port, flash write and power-off "
  201. "are not yet supported.\n");
  202. /* Get RTC IRQ and register the chip */
  203. if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) {
  204. if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0)
  205. edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO);
  206. else
  207. gpio_free(EDMINIV2_RTC_GPIO);
  208. }
  209. if (edmini_v2_i2c_rtc.irq == 0)
  210. pr_warning("edmini_v2: failed to get RTC IRQ\n");
  211. i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1);
  212. }
  213. /* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */
  214. MACHINE_START(EDMINI_V2, "LaCie Ethernet Disk mini V2")
  215. /* Maintainer: Christopher Moore <moore@free.fr> */
  216. .phys_io = ORION5X_REGS_PHYS_BASE,
  217. .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
  218. .boot_params = 0x00000100,
  219. .init_machine = edmini_v2_init,
  220. .map_io = orion5x_map_io,
  221. .init_irq = orion5x_init_irq,
  222. .timer = &orion5x_timer,
  223. .fixup = tag_fixup_mem32,
  224. MACHINE_END