board-sam9rlek.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*
  2. * Copyright (C) 2005 SAN People
  3. * Copyright (C) 2007 Atmel Corporation
  4. *
  5. * This file is subject to the terms and conditions of the GNU General Public
  6. * License. See the file COPYING in the main directory of this archive for
  7. * more details.
  8. */
  9. #include <linux/types.h>
  10. #include <linux/init.h>
  11. #include <linux/mm.h>
  12. #include <linux/module.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/fb.h>
  16. #include <linux/clk.h>
  17. #include <linux/input.h>
  18. #include <linux/gpio_keys.h>
  19. #include <video/atmel_lcdc.h>
  20. #include <asm/setup.h>
  21. #include <asm/mach-types.h>
  22. #include <asm/irq.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/irq.h>
  26. #include <mach/hardware.h>
  27. #include <mach/board.h>
  28. #include <mach/gpio.h>
  29. #include <mach/at91sam9_smc.h>
  30. #include <mach/at91_shdwc.h>
  31. #include "sam9_smc.h"
  32. #include "generic.h"
  33. static void __init ek_map_io(void)
  34. {
  35. /* Initialize processor: 12.000 MHz crystal */
  36. at91sam9rl_initialize(12000000);
  37. /* DBGU on ttyS0. (Rx & Tx only) */
  38. at91_register_uart(0, 0, 0);
  39. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
  40. at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
  41. /* set serial console to ttyS0 (ie, DBGU) */
  42. at91_set_serial_console(0);
  43. }
  44. static void __init ek_init_irq(void)
  45. {
  46. at91sam9rl_init_interrupts(NULL);
  47. }
  48. /*
  49. * USB HS Device port
  50. */
  51. static struct usba_platform_data __initdata ek_usba_udc_data = {
  52. .vbus_pin = AT91_PIN_PA8,
  53. };
  54. /*
  55. * MCI (SD/MMC)
  56. */
  57. static struct at91_mmc_data __initdata ek_mmc_data = {
  58. .wire4 = 1,
  59. .det_pin = AT91_PIN_PA15,
  60. // .wp_pin = ... not connected
  61. // .vcc_pin = ... not connected
  62. };
  63. /*
  64. * NAND flash
  65. */
  66. static struct mtd_partition __initdata ek_nand_partition[] = {
  67. {
  68. .name = "Partition 1",
  69. .offset = 0,
  70. .size = SZ_256K,
  71. },
  72. {
  73. .name = "Partition 2",
  74. .offset = MTDPART_OFS_NXTBLK,
  75. .size = MTDPART_SIZ_FULL,
  76. },
  77. };
  78. static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
  79. {
  80. *num_partitions = ARRAY_SIZE(ek_nand_partition);
  81. return ek_nand_partition;
  82. }
  83. static struct atmel_nand_data __initdata ek_nand_data = {
  84. .ale = 21,
  85. .cle = 22,
  86. // .det_pin = ... not connected
  87. .rdy_pin = AT91_PIN_PD17,
  88. .enable_pin = AT91_PIN_PB6,
  89. .partition_info = nand_partitions,
  90. };
  91. static struct sam9_smc_config __initdata ek_nand_smc_config = {
  92. .ncs_read_setup = 0,
  93. .nrd_setup = 1,
  94. .ncs_write_setup = 0,
  95. .nwe_setup = 1,
  96. .ncs_read_pulse = 3,
  97. .nrd_pulse = 3,
  98. .ncs_write_pulse = 3,
  99. .nwe_pulse = 3,
  100. .read_cycle = 5,
  101. .write_cycle = 5,
  102. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  103. .tdf_cycles = 2,
  104. };
  105. static void __init ek_add_device_nand(void)
  106. {
  107. /* configure chip-select 3 (NAND) */
  108. sam9_smc_configure(3, &ek_nand_smc_config);
  109. at91_add_device_nand(&ek_nand_data);
  110. }
  111. /*
  112. * SPI devices
  113. */
  114. static struct spi_board_info ek_spi_devices[] = {
  115. { /* DataFlash chip */
  116. .modalias = "mtd_dataflash",
  117. .chip_select = 0,
  118. .max_speed_hz = 15 * 1000 * 1000,
  119. .bus_num = 0,
  120. },
  121. };
  122. /*
  123. * LCD Controller
  124. */
  125. #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
  126. static struct fb_videomode at91_tft_vga_modes[] = {
  127. {
  128. .name = "TX09D50VM1CCA @ 60",
  129. .refresh = 60,
  130. .xres = 240, .yres = 320,
  131. .pixclock = KHZ2PICOS(4965),
  132. .left_margin = 1, .right_margin = 33,
  133. .upper_margin = 1, .lower_margin = 0,
  134. .hsync_len = 5, .vsync_len = 1,
  135. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  136. .vmode = FB_VMODE_NONINTERLACED,
  137. },
  138. };
  139. static struct fb_monspecs at91fb_default_monspecs = {
  140. .manufacturer = "HIT",
  141. .monitor = "TX09D50VM1CCA",
  142. .modedb = at91_tft_vga_modes,
  143. .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
  144. .hfmin = 15000,
  145. .hfmax = 64000,
  146. .vfmin = 50,
  147. .vfmax = 150,
  148. };
  149. #define AT91SAM9RL_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
  150. | ATMEL_LCDC_DISTYPE_TFT \
  151. | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
  152. static void at91_lcdc_power_control(int on)
  153. {
  154. if (on)
  155. at91_set_gpio_value(AT91_PIN_PC1, 0); /* power up */
  156. else
  157. at91_set_gpio_value(AT91_PIN_PC1, 1); /* power down */
  158. }
  159. /* Driver datas */
  160. static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
  161. .lcdcon_is_backlight = true,
  162. .default_bpp = 16,
  163. .default_dmacon = ATMEL_LCDC_DMAEN,
  164. .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2,
  165. .default_monspecs = &at91fb_default_monspecs,
  166. .atmel_lcdfb_power_control = at91_lcdc_power_control,
  167. .guard_time = 1,
  168. .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
  169. };
  170. #else
  171. static struct atmel_lcdfb_info __initdata ek_lcdc_data;
  172. #endif
  173. /*
  174. * AC97
  175. * reset_pin is not connected: NRST
  176. */
  177. static struct ac97c_platform_data ek_ac97_data = {
  178. };
  179. /*
  180. * LEDs
  181. */
  182. static struct gpio_led ek_leds[] = {
  183. { /* "bottom" led, green, userled1 to be defined */
  184. .name = "ds1",
  185. .gpio = AT91_PIN_PD15,
  186. .active_low = 1,
  187. .default_trigger = "none",
  188. },
  189. { /* "bottom" led, green, userled2 to be defined */
  190. .name = "ds2",
  191. .gpio = AT91_PIN_PD16,
  192. .active_low = 1,
  193. .default_trigger = "none",
  194. },
  195. { /* "power" led, yellow */
  196. .name = "ds3",
  197. .gpio = AT91_PIN_PD14,
  198. .default_trigger = "heartbeat",
  199. }
  200. };
  201. /*
  202. * Touchscreen
  203. */
  204. static struct at91_tsadcc_data ek_tsadcc_data = {
  205. .adc_clock = 1000000,
  206. .pendet_debounce = 0x0f,
  207. .ts_sample_hold_time = 0x03,
  208. };
  209. /*
  210. * GPIO Buttons
  211. */
  212. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  213. static struct gpio_keys_button ek_buttons[] = {
  214. {
  215. .gpio = AT91_PIN_PB0,
  216. .code = BTN_2,
  217. .desc = "Right Click",
  218. .active_low = 1,
  219. .wakeup = 1,
  220. },
  221. {
  222. .gpio = AT91_PIN_PB1,
  223. .code = BTN_1,
  224. .desc = "Left Click",
  225. .active_low = 1,
  226. .wakeup = 1,
  227. }
  228. };
  229. static struct gpio_keys_platform_data ek_button_data = {
  230. .buttons = ek_buttons,
  231. .nbuttons = ARRAY_SIZE(ek_buttons),
  232. };
  233. static struct platform_device ek_button_device = {
  234. .name = "gpio-keys",
  235. .id = -1,
  236. .num_resources = 0,
  237. .dev = {
  238. .platform_data = &ek_button_data,
  239. }
  240. };
  241. static void __init ek_add_device_buttons(void)
  242. {
  243. at91_set_gpio_input(AT91_PIN_PB1, 1); /* btn1 */
  244. at91_set_deglitch(AT91_PIN_PB1, 1);
  245. at91_set_gpio_input(AT91_PIN_PB0, 1); /* btn2 */
  246. at91_set_deglitch(AT91_PIN_PB0, 1);
  247. platform_device_register(&ek_button_device);
  248. }
  249. #else
  250. static void __init ek_add_device_buttons(void) {}
  251. #endif
  252. static void __init ek_board_init(void)
  253. {
  254. /* Serial */
  255. at91_add_device_serial();
  256. /* USB HS */
  257. at91_add_device_usba(&ek_usba_udc_data);
  258. /* I2C */
  259. at91_add_device_i2c(NULL, 0);
  260. /* NAND */
  261. ek_add_device_nand();
  262. /* SPI */
  263. at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
  264. /* MMC */
  265. at91_add_device_mmc(0, &ek_mmc_data);
  266. /* LCD Controller */
  267. at91_add_device_lcdc(&ek_lcdc_data);
  268. /* AC97 */
  269. at91_add_device_ac97(&ek_ac97_data);
  270. /* Touch Screen Controller */
  271. at91_add_device_tsadcc(&ek_tsadcc_data);
  272. /* LEDs */
  273. at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
  274. /* Push Buttons */
  275. ek_add_device_buttons();
  276. }
  277. MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
  278. /* Maintainer: Atmel */
  279. .phys_io = AT91_BASE_SYS,
  280. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  281. .boot_params = AT91_SDRAM_BASE + 0x100,
  282. .timer = &at91sam926x_timer,
  283. .map_io = ek_map_io,
  284. .init_irq = ek_init_irq,
  285. .init_machine = ek_board_init,
  286. MACHINE_END