board-sh7785lcr.c 6.5 KB

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