board-sam9261ek.c 10 KB

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