board-mackerel.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 <video/sh_mobile_lcdc.h>
  37. #include <mach/common.h>
  38. #include <mach/sh7372.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/time.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach-types.h>
  43. /*
  44. * Address Interface BusWidth note
  45. * ------------------------------------------------------------------
  46. * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
  47. * 0x0800_0000 user area -
  48. * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
  49. * 0x1400_0000 Ether (LAN9220) 16bit
  50. * 0x1600_0000 user area - cannot use with NAND
  51. * 0x1800_0000 user area -
  52. * 0x1A00_0000 -
  53. * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
  54. */
  55. /* MTD */
  56. static struct mtd_partition nor_flash_partitions[] = {
  57. {
  58. .name = "loader",
  59. .offset = 0x00000000,
  60. .size = 512 * 1024,
  61. .mask_flags = MTD_WRITEABLE,
  62. },
  63. {
  64. .name = "bootenv",
  65. .offset = MTDPART_OFS_APPEND,
  66. .size = 512 * 1024,
  67. .mask_flags = MTD_WRITEABLE,
  68. },
  69. {
  70. .name = "kernel_ro",
  71. .offset = MTDPART_OFS_APPEND,
  72. .size = 8 * 1024 * 1024,
  73. .mask_flags = MTD_WRITEABLE,
  74. },
  75. {
  76. .name = "kernel",
  77. .offset = MTDPART_OFS_APPEND,
  78. .size = 8 * 1024 * 1024,
  79. },
  80. {
  81. .name = "data",
  82. .offset = MTDPART_OFS_APPEND,
  83. .size = MTDPART_SIZ_FULL,
  84. },
  85. };
  86. static struct physmap_flash_data nor_flash_data = {
  87. .width = 2,
  88. .parts = nor_flash_partitions,
  89. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  90. };
  91. static struct resource nor_flash_resources[] = {
  92. [0] = {
  93. .start = 0x00000000,
  94. .end = 0x08000000 - 1,
  95. .flags = IORESOURCE_MEM,
  96. }
  97. };
  98. static struct platform_device nor_flash_device = {
  99. .name = "physmap-flash",
  100. .dev = {
  101. .platform_data = &nor_flash_data,
  102. },
  103. .num_resources = ARRAY_SIZE(nor_flash_resources),
  104. .resource = nor_flash_resources,
  105. };
  106. /* SMSC */
  107. static struct resource smc911x_resources[] = {
  108. {
  109. .start = 0x14000000,
  110. .end = 0x16000000 - 1,
  111. .flags = IORESOURCE_MEM,
  112. }, {
  113. .start = evt2irq(0x02c0) /* IRQ6A */,
  114. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  115. },
  116. };
  117. static struct smsc911x_platform_config smsc911x_info = {
  118. .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
  119. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  120. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  121. };
  122. static struct platform_device smc911x_device = {
  123. .name = "smsc911x",
  124. .id = -1,
  125. .num_resources = ARRAY_SIZE(smc911x_resources),
  126. .resource = smc911x_resources,
  127. .dev = {
  128. .platform_data = &smsc911x_info,
  129. },
  130. };
  131. /* LCDC */
  132. static struct fb_videomode mackerel_lcdc_modes[] = {
  133. {
  134. .name = "WVGA Panel",
  135. .xres = 800,
  136. .yres = 480,
  137. .left_margin = 220,
  138. .right_margin = 110,
  139. .hsync_len = 70,
  140. .upper_margin = 20,
  141. .lower_margin = 5,
  142. .vsync_len = 5,
  143. .sync = 0,
  144. },
  145. };
  146. static struct sh_mobile_lcdc_info lcdc_info = {
  147. .clock_source = LCDC_CLK_BUS,
  148. .ch[0] = {
  149. .chan = LCDC_CHAN_MAINLCD,
  150. .bpp = 16,
  151. .lcd_cfg = mackerel_lcdc_modes,
  152. .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
  153. .interface_type = RGB24,
  154. .clock_divider = 2,
  155. .flags = 0,
  156. .lcd_size_cfg.width = 152,
  157. .lcd_size_cfg.height = 91,
  158. }
  159. };
  160. static struct resource lcdc_resources[] = {
  161. [0] = {
  162. .name = "LCDC",
  163. .start = 0xfe940000,
  164. .end = 0xfe943fff,
  165. .flags = IORESOURCE_MEM,
  166. },
  167. [1] = {
  168. .start = intcs_evt2irq(0x580),
  169. .flags = IORESOURCE_IRQ,
  170. },
  171. };
  172. static struct platform_device lcdc_device = {
  173. .name = "sh_mobile_lcdc_fb",
  174. .num_resources = ARRAY_SIZE(lcdc_resources),
  175. .resource = lcdc_resources,
  176. .dev = {
  177. .platform_data = &lcdc_info,
  178. .coherent_dma_mask = ~0,
  179. },
  180. };
  181. static struct platform_device *mackerel_devices[] __initdata = {
  182. &nor_flash_device,
  183. &smc911x_device,
  184. &lcdc_device,
  185. };
  186. static struct map_desc mackerel_io_desc[] __initdata = {
  187. /* create a 1:1 entity map for 0xe6xxxxxx
  188. * used by CPGA, INTC and PFC.
  189. */
  190. {
  191. .virtual = 0xe6000000,
  192. .pfn = __phys_to_pfn(0xe6000000),
  193. .length = 256 << 20,
  194. .type = MT_DEVICE_NONSHARED
  195. },
  196. };
  197. static void __init mackerel_map_io(void)
  198. {
  199. iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
  200. /* setup early devices and console here as well */
  201. sh7372_add_early_devices();
  202. shmobile_setup_console();
  203. }
  204. static void __init mackerel_init(void)
  205. {
  206. sh7372_pinmux_init();
  207. /* enable SCIFA0 */
  208. gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
  209. gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
  210. /* enable SMSC911X */
  211. gpio_request(GPIO_FN_CS5A, NULL);
  212. gpio_request(GPIO_FN_IRQ6_39, NULL);
  213. /* LCDC */
  214. gpio_request(GPIO_FN_LCDD17, NULL);
  215. gpio_request(GPIO_FN_LCDD16, NULL);
  216. gpio_request(GPIO_FN_LCDD15, NULL);
  217. gpio_request(GPIO_FN_LCDD14, NULL);
  218. gpio_request(GPIO_FN_LCDD13, NULL);
  219. gpio_request(GPIO_FN_LCDD12, NULL);
  220. gpio_request(GPIO_FN_LCDD11, NULL);
  221. gpio_request(GPIO_FN_LCDD10, NULL);
  222. gpio_request(GPIO_FN_LCDD9, NULL);
  223. gpio_request(GPIO_FN_LCDD8, NULL);
  224. gpio_request(GPIO_FN_LCDD7, NULL);
  225. gpio_request(GPIO_FN_LCDD6, NULL);
  226. gpio_request(GPIO_FN_LCDD5, NULL);
  227. gpio_request(GPIO_FN_LCDD4, NULL);
  228. gpio_request(GPIO_FN_LCDD3, NULL);
  229. gpio_request(GPIO_FN_LCDD2, NULL);
  230. gpio_request(GPIO_FN_LCDD1, NULL);
  231. gpio_request(GPIO_FN_LCDD0, NULL);
  232. gpio_request(GPIO_FN_LCDDISP, NULL);
  233. gpio_request(GPIO_FN_LCDDCK, NULL);
  234. gpio_request(GPIO_PORT31, NULL); /* backlight */
  235. gpio_direction_output(GPIO_PORT31, 1);
  236. gpio_request(GPIO_PORT151, NULL); /* LCDDON */
  237. gpio_direction_output(GPIO_PORT151, 1);
  238. sh7372_add_standard_devices();
  239. platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
  240. }
  241. static void __init mackerel_timer_init(void)
  242. {
  243. sh7372_clock_init();
  244. shmobile_timer.init();
  245. }
  246. static struct sys_timer mackerel_timer = {
  247. .init = mackerel_timer_init,
  248. };
  249. MACHINE_START(MACKEREL, "mackerel")
  250. .map_io = mackerel_map_io,
  251. .init_irq = sh7372_init_irq,
  252. .init_machine = mackerel_init,
  253. .timer = &mackerel_timer,
  254. MACHINE_END