edmini_v2-setup.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. * General Setup
  102. ****************************************************************************/
  103. static unsigned int edminiv2_mpp_modes[] __initdata = {
  104. MPP0_UNUSED,
  105. MPP1_UNUSED,
  106. MPP2_UNUSED,
  107. MPP3_GPIO, /* RTC interrupt */
  108. MPP4_UNUSED,
  109. MPP5_UNUSED,
  110. MPP6_UNUSED,
  111. MPP7_UNUSED,
  112. MPP8_UNUSED,
  113. MPP9_UNUSED,
  114. MPP10_UNUSED,
  115. MPP11_UNUSED,
  116. MPP12_SATA_LED, /* SATA 0 presence */
  117. MPP13_SATA_LED, /* SATA 1 presence */
  118. MPP14_SATA_LED, /* SATA 0 active */
  119. MPP15_SATA_LED, /* SATA 1 active */
  120. /* 16: Power LED control (0 = On, 1 = Off) */
  121. MPP16_GPIO,
  122. /* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */
  123. MPP17_GPIO,
  124. /* 18: Power button status (0 = Released, 1 = Pressed) */
  125. MPP18_GPIO,
  126. MPP19_UNUSED,
  127. 0,
  128. };
  129. void __init edmini_v2_init(void)
  130. {
  131. orion5x_mpp_conf(edminiv2_mpp_modes);
  132. /*
  133. * Configure peripherals.
  134. */
  135. orion5x_ehci0_init();
  136. orion5x_eth_init(&edmini_v2_eth_data);
  137. orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE,
  138. EDMINI_V2_NOR_BOOT_SIZE);
  139. platform_device_register(&edmini_v2_nor_flash);
  140. pr_notice("edmini_v2: USB device port, flash write and power-off "
  141. "are not yet supported.\n");
  142. /* Get RTC IRQ and register the chip */
  143. if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) {
  144. if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0)
  145. edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO);
  146. else
  147. gpio_free(EDMINIV2_RTC_GPIO);
  148. }
  149. if (edmini_v2_i2c_rtc.irq == 0)
  150. pr_warning("edmini_v2: failed to get RTC IRQ\n");
  151. i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1);
  152. }