preliminaryDataProcessing.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*
  2. * arch/arm/mach-orion5x/net2big-setup.c
  3. *
  4. * LaCie 2Big Network NAS setup
  5. *
  6. * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/mv643xx_eth.h>
  17. #include <linux/leds.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/input.h>
  20. #include <linux/i2c.h>
  21. #include <linux/ata_platform.h>
  22. #include <linux/gpio.h>
  23. #include <linux/delay.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <mach/orion5x.h>
  27. #include <plat/orion-gpio.h>
  28. #include "common.h"
  29. #include "mpp.h"
  30. /*****************************************************************************
  31. * LaCie 2Big Network Info
  32. ****************************************************************************/
  33. /*
  34. * 512KB NOR flash Device bus boot chip select
  35. */
  36. #define NET2BIG_NOR_BOOT_BASE 0xfff80000
  37. #define NET2BIG_NOR_BOOT_SIZE SZ_512K
  38. /*****************************************************************************
  39. * 512KB NOR Flash on Boot Device
  40. ****************************************************************************/
  41. /*
  42. * TODO: Check write support on flash MX29LV400CBTC-70G
  43. */
  44. static struct mtd_partition net2big_partitions[] = {
  45. {
  46. .name = "Full512kb",
  47. .size = MTDPART_SIZ_FULL,
  48. .offset = 0x00000000,
  49. .mask_flags = MTD_WRITEABLE,
  50. },
  51. };
  52. static struct physmap_flash_data net2big_nor_flash_data = {
  53. .width = 1,
  54. .parts = net2big_partitions,
  55. .nr_parts = ARRAY_SIZE(net2big_partitions),
  56. };
  57. static struct resource net2big_nor_flash_resource = {
  58. .flags = IORESOURCE_MEM,
  59. .start = NET2BIG_NOR_BOOT_BASE,
  60. .end = NET2BIG_NOR_BOOT_BASE
  61. + NET2BIG_NOR_BOOT_SIZE - 1,
  62. };
  63. static struct platform_device net2big_nor_flash = {
  64. .name = "physmap-flash",
  65. .id = 0,
  66. .dev = {
  67. .platform_data = &net2big_nor_flash_data,
  68. },
  69. .num_resources = 1,
  70. .resource = &net2big_nor_flash_resource,
  71. };
  72. /*****************************************************************************
  73. * Ethernet
  74. ****************************************************************************/
  75. static struct mv643xx_eth_platform_data net2big_eth_data = {
  76. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  77. };
  78. /*****************************************************************************
  79. * I2C devices
  80. ****************************************************************************/
  81. /*
  82. * i2c addr | chip | description
  83. * 0x32 | Ricoh 5C372b | RTC
  84. * 0x50 | HT24LC08 | eeprom (1kB)
  85. */
  86. static struct i2c_board_info __initdata net2big_i2c_devices[] = {
  87. {
  88. I2C_BOARD_INFO("rs5c372b", 0x32),
  89. }, {
  90. I2C_BOARD_INFO("24c08", 0x50),
  91. },
  92. };
  93. /*****************************************************************************
  94. * SATA
  95. ****************************************************************************/
  96. static struct mv_sata_platform_data net2big_sata_data = {
  97. .n_ports = 2,
  98. };
  99. #define NET2BIG_GPIO_SATA_POWER_REQ 19
  100. #define NET2BIG_GPIO_SATA0_POWER 23
  101. #define NET2BIG_GPIO_SATA1_POWER 25
  102. static void __init net2big_sata_power_init(void)
  103. {
  104. int err;
  105. /* Configure GPIOs over MPP max number. */
  106. orion_gpio_set_valid(NET2BIG_GPIO_SATA0_POWER, 1);
  107. orion_gpio_set_valid(NET2BIG_GPIO_SATA1_POWER, 1);
  108. err = gpio_request(NET2BIG_GPIO_SATA0_POWER, "SATA0 power status");
  109. if (err == 0) {
  110. err = gpio_direction_input(NET2BIG_GPIO_SATA0_POWER);
  111. if (err)
  112. gpio_free(NET2BIG_GPIO_SATA0_POWER);
  113. }
  114. if (err) {
  115. pr_err("net2big: failed to setup SATA0 power GPIO\n");
  116. return;
  117. }
  118. err = gpio_request(NET2BIG_GPIO_SATA1_POWER, "SATA1 power status");
  119. if (err == 0) {
  120. err = gpio_direction_input(NET2BIG_GPIO_SATA1_POWER);
  121. if (err)
  122. gpio_free(NET2BIG_GPIO_SATA1_POWER);
  123. }
  124. if (err) {
  125. pr_err("net2big: failed to setup SATA1 power GPIO\n");
  126. goto err_free_1;
  127. }
  128. err = gpio_request(NET2BIG_GPIO_SATA_POWER_REQ, "SATA power request");
  129. if (err == 0) {
  130. err = gpio_direction_output(NET2BIG_GPIO_SATA_POWER_REQ, 0);
  131. if (err)
  132. gpio_free(NET2BIG_GPIO_SATA_POWER_REQ);
  133. }
  134. if (err) {
  135. pr_err("net2big: failed to setup SATA power request GPIO\n");
  136. goto err_free_2;
  137. }
  138. if (gpio_get_value(NET2BIG_GPIO_SATA0_POWER) &&
  139. gpio_get_value(NET2BIG_GPIO_SATA1_POWER)) {
  140. return;
  141. }
  142. /*
  143. * SATA power up on both disk is done by pulling high the CPLD power
  144. * request line. The 300ms delay is related to the CPLD clock and is
  145. * needed to be sure that the CPLD has take into account the low line
  146. * status.
  147. */
  148. msleep(300);
  149. gpio_set_value(NET2BIG_GPIO_SATA_POWER_REQ, 1);
  150. pr_info("net2big: power up SATA hard disks\n");
  151. return;
  152. err_free_2:
  153. gpio_free(NET2BIG_GPIO_SATA1_POWER);
  154. err_free_1:
  155. gpio_free(NET2BIG_GPIO_SATA0_POWER);
  156. return;
  157. }
  158. /*****************************************************************************
  159. * GPIO LEDs
  160. ****************************************************************************/
  161. /*
  162. * The power front LEDs (blue and red) and SATA red LEDs are controlled via a
  163. * single GPIO line and are compatible with the leds-gpio driver.
  164. *
  165. * The SATA blue LEDs have some hardware blink capabilities which are detailed
  166. * in the following array:
  167. *
  168. * SATAx blue LED | SATAx activity | LED state
  169. * | |
  170. * 0 | 0 | blink (rate 300ms)
  171. * 1 | 0 | off
  172. * ? | 1 | on
  173. *
  174. * Notes: The blue and the red front LED's can't be on at the same time.
  175. * Blue LED have priority.
  176. */
  177. #define NET2BIG_GPIO_PWR_RED_LED 6
  178. #define NET2BIG_GPIO_PWR_BLUE_LED 16
  179. #define NET2BIG_GPIO_PWR_LED_BLINK_STOP 7
  180. #define NET2BIG_GPIO_SATA0_RED_LED 11
  181. #define NET2BIG_GPIO_SATA1_RED_LED 10
  182. #define NET2BIG_GPIO_SATA0_BLUE_LED 17
  183. #define NET2BIG_GPIO_SATA1_BLUE_LED 13
  184. static struct gpio_led net2big_leds[] = {
  185. {
  186. .name = "net2big:red:power",
  187. .gpio = NET2BIG_GPIO_PWR_RED_LED,
  188. },
  189. {
  190. .name = "net2big:blue:power",
  191. .gpio = NET2BIG_GPIO_PWR_BLUE_LED,
  192. },
  193. {
  194. .name = "net2big:red:sata0",
  195. .gpio = NET2BIG_GPIO_SATA0_RED_LED,
  196. },
  197. {
  198. .name = "net2big:red:sata1",
  199. .gpio = NET2BIG_GPIO_SATA1_RED_LED,
  200. },
  201. };
  202. static struct gpio_led_platform_data net2big_led_data = {
  203. .num_leds = ARRAY_SIZE(net2big_leds),
  204. .leds = net2big_leds,
  205. };
  206. static struct platform_device net2big_gpio_leds = {
  207. .name = "leds-gpio",
  208. .id = -1,