board-stamp9g20.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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/at91sam9_smc.h>
  27. #include "sam9_smc.h"
  28. #include "generic.h"
  29. static void __init portuxg20_map_io(void)
  30. {
  31. /* Initialize processor: 18.432 MHz crystal */
  32. at91sam9260_initialize(18432000);
  33. /* DGBU on ttyS0. (Rx & Tx only) */
  34. at91_register_uart(0, 0, 0);
  35. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
  36. at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
  37. | ATMEL_UART_DTR | ATMEL_UART_DSR
  38. | ATMEL_UART_DCD | ATMEL_UART_RI);
  39. /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
  40. at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
  41. /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
  42. at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
  43. /* USART4 on ttyS5. (Rx, Tx only) */
  44. at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
  45. /* USART5 on ttyS6. (Rx, Tx only) */
  46. at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
  47. /* set serial console to ttyS0 (ie, DBGU) */
  48. at91_set_serial_console(0);
  49. }
  50. static void __init stamp9g20_map_io(void)
  51. {
  52. /* Initialize processor: 18.432 MHz crystal */
  53. at91sam9260_initialize(18432000);
  54. /* DGBU on ttyS0. (Rx & Tx only) */
  55. at91_register_uart(0, 0, 0);
  56. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
  57. at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
  58. | ATMEL_UART_DTR | ATMEL_UART_DSR
  59. | ATMEL_UART_DCD | ATMEL_UART_RI);
  60. /* set serial console to ttyS0 (ie, DBGU) */
  61. at91_set_serial_console(0);
  62. }
  63. static void __init init_irq(void)
  64. {
  65. at91sam9260_init_interrupts(NULL);
  66. }
  67. /*
  68. * NAND flash
  69. */
  70. static struct atmel_nand_data __initdata nand_data = {
  71. .ale = 21,
  72. .cle = 22,
  73. .rdy_pin = AT91_PIN_PC13,
  74. .enable_pin = AT91_PIN_PC14,
  75. .bus_width_16 = 0,
  76. };
  77. static struct sam9_smc_config __initdata nand_smc_config = {
  78. .ncs_read_setup = 0,
  79. .nrd_setup = 2,
  80. .ncs_write_setup = 0,
  81. .nwe_setup = 2,
  82. .ncs_read_pulse = 4,
  83. .nrd_pulse = 4,
  84. .ncs_write_pulse = 4,
  85. .nwe_pulse = 4,
  86. .read_cycle = 7,
  87. .write_cycle = 7,
  88. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  89. .tdf_cycles = 3,
  90. };
  91. static void __init add_device_nand(void)
  92. {
  93. /* configure chip-select 3 (NAND) */
  94. sam9_smc_configure(3, &nand_smc_config);
  95. at91_add_device_nand(&nand_data);
  96. }
  97. /*
  98. * MCI (SD/MMC)
  99. * det_pin, wp_pin and vcc_pin are not connected
  100. */
  101. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  102. static struct mci_platform_data __initdata mmc_data = {
  103. .slot[0] = {
  104. .bus_width = 4,
  105. },
  106. };
  107. #else
  108. static struct at91_mmc_data __initdata mmc_data = {
  109. .slot_b = 0,
  110. .wire4 = 1,
  111. };
  112. #endif
  113. /*
  114. * USB Host port
  115. */
  116. static struct at91_usbh_data __initdata usbh_data = {
  117. .ports = 2,
  118. };
  119. /*
  120. * USB Device port
  121. */
  122. static struct at91_udc_data __initdata portuxg20_udc_data = {
  123. .vbus_pin = AT91_PIN_PC7,
  124. .pullup_pin = 0, /* pull-up driven by UDC */
  125. };
  126. static struct at91_udc_data __initdata stamp9g20_udc_data = {
  127. .vbus_pin = AT91_PIN_PA22,
  128. .pullup_pin = 0, /* pull-up driven by UDC */
  129. };
  130. /*
  131. * MACB Ethernet device
  132. */
  133. static struct at91_eth_data __initdata macb_data = {
  134. .phy_irq_pin = AT91_PIN_PA28,
  135. .is_rmii = 1,
  136. };
  137. /*
  138. * LEDs
  139. */
  140. static struct gpio_led portuxg20_leds[] = {
  141. {
  142. .name = "LED2",
  143. .gpio = AT91_PIN_PC5,
  144. .default_trigger = "none",
  145. }, {
  146. .name = "LED3",
  147. .gpio = AT91_PIN_PC4,
  148. .default_trigger = "none",
  149. }, {
  150. .name = "LED4",
  151. .gpio = AT91_PIN_PC10,
  152. .default_trigger = "heartbeat",
  153. }
  154. };
  155. static struct gpio_led stamp9g20_leds[] = {
  156. {
  157. .name = "D8",
  158. .gpio = AT91_PIN_PB18,
  159. .active_low = 1,
  160. .default_trigger = "none",
  161. }, {
  162. .name = "D9",
  163. .gpio = AT91_PIN_PB19,
  164. .active_low = 1,
  165. .default_trigger = "none",
  166. }, {
  167. .name = "D10",
  168. .gpio = AT91_PIN_PB20,
  169. .active_low = 1,
  170. .default_trigger = "heartbeat",
  171. }
  172. };
  173. /*
  174. * SPI devices
  175. */
  176. static struct spi_board_info portuxg20_spi_devices[] = {
  177. {
  178. .modalias = "spidev",
  179. .chip_select = 0,
  180. .max_speed_hz = 1 * 1000 * 1000,
  181. .bus_num = 0,
  182. }, {
  183. .modalias = "spidev",
  184. .chip_select = 0,
  185. .max_speed_hz = 1 * 1000 * 1000,
  186. .bus_num = 1,
  187. },
  188. };
  189. /*
  190. * Dallas 1-Wire
  191. */
  192. static struct w1_gpio_platform_data w1_gpio_pdata = {
  193. .pin = AT91_PIN_PA29,
  194. .is_open_drain = 1,
  195. };
  196. static struct platform_device w1_device = {
  197. .name = "w1-gpio",
  198. .id = -1,
  199. .dev.platform_data = &w1_gpio_pdata,
  200. };
  201. void add_w1(void)
  202. {
  203. at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
  204. at91_set_multi_drive(w1_gpio_pdata.pin, 1);
  205. platform_device_register(&w1_device);
  206. }
  207. static void __init generic_board_init(void)
  208. {
  209. /* Serial */
  210. at91_add_device_serial();
  211. /* NAND */
  212. add_device_nand();
  213. /* MMC */
  214. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  215. at91_add_device_mci(0, &mmc_data);
  216. #else
  217. at91_add_device_mmc(0, &mmc_data);
  218. #endif
  219. /* USB Host */
  220. at91_add_device_usbh(&usbh_data);
  221. /* Ethernet */
  222. at91_add_device_eth(&macb_data);
  223. /* I2C */
  224. at91_add_device_i2c(NULL, 0);
  225. /* W1 */
  226. add_w1();
  227. }
  228. static void __init portuxg20_board_init(void)
  229. {
  230. generic_board_init();
  231. /* SPI */
  232. at91_add_device_spi(portuxg20_spi_devices, ARRAY_SIZE(portuxg20_spi_devices));
  233. /* USB Device */
  234. at91_add_device_udc(&portuxg20_udc_data);
  235. /* LEDs */
  236. at91_gpio_leds(portuxg20_leds, ARRAY_SIZE(portuxg20_leds));
  237. }
  238. static void __init stamp9g20_board_init(void)
  239. {
  240. generic_board_init();
  241. /* USB Device */
  242. at91_add_device_udc(&stamp9g20_udc_data);
  243. /* LEDs */
  244. at91_gpio_leds(stamp9g20_leds, ARRAY_SIZE(stamp9g20_leds));
  245. }
  246. MACHINE_START(PORTUXG20, "taskit PortuxG20")
  247. /* Maintainer: taskit GmbH */
  248. .phys_io = AT91_BASE_SYS,
  249. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  250. .boot_params = AT91_SDRAM_BASE + 0x100,
  251. .timer = &at91sam926x_timer,
  252. .map_io = portuxg20_map_io,
  253. .init_irq = init_irq,
  254. .init_machine = portuxg20_board_init,
  255. MACHINE_END
  256. MACHINE_START(STAMP9G20, "taskit Stamp9G20")
  257. /* Maintainer: taskit GmbH */
  258. .phys_io = AT91_BASE_SYS,
  259. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  260. .boot_params = AT91_SDRAM_BASE + 0x100,
  261. .timer = &at91sam926x_timer,
  262. .map_io = stamp9g20_map_io,
  263. .init_irq = init_irq,
  264. .init_machine = stamp9g20_board_init,
  265. MACHINE_END