board-at572d940hf_ek.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. /*
  2. * linux/arch/arm/mach-at91/board-at572d940hf_ek.c
  3. *
  4. * Copyright (C) 2008 Atmel Antonio R. Costa <costa.antonior@gmail.com>
  5. * Copyright (C) 2005 SAN People
  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/ds1305.h>
  28. #include <linux/irq.h>
  29. #include <linux/mtd/physmap.h>
  30. #include <mach/hardware.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/board.h>
  38. #include <mach/gpio.h>
  39. #include <mach/at91sam9_smc.h>
  40. #include <mach/system_rev.h>
  41. #include "sam9_smc.h"
  42. #include "generic.h"
  43. static void __init eb_init_early(void)
  44. {
  45. /* Initialize processor: 12.500 MHz crystal */
  46. at572d940hf_initialize(12000000);
  47. /* DBGU on ttyS0. (Rx & Tx only) */
  48. at91_register_uart(0, 0, 0);
  49. /* USART0 on ttyS1. (Rx & Tx only) */
  50. at91_register_uart(AT572D940HF_ID_US0, 1, 0);
  51. /* USART1 on ttyS2. (Rx & Tx only) */
  52. at91_register_uart(AT572D940HF_ID_US1, 2, 0);
  53. /* USART2 on ttyS3. (Tx & Rx only */
  54. at91_register_uart(AT572D940HF_ID_US2, 3, 0);
  55. /* set serial console to ttyS0 (ie, DBGU) */
  56. at91_set_serial_console(0);
  57. }
  58. static void __init eb_init_irq(void)
  59. {
  60. at572d940hf_init_interrupts(NULL);
  61. }
  62. /*
  63. * USB Host Port
  64. */
  65. static struct at91_usbh_data __initdata eb_usbh_data = {
  66. .ports = 2,
  67. };
  68. /*
  69. * USB Device Port
  70. */
  71. static struct at91_udc_data __initdata eb_udc_data = {
  72. .vbus_pin = 0, /* no VBUS detection,UDC always on */
  73. .pullup_pin = 0, /* pull-up driven by UDC */
  74. };
  75. /*
  76. * MCI (SD/MMC)
  77. */
  78. static struct at91_mmc_data __initdata eb_mmc_data = {
  79. .wire4 = 1,
  80. /* .det_pin = ... not connected */
  81. /* .wp_pin = ... not connected */
  82. /* .vcc_pin = ... not connected */
  83. };
  84. /*
  85. * MACB Ethernet device
  86. */
  87. static struct at91_eth_data __initdata eb_eth_data = {
  88. .phy_irq_pin = AT91_PIN_PB25,
  89. .is_rmii = 1,
  90. };
  91. /*
  92. * NOR flash
  93. */
  94. static struct mtd_partition eb_nor_partitions[] = {
  95. {
  96. .name = "Raw Environment",
  97. .offset = 0,
  98. .size = SZ_4M,
  99. .mask_flags = 0,
  100. },
  101. {
  102. .name = "OS FS",
  103. .offset = MTDPART_OFS_APPEND,
  104. .size = 3 * SZ_1M,
  105. .mask_flags = 0,
  106. },
  107. {
  108. .name = "APP FS",
  109. .offset = MTDPART_OFS_APPEND,
  110. .size = MTDPART_SIZ_FULL,
  111. .mask_flags = 0,
  112. },
  113. };
  114. static void nor_flash_set_vpp(struct map_info* mi, int i) {
  115. };
  116. static struct physmap_flash_data nor_flash_data = {
  117. .width = 4,
  118. .parts = eb_nor_partitions,
  119. .nr_parts = ARRAY_SIZE(eb_nor_partitions),
  120. .set_vpp = nor_flash_set_vpp,
  121. };
  122. static struct resource nor_flash_resources[] = {
  123. {
  124. .start = AT91_CHIPSELECT_0,
  125. .end = AT91_CHIPSELECT_0 + SZ_16M - 1,
  126. .flags = IORESOURCE_MEM,
  127. },
  128. };
  129. static struct platform_device nor_flash = {
  130. .name = "physmap-flash",
  131. .id = 0,
  132. .dev = {
  133. .platform_data = &nor_flash_data,
  134. },
  135. .resource = nor_flash_resources,
  136. .num_resources = ARRAY_SIZE(nor_flash_resources),
  137. };
  138. static struct sam9_smc_config __initdata eb_nor_smc_config = {
  139. .ncs_read_setup = 1,
  140. .nrd_setup = 1,
  141. .ncs_write_setup = 1,
  142. .nwe_setup = 1,
  143. .ncs_read_pulse = 7,
  144. .nrd_pulse = 7,
  145. .ncs_write_pulse = 7,
  146. .nwe_pulse = 7,
  147. .read_cycle = 9,
  148. .write_cycle = 9,
  149. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_32,
  150. .tdf_cycles = 1,
  151. };
  152. static void __init eb_add_device_nor(void)
  153. {
  154. /* configure chip-select 0 (NOR) */
  155. sam9_smc_configure(0, &eb_nor_smc_config);
  156. platform_device_register(&nor_flash);
  157. }
  158. /*
  159. * NAND flash
  160. */
  161. static struct mtd_partition __initdata eb_nand_partition[] = {
  162. {
  163. .name = "Partition 1",
  164. .offset = 0,
  165. .size = SZ_16M,
  166. },
  167. {
  168. .name = "Partition 2",
  169. .offset = MTDPART_OFS_NXTBLK,
  170. .size = MTDPART_SIZ_FULL,
  171. }
  172. };
  173. static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
  174. {
  175. *num_partitions = ARRAY_SIZE(eb_nand_partition);
  176. return eb_nand_partition;
  177. }
  178. static struct atmel_nand_data __initdata eb_nand_data = {
  179. .ale = 22,
  180. .cle = 21,
  181. /* .det_pin = ... not connected */
  182. /* .rdy_pin = AT91_PIN_PC16, */
  183. .enable_pin = AT91_PIN_PA15,
  184. .partition_info = nand_partitions,
  185. };
  186. static struct sam9_smc_config __initdata eb_nand_smc_config = {
  187. .ncs_read_setup = 0,
  188. .nrd_setup = 0,
  189. .ncs_write_setup = 1,
  190. .nwe_setup = 1,
  191. .ncs_read_pulse = 3,
  192. .nrd_pulse = 3,
  193. .ncs_write_pulse = 3,
  194. .nwe_pulse = 3,
  195. .read_cycle = 5,
  196. .write_cycle = 5,
  197. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
  198. .tdf_cycles = 12,
  199. };
  200. static void __init eb_add_device_nand(void)
  201. {
  202. ek_nand_data.bus_width_16 = !board_have_nand_8bit();
  203. /* setup bus-width (8 or 16) */
  204. if (eb_nand_data.bus_width_16)
  205. eb_nand_smc_config.mode |= AT91_SMC_DBW_16;
  206. else
  207. eb_nand_smc_config.mode |= AT91_SMC_DBW_8;
  208. /* configure chip-select 3 (NAND) */
  209. sam9_smc_configure(3, &eb_nand_smc_config);
  210. at91_add_device_nand(&eb_nand_data);
  211. }
  212. /*
  213. * SPI devices
  214. */
  215. static struct resource rtc_resources[] = {
  216. [0] = {
  217. .start = AT572D940HF_ID_IRQ1,
  218. .end = AT572D940HF_ID_IRQ1,
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. };
  222. static struct ds1305_platform_data ds1306_data = {
  223. .is_ds1306 = true,
  224. .en_1hz = false,
  225. };
  226. static struct spi_board_info eb_spi_devices[] = {
  227. { /* RTC Dallas DS1306 */
  228. .modalias = "rtc-ds1305",
  229. .chip_select = 3,
  230. .mode = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA,
  231. .max_speed_hz = 500000,
  232. .bus_num = 0,
  233. .irq = AT572D940HF_ID_IRQ1,
  234. .platform_data = (void *) &ds1306_data,
  235. },
  236. #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
  237. { /* Dataflash card */
  238. .modalias = "mtd_dataflash",
  239. .chip_select = 0,
  240. .max_speed_hz = 15 * 1000 * 1000,
  241. .bus_num = 0,
  242. },
  243. #endif
  244. };
  245. static void __init eb_board_init(void)
  246. {
  247. /* Serial */
  248. at91_add_device_serial();
  249. /* USB Host */
  250. at91_add_device_usbh(&eb_usbh_data);
  251. /* USB Device */
  252. at91_add_device_udc(&eb_udc_data);
  253. /* I2C */
  254. at91_add_device_i2c(NULL, 0);
  255. /* NOR */
  256. eb_add_device_nor();
  257. /* NAND */
  258. eb_add_device_nand();
  259. /* SPI */
  260. at91_add_device_spi(eb_spi_devices, ARRAY_SIZE(eb_spi_devices));
  261. /* MMC */
  262. at91_add_device_mmc(0, &eb_mmc_data);
  263. /* Ethernet */
  264. at91_add_device_eth(&eb_eth_data);
  265. /* mAgic */
  266. at91_add_device_mAgic();
  267. }
  268. MACHINE_START(AT572D940HFEB, "Atmel AT91D940HF-EB")
  269. /* Maintainer: Atmel <costa.antonior@gmail.com> */
  270. .boot_params = AT91_SDRAM_BASE + 0x100,
  271. .timer = &at91sam926x_timer,
  272. .map_io = at572d940hf_map_io,
  273. .init_early = eb_init_early,
  274. .init_irq = eb_init_irq,
  275. .init_machine = eb_board_init,
  276. MACHINE_END