board-mackerel.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * mackerel board support
  3. *
  4. * Copyright (C) 2010 Renesas Solutions Corp.
  5. * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * based on ap4evb
  8. * Copyright (C) 2010 Magnus Damm
  9. * Copyright (C) 2008 Yoshihiro Shimoda
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; version 2 of the License.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #include <linux/kernel.h>
  25. #include <linux/init.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/irq.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/gpio.h>
  30. #include <linux/input.h>
  31. #include <linux/io.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <linux/mtd/physmap.h>
  35. #include <linux/smsc911x.h>
  36. #include <mach/common.h>
  37. #include <mach/sh7372.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/time.h>
  40. #include <asm/mach/map.h>
  41. #include <asm/mach-types.h>
  42. /*
  43. * Address Interface BusWidth note
  44. * ------------------------------------------------------------------
  45. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  46. * 0x0800_0000 user area -
  47. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  48. * 0x1400_0000 Ether (LAN9220) 16bit
  49. * 0x1600_0000 user area - cannot use with NAND
  50. * 0x1800_0000 user area -
  51. * 0x1A00_0000 -
  52. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  53. */
  54. /* MTD */
  55. static struct mtd_partition nor_flash_partitions[] = {
  56. {
  57. .name = "loader",
  58. .offset = 0x00000000,
  59. .size = 512 * 1024,
  60. .mask_flags = MTD_WRITEABLE,
  61. },
  62. {
  63. .name = "bootenv",
  64. .offset = MTDPART_OFS_APPEND,
  65. .size = 512 * 1024,
  66. .mask_flags = MTD_WRITEABLE,
  67. },
  68. {
  69. .name = "kernel_ro",
  70. .offset = MTDPART_OFS_APPEND,
  71. .size = 8 * 1024 * 1024,
  72. .mask_flags = MTD_WRITEABLE,
  73. },
  74. {
  75. .name = "kernel",
  76. .offset = MTDPART_OFS_APPEND,
  77. .size = 8 * 1024 * 1024,
  78. },
  79. {
  80. .name = "data",
  81. .offset = MTDPART_OFS_APPEND,
  82. .size = MTDPART_SIZ_FULL,
  83. },
  84. };
  85. static struct physmap_flash_data nor_flash_data = {
  86. .width = 2,
  87. .parts = nor_flash_partitions,
  88. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  89. };
  90. static struct resource nor_flash_resources[] = {
  91. [0] = {
  92. .start = 0x00000000,
  93. .end = 0x08000000 - 1,
  94. .flags = IORESOURCE_MEM,
  95. }
  96. };
  97. static struct platform_device nor_flash_device = {
  98. .name = "physmap-flash",
  99. .dev = {
  100. .platform_data = &nor_flash_data,
  101. },
  102. .num_resources = ARRAY_SIZE(nor_flash_resources),
  103. .resource = nor_flash_resources,
  104. };
  105. /* SMSC */
  106. static struct resource smc911x_resources[] = {
  107. {
  108. .start = 0x14000000,
  109. .end = 0x16000000 - 1,
  110. .flags = IORESOURCE_MEM,
  111. }, {
  112. .start = evt2irq(0x02c0) /* IRQ6A */,
  113. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  114. },
  115. };
  116. static struct smsc911x_platform_config smsc911x_info = {
  117. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  118. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  119. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  120. };
  121. static struct platform_device smc911x_device = {
  122. .name = "smsc911x",
  123. .id = -1,
  124. .num_resources = ARRAY_SIZE(smc911x_resources),
  125. .resource = smc911x_resources,
  126. .dev = {
  127. .platform_data = &smsc911x_info,
  128. },
  129. };
  130. static struct platform_device *mackerel_devices[] __initdata = {
  131. &nor_flash_device,
  132. &smc911x_device,
  133. };
  134. static struct map_desc mackerel_io_desc[] __initdata = {
  135. /* create a 1:1 entity map for 0xe6xxxxxx
  136. * used by CPGA, INTC and PFC.
  137. */
  138. {
  139. .virtual = 0xe6000000,
  140. .pfn = __phys_to_pfn(0xe6000000),
  141. .length = 256 << 20,
  142. .type = MT_DEVICE_NONSHARED
  143. },
  144. };
  145. static void __init mackerel_map_io(void)
  146. {
  147. iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
  148. /* setup early devices and console here as well */
  149. sh7372_add_early_devices();
  150. shmobile_setup_console();
  151. }
  152. static void __init mackerel_init(void)
  153. {
  154. sh7372_pinmux_init();
  155. /* enable SCIFA0 */
  156. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  157. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  158. /* enable SMSC911X */
  159. gpio_request(GPIO_FN_CS5A, NULL);
  160. gpio_request(GPIO_FN_IRQ6_39, NULL);
  161. sh7372_add_standard_devices();
  162. platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
  163. }
  164. static void __init mackerel_timer_init(void)
  165. {
  166. sh7372_clock_init();
  167. shmobile_timer.init();
  168. }
  169. static struct sys_timer mackerel_timer = {
  170. .init = mackerel_timer_init,
  171. };
  172. MACHINE_START(MACKEREL, "mackerel")
  173. .map_io = mackerel_map_io,
  174. .init_irq = sh7372_init_irq,
  175. .init_machine = mackerel_init,
  176. .timer = &mackerel_timer,
  177. MACHINE_END