board-stamp9g20.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /*
  2. * Copyright (C) 2010 Christian Glindkamp <christian.glindkamp@taskit.de>
  3. * taskit GmbH
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/mm.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/gpio.h>
  22. #include <linux/w1-gpio.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <mach/board.h>
  26. #include <mach/at91_aic.h>
  27. #include <mach/at91sam9_smc.h>
  28. #include "sam9_smc.h"
  29. #include "generic.h"
  30. void __init stamp9g20_init_early(void)
  31. {
  32. /* Initialize processor: 18.432 MHz crystal */
  33. at91_initialize(18432000);
  34. }
  35. /*
  36. * NAND flash
  37. */
  38. static struct atmel_nand_data __initdata nand_data = {
  39. .ale = 21,
  40. .cle = 22,
  41. .rdy_pin = AT91_PIN_PC13,
  42. .enable_pin = AT91_PIN_PC14,
  43. .bus_width_16 = 0,
  44. .det_pin = -EINVAL,
  45. .ecc_mode = NAND_ECC_SOFT,
  46. };
  47. static struct sam9_smc_config __initdata nand_smc_config = {
  48. .ncs_read_setup = 0,
  49. .nrd_setup = 2,
  50. .ncs_write_setup = 0,
  51. .nwe_setup = 2,
  52. .ncs_read_pulse = 4,
  53. .nrd_pulse = 4,
  54. .ncs_write_pulse = 4,
  55. .nwe_pulse = 4,
  56. .read_cycle = 7,
  57. .write_cycle = 7,
  58. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  59. .tdf_cycles = 3,
  60. };
  61. static void __init add_device_nand(void)
  62. {
  63. /* configure chip-select 3 (NAND) */
  64. sam9_smc_configure(0, 3, &nand_smc_config);
  65. at91_add_device_nand(&nand_data);
  66. }
  67. /*
  68. * MCI (SD/MMC)
  69. * det_pin, wp_pin and vcc_pin are not connected
  70. */
  71. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  72. static struct mci_platform_data __initdata mmc_data = {
  73. .slot[0] = {
  74. .bus_width = 4,
  75. .detect_pin = -1,
  76. .wp_pin = -1,
  77. },
  78. };
  79. #else
  80. static struct at91_mmc_data __initdata mmc_data = {
  81. .slot_b = 0,
  82. .wire4 = 1,
  83. .det_pin = -EINVAL,
  84. .wp_pin = -EINVAL,
  85. .vcc_pin = -EINVAL,
  86. };
  87. #endif
  88. /*
  89. * USB Host port
  90. */
  91. static struct at91_usbh_data __initdata usbh_data = {
  92. .ports = 2,
  93. .vbus_pin = {-EINVAL, -EINVAL},
  94. .overcurrent_pin= {-EINVAL, -EINVAL},
  95. };
  96. /*
  97. * USB Device port
  98. */
  99. static struct at91_udc_data __initdata portuxg20_udc_data = {
  100. .vbus_pin = AT91_PIN_PC7,
  101. .pullup_pin = -EINVAL, /* pull-up driven by UDC */
  102. };
  103. static struct at91_udc_data __initdata stamp9g20evb_udc_data = {
  104. .vbus_pin = AT91_PIN_PA22,
  105. .pullup_pin = -EINVAL, /* pull-up driven by UDC */
  106. };
  107. /*
  108. * MACB Ethernet device
  109. */
  110. static struct macb_platform_data __initdata macb_data = {
  111. .phy_irq_pin = AT91_PIN_PA28,
  112. .is_rmii = 1,
  113. };
  114. /*
  115. * LEDs
  116. */
  117. static struct gpio_led portuxg20_leds[] = {
  118. {
  119. .name = "LED2",
  120. .gpio = AT91_PIN_PC5,
  121. .default_trigger = "none",
  122. }, {
  123. .name = "LED3",
  124. .gpio = AT91_PIN_PC4,
  125. .default_trigger = "none",
  126. }, {
  127. .name = "LED4",
  128. .gpio = AT91_PIN_PC10,
  129. .default_trigger = "heartbeat",
  130. }
  131. };
  132. static struct gpio_led stamp9g20evb_leds[] = {
  133. {
  134. .name = "D8",
  135. .gpio = AT91_PIN_PB18,
  136. .active_low = 1,
  137. .default_trigger = "none",
  138. }, {
  139. .name = "D9",
  140. .gpio = AT91_PIN_PB19,
  141. .active_low = 1,
  142. .default_trigger = "none",
  143. }, {
  144. .name = "D10",
  145. .gpio = AT91_PIN_PB20,
  146. .active_low = 1,
  147. .default_trigger = "heartbeat",
  148. }
  149. };
  150. /*
  151. * SPI devices
  152. */
  153. static struct spi_board_info portuxg20_spi_devices[] = {
  154. {
  155. .modalias = "spidev",
  156. .chip_select = 0,
  157. .max_speed_hz = 1 * 1000 * 1000,
  158. .bus_num = 0,
  159. }, {
  160. .modalias = "spidev",
  161. .chip_select = 0,
  162. .max_speed_hz = 1 * 1000 * 1000,
  163. .bus_num = 1,
  164. },
  165. };
  166. /*
  167. * Dallas 1-Wire
  168. */
  169. static struct w1_gpio_platform_data w1_gpio_pdata = {
  170. .pin = AT91_PIN_PA29,
  171. .is_open_drain = 1,
  172. };
  173. static struct platform_device w1_device = {
  174. .name = "w1-gpio",
  175. .id = -1,
  176. .dev.platform_data = &w1_gpio_pdata,
  177. };
  178. void add_w1(void)
  179. {
  180. at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
  181. at91_set_multi_drive(w1_gpio_pdata.pin, 1);
  182. platform_device_register(&w1_device);
  183. }
  184. void __init stamp9g20_board_init(void)
  185. {
  186. /* Serial */
  187. /* DGBU on ttyS0. (Rx & Tx only) */
  188. at91_register_uart(0, 0, 0);
  189. at91_add_device_serial();
  190. /* NAND */
  191. add_device_nand();
  192. /* MMC */
  193. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  194. at91_add_device_mci(0, &mmc_data);
  195. #else
  196. at91_add_device_mmc(0, &mmc_data);
  197. #endif
  198. /* W1 */
  199. add_w1();
  200. }
  201. static void __init portuxg20_board_init(void)
  202. {
  203. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
  204. at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
  205. | ATMEL_UART_DTR | ATMEL_UART_DSR
  206. | ATMEL_UART_DCD | ATMEL_UART_RI);
  207. /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
  208. at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
  209. /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
  210. at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
  211. /* USART4 on ttyS5. (Rx, Tx only) */
  212. at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
  213. /* USART5 on ttyS6. (Rx, Tx only) */
  214. at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
  215. stamp9g20_board_init();
  216. /* USB Host */
  217. at91_add_device_usbh(&usbh_data);
  218. /* USB Device */
  219. at91_add_device_udc(&portuxg20_udc_data);
  220. /* Ethernet */
  221. at91_add_device_eth(&macb_data);
  222. /* I2C */
  223. at91_add_device_i2c(NULL, 0);
  224. /* SPI */
  225. at91_add_device_spi(portuxg20_spi_devices, ARRAY_SIZE(portuxg20_spi_devices));
  226. /* LEDs */
  227. at91_gpio_leds(portuxg20_leds, ARRAY_SIZE(portuxg20_leds));
  228. }
  229. static void __init stamp9g20evb_board_init(void)
  230. {
  231. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
  232. at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
  233. | ATMEL_UART_DTR | ATMEL_UART_DSR
  234. | ATMEL_UART_DCD | ATMEL_UART_RI);
  235. stamp9g20_board_init();
  236. /* USB Host */
  237. at91_add_device_usbh(&usbh_data);
  238. /* USB Device */
  239. at91_add_device_udc(&stamp9g20evb_udc_data);
  240. /* Ethernet */
  241. at91_add_device_eth(&macb_data);
  242. /* I2C */
  243. at91_add_device_i2c(NULL, 0);
  244. /* LEDs */
  245. at91_gpio_leds(stamp9g20evb_leds, ARRAY_SIZE(stamp9g20evb_leds));
  246. }
  247. MACHINE_START(PORTUXG20, "taskit PortuxG20")
  248. /* Maintainer: taskit GmbH */
  249. .timer = &at91sam926x_timer,
  250. .map_io = at91_map_io,
  251. .handle_irq = at91_aic_handle_irq,
  252. .init_early = stamp9g20_init_early,
  253. .init_irq = at91_init_irq_default,
  254. .init_machine = portuxg20_board_init,
  255. MACHINE_END
  256. MACHINE_START(STAMP9G20, "taskit Stamp9G20")
  257. /* Maintainer: taskit GmbH */
  258. .timer = &at91sam926x_timer,
  259. .map_io = at91_map_io,
  260. .handle_irq = at91_aic_handle_irq,
  261. .init_early = stamp9g20_init_early,
  262. .init_irq = at91_init_irq_default,
  263. .init_machine = stamp9g20evb_board_init,
  264. MACHINE_END