main.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * linux/arch/arm/mach-at91/board-yl-9200.c
  3. *
  4. * Adapted from various board files in arch/arm/mach-at91
  5. *
  6. * Modifications for YL-9200 platform:
  7. * Copyright (C) 2007 S. Birtles
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/types.h>
  24. #include <linux/gpio.h>
  25. #include <linux/init.h>
  26. #include <linux/mm.h>
  27. #include <linux/module.h>
  28. #include <linux/dma-mapping.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/spi/ads7846.h>
  32. #include <linux/mtd/physmap.h>
  33. #include <linux/gpio_keys.h>
  34. #include <linux/input.h>
  35. #include <asm/setup.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/irq.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/map.h>
  40. #include <asm/mach/irq.h>
  41. #include <mach/hardware.h>
  42. #include <mach/at91rm9200_mc.h>
  43. #include <mach/at91_ramc.h>
  44. #include <mach/cpu.h>
  45. #include "at91_aic.h"
  46. #include "board.h"
  47. #include "generic.h"
  48. static void __init yl9200_init_early(void)
  49. {
  50. /* Set cpu type: PQFP */
  51. at91rm9200_set_type(ARCH_REVISON_9200_PQFP);
  52. /* Initialize processor: 18.432 MHz crystal */
  53. at91_initialize(18432000);
  54. }
  55. /*
  56. * LEDs
  57. */
  58. static struct gpio_led yl9200_leds[] = {
  59. { /* D2 */
  60. .name = "led2",
  61. .gpio = AT91_PIN_PB17,
  62. .active_low = 1,
  63. .default_trigger = "timer",
  64. },
  65. { /* D3 */
  66. .name = "led3",
  67. .gpio = AT91_PIN_PB16,
  68. .active_low = 1,
  69. .default_trigger = "heartbeat",
  70. },
  71. { /* D4 */
  72. .name = "led4",
  73. .gpio = AT91_PIN_PB15,
  74. .active_low = 1,
  75. },
  76. { /* D5 */
  77. .name = "led5",
  78. .gpio = AT91_PIN_PB8,
  79. .active_low = 1,
  80. }
  81. };
  82. /*
  83. * Ethernet
  84. */
  85. static struct macb_platform_data __initdata yl9200_eth_data = {
  86. .phy_irq_pin = AT91_PIN_PB28,
  87. .is_rmii = 1,
  88. };
  89. /*
  90. * USB Host
  91. */
  92. static struct at91_usbh_data __initdata yl9200_usbh_data = {
  93. .ports = 1, /* PQFP version of AT91RM9200 */
  94. .vbus_pin = {-EINVAL, -EINVAL},
  95. .overcurrent_pin= {-EINVAL, -EINVAL},
  96. };
  97. /*
  98. * USB Device
  99. */
  100. static struct at91_udc_data __initdata yl9200_udc_data = {
  101. .pullup_pin = AT91_PIN_PC4,
  102. .vbus_pin = AT91_PIN_PC5,
  103. .pullup_active_low = 1, /* Active Low due to PNP transistor (pg 7) */
  104. };
  105. /*
  106. * MMC
  107. */
  108. static struct mci_platform_data __initdata yl9200_mci0_data = {
  109. .slot[0] = {
  110. .bus_width = 4,
  111. .detect_pin = AT91_PIN_PB9,
  112. .wp_pin = -EINVAL,
  113. },
  114. };
  115. /*
  116. * NAND Flash
  117. */
  118. static struct mtd_partition __initdata yl9200_nand_partition[] = {
  119. {
  120. .name = "AT91 NAND partition 1, boot",
  121. .offset = 0,
  122. .size = SZ_256K
  123. },
  124. {
  125. .name = "AT91 NAND partition 2, kernel",
  126. .offset = MTDPART_OFS_NXTBLK,
  127. .size = (2 * SZ_1M) - SZ_256K
  128. },
  129. {
  130. .name = "AT91 NAND partition 3, filesystem",
  131. .offset = MTDPART_OFS_NXTBLK,
  132. .size = 14 * SZ_1M
  133. },
  134. {
  135. .name = "AT91 NAND partition 4, storage",
  136. .offset = MTDPART_OFS_NXTBLK,
  137. .size = SZ_16M
  138. },
  139. {
  140. .name = "AT91 NAND partition 5, ext-fs",
  141. .offset = MTDPART_OFS_NXTBLK,
  142. .size = SZ_32M
  143. }
  144. };
  145. static struct atmel_nand_data __initdata yl9200_nand_data = {
  146. .ale = 6,
  147. .cle = 7,
  148. .det_pin = -EINVAL,
  149. .rdy_pin = AT91_PIN_PC14, /* R/!B (Sheet10) */
  150. .enable_pin = AT91_PIN_PC15, /* !CE (Sheet10) */
  151. .ecc_mode = NAND_ECC_SOFT,
  152. .parts = yl9200_nand_partition,
  153. .num_parts = ARRAY_SIZE(yl9200_nand_partition),
  154. };
  155. /*
  156. * NOR Flash
  157. */
  158. #define YL9200_FLASH_BASE AT91_CHIPSELECT_0
  159. #define YL9200_FLASH_SIZE SZ_16M
  160. static struct mtd_partition yl9200_flash_partitions[] = {
  161. {
  162. .name = "Bootloader",
  163. .offset = 0,
  164. .size = SZ_256K,
  165. .mask_flags = MTD_WRITEABLE, /* force read-only */
  166. },
  167. {
  168. .name = "Kernel",
  169. .offset = MTDPART_OFS_NXTBLK,
  170. .size = (2 * SZ_1M) - SZ_256K
  171. },
  172. {
  173. .name = "Filesystem",
  174. .offset = MTDPART_OFS_NXTBLK,
  175. .size = MTDPART_SIZ_FULL
  176. }
  177. };
  178. static struct physmap_flash_data yl9200_flash_data = {
  179. .width = 2,
  180. .parts = yl9200_flash_partitions,
  181. .nr_parts = ARRAY_SIZE(yl9200_flash_partitions),
  182. };
  183. static struct resource yl9200_flash_resources[] = {
  184. {
  185. .start = YL9200_FLASH_BASE,
  186. .end = YL9200_FLASH_BASE + YL9200_FLASH_SIZE - 1,
  187. .flags = IORESOURCE_MEM,
  188. }
  189. };
  190. static struct platform_device yl9200_flash = {
  191. .name = "physmap-flash",
  192. .id = 0,
  193. .dev = {
  194. .platform_data = &yl9200_flash_data,
  195. },
  196. .resource = yl9200_flash_resources,
  197. .num_resources = ARRAY_SIZE(yl9200_flash_resources),
  198. };
  199. /*
  200. * I2C (TWI)
  201. */
  202. static struct i2c_board_info __initdata yl9200_i2c_devices[] = {
  203. { /* EEPROM */
  204. I2C_BOARD_INFO("24c128", 0x50),
  205. }
  206. };
  207. /*
  208. * GPIO Buttons
  209. */
  210. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  211. static struct gpio_keys_button yl9200_buttons[] = {
  212. {
  213. .gpio = AT91_PIN_PA24,
  214. .code = BTN_2,
  215. .desc = "SW2",
  216. .active_low = 1,
  217. .wakeup = 1,
  218. },
  219. {
  220. .gpio = AT91_PIN_PB1,
  221. .code = BTN_3,
  222. .desc = "SW3",
  223. .active_low = 1,