board-at572d940hf_ek.c 7.1 KB

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