board-cpu9krea.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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/gpio.h>
  24. #include <linux/init.h>
  25. #include <linux/mm.h>
  26. #include <linux/module.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/clk.h>
  29. #include <linux/gpio_keys.h>
  30. #include <linux/input.h>
  31. #include <linux/mtd/physmap.h>
  32. #include <asm/setup.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/irq.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/irq.h>
  38. #include <mach/hardware.h>
  39. #include <mach/at91sam9_smc.h>
  40. #include <mach/at91sam9260_matrix.h>
  41. #include <mach/at91_matrix.h>
  42. #include "at91_aic.h"
  43. #include "board.h"
  44. #include "sam9_smc.h"
  45. #include "generic.h"
  46. #include "gpio.h"
  47. static void __init cpu9krea_init_early(void)
  48. {
  49. /* Initialize processor: 18.432 MHz crystal */
  50. at91_initialize(18432000);
  51. }
  52. /*
  53. * USB Host port
  54. */
  55. static struct at91_usbh_data __initdata cpu9krea_usbh_data = {
  56. .ports = 2,
  57. .vbus_pin = {-EINVAL, -EINVAL},
  58. .overcurrent_pin= {-EINVAL, -EINVAL},
  59. };
  60. /*
  61. * USB Device port
  62. */
  63. static struct at91_udc_data __initdata cpu9krea_udc_data = {
  64. .vbus_pin = AT91_PIN_PC8,
  65. .pullup_pin = -EINVAL, /* pull-up driven by UDC */
  66. };
  67. /*
  68. * MACB Ethernet device
  69. */
  70. static struct macb_platform_data __initdata cpu9krea_macb_data = {
  71. .phy_irq_pin = -EINVAL,
  72. .is_rmii = 1,
  73. };
  74. /*
  75. * NAND flash
  76. */
  77. static struct atmel_nand_data __initdata cpu9krea_nand_data = {
  78. .ale = 21,
  79. .cle = 22,
  80. .rdy_pin = AT91_PIN_PC13,
  81. .enable_pin = AT91_PIN_PC14,
  82. .bus_width_16 = 0,
  83. .det_pin = -EINVAL,
  84. .ecc_mode = NAND_ECC_SOFT,
  85. };
  86. #ifdef CONFIG_MACH_CPU9260
  87. static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
  88. .ncs_read_setup = 0,
  89. .nrd_setup = 1,
  90. .ncs_write_setup = 0,
  91. .nwe_setup = 1,
  92. .ncs_read_pulse = 3,
  93. .nrd_pulse = 3,
  94. .ncs_write_pulse = 3,
  95. .nwe_pulse = 3,
  96. .read_cycle = 5,
  97. .write_cycle = 5,
  98. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  99. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  100. .tdf_cycles = 2,
  101. };
  102. #else
  103. static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
  104. .ncs_read_setup = 0,
  105. .nrd_setup = 2,
  106. .ncs_write_setup = 0,
  107. .nwe_setup = 2,
  108. .ncs_read_pulse = 4,
  109. .nrd_pulse = 4,
  110. .ncs_write_pulse = 4,
  111. .nwe_pulse = 4,
  112. .read_cycle = 7,
  113. .write_cycle = 7,
  114. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  115. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  116. .tdf_cycles = 3,
  117. };
  118. #endif
  119. static void __init cpu9krea_add_device_nand(void)
  120. {
  121. sam9_smc_configure(0, 3, &cpu9krea_nand_smc_config);
  122. at91_add_device_nand(&cpu9krea_nand_data);
  123. }
  124. /*
  125. * NOR flash
  126. */
  127. static struct physmap_flash_data cpuat9260_nor_data = {
  128. .width = 2,
  129. };
  130. #define NOR_BASE AT91_CHIPSELECT_0
  131. #define NOR_SIZE SZ_64M
  132. static struct resource nor_flash_resources[] = {
  133. {
  134. .start = NOR_BASE,
  135. .end = NOR_BASE + NOR_SIZE - 1,
  136. .flags = IORESOURCE_MEM,
  137. }
  138. };
  139. static struct platform_device cpu9krea_nor_flash = {
  140. .name = "physmap-flash",
  141. .id = 0,
  142. .dev = {
  143. .platform_data = &cpuat9260_nor_data,
  144. },
  145. .resource = nor_flash_resources,
  146. .num_resources = ARRAY_SIZE(nor_flash_resources),
  147. };
  148. #ifdef CONFIG_MACH_CPU9260
  149. static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
  150. .ncs_read_setup = 0,
  151. .nrd_setup = 1,
  152. .ncs_write_setup = 0,
  153. .nwe_setup = 1,
  154. .ncs_read_pulse = 10,
  155. .nrd_pulse = 10,
  156. .ncs_write_pulse = 6,
  157. .nwe_pulse = 6,
  158. .read_cycle = 12,
  159. .write_cycle = 8,
  160. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  161. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
  162. | AT91_SMC_DBW_16,
  163. .tdf_cycles = 2,
  164. };
  165. #else
  166. static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = {
  167. .ncs_read_setup = 0,
  168. .nrd_setup = 1,
  169. .ncs_write_setup = 0,
  170. .nwe_setup = 1,
  171. .ncs_read_pulse = 13,
  172. .nrd_pulse = 13,
  173. .ncs_write_pulse = 8,
  174. .nwe_pulse = 8,
  175. .read_cycle = 15,
  176. .write_cycle = 10,
  177. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  178. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
  179. | AT91_SMC_DBW_16,
  180. .tdf_cycles = 2,
  181. };
  182. #endif
  183. static __init void cpu9krea_add_device_nor(void)
  184. {
  185. unsigned long csa;
  186. csa = at91_matrix_read(AT91_MATRIX_EBICSA);
  187. at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);
  188. /* configure chip-select 0 (NOR) */
  189. sam9_smc_configure(0, 0, &cpu9krea_nor_smc_config);
  190. platform_device_register(&cpu9krea_nor_flash);
  191. }
  192. /*
  193. * LEDs
  194. */
  195. static struct gpio_led cpu9krea_leds[] = {
  196. { /* LED1 */
  197. .name = "LED1",
  198. .gpio = AT91_PIN_PC11,
  199. .active_low = 1,
  200. .default_trigger = "timer",
  201. },
  202. { /* LED2 */
  203. .name = "LED2",
  204. .gpio = AT91_PIN_PC12,
  205. .active_low = 1,
  206. .default_trigger = "heartbeat",
  207. },
  208. { /* LED3 */
  209. .name = "LED3",
  210. .gpio = AT91_PIN_PC7,
  211. .active_low = 1,
  212. .default_trigger = "none",
  213. },
  214. { /* LED4 */
  215. .name = "LED4",
  216. .gpio = AT91_PIN_PC9,
  217. .active_low = 1,
  218. .default_trigger = "none",
  219. }
  220. };
  221. static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = {
  222. {
  223. I2C_BOARD_INFO("ds1339", 0x68),
  224. },
  225. };
  226. /*
  227. * GPIO Buttons
  228. */
  229. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  230. static struct gpio_keys_button cpu9krea_buttons[] = {
  231. {
  232. .gpio = AT91_PIN_PC3,
  233. .code = BTN_0,
  234. .desc = "BP1",
  235. .active_low = 1,
  236. .wakeup = 1,
  237. },
  238. {
  239. .gpio = AT91_PIN_PB20,
  240. .code = BTN_1,
  241. .desc = "BP2",
  242. .active_low = 1,
  243. .wakeup = 1,
  244. }
  245. };
  246. static struct gpio_keys_platform_data cpu9krea_button_data = {
  247. .buttons = cpu9krea_buttons,
  248. .nbuttons = ARRAY_SIZE(cpu9krea_buttons),
  249. };
  250. static struct platform_device cpu9krea_button_device = {
  251. .name = "gpio-keys",
  252. .id = -1,
  253. .num_resources = 0,
  254. .dev = {
  255. .platform_data = &cpu9krea_button_data,
  256. }
  257. };
  258. static void __init cpu9krea_add_device_buttons(void)
  259. {
  260. at91_set_gpio_input(AT91_PIN_PC3, 1); /* BP1 */
  261. at91_set_deglitch(AT91_PIN_PC3, 1);
  262. at91_set_gpio_input(AT91_PIN_PB20, 1); /* BP2 */
  263. at91_set_deglitch(AT91_PIN_PB20, 1);
  264. platform_device_register(&cpu9krea_button_device);
  265. }
  266. #else
  267. static void __init cpu9krea_add_device_buttons(void)
  268. {
  269. }
  270. #endif
  271. /*
  272. * MCI (SD/MMC)
  273. */
  274. static struct mci_platform_data __initdata cpu9krea_mci0_data = {
  275. .slot[0] = {
  276. .bus_width = 4,
  277. .detect_pin = AT91_PIN_PA29,
  278. .wp_pin = -EINVAL,
  279. },
  280. };
  281. static void __init cpu9krea_board_init(void)
  282. {
  283. at91_register_devices();
  284. /* NOR */
  285. cpu9krea_add_device_nor();
  286. /* Serial */
  287. /* DGBU on ttyS0. (Rx & Tx only) */
  288. at91_register_uart(0, 0, 0);
  289. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
  290. at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |
  291. ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
  292. ATMEL_UART_DCD | ATMEL_UART_RI);
  293. /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
  294. at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |
  295. ATMEL_UART_RTS);
  296. /* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
  297. at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |
  298. ATMEL_UART_RTS);
  299. /* USART3 on ttyS4. (Rx, Tx) */
  300. at91_register_uart(AT91SAM9260_ID_US3, 4, 0);
  301. /* USART4 on ttyS5. (Rx, Tx) */
  302. at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
  303. /* USART5 on ttyS6. (Rx, Tx) */
  304. at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
  305. at91_add_device_serial();
  306. /* USB Host */
  307. at91_add_device_usbh(&cpu9krea_usbh_data);
  308. /* USB Device */
  309. at91_add_device_udc(&cpu9krea_udc_data);
  310. /* NAND */
  311. cpu9krea_add_device_nand();
  312. /* Ethernet */
  313. at91_add_device_eth(&cpu9krea_macb_data);
  314. /* MMC */
  315. at91_add_device_mci(0, &cpu9krea_mci0_data);
  316. /* I2C */
  317. at91_add_device_i2c(cpu9krea_i2c_devices,
  318. ARRAY_SIZE(cpu9krea_i2c_devices));
  319. /* LEDs */
  320. at91_gpio_leds(cpu9krea_leds, ARRAY_SIZE(cpu9krea_leds));
  321. /* Push Buttons */
  322. cpu9krea_add_device_buttons();
  323. }
  324. #ifdef CONFIG_MACH_CPU9260
  325. MACHINE_START(CPUAT9260, "Eukrea CPU9260")
  326. #else
  327. MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
  328. #endif
  329. /* Maintainer: Eric Benard - EUKREA Electromatique */
  330. .init_time = at91_init_time,
  331. .map_io = at91_map_io,
  332. .handle_irq = at91_aic_handle_irq,
  333. .init_early = cpu9krea_init_early,
  334. .init_irq = at91_init_irq_default,
  335. .init_machine = cpu9krea_board_init,
  336. MACHINE_END