board-sh7785lcr.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * Renesas Technology Corp. R0P7785LC0011RL Support.
  3. *
  4. * Copyright (C) 2008 Yoshihiro Shimoda
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/sm501.h>
  13. #include <linux/sm501-regs.h>
  14. #include <linux/fb.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/delay.h>
  17. #include <linux/i2c.h>
  18. #include <linux/i2c-pca-platform.h>
  19. #include <linux/i2c-algo-pca.h>
  20. #include <linux/irq.h>
  21. #include <asm/heartbeat.h>
  22. #include <mach/sh7785lcr.h>
  23. /*
  24. * NOTE: This board has 2 physical memory maps.
  25. * Please look at include/asm-sh/sh7785lcr.h or hardware manual.
  26. */
  27. static struct resource heartbeat_resources[] = {
  28. [0] = {
  29. .start = PLD_LEDCR,
  30. .end = PLD_LEDCR,
  31. .flags = IORESOURCE_MEM,
  32. },
  33. };
  34. static struct heartbeat_data heartbeat_data = {
  35. .regsize = 8,
  36. };
  37. static struct platform_device heartbeat_device = {
  38. .name = "heartbeat",
  39. .id = -1,
  40. .dev = {
  41. .platform_data = &heartbeat_data,
  42. },
  43. .num_resources = ARRAY_SIZE(heartbeat_resources),
  44. .resource = heartbeat_resources,
  45. };
  46. static struct mtd_partition nor_flash_partitions[] = {
  47. {
  48. .name = "loader",
  49. .offset = 0x00000000,
  50. .size = 512 * 1024,
  51. },
  52. {
  53. .name = "bootenv",
  54. .offset = MTDPART_OFS_APPEND,
  55. .size = 512 * 1024,
  56. },
  57. {
  58. .name = "kernel",
  59. .offset = MTDPART_OFS_APPEND,
  60. .size = 4 * 1024 * 1024,
  61. },
  62. {
  63. .name = "data",
  64. .offset = MTDPART_OFS_APPEND,
  65. .size = MTDPART_SIZ_FULL,
  66. },
  67. };
  68. static struct physmap_flash_data nor_flash_data = {
  69. .width = 4,
  70. .parts = nor_flash_partitions,
  71. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  72. };
  73. static struct resource nor_flash_resources[] = {
  74. [0] = {
  75. .start = NOR_FLASH_ADDR,
  76. .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1,
  77. .flags = IORESOURCE_MEM,
  78. }
  79. };
  80. static struct platform_device nor_flash_device = {
  81. .name = "physmap-flash",
  82. .dev = {
  83. .platform_data = &nor_flash_data,
  84. },
  85. .num_resources = ARRAY_SIZE(nor_flash_resources),
  86. .resource = nor_flash_resources,
  87. };
  88. static struct resource r8a66597_usb_host_resources[] = {
  89. [0] = {
  90. .name = "r8a66597_hcd",
  91. .start = R8A66597_ADDR,
  92. .end = R8A66597_ADDR + R8A66597_SIZE - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. [1] = {
  96. .name = "r8a66597_hcd",
  97. .start = 2,
  98. .end = 2,
  99. .flags = IORESOURCE_IRQ,
  100. },
  101. };
  102. static struct platform_device r8a66597_usb_host_device = {
  103. .name = "r8a66597_hcd",
  104. .id = -1,
  105. .dev = {
  106. .dma_mask = NULL,
  107. .coherent_dma_mask = 0xffffffff,
  108. },
  109. .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
  110. .resource = r8a66597_usb_host_resources,
  111. };
  112. static struct resource sm501_resources[] = {
  113. [0] = {
  114. .start = SM107_MEM_ADDR,
  115. .end = SM107_MEM_ADDR + SM107_MEM_SIZE - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. [1] = {
  119. .start = SM107_REG_ADDR,
  120. .end = SM107_REG_ADDR + SM107_REG_SIZE - 1,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. [2] = {
  124. .start = 10,
  125. .flags = IORESOURCE_IRQ,
  126. },
  127. };
  128. static struct fb_videomode sm501_default_mode_crt = {
  129. .pixclock = 35714, /* 28MHz */
  130. .xres = 640,
  131. .yres = 480,
  132. .left_margin = 105,
  133. .right_margin = 16,
  134. .upper_margin = 33,
  135. .lower_margin = 10,
  136. .hsync_len = 39,
  137. .vsync_len = 2,
  138. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  139. };
  140. static struct fb_videomode sm501_default_mode_pnl = {
  141. .pixclock = 40000, /* 25MHz */
  142. .xres = 640,
  143. .yres = 480,
  144. .left_margin = 2,
  145. .right_margin = 16,
  146. .upper_margin = 33,
  147. .lower_margin = 10,
  148. .hsync_len = 39,
  149. .vsync_len = 2,
  150. .sync = 0,
  151. };
  152. static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
  153. .def_bpp = 16,
  154. .def_mode = &sm501_default_mode_pnl,
  155. .flags = SM501FB_FLAG_USE_INIT_MODE |
  156. SM501FB_FLAG_USE_HWCURSOR |
  157. SM501FB_FLAG_USE_HWACCEL |
  158. SM501FB_FLAG_DISABLE_AT_EXIT |
  159. SM501FB_FLAG_PANEL_NO_VBIASEN,
  160. };
  161. static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
  162. .def_bpp = 16,
  163. .def_mode = &sm501_default_mode_crt,
  164. .flags = SM501FB_FLAG_USE_INIT_MODE |
  165. SM501FB_FLAG_USE_HWCURSOR |
  166. SM501FB_FLAG_USE_HWACCEL |
  167. SM501FB_FLAG_DISABLE_AT_EXIT,
  168. };
  169. static struct sm501_platdata_fb sm501_fb_pdata = {
  170. .fb_route = SM501_FB_OWN,
  171. .fb_crt = &sm501_pdata_fbsub_crt,
  172. .fb_pnl = &sm501_pdata_fbsub_pnl,
  173. };
  174. static struct sm501_initdata sm501_initdata = {
  175. .gpio_high = {
  176. .set = 0x00001fe0,
  177. .mask = 0x0,
  178. },
  179. .devices = 0,
  180. .mclk = 84 * 1000000,
  181. .m1xclk = 112 * 1000000,
  182. };
  183. static struct sm501_platdata sm501_platform_data = {
  184. .init = &sm501_initdata,
  185. .fb = &sm501_fb_pdata,
  186. };
  187. static struct platform_device sm501_device = {
  188. .name = "sm501",
  189. .id = -1,
  190. .dev = {
  191. .platform_data = &sm501_platform_data,
  192. },
  193. .num_resources = ARRAY_SIZE(sm501_resources),
  194. .resource = sm501_resources,
  195. };
  196. static struct resource i2c_resources[] = {
  197. [0] = {
  198. .start = PCA9564_ADDR,
  199. .end = PCA9564_ADDR + PCA9564_SIZE - 1,
  200. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
  201. },
  202. [1] = {
  203. .start = 12,
  204. .end = 12,
  205. .flags = IORESOURCE_IRQ,
  206. },
  207. };
  208. static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
  209. .gpio = 0,
  210. .i2c_clock_speed = I2C_PCA_CON_330kHz,
  211. .timeout = HZ,
  212. };
  213. static struct platform_device i2c_device = {
  214. .name = "i2c-pca-platform",
  215. .id = -1,
  216. .dev = {
  217. .platform_data = &i2c_platform_data,
  218. },
  219. .num_resources = ARRAY_SIZE(i2c_resources),
  220. .resource = i2c_resources,
  221. };
  222. static struct platform_device *sh7785lcr_devices[] __initdata = {
  223. &heartbeat_device,
  224. &nor_flash_device,
  225. &r8a66597_usb_host_device,
  226. &sm501_device,
  227. &i2c_device,
  228. };
  229. static struct i2c_board_info __initdata sh7785lcr_i2c_devices[] = {
  230. {
  231. I2C_BOARD_INFO("r2025sd", 0x32),
  232. },
  233. };
  234. static int __init sh7785lcr_devices_setup(void)
  235. {
  236. i2c_register_board_info(0, sh7785lcr_i2c_devices,
  237. ARRAY_SIZE(sh7785lcr_i2c_devices));
  238. return platform_add_devices(sh7785lcr_devices,
  239. ARRAY_SIZE(sh7785lcr_devices));
  240. }
  241. __initcall(sh7785lcr_devices_setup);
  242. /* Initialize IRQ setting */
  243. void __init init_sh7785lcr_IRQ(void)
  244. {
  245. plat_irq_setup_pins(IRQ_MODE_IRQ7654);
  246. plat_irq_setup_pins(IRQ_MODE_IRQ3210);
  247. }
  248. static void sh7785lcr_power_off(void)
  249. {
  250. unsigned char *p;
  251. p = ioremap(PLD_POFCR, PLD_POFCR + 1);
  252. if (!p) {
  253. printk(KERN_ERR "%s: ioremap error.\n", __func__);
  254. return;
  255. }
  256. *p = 0x01;
  257. iounmap(p);
  258. set_bl_bit();
  259. while (1)
  260. cpu_relax();
  261. }
  262. /* Initialize the board */
  263. static void __init sh7785lcr_setup(char **cmdline_p)
  264. {
  265. void __iomem *sm501_reg;
  266. printk(KERN_INFO "Renesas Technology Corp. R0P7785LC0011RL support.\n");
  267. pm_power_off = sh7785lcr_power_off;
  268. /* sm501 DRAM configuration */
  269. sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
  270. writel(0x000307c2, sm501_reg);
  271. }
  272. /*
  273. * The Machine Vector
  274. */
  275. static struct sh_machine_vector mv_sh7785lcr __initmv = {
  276. .mv_name = "SH7785LCR",
  277. .mv_setup = sh7785lcr_setup,
  278. .mv_init_irq = init_sh7785lcr_IRQ,
  279. };