board-sam9261ek.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*
  2. * linux/arch/arm/mach-at91/board-sam9261ek.c
  3. *
  4. * Copyright (C) 2005 SAN People
  5. * Copyright (C) 2006 Atmel
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/types.h>
  22. #include <linux/init.h>
  23. #include <linux/mm.h>
  24. #include <linux/module.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/spi/ads7846.h>
  28. #include <linux/dm9000.h>
  29. #include <asm/hardware.h>
  30. #include <asm/setup.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/irq.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/irq.h>
  36. #include <asm/arch/board.h>
  37. #include <asm/arch/gpio.h>
  38. #include <asm/arch/at91sam926x_mc.h>
  39. #include "generic.h"
  40. /*
  41. * Serial port configuration.
  42. * 0 .. 2 = USART0 .. USART2
  43. * 3 = DBGU
  44. */
  45. static struct at91_uart_config __initdata ek_uart_config = {
  46. .console_tty = 0, /* ttyS0 */
  47. .nr_tty = 1,
  48. .tty_map = { 3, -1, -1, -1 } /* ttyS0, ..., ttyS3 */
  49. };
  50. static void __init ek_map_io(void)
  51. {
  52. /* Initialize processor: 18.432 MHz crystal */
  53. at91sam9261_initialize(18432000);
  54. /* Setup the LEDs */
  55. at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
  56. /* Setup the serial ports and console */
  57. at91_init_serial(&ek_uart_config);
  58. }
  59. static void __init ek_init_irq(void)
  60. {
  61. at91sam9261_init_interrupts(NULL);
  62. }
  63. /*
  64. * DM9000 ethernet device
  65. */
  66. #if defined(CONFIG_DM9000)
  67. static struct resource at91sam9261_dm9000_resource[] = {
  68. [0] = {
  69. .start = AT91_CHIPSELECT_2,
  70. .end = AT91_CHIPSELECT_2 + 3,
  71. .flags = IORESOURCE_MEM
  72. },
  73. [1] = {
  74. .start = AT91_CHIPSELECT_2 + 0x44,
  75. .end = AT91_CHIPSELECT_2 + 0xFF,
  76. .flags = IORESOURCE_MEM
  77. },
  78. [2] = {
  79. .start = AT91_PIN_PC11,
  80. .end = AT91_PIN_PC11,
  81. .flags = IORESOURCE_IRQ
  82. }
  83. };
  84. static struct dm9000_plat_data dm9000_platdata = {
  85. .flags = DM9000_PLATF_16BITONLY,
  86. };
  87. static struct platform_device at91sam9261_dm9000_device = {
  88. .name = "dm9000",
  89. .id = 0,
  90. .num_resources = ARRAY_SIZE(at91sam9261_dm9000_resource),
  91. .resource = at91sam9261_dm9000_resource,
  92. .dev = {
  93. .platform_data = &dm9000_platdata,
  94. }
  95. };
  96. static void __init ek_add_device_dm9000(void)
  97. {
  98. /*
  99. * Configure Chip-Select 2 on SMC for the DM9000.
  100. * Note: These timings were calculated for MASTER_CLOCK = 100000000
  101. * according to the DM9000 timings.
  102. */
  103. at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
  104. at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8));
  105. at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
  106. at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));
  107. /* Configure Reset signal as output */
  108. at91_set_gpio_output(AT91_PIN_PC10, 0);
  109. /* Configure Interrupt pin as input, no pull-up */
  110. at91_set_gpio_input(AT91_PIN_PC11, 0);
  111. platform_device_register(&at91sam9261_dm9000_device);
  112. }
  113. #else
  114. static void __init ek_add_device_dm9000(void) {}
  115. #endif /* CONFIG_DM9000 */
  116. /*
  117. * USB Host Port
  118. */
  119. static struct at91_usbh_data __initdata ek_usbh_data = {
  120. .ports = 2,
  121. };
  122. /*
  123. * USB Device Port
  124. */
  125. static struct at91_udc_data __initdata ek_udc_data = {
  126. .vbus_pin = AT91_PIN_PB29,
  127. .pullup_pin = 0, /* pull-up driven by UDC */
  128. };
  129. /*
  130. * MCI (SD/MMC)
  131. */
  132. static struct at91_mmc_data __initdata ek_mmc_data = {
  133. .wire4 = 1,
  134. // .det_pin = ... not connected
  135. // .wp_pin = ... not connected
  136. // .vcc_pin = ... not connected
  137. };
  138. /*
  139. * NAND flash
  140. */
  141. static struct mtd_partition __initdata ek_nand_partition[] = {
  142. {
  143. .name = "Partition 1",
  144. .offset = 0,
  145. .size = 256 * 1024,
  146. },
  147. {
  148. .name = "Partition 2",
  149. .offset = 256 * 1024 ,
  150. .size = MTDPART_SIZ_FULL,
  151. },
  152. };
  153. static struct mtd_partition *nand_partitions(int size, int *num_partitions)
  154. {
  155. *num_partitions = ARRAY_SIZE(ek_nand_partition);
  156. return ek_nand_partition;
  157. }
  158. static struct at91_nand_data __initdata ek_nand_data = {
  159. .ale = 22,
  160. .cle = 21,
  161. // .det_pin = ... not connected
  162. .rdy_pin = AT91_PIN_PC15,
  163. .enable_pin = AT91_PIN_PC14,
  164. .partition_info = nand_partitions,
  165. #if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
  166. .bus_width_16 = 1,
  167. #else
  168. .bus_width_16 = 0,
  169. #endif
  170. };
  171. /*
  172. * ADS7846 Touchscreen
  173. */
  174. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  175. static int ads7843_pendown_state(void)
  176. {
  177. return !at91_get_gpio_value(AT91_PIN_PC2); /* Touchscreen PENIRQ */
  178. }
  179. static struct ads7846_platform_data ads_info = {
  180. .model = 7843,
  181. .x_min = 150,
  182. .x_max = 3830,
  183. .y_min = 190,
  184. .y_max = 3830,
  185. .vref_delay_usecs = 100,
  186. .x_plate_ohms = 450,
  187. .y_plate_ohms = 250,
  188. .pressure_max = 15000,
  189. .debounce_max = 1,
  190. .debounce_rep = 0,
  191. .debounce_tol = (~0),
  192. .get_pendown_state = ads7843_pendown_state,
  193. };
  194. static void __init ek_add_device_ts(void)
  195. {
  196. at91_set_B_periph(AT91_PIN_PC2, 1); /* External IRQ0, with pullup */
  197. at91_set_gpio_input(AT91_PIN_PA11, 1); /* Touchscreen BUSY signal */
  198. }
  199. #else
  200. static void __init ek_add_device_ts(void) {}
  201. #endif
  202. /*
  203. * SPI devices
  204. */
  205. static struct spi_board_info ek_spi_devices[] = {
  206. { /* DataFlash chip */
  207. .modalias = "mtd_dataflash",
  208. .chip_select = 0,
  209. .max_speed_hz = 15 * 1000 * 1000,
  210. .bus_num = 0,
  211. },
  212. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  213. {
  214. .modalias = "ads7846",
  215. .chip_select = 2,
  216. .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
  217. .bus_num = 0,
  218. .platform_data = &ads_info,
  219. .irq = AT91SAM9261_ID_IRQ0,
  220. },
  221. #endif
  222. #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
  223. { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
  224. .modalias = "mtd_dataflash",
  225. .chip_select = 3,
  226. .max_speed_hz = 15 * 1000 * 1000,
  227. .bus_num = 0,
  228. },
  229. #elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
  230. { /* AT73C213 DAC */
  231. .modalias = "at73c213",
  232. .chip_select = 3,
  233. .max_speed_hz = 10 * 1000 * 1000,
  234. .bus_num = 0,
  235. },
  236. #endif
  237. };
  238. static void __init ek_board_init(void)
  239. {
  240. /* Serial */
  241. at91_add_device_serial();
  242. /* USB Host */
  243. at91_add_device_usbh(&ek_usbh_data);
  244. /* USB Device */
  245. at91_add_device_udc(&ek_udc_data);
  246. /* I2C */
  247. at91_add_device_i2c();
  248. /* NAND */
  249. at91_add_device_nand(&ek_nand_data);
  250. /* DM9000 ethernet */
  251. ek_add_device_dm9000();
  252. /* spi0 and mmc/sd share the same PIO pins */
  253. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  254. /* SPI */
  255. at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
  256. /* Touchscreen */
  257. ek_add_device_ts();
  258. #else
  259. /* MMC */
  260. at91_add_device_mmc(0, &ek_mmc_data);
  261. #endif
  262. }
  263. MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
  264. /* Maintainer: Atmel */
  265. .phys_io = AT91_BASE_SYS,
  266. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  267. .boot_params = AT91_SDRAM_BASE + 0x100,
  268. .timer = &at91sam926x_timer,
  269. .map_io = ek_map_io,
  270. .init_irq = ek_init_irq,
  271. .init_machine = ek_board_init,
  272. MACHINE_END