edmini_v2-setup.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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/mbus.h>
  25. #include <linux/mtd/physmap.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. * RTC 5C372a on I2C bus
  88. ****************************************************************************/
  89. #define EDMINIV2_RTC_GPIO 3
  90. static struct i2c_board_info __initdata edmini_v2_i2c_rtc = {
  91. I2C_BOARD_INFO("rs5c372a", 0x32),
  92. .irq = 0,
  93. };
  94. /*****************************************************************************
  95. * General Setup
  96. ****************************************************************************/
  97. static unsigned int edminiv2_mpp_modes[] __initdata = {
  98. MPP0_UNUSED,
  99. MPP1_UNUSED,
  100. MPP2_UNUSED,
  101. MPP3_GPIO, /* RTC interrupt */
  102. MPP4_UNUSED,
  103. MPP5_UNUSED,
  104. MPP6_UNUSED,
  105. MPP7_UNUSED,
  106. MPP8_UNUSED,
  107. MPP9_UNUSED,
  108. MPP10_UNUSED,
  109. MPP11_UNUSED,
  110. MPP12_SATA_LED, /* SATA 0 presence */
  111. MPP13_SATA_LED, /* SATA 1 presence */
  112. MPP14_SATA_LED, /* SATA 0 active */
  113. MPP15_SATA_LED, /* SATA 1 active */
  114. /* 16: Power LED control (0 = On, 1 = Off) */
  115. MPP16_GPIO,
  116. /* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */
  117. MPP17_GPIO,
  118. /* 18: Power button status (0 = Released, 1 = Pressed) */
  119. MPP18_GPIO,
  120. MPP19_UNUSED,
  121. 0,
  122. };
  123. void __init edmini_v2_init(void)
  124. {
  125. orion5x_mpp_conf(edminiv2_mpp_modes);
  126. /*
  127. * Configure peripherals.
  128. */
  129. orion5x_ehci0_init();
  130. mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
  131. ORION_MBUS_DEVBUS_BOOT_ATTR,
  132. EDMINI_V2_NOR_BOOT_BASE,
  133. EDMINI_V2_NOR_BOOT_SIZE);
  134. platform_device_register(&edmini_v2_nor_flash);
  135. pr_notice("edmini_v2: USB device port, flash write and power-off "
  136. "are not yet supported.\n");
  137. /* Get RTC IRQ and register the chip */
  138. if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) {
  139. if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0)
  140. edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO);
  141. else
  142. gpio_free(EDMINIV2_RTC_GPIO);
  143. }
  144. if (edmini_v2_i2c_rtc.irq == 0)
  145. pr_warning("edmini_v2: failed to get RTC IRQ\n");
  146. i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1);
  147. }