board-sam9261ek.c 12 KB

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