board-sam9261ek.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*
  2. * linux/arch/arm/mach-at91rm9200/board-ek.c
  3. *
  4. * Copyright (C) 2005 SAN People
  5. * Copyright (C) 2006 Atmel
  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/dm9000.h>
  28. #include <asm/hardware.h>
  29. #include <asm/setup.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/irq.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <asm/mach/irq.h>
  35. #include <asm/arch/board.h>
  36. #include <asm/arch/gpio.h>
  37. #include <asm/arch/at91sam926x_mc.h>
  38. #include "generic.h"
  39. /*
  40. * Serial port configuration.
  41. * 0 .. 2 = USART0 .. USART2
  42. * 3 = DBGU
  43. */
  44. static struct at91_uart_config __initdata ek_uart_config = {
  45. .console_tty = 0, /* ttyS0 */
  46. .nr_tty = 1,
  47. .tty_map = { 3, -1, -1, -1 } /* ttyS0, ..., ttyS3 */
  48. };
  49. static void __init ek_map_io(void)
  50. {
  51. /* Initialize processor: 18.432 MHz crystal */
  52. at91sam9261_initialize(18432000);
  53. /* Setup the serial ports and console */
  54. at91_init_serial(&ek_uart_config);
  55. }
  56. static void __init ek_init_irq(void)
  57. {
  58. at91sam9261_init_interrupts(NULL);
  59. }
  60. /*
  61. * DM9000 ethernet device
  62. */
  63. #if defined(CONFIG_DM9000)
  64. static struct resource at91sam9261_dm9000_resource[] = {
  65. [0] = {
  66. .start = AT91_CHIPSELECT_2,
  67. .end = AT91_CHIPSELECT_2 + 3,
  68. .flags = IORESOURCE_MEM
  69. },
  70. [1] = {
  71. .start = AT91_CHIPSELECT_2 + 0x44,
  72. .end = AT91_CHIPSELECT_2 + 0xFF,
  73. .flags = IORESOURCE_MEM
  74. },
  75. [2] = {
  76. .start = AT91_PIN_PC11,
  77. .end = AT91_PIN_PC11,
  78. .flags = IORESOURCE_IRQ
  79. }
  80. };
  81. static struct dm9000_plat_data dm9000_platdata = {
  82. .flags = DM9000_PLATF_16BITONLY,
  83. };
  84. static struct platform_device at91sam9261_dm9000_device = {
  85. .name = "dm9000",
  86. .id = 0,
  87. .num_resources = ARRAY_SIZE(at91sam9261_dm9000_resource),
  88. .resource = at91sam9261_dm9000_resource,
  89. .dev = {
  90. .platform_data = &dm9000_platdata,
  91. }
  92. };
  93. static void __init ek_add_device_dm9000(void)
  94. {
  95. /*
  96. * Configure Chip-Select 2 on SMC for the DM9000.
  97. * Note: These timings were calculated for MASTER_CLOCK = 100000000
  98. * according to the DM9000 timings.
  99. */
  100. at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
  101. at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8));
  102. at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
  103. at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));
  104. /* Configure Reset signal as output */
  105. at91_set_gpio_output(AT91_PIN_PC10, 0);
  106. /* Configure Interrupt pin as input, no pull-up */
  107. at91_set_gpio_input(AT91_PIN_PC11, 0);
  108. platform_device_register(&at91sam9261_dm9000_device);
  109. }
  110. #else
  111. static void __init ek_add_device_dm9000(void) {}
  112. #endif /* CONFIG_DM9000 */
  113. /*
  114. * USB Host Port
  115. */
  116. static struct at91_usbh_data __initdata ek_usbh_data = {
  117. .ports = 2,
  118. };
  119. /*
  120. * USB Device Port
  121. */
  122. static struct at91_udc_data __initdata ek_udc_data = {
  123. .vbus_pin = AT91_PIN_PB29,
  124. .pullup_pin = 0, /* pull-up driven by UDC */
  125. };
  126. /*
  127. * MCI (SD/MMC)
  128. */
  129. static struct at91_mmc_data __initdata ek_mmc_data = {
  130. .wire4 = 1,
  131. // .det_pin = ... not connected
  132. // .wp_pin = ... not connected
  133. // .vcc_pin = ... not connected
  134. };
  135. /*
  136. * NAND flash
  137. */
  138. static struct mtd_partition __initdata ek_nand_partition[] = {
  139. {
  140. .name = "Partition 1",
  141. .offset = 0,
  142. .size = 256 * 1024,
  143. },
  144. {
  145. .name = "Partition 2",
  146. .offset = 256 * 1024 ,
  147. .size = MTDPART_SIZ_FULL,
  148. },
  149. };
  150. static struct mtd_partition *nand_partitions(int size, int *num_partitions)
  151. {
  152. *num_partitions = ARRAY_SIZE(ek_nand_partition);
  153. return ek_nand_partition;
  154. }
  155. static struct at91_nand_data __initdata ek_nand_data = {
  156. .ale = 22,
  157. .cle = 21,
  158. // .det_pin = ... not connected
  159. .rdy_pin = AT91_PIN_PC15,
  160. .enable_pin = AT91_PIN_PC14,
  161. .partition_info = nand_partitions,
  162. #if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
  163. .bus_width_16 = 1,
  164. #else
  165. .bus_width_16 = 0,
  166. #endif
  167. };
  168. /*
  169. * SPI devices
  170. */
  171. static struct spi_board_info ek_spi_devices[] = {
  172. { /* DataFlash chip */
  173. .modalias = "mtd_dataflash",
  174. .chip_select = 0,
  175. .max_speed_hz = 15 * 1000 * 1000,
  176. .bus_num = 0,
  177. },
  178. #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
  179. { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
  180. .modalias = "mtd_dataflash",
  181. .chip_select = 3,
  182. .max_speed_hz = 15 * 1000 * 1000,
  183. .bus_num = 0,
  184. },
  185. #elif defined(CONFIG_SND_AT73C213)
  186. { /* AT73C213 DAC */
  187. .modalias = "snd_at73c213",
  188. .chip_select = 3,
  189. .max_speed_hz = 10 * 1000 * 1000,
  190. .bus_num = 0,
  191. },
  192. #endif
  193. };
  194. static void __init ek_board_init(void)
  195. {
  196. /* Serial */
  197. at91_add_device_serial();
  198. /* USB Host */
  199. at91_add_device_usbh(&ek_usbh_data);
  200. /* USB Device */
  201. at91_add_device_udc(&ek_udc_data);
  202. /* I2C */
  203. at91_add_device_i2c();
  204. /* NAND */
  205. at91_add_device_nand(&ek_nand_data);
  206. /* DM9000 ethernet */
  207. ek_add_device_dm9000();
  208. /* spi0 and mmc/sd share the same PIO pins */
  209. #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
  210. /* SPI */
  211. at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
  212. #else
  213. /* MMC */
  214. at91_add_device_mmc(&ek_mmc_data);
  215. #endif
  216. }
  217. MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
  218. /* Maintainer: Atmel */
  219. .phys_io = AT91_BASE_SYS,
  220. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  221. .boot_params = AT91_SDRAM_BASE + 0x100,
  222. .timer = &at91sam926x_timer,
  223. .map_io = ek_map_io,
  224. .init_irq = ek_init_irq,
  225. .init_machine = ek_board_init,
  226. MACHINE_END