board-ap4evb.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. * AP4EVB board support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  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; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/physmap.h>
  29. #include <linux/io.h>
  30. #include <linux/smsc911x.h>
  31. #include <linux/gpio.h>
  32. #include <mach/common.h>
  33. #include <mach/sh7372.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. /*
  38. * Address Interface BusWidth note
  39. * ------------------------------------------------------------------
  40. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  41. * 0x0800_0000 user area -
  42. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  43. * 0x1400_0000 Ether (LAN9220) 16bit
  44. * 0x1600_0000 user area - cannot use with NAND
  45. * 0x1800_0000 user area -
  46. * 0x1A00_0000 -
  47. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  48. */
  49. /*
  50. * NOR Flash ROM
  51. *
  52. * SW1 | SW2 | SW7 | NOR Flash ROM
  53. * bit1 | bit1 bit2 | bit1 | Memory allocation
  54. * ------+------------+------+------------------
  55. * OFF | ON OFF | ON | Area 0
  56. * OFF | ON OFF | OFF | Area 4
  57. */
  58. /*
  59. * NAND Flash ROM
  60. *
  61. * SW1 | SW2 | SW7 | NAND Flash ROM
  62. * bit1 | bit1 bit2 | bit2 | Memory allocation
  63. * ------+------------+------+------------------
  64. * OFF | ON OFF | ON | FCE 0
  65. * OFF | ON OFF | OFF | FCE 1
  66. */
  67. /*
  68. * SMSC 9220
  69. *
  70. * SW1 SMSC 9220
  71. * -----------------------
  72. * ON access disable
  73. * OFF access enable
  74. */
  75. /* MTD */
  76. static struct mtd_partition nor_flash_partitions[] = {
  77. {
  78. .name = "loader",
  79. .offset = 0x00000000,
  80. .size = 512 * 1024,
  81. },
  82. {
  83. .name = "bootenv",
  84. .offset = MTDPART_OFS_APPEND,
  85. .size = 512 * 1024,
  86. },
  87. {
  88. .name = "kernel_ro",
  89. .offset = MTDPART_OFS_APPEND,
  90. .size = 8 * 1024 * 1024,
  91. .mask_flags = MTD_WRITEABLE,
  92. },
  93. {
  94. .name = "kernel",
  95. .offset = MTDPART_OFS_APPEND,
  96. .size = 8 * 1024 * 1024,
  97. },
  98. {
  99. .name = "data",
  100. .offset = MTDPART_OFS_APPEND,
  101. .size = MTDPART_SIZ_FULL,
  102. },
  103. };
  104. static struct physmap_flash_data nor_flash_data = {
  105. .width = 2,
  106. .parts = nor_flash_partitions,
  107. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  108. };
  109. static struct resource nor_flash_resources[] = {
  110. [0] = {
  111. .start = 0x00000000,
  112. .end = 0x08000000 - 1,
  113. .flags = IORESOURCE_MEM,
  114. }
  115. };
  116. static struct platform_device nor_flash_device = {
  117. .name = "physmap-flash",
  118. .dev = {
  119. .platform_data = &nor_flash_data,
  120. },
  121. .num_resources = ARRAY_SIZE(nor_flash_resources),
  122. .resource = nor_flash_resources,
  123. };
  124. /* SMSC 9220 */
  125. static struct resource smc911x_resources[] = {
  126. {
  127. .start = 0x14000000,
  128. .end = 0x16000000 - 1,
  129. .flags = IORESOURCE_MEM,
  130. }, {
  131. .start = 6,
  132. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  133. },
  134. };
  135. static struct smsc911x_platform_config smsc911x_info = {
  136. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  137. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  138. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  139. };
  140. static struct platform_device smc911x_device = {
  141. .name = "smsc911x",
  142. .id = -1,
  143. .num_resources = ARRAY_SIZE(smc911x_resources),
  144. .resource = smc911x_resources,
  145. .dev = {
  146. .platform_data = &smsc911x_info,
  147. },
  148. };
  149. static struct platform_device *ap4evb_devices[] __initdata = {
  150. &nor_flash_device,
  151. &smc911x_device,
  152. };
  153. static struct map_desc ap4evb_io_desc[] __initdata = {
  154. /* create a 1:1 entity map for 0xe6xxxxxx
  155. * used by CPGA, INTC and PFC.
  156. */
  157. {
  158. .virtual = 0xe6000000,
  159. .pfn = __phys_to_pfn(0xe6000000),
  160. .length = 256 << 20,
  161. .type = MT_DEVICE_NONSHARED
  162. },
  163. };
  164. static void __init ap4evb_map_io(void)
  165. {
  166. iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
  167. /* setup early devices, clocks and console here as well */
  168. sh7372_add_early_devices();
  169. sh7367_clock_init(); /* use g3 clocks for now */
  170. shmobile_setup_console();
  171. }
  172. static void __init ap4evb_init(void)
  173. {
  174. sh7372_pinmux_init();
  175. /* enable SCIFA0 */
  176. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  177. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  178. /* enable SMSC911X */
  179. gpio_request(GPIO_FN_CS5A, NULL);
  180. gpio_request(GPIO_FN_IRQ6_39, NULL);
  181. /* enable LED 1 - 4 */
  182. gpio_request(GPIO_PORT185, NULL);
  183. gpio_request(GPIO_PORT186, NULL);
  184. gpio_request(GPIO_PORT187, NULL);
  185. gpio_request(GPIO_PORT188, NULL);
  186. gpio_direction_output(GPIO_PORT185, 1);
  187. gpio_direction_output(GPIO_PORT186, 1);
  188. gpio_direction_output(GPIO_PORT187, 1);
  189. gpio_direction_output(GPIO_PORT188, 1);
  190. gpio_export(GPIO_PORT185, 0);
  191. gpio_export(GPIO_PORT186, 0);
  192. gpio_export(GPIO_PORT187, 0);
  193. gpio_export(GPIO_PORT188, 0);
  194. /* enable Debug switch (S6) */
  195. gpio_request(GPIO_PORT32, NULL);
  196. gpio_request(GPIO_PORT33, NULL);
  197. gpio_request(GPIO_PORT34, NULL);
  198. gpio_request(GPIO_PORT35, NULL);
  199. gpio_direction_input(GPIO_PORT32);
  200. gpio_direction_input(GPIO_PORT33);
  201. gpio_direction_input(GPIO_PORT34);
  202. gpio_direction_input(GPIO_PORT35);
  203. gpio_export(GPIO_PORT32, 0);
  204. gpio_export(GPIO_PORT33, 0);
  205. gpio_export(GPIO_PORT34, 0);
  206. gpio_export(GPIO_PORT35, 0);
  207. sh7372_add_standard_devices();
  208. platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
  209. }
  210. MACHINE_START(AP4EVB, "ap4evb")
  211. .phys_io = 0xe6000000,
  212. .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
  213. .map_io = ap4evb_map_io,
  214. .init_irq = sh7372_init_irq,
  215. .init_machine = ap4evb_init,
  216. .timer = &shmobile_timer,
  217. MACHINE_END