board-sam9261ek.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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 <linux/fb.h>
  30. #include <video/atmel_lcdc.h>
  31. #include <asm/hardware.h>
  32. #include <asm/setup.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/irq.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/irq.h>
  38. #include <asm/arch/board.h>
  39. #include <asm/arch/gpio.h>
  40. #include <asm/arch/at91sam926x_mc.h>
  41. #include "generic.h"
  42. /*
  43. * Serial port configuration.
  44. * 0 .. 2 = USART0 .. USART2
  45. * 3 = DBGU
  46. */
  47. static struct at91_uart_config __initdata ek_uart_config = {
  48. .console_tty = 0, /* ttyS0 */
  49. .nr_tty = 1,
  50. .tty_map = { 3, -1, -1, -1 } /* ttyS0, ..., ttyS3 */
  51. };
  52. static void __init ek_map_io(void)
  53. {
  54. /* Initialize processor: 18.432 MHz crystal */
  55. at91sam9261_initialize(18432000);
  56. /* Setup the LEDs */
  57. at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
  58. /* Setup the serial ports and console */
  59. at91_init_serial(&ek_uart_config);
  60. }
  61. static void __init ek_init_irq(void)
  62. {
  63. at91sam9261_init_interrupts(NULL);
  64. }
  65. /*
  66. * DM9000 ethernet device
  67. */
  68. #if defined(CONFIG_DM9000)
  69. static struct resource at91sam9261_dm9000_resource[] = {
  70. [0] = {
  71. .start = AT91_CHIPSELECT_2,
  72. .end = AT91_CHIPSELECT_2 + 3,
  73. .flags = IORESOURCE_MEM
  74. },
  75. [1] = {
  76. .start = AT91_CHIPSELECT_2 + 0x44,
  77. .end = AT91_CHIPSELECT_2 + 0xFF,
  78. .flags = IORESOURCE_MEM
  79. },
  80. [2] = {
  81. .start = AT91_PIN_PC11,
  82. .end = AT91_PIN_PC11,
  83. .flags = IORESOURCE_IRQ
  84. }
  85. };
  86. static struct dm9000_plat_data dm9000_platdata = {
  87. .flags = DM9000_PLATF_16BITONLY,
  88. };
  89. static struct platform_device at91sam9261_dm9000_device = {
  90. .name = "dm9000",
  91. .id = 0,
  92. .num_resources = ARRAY_SIZE(at91sam9261_dm9000_resource),
  93. .resource = at91sam9261_dm9000_resource,
  94. .dev = {
  95. .platform_data = &dm9000_platdata,
  96. }
  97. };
  98. static void __init ek_add_device_dm9000(void)
  99. {
  100. /*
  101. * Configure Chip-Select 2 on SMC for the DM9000.
  102. * Note: These timings were calculated for MASTER_CLOCK = 100000000
  103. * according to the DM9000 timings.
  104. */
  105. 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));
  106. 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));
  107. at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
  108. 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));
  109. /* Configure Reset signal as output */
  110. at91_set_gpio_output(AT91_PIN_PC10, 0);
  111. /* Configure Interrupt pin as input, no pull-up */
  112. at91_set_gpio_input(AT91_PIN_PC11, 0);
  113. platform_device_register(&at91sam9261_dm9000_device);
  114. }
  115. #else
  116. static void __init ek_add_device_dm9000(void) {}
  117. #endif /* CONFIG_DM9000 */
  118. /*
  119. * USB Host Port
  120. */
  121. static struct at91_usbh_data __initdata ek_usbh_data = {
  122. .ports = 2,
  123. };
  124. /*
  125. * USB Device Port
  126. */
  127. static struct at91_udc_data __initdata ek_udc_data = {
  128. .vbus_pin = AT91_PIN_PB29,
  129. .pullup_pin = 0, /* pull-up driven by UDC */
  130. };
  131. /*
  132. * MCI (SD/MMC)
  133. */
  134. static struct at91_mmc_data __initdata ek_mmc_data = {
  135. .wire4 = 1,
  136. // .det_pin = ... not connected
  137. // .wp_pin = ... not connected
  138. // .vcc_pin = ... not connected
  139. };
  140. /*
  141. * NAND flash
  142. */
  143. static struct mtd_partition __initdata ek_nand_partition[] = {
  144. {
  145. .name = "Partition 1",
  146. .offset = 0,
  147. .size = 256 * 1024,
  148. },
  149. {
  150. .name = "Partition 2",
  151. .offset = 256 * 1024 ,
  152. .size = MTDPART_SIZ_FULL,
  153. },
  154. };
  155. static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
  156. {
  157. *num_partitions = ARRAY_SIZE(ek_nand_partition);
  158. return ek_nand_partition;
  159. }
  160. static struct at91_nand_data __initdata ek_nand_data = {
  161. .ale = 22,
  162. .cle = 21,
  163. // .det_pin = ... not connected
  164. .rdy_pin = AT91_PIN_PC15,
  165. .enable_pin = AT91_PIN_PC14,
  166. .partition_info = nand_partitions,
  167. #if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
  168. .bus_width_16 = 1,
  169. #else
  170. .bus_width_16 = 0,
  171. #endif
  172. };
  173. /*
  174. * ADS7846 Touchscreen
  175. */
  176. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  177. static int ads7843_pendown_state(void)
  178. {
  179. return !at91_get_gpio_value(AT91_PIN_PC2); /* Touchscreen PENIRQ */
  180. }
  181. static struct ads7846_platform_data ads_info = {
  182. .model = 7843,
  183. .x_min = 150,
  184. .x_max = 3830,
  185. .y_min = 190,
  186. .y_max = 3830,
  187. .vref_delay_usecs = 100,
  188. .x_plate_ohms = 450,
  189. .y_plate_ohms = 250,
  190. .pressure_max = 15000,
  191. .debounce_max = 1,
  192. .debounce_rep = 0,
  193. .debounce_tol = (~0),
  194. .get_pendown_state = ads7843_pendown_state,
  195. };
  196. static void __init ek_add_device_ts(void)
  197. {
  198. at91_set_B_periph(AT91_PIN_PC2, 1); /* External IRQ0, with pullup */
  199. at91_set_gpio_input(AT91_PIN_PA11, 1); /* Touchscreen BUSY signal */
  200. }
  201. #else
  202. static void __init ek_add_device_ts(void) {}
  203. #endif
  204. /*
  205. * SPI devices
  206. */
  207. static struct spi_board_info ek_spi_devices[] = {
  208. { /* DataFlash chip */
  209. .modalias = "mtd_dataflash",
  210. .chip_select = 0,
  211. .max_speed_hz = 15 * 1000 * 1000,
  212. .bus_num = 0,
  213. },
  214. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  215. {
  216. .modalias = "ads7846",
  217. .chip_select = 2,
  218. .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
  219. .bus_num = 0,
  220. .platform_data = &ads_info,
  221. .irq = AT91SAM9261_ID_IRQ0,
  222. },
  223. #endif
  224. #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
  225. { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
  226. .modalias = "mtd_dataflash",
  227. .chip_select = 3,
  228. .max_speed_hz = 15 * 1000 * 1000,
  229. .bus_num = 0,
  230. },
  231. #elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
  232. { /* AT73C213 DAC */
  233. .modalias = "at73c213",
  234. .chip_select = 3,
  235. .max_speed_hz = 10 * 1000 * 1000,
  236. .bus_num = 0,
  237. },
  238. #endif
  239. };
  240. /*
  241. * LCD Controller
  242. */
  243. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  244. static struct fb_videomode at91_tft_vga_modes[] = {
  245. {
  246. .name = "TX09D50VM1CCA @ 60",
  247. .refresh = 60,
  248. .xres = 240, .yres = 320,
  249. .pixclock = KHZ2PICOS(4965),
  250. .left_margin = 1, .right_margin = 33,
  251. .upper_margin = 1, .lower_margin = 0,
  252. .hsync_len = 5, .vsync_len = 1,
  253. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  254. .vmode = FB_VMODE_NONINTERLACED,
  255. },
  256. };
  257. static struct fb_monspecs at91fb_default_monspecs = {
  258. .manufacturer = "HIT",
  259. .monitor = "TX09D50VM1CCA",
  260. .modedb = at91_tft_vga_modes,
  261. .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
  262. .hfmin = 15000,
  263. .hfmax = 64000,
  264. .vfmin = 50,
  265. .vfmax = 150,
  266. };
  267. #define AT91SAM9261_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
  268. | ATMEL_LCDC_DISTYPE_TFT \
  269. | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
  270. static void at91_lcdc_power_control(int on)
  271. {
  272. if (on)
  273. at91_set_gpio_value(AT91_PIN_PA12, 0); /* power up */
  274. else
  275. at91_set_gpio_value(AT91_PIN_PA12, 1); /* power down */
  276. }
  277. /* Driver datas */
  278. static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
  279. .default_bpp = 16,
  280. .default_dmacon = ATMEL_LCDC_DMAEN,
  281. .default_lcdcon2 = AT91SAM9261_DEFAULT_LCDCON2,
  282. .default_monspecs = &at91fb_default_monspecs,
  283. .atmel_lcdfb_power_control = at91_lcdc_power_control,
  284. .guard_time = 1,
  285. };
  286. #else
  287. static struct atmel_lcdfb_info __initdata ek_lcdc_data;
  288. #endif
  289. static void __init ek_board_init(void)
  290. {
  291. /* Serial */
  292. at91_add_device_serial();
  293. /* USB Host */
  294. at91_add_device_usbh(&ek_usbh_data);
  295. /* USB Device */
  296. at91_add_device_udc(&ek_udc_data);
  297. /* I2C */
  298. at91_add_device_i2c();
  299. /* NAND */
  300. at91_add_device_nand(&ek_nand_data);
  301. /* DM9000 ethernet */
  302. ek_add_device_dm9000();
  303. /* spi0 and mmc/sd share the same PIO pins */
  304. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  305. /* SPI */
  306. at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
  307. /* Touchscreen */
  308. ek_add_device_ts();
  309. #else
  310. /* MMC */
  311. at91_add_device_mmc(0, &ek_mmc_data);
  312. #endif
  313. /* LCD Controller */
  314. at91_add_device_lcdc(&ek_lcdc_data);
  315. }
  316. MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
  317. /* Maintainer: Atmel */
  318. .phys_io = AT91_BASE_SYS,
  319. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  320. .boot_params = AT91_SDRAM_BASE + 0x100,
  321. .timer = &at91sam926x_timer,
  322. .map_io = ek_map_io,
  323. .init_irq = ek_init_irq,
  324. .init_machine = ek_board_init,
  325. MACHINE_END