board-sam9261ek.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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 serial ports and console */
  55. at91_init_serial(&ek_uart_config);
  56. }
  57. static void __init ek_init_irq(void)
  58. {
  59. at91sam9261_init_interrupts(NULL);
  60. }
  61. /*
  62. * DM9000 ethernet device
  63. */
  64. #if defined(CONFIG_DM9000)
  65. static struct resource at91sam9261_dm9000_resource[] = {
  66. [0] = {
  67. .start = AT91_CHIPSELECT_2,
  68. .end = AT91_CHIPSELECT_2 + 3,
  69. .flags = IORESOURCE_MEM
  70. },
  71. [1] = {
  72. .start = AT91_CHIPSELECT_2 + 0x44,
  73. .end = AT91_CHIPSELECT_2 + 0xFF,
  74. .flags = IORESOURCE_MEM
  75. },
  76. [2] = {
  77. .start = AT91_PIN_PC11,
  78. .end = AT91_PIN_PC11,
  79. .flags = IORESOURCE_IRQ
  80. }
  81. };
  82. static struct dm9000_plat_data dm9000_platdata = {
  83. .flags = DM9000_PLATF_16BITONLY,
  84. };
  85. static struct platform_device at91sam9261_dm9000_device = {
  86. .name = "dm9000",
  87. .id = 0,
  88. .num_resources = ARRAY_SIZE(at91sam9261_dm9000_resource),
  89. .resource = at91sam9261_dm9000_resource,
  90. .dev = {
  91. .platform_data = &dm9000_platdata,
  92. }
  93. };
  94. static void __init ek_add_device_dm9000(void)
  95. {
  96. /*
  97. * Configure Chip-Select 2 on SMC for the DM9000.
  98. * Note: These timings were calculated for MASTER_CLOCK = 100000000
  99. * according to the DM9000 timings.
  100. */
  101. 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));
  102. 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));
  103. at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
  104. 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));
  105. /* Configure Reset signal as output */
  106. at91_set_gpio_output(AT91_PIN_PC10, 0);
  107. /* Configure Interrupt pin as input, no pull-up */
  108. at91_set_gpio_input(AT91_PIN_PC11, 0);
  109. platform_device_register(&at91sam9261_dm9000_device);
  110. }
  111. #else
  112. static void __init ek_add_device_dm9000(void) {}
  113. #endif /* CONFIG_DM9000 */
  114. /*
  115. * USB Host Port
  116. */
  117. static struct at91_usbh_data __initdata ek_usbh_data = {
  118. .ports = 2,
  119. };
  120. /*
  121. * USB Device Port
  122. */
  123. static struct at91_udc_data __initdata ek_udc_data = {
  124. .vbus_pin = AT91_PIN_PB29,
  125. .pullup_pin = 0, /* pull-up driven by UDC */
  126. };
  127. /*
  128. * MCI (SD/MMC)
  129. */
  130. static struct at91_mmc_data __initdata ek_mmc_data = {
  131. .wire4 = 1,
  132. // .det_pin = ... not connected
  133. // .wp_pin = ... not connected
  134. // .vcc_pin = ... not connected
  135. };
  136. /*
  137. * NAND flash
  138. */
  139. static struct mtd_partition __initdata ek_nand_partition[] = {
  140. {
  141. .name = "Partition 1",
  142. .offset = 0,
  143. .size = 256 * 1024,
  144. },
  145. {
  146. .name = "Partition 2",
  147. .offset = 256 * 1024 ,
  148. .size = MTDPART_SIZ_FULL,
  149. },
  150. };
  151. static struct mtd_partition *nand_partitions(int size, int *num_partitions)
  152. {
  153. *num_partitions = ARRAY_SIZE(ek_nand_partition);
  154. return ek_nand_partition;
  155. }
  156. static struct at91_nand_data __initdata ek_nand_data = {
  157. .ale = 22,
  158. .cle = 21,
  159. // .det_pin = ... not connected
  160. .rdy_pin = AT91_PIN_PC15,
  161. .enable_pin = AT91_PIN_PC14,
  162. .partition_info = nand_partitions,
  163. #if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
  164. .bus_width_16 = 1,
  165. #else
  166. .bus_width_16 = 0,
  167. #endif
  168. };
  169. /*
  170. * ADS7846 Touchscreen
  171. */
  172. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  173. static int ads7843_pendown_state(void)
  174. {
  175. return !at91_get_gpio_value(AT91_PIN_PC2); /* Touchscreen PENIRQ */
  176. }
  177. static struct ads7846_platform_data ads_info = {
  178. .model = 7843,
  179. .x_min = 150,
  180. .x_max = 3830,
  181. .y_min = 190,
  182. .y_max = 3830,
  183. .vref_delay_usecs = 100,
  184. .x_plate_ohms = 450,
  185. .y_plate_ohms = 250,
  186. .pressure_max = 15000,
  187. .debounce_max = 1,
  188. .debounce_rep = 0,
  189. .debounce_tol = (~0),
  190. .get_pendown_state = ads7843_pendown_state,
  191. };
  192. static void __init ek_add_device_ts(void)
  193. {
  194. at91_set_B_periph(AT91_PIN_PC2, 1); /* External IRQ0, with pullup */
  195. at91_set_gpio_input(AT91_PIN_PA11, 1); /* Touchscreen BUSY signal */
  196. }
  197. #else
  198. static void __init ek_add_device_ts(void) {}
  199. #endif
  200. /*
  201. * SPI devices
  202. */
  203. static struct spi_board_info ek_spi_devices[] = {
  204. { /* DataFlash chip */
  205. .modalias = "mtd_dataflash",
  206. .chip_select = 0,
  207. .max_speed_hz = 15 * 1000 * 1000,
  208. .bus_num = 0,
  209. },
  210. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  211. {
  212. .modalias = "ads7846",
  213. .chip_select = 2,
  214. .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
  215. .bus_num = 0,
  216. .platform_data = &ads_info,
  217. .irq = AT91SAM9261_ID_IRQ0,
  218. },
  219. #endif
  220. #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
  221. { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
  222. .modalias = "mtd_dataflash",
  223. .chip_select = 3,
  224. .max_speed_hz = 15 * 1000 * 1000,
  225. .bus_num = 0,
  226. },
  227. #elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
  228. { /* AT73C213 DAC */
  229. .modalias = "at73c213",
  230. .chip_select = 3,
  231. .max_speed_hz = 10 * 1000 * 1000,
  232. .bus_num = 0,
  233. },
  234. #endif
  235. };
  236. static void __init ek_board_init(void)
  237. {
  238. /* Serial */
  239. at91_add_device_serial();
  240. /* USB Host */
  241. at91_add_device_usbh(&ek_usbh_data);
  242. /* USB Device */
  243. at91_add_device_udc(&ek_udc_data);
  244. /* I2C */
  245. at91_add_device_i2c();
  246. /* NAND */
  247. at91_add_device_nand(&ek_nand_data);
  248. /* DM9000 ethernet */
  249. ek_add_device_dm9000();
  250. /* spi0 and mmc/sd share the same PIO pins */
  251. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  252. /* SPI */
  253. at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
  254. /* Touchscreen */
  255. ek_add_device_ts();
  256. #else
  257. /* MMC */
  258. at91_add_device_mmc(0, &ek_mmc_data);
  259. #endif
  260. }
  261. MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
  262. /* Maintainer: Atmel */
  263. .phys_io = AT91_BASE_SYS,
  264. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  265. .boot_params = AT91_SDRAM_BASE + 0x100,
  266. .timer = &at91sam926x_timer,
  267. .map_io = ek_map_io,
  268. .init_irq = ek_init_irq,
  269. .init_machine = ek_board_init,
  270. MACHINE_END