board-cpu9krea.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. /*
  2. * linux/arch/arm/mach-at91/board-cpu9krea.c
  3. *
  4. * Copyright (C) 2005 SAN People
  5. * Copyright (C) 2006 Atmel
  6. * Copyright (C) 2009 Eric Benard - eric@eukrea.com
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/types.h>
  23. #include <linux/init.h>
  24. #include <linux/mm.h>
  25. #include <linux/module.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/clk.h>
  28. #include <linux/gpio_keys.h>
  29. #include <linux/input.h>
  30. #include <linux/mtd/physmap.h>
  31. #include <asm/setup.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/irq.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <mach/hardware.h>
  38. #include <mach/board.h>
  39. #include <mach/gpio.h>
  40. #include <mach/at91sam9_smc.h>
  41. #include <mach/at91sam9260_matrix.h>
  42. #include "sam9_smc.h"
  43. #include "generic.h"
  44. static void __init cpu9krea_map_io(void)
  45. {
  46. /* Initialize processor: 18.432 MHz crystal */
  47. at91sam9260_initialize(18432000);
  48. /* DGBU on ttyS0. (Rx & Tx only) */
  49. at91_register_uart(0, 0, 0);
  50. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
  51. at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |
  52. ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
  53. ATMEL_UART_DCD | ATMEL_UART_RI);
  54. /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
  55. at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |
  56. ATMEL_UART_RTS);
  57. /* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
  58. at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |
  59. ATMEL_UART_RTS);
  60. /* USART3 on ttyS4. (Rx, Tx) */
  61. at91_register_uart(AT91SAM9260_ID_US3, 4, 0);
  62. /* USART4 on ttyS5. (Rx, Tx) */
  63. at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
  64. /* USART5 on ttyS6. (Rx, Tx) */
  65. at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
  66. /* set serial console to ttyS0 (ie, DBGU) */
  67. at91_set_serial_console(0);
  68. }
  69. static void __init cpu9krea_init_irq(void)
  70. {
  71. at91sam9260_init_interrupts(NULL);
  72. }
  73. /*
  74. * USB Host port
  75. */
  76. static struct at91_usbh_data __initdata cpu9krea_usbh_data = {
  77. .ports = 2,
  78. };
  79. /*
  80. * USB Device port
  81. */
  82. static struct at91_udc_data __initdata cpu9krea_udc_data = {
  83. .vbus_pin = AT91_PIN_PC8,
  84. .pullup_pin = 0, /* pull-up driven by UDC */
  85. };
  86. /*
  87. * MACB Ethernet device
  88. */
  89. static struct at91_eth_data __initdata cpu9krea_macb_data = {
  90. .is_rmii = 1,
  91. };
  92. /*
  93. * NAND flash
  94. */
  95. static struct atmel_nand_data __initdata cpu9krea_nand_data = {
  96. .ale = 21,
  97. .cle = 22,
  98. .rdy_pin = AT91_PIN_PC13,
  99. .enable_pin = AT91_PIN_PC14,
  100. .bus_width_16 = 0,
  101. };
  102. #ifdef CONFIG_MACH_CPU9260
  103. static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
  104. .ncs_read_setup = 0,
  105. .nrd_setup = 1,
  106. .ncs_write_setup = 0,
  107. .nwe_setup = 1,
  108. .ncs_read_pulse = 3,
  109. .nrd_pulse = 3,
  110. .ncs_write_pulse = 3,
  111. .nwe_pulse = 3,
  112. .read_cycle = 5,
  113. .write_cycle = 5,
  114. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  115. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  116. .tdf_cycles = 2,
  117. };
  118. #else
  119. static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
  120. .ncs_read_setup = 0,
  121. .nrd_setup = 2,
  122. .ncs_write_setup = 0,
  123. .nwe_setup = 2,
  124. .ncs_read_pulse = 4,
  125. .nrd_pulse = 4,
  126. .ncs_write_pulse = 4,
  127. .nwe_pulse = 4,
  128. .read_cycle = 7,
  129. .write_cycle = 7,
  130. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  131. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  132. .tdf_cycles = 3,
  133. };
  134. #endif
  135. static void __init cpu9krea_add_device_nand(void)
  136. {
  137. sam9_smc_configure(3, &cpu9krea_nand_smc_config);
  138. at91_add_device_nand(&cpu9krea_nand_data);
  139. }
  140. /*
  141. * NOR flash
  142. */
  143. static struct physmap_flash_data cpuat9260_nor_data = {
  144. .width = 2,
  145. };
  146. #define NOR_BASE AT91_CHIPSELECT_0
  147. #define NOR_SIZE SZ_64M
  148. static struct resource nor_flash_resources[] = {
  149. {
  150. .start = NOR_BASE,
  151. .end = NOR_BASE + NOR_SIZE - 1,
  152. .flags = IORESOURCE_MEM,
  153. }
  154. };
  155. static struct platform_device cpu9krea_nor_flash = {
  156. .name = "physmap-flash",
  157. .id = 0,
  158. .dev = {
  159. .platform_data = &cpuat9260_nor_data,
  160. },
  161. .resource = nor_flash_resources,
  162. .num_resources = ARRAY_SIZE(nor_flash_resources),
  163. };
  164. #ifdef CONFIG_MACH_CPU9260
  165. static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
  166. .ncs_read_setup = 0,
  167. .nrd_setup = 1,
  168. .ncs_write_setup = 0,
  169. .nwe_setup = 1,
  170. .ncs_read_pulse = 10,
  171. .nrd_pulse = 10,
  172. .ncs_write_pulse = 6,
  173. .nwe_pulse = 6,
  174. .read_cycle = 12,
  175. .write_cycle = 8,
  176. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  177. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
  178. | AT91_SMC_DBW_16,
  179. .tdf_cycles = 2,
  180. };
  181. #else
  182. static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
  183. .ncs_read_setup = 0,
  184. .nrd_setup = 1,
  185. .ncs_write_setup = 0,
  186. .nwe_setup = 1,
  187. .ncs_read_pulse = 13,
  188. .nrd_pulse = 13,
  189. .ncs_write_pulse = 8,
  190. .nwe_pulse = 8,
  191. .read_cycle = 15,
  192. .write_cycle = 10,
  193. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  194. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
  195. | AT91_SMC_DBW_16,
  196. .tdf_cycles = 2,
  197. };
  198. #endif
  199. static __init void cpu9krea_add_device_nor(void)
  200. {
  201. unsigned long csa;
  202. csa = at91_sys_read(AT91_MATRIX_EBICSA);
  203. at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);
  204. /* configure chip-select 0 (NOR) */
  205. sam9_smc_configure(0, &cpu9krea_nor_smc_config);
  206. platform_device_register(&cpu9krea_nor_flash);
  207. }
  208. /*
  209. * LEDs
  210. */
  211. static struct gpio_led cpu9krea_leds[] = {
  212. { /* LED1 */
  213. .name = "LED1",
  214. .gpio = AT91_PIN_PC11,
  215. .active_low = 1,
  216. .default_trigger = "timer",
  217. },
  218. { /* LED2 */
  219. .name = "LED2",
  220. .gpio = AT91_PIN_PC12,
  221. .active_low = 1,
  222. .default_trigger = "heartbeat",
  223. },
  224. { /* LED3 */
  225. .name = "LED3",
  226. .gpio = AT91_PIN_PC7,
  227. .active_low = 1,
  228. .default_trigger = "none",
  229. },
  230. { /* LED4 */
  231. .name = "LED4",
  232. .gpio = AT91_PIN_PC9,
  233. .active_low = 1,
  234. .default_trigger = "none",
  235. }
  236. };
  237. static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = {
  238. {
  239. I2C_BOARD_INFO("rtc-ds1307", 0x68),
  240. .type = "ds1339",
  241. },
  242. };
  243. /*
  244. * GPIO Buttons
  245. */
  246. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  247. static struct gpio_keys_button cpu9krea_buttons[] = {
  248. {
  249. .gpio = AT91_PIN_PC3,
  250. .code = BTN_0,
  251. .desc = "BP1",
  252. .active_low = 1,
  253. .wakeup = 1,
  254. },
  255. {
  256. .gpio = AT91_PIN_PB20,
  257. .code = BTN_1,
  258. .desc = "BP2",
  259. .active_low = 1,
  260. .wakeup = 1,
  261. }
  262. };
  263. static struct gpio_keys_platform_data cpu9krea_button_data = {
  264. .buttons = cpu9krea_buttons,
  265. .nbuttons = ARRAY_SIZE(cpu9krea_buttons),
  266. };
  267. static struct platform_device cpu9krea_button_device = {
  268. .name = "gpio-keys",
  269. .id = -1,
  270. .num_resources = 0,
  271. .dev = {
  272. .platform_data = &cpu9krea_button_data,
  273. }
  274. };
  275. static void __init cpu9krea_add_device_buttons(void)
  276. {
  277. at91_set_gpio_input(AT91_PIN_PC3, 1); /* BP1 */
  278. at91_set_deglitch(AT91_PIN_PC3, 1);
  279. at91_set_gpio_input(AT91_PIN_PB20, 1); /* BP2 */
  280. at91_set_deglitch(AT91_PIN_PB20, 1);
  281. platform_device_register(&cpu9krea_button_device);
  282. }
  283. #else
  284. static void __init cpu9krea_add_device_buttons(void)
  285. {
  286. }
  287. #endif
  288. /*
  289. * MCI (SD/MMC)
  290. */
  291. static struct at91_mmc_data __initdata cpu9krea_mmc_data = {
  292. .slot_b = 0,
  293. .wire4 = 1,
  294. .det_pin = AT91_PIN_PA29,
  295. };
  296. static void __init cpu9krea_board_init(void)
  297. {
  298. /* NOR */
  299. cpu9krea_add_device_nor();
  300. /* Serial */
  301. at91_add_device_serial();
  302. /* USB Host */
  303. at91_add_device_usbh(&cpu9krea_usbh_data);
  304. /* USB Device */
  305. at91_add_device_udc(&cpu9krea_udc_data);
  306. /* NAND */
  307. cpu9krea_add_device_nand();
  308. /* Ethernet */
  309. at91_add_device_eth(&cpu9krea_macb_data);
  310. /* MMC */
  311. at91_add_device_mmc(0, &cpu9krea_mmc_data);
  312. /* I2C */
  313. at91_add_device_i2c(cpu9krea_i2c_devices,
  314. ARRAY_SIZE(cpu9krea_i2c_devices));
  315. /* LEDs */
  316. at91_gpio_leds(cpu9krea_leds, ARRAY_SIZE(cpu9krea_leds));
  317. /* Push Buttons */
  318. cpu9krea_add_device_buttons();
  319. }
  320. #ifdef CONFIG_MACH_CPU9260
  321. MACHINE_START(CPUAT9260, "Eukrea CPU9260")
  322. #else
  323. MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
  324. #endif
  325. /* Maintainer: Eric Benard - EUKREA Electromatique */
  326. .phys_io = AT91_BASE_SYS,
  327. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  328. .boot_params = AT91_SDRAM_BASE + 0x100,
  329. .timer = &at91sam926x_timer,
  330. .map_io = cpu9krea_map_io,
  331. .init_irq = cpu9krea_init_irq,
  332. .init_machine = cpu9krea_board_init,
  333. MACHINE_END