board-sam9263ek.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * linux/arch/arm/mach-at91/board-sam9263ek.c
  3. *
  4. * Copyright (C) 2005 SAN People
  5. * Copyright (C) 2007 Atmel Corporation.
  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/ads7846.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 = 2,
  47. .tty_map = { 3, 0, -1, -1, } /* ttyS0, ..., ttyS3 */
  48. };
  49. static void __init ek_map_io(void)
  50. {
  51. /* Initialize processor: 16.367 MHz crystal */
  52. at91sam9263_initialize(16367660);
  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. at91sam9263_init_interrupts(NULL);
  59. }
  60. /*
  61. * USB Host port
  62. */
  63. static struct at91_usbh_data __initdata ek_usbh_data = {
  64. .ports = 2,
  65. .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 },
  66. };
  67. /*
  68. * USB Device port
  69. */
  70. static struct at91_udc_data __initdata ek_udc_data = {
  71. .vbus_pin = AT91_PIN_PA25,
  72. .pullup_pin = 0, /* pull-up driven by UDC */
  73. };
  74. /*
  75. * ADS7846 Touchscreen
  76. */
  77. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  78. static int ads7843_pendown_state(void)
  79. {
  80. return !at91_get_gpio_value(AT91_PIN_PA15); /* Touchscreen PENIRQ */
  81. }
  82. static struct ads7846_platform_data ads_info = {
  83. .model = 7843,
  84. .x_min = 150,
  85. .x_max = 3830,
  86. .y_min = 190,
  87. .y_max = 3830,
  88. .vref_delay_usecs = 100,
  89. .x_plate_ohms = 450,
  90. .y_plate_ohms = 250,
  91. .pressure_max = 15000,
  92. .debounce_max = 1,
  93. .debounce_rep = 0,
  94. .debounce_tol = (~0),
  95. .get_pendown_state = ads7843_pendown_state,
  96. };
  97. static void __init ek_add_device_ts(void)
  98. {
  99. at91_set_B_periph(AT91_PIN_PA15, 1); /* External IRQ1, with pullup */
  100. at91_set_gpio_input(AT91_PIN_PA31, 1); /* Touchscreen BUSY signal */
  101. }
  102. #else
  103. static void __init ek_add_device_ts(void) {}
  104. #endif
  105. /*
  106. * SPI devices.
  107. */
  108. static struct spi_board_info ek_spi_devices[] = {
  109. #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
  110. { /* DataFlash card */
  111. .modalias = "mtd_dataflash",
  112. .chip_select = 0,
  113. .max_speed_hz = 15 * 1000 * 1000,
  114. .bus_num = 0,
  115. },
  116. #endif
  117. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  118. {
  119. .modalias = "ads7846",
  120. .chip_select = 3,
  121. .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
  122. .bus_num = 0,
  123. .platform_data = &ads_info,
  124. .irq = AT91SAM9263_ID_IRQ1,
  125. },
  126. #endif
  127. };
  128. /*
  129. * MCI (SD/MMC)
  130. */
  131. static struct at91_mmc_data __initdata ek_mmc_data = {
  132. .wire4 = 1,
  133. .det_pin = AT91_PIN_PE18,
  134. .wp_pin = AT91_PIN_PE19,
  135. // .vcc_pin = ... not connected
  136. };
  137. /*
  138. * MACB Ethernet device
  139. */
  140. static struct at91_eth_data __initdata ek_macb_data = {
  141. .is_rmii = 1,
  142. };
  143. /*
  144. * NAND flash
  145. */
  146. static struct mtd_partition __initdata ek_nand_partition[] = {
  147. {
  148. .name = "Partition 1",
  149. .offset = 0,
  150. .size = 64 * 1024 * 1024,
  151. },
  152. {
  153. .name = "Partition 2",
  154. .offset = 64 * 1024 * 1024,
  155. .size = MTDPART_SIZ_FULL,
  156. },
  157. };
  158. static struct mtd_partition *nand_partitions(int size, int *num_partitions)
  159. {
  160. *num_partitions = ARRAY_SIZE(ek_nand_partition);
  161. return ek_nand_partition;
  162. }
  163. static struct at91_nand_data __initdata ek_nand_data = {
  164. .ale = 21,
  165. .cle = 22,
  166. // .det_pin = ... not connected
  167. .rdy_pin = AT91_PIN_PA22,
  168. .enable_pin = AT91_PIN_PD15,
  169. .partition_info = nand_partitions,
  170. #if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
  171. .bus_width_16 = 1,
  172. #else
  173. .bus_width_16 = 0,
  174. #endif
  175. };
  176. /*
  177. * AC97
  178. */
  179. static struct atmel_ac97_data ek_ac97_data = {
  180. .reset_pin = AT91_PIN_PA13,
  181. };
  182. static void __init ek_board_init(void)
  183. {
  184. /* Serial */
  185. at91_add_device_serial();
  186. /* USB Host */
  187. at91_add_device_usbh(&ek_usbh_data);
  188. /* USB Device */
  189. at91_add_device_udc(&ek_udc_data);
  190. /* SPI */
  191. at91_set_gpio_output(AT91_PIN_PE20, 1); /* select spi0 clock */
  192. at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
  193. /* Touchscreen */
  194. ek_add_device_ts();
  195. /* MMC */
  196. at91_add_device_mmc(1, &ek_mmc_data);
  197. /* Ethernet */
  198. at91_add_device_eth(&ek_macb_data);
  199. /* NAND */
  200. at91_add_device_nand(&ek_nand_data);
  201. /* I2C */
  202. at91_add_device_i2c();
  203. /* AC97 */
  204. at91_add_device_ac97(&ek_ac97_data);
  205. }
  206. MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
  207. /* Maintainer: Atmel */
  208. .phys_io = AT91_BASE_SYS,
  209. .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
  210. .boot_params = AT91_SDRAM_BASE + 0x100,
  211. .timer = &at91sam926x_timer,
  212. .map_io = ek_map_io,
  213. .init_irq = ek_init_irq,
  214. .init_machine = ek_board_init,
  215. MACHINE_END