board-sam9rlek.c 6.8 KB

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