setup.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*
  2. * Renesas Technology Sales RTS7751R2D Support.
  3. *
  4. * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
  5. * Copyright (C) 2004 - 2007 Paul Mundt
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/ata_platform.h>
  17. #include <linux/sm501.h>
  18. #include <linux/sm501-regs.h>
  19. #include <linux/pm.h>
  20. #include <linux/fb.h>
  21. #include <linux/spi/spi.h>
  22. #include <linux/spi/spi_bitbang.h>
  23. #include <asm/machvec.h>
  24. #include <mach/r2d.h>
  25. #include <asm/io.h>
  26. #include <asm/io_trapped.h>
  27. #include <asm/spi.h>
  28. static struct resource cf_ide_resources[] = {
  29. [0] = {
  30. .start = PA_AREA5_IO + 0x1000,
  31. .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. [1] = {
  35. .start = PA_AREA5_IO + 0x80c,
  36. .end = PA_AREA5_IO + 0x80c,
  37. .flags = IORESOURCE_MEM,
  38. },
  39. #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
  40. [2] = {
  41. .start = IRQ_CF_IDE,
  42. .flags = IORESOURCE_IRQ,
  43. },
  44. #endif
  45. };
  46. static struct pata_platform_info pata_info = {
  47. .ioport_shift = 1,
  48. };
  49. static struct platform_device cf_ide_device = {
  50. .name = "pata_platform",
  51. .id = -1,
  52. .num_resources = ARRAY_SIZE(cf_ide_resources),
  53. .resource = cf_ide_resources,
  54. .dev = {
  55. .platform_data = &pata_info,
  56. },
  57. };
  58. static struct spi_board_info spi_bus[] = {
  59. {
  60. .modalias = "rtc-r9701",
  61. .max_speed_hz = 1000000,
  62. .mode = SPI_MODE_3,
  63. },
  64. };
  65. static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
  66. {
  67. BUG_ON(cs != 0); /* Single Epson RTC-9701JE attached on CS0 */
  68. __raw_writew(state == BITBANG_CS_ACTIVE, PA_RTCCE);
  69. }
  70. static struct sh_spi_info spi_info = {
  71. .num_chipselect = 1,
  72. .chip_select = r2d_chip_select,
  73. };
  74. static struct resource spi_sh_sci_resources[] = {
  75. {
  76. .start = 0xffe00000,
  77. .end = 0xffe0001f,
  78. .flags = IORESOURCE_MEM,
  79. },
  80. };
  81. static struct platform_device spi_sh_sci_device = {
  82. .name = "spi_sh_sci",
  83. .id = -1,
  84. .num_resources = ARRAY_SIZE(spi_sh_sci_resources),
  85. .resource = spi_sh_sci_resources,
  86. .dev = {
  87. .platform_data = &spi_info,
  88. },
  89. };
  90. static struct resource heartbeat_resources[] = {
  91. [0] = {
  92. .start = PA_OUTPORT,
  93. .end = PA_OUTPORT,
  94. .flags = IORESOURCE_MEM,
  95. },
  96. };
  97. static struct platform_device heartbeat_device = {
  98. .name = "heartbeat",
  99. .id = -1,
  100. .num_resources = ARRAY_SIZE(heartbeat_resources),
  101. .resource = heartbeat_resources,
  102. };
  103. static struct resource sm501_resources[] = {
  104. [0] = {
  105. .start = 0x10000000,
  106. .end = 0x13e00000 - 1,
  107. .flags = IORESOURCE_MEM,
  108. },
  109. [1] = {
  110. .start = 0x13e00000,
  111. .end = 0x13ffffff,
  112. .flags = IORESOURCE_MEM,
  113. },
  114. [2] = {
  115. .start = IRQ_VOYAGER,
  116. .flags = IORESOURCE_IRQ,
  117. },
  118. };
  119. static struct fb_videomode sm501_default_mode = {
  120. .pixclock = 35714,
  121. .xres = 640,
  122. .yres = 480,
  123. .left_margin = 105,
  124. .right_margin = 50,
  125. .upper_margin = 35,
  126. .lower_margin = 0,
  127. .hsync_len = 96,
  128. .vsync_len = 2,
  129. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  130. };
  131. static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
  132. .def_bpp = 16,
  133. .def_mode = &sm501_default_mode,
  134. .flags = SM501FB_FLAG_USE_INIT_MODE |
  135. SM501FB_FLAG_USE_HWCURSOR |
  136. SM501FB_FLAG_USE_HWACCEL |
  137. SM501FB_FLAG_DISABLE_AT_EXIT,
  138. };
  139. static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
  140. .flags = (SM501FB_FLAG_USE_INIT_MODE |
  141. SM501FB_FLAG_USE_HWCURSOR |
  142. SM501FB_FLAG_USE_HWACCEL |
  143. SM501FB_FLAG_DISABLE_AT_EXIT),
  144. };
  145. static struct sm501_platdata_fb sm501_fb_pdata = {
  146. .fb_route = SM501_FB_OWN,
  147. .fb_crt = &sm501_pdata_fbsub_crt,
  148. .fb_pnl = &sm501_pdata_fbsub_pnl,
  149. .flags = SM501_FBPD_SWAP_FB_ENDIAN,
  150. };
  151. static struct sm501_initdata sm501_initdata = {
  152. .devices = SM501_USE_USB_HOST | SM501_USE_UART0,
  153. };
  154. static struct sm501_platdata sm501_platform_data = {
  155. .init = &sm501_initdata,
  156. .fb = &sm501_fb_pdata,
  157. };
  158. static struct platform_device sm501_device = {
  159. .name = "sm501",
  160. .id = -1,
  161. .dev = {
  162. .platform_data = &sm501_platform_data,
  163. },
  164. .num_resources = ARRAY_SIZE(sm501_resources),
  165. .resource = sm501_resources,
  166. };
  167. static struct mtd_partition r2d_partitions[] = {
  168. {
  169. .name = "U-Boot",
  170. .offset = 0x00000000,
  171. .size = 0x00040000,
  172. .mask_flags = MTD_WRITEABLE,
  173. }, {
  174. .name = "Environment",
  175. .offset = MTDPART_OFS_NXTBLK,
  176. .size = 0x00040000,
  177. .mask_flags = MTD_WRITEABLE,
  178. }, {
  179. .name = "Kernel",
  180. .offset = MTDPART_OFS_NXTBLK,
  181. .size = 0x001c0000,
  182. }, {
  183. .name = "Flash_FS",
  184. .offset = MTDPART_OFS_NXTBLK,
  185. .size = MTDPART_SIZ_FULL,
  186. }
  187. };
  188. static struct physmap_flash_data flash_data = {
  189. .width = 2,
  190. .nr_parts = ARRAY_SIZE(r2d_partitions),
  191. .parts = r2d_partitions,
  192. };
  193. static struct resource flash_resource = {
  194. .start = 0x00000000,
  195. .end = 0x02000000,
  196. .flags = IORESOURCE_MEM,
  197. };
  198. static struct platform_device flash_device = {
  199. .name = "physmap-flash",
  200. .id = -1,
  201. .resource = &flash_resource,
  202. .num_resources = 1,
  203. .dev = {
  204. .platform_data = &flash_data,
  205. },
  206. };
  207. static struct platform_device *rts7751r2d_devices[] __initdata = {
  208. &sm501_device,
  209. &heartbeat_device,
  210. &spi_sh_sci_device,
  211. };
  212. /*
  213. * The CF is connected with a 16-bit bus where 8-bit operations are
  214. * unsupported. The linux ata driver is however using 8-bit operations, so
  215. * insert a trapped io filter to convert 8-bit operations into 16-bit.
  216. */
  217. static struct trapped_io cf_trapped_io = {
  218. .resource = cf_ide_resources,
  219. .num_resources = 2,
  220. .minimum_bus_width = 16,
  221. };
  222. static int __init rts7751r2d_devices_setup(void)
  223. {
  224. if (register_trapped_io(&cf_trapped_io) == 0)
  225. platform_device_register(&cf_ide_device);
  226. if (mach_is_r2d_plus())
  227. platform_device_register(&flash_device);
  228. spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
  229. return platform_add_devices(rts7751r2d_devices,
  230. ARRAY_SIZE(rts7751r2d_devices));
  231. }
  232. device_initcall(rts7751r2d_devices_setup);
  233. static void rts7751r2d_power_off(void)
  234. {
  235. __raw_writew(0x0001, PA_POWOFF);
  236. }
  237. /*
  238. * Initialize the board
  239. */
  240. static void __init rts7751r2d_setup(char **cmdline_p)
  241. {
  242. void __iomem *sm501_reg;
  243. u16 ver = __raw_readw(PA_VERREG);
  244. printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
  245. printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
  246. (ver >> 4) & 0xf, ver & 0xf);
  247. __raw_writew(0x0000, PA_OUTPORT);
  248. pm_power_off = rts7751r2d_power_off;
  249. /* sm501 dram configuration:
  250. * ColSizeX = 11 - External Memory Column Size: 256 words.
  251. * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
  252. * RstX = 1 - External Memory Reset: Normal.
  253. * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
  254. * BwC = 1 - Local Memory Block Write Cycle Time: 2 clocks.
  255. * BwP = 1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
  256. * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
  257. * Rst = 1 - Internal Memory Reset: Normal.
  258. * RA = 1 - Internal Memory Remain in Active State: Do not remain.
  259. */
  260. sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
  261. writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
  262. }
  263. /*
  264. * The Machine Vector
  265. */
  266. static struct sh_machine_vector mv_rts7751r2d __initmv = {
  267. .mv_name = "RTS7751R2D",
  268. .mv_setup = rts7751r2d_setup,
  269. .mv_init_irq = init_rts7751r2d_IRQ,
  270. .mv_irq_demux = rts7751r2d_irq_demux,
  271. };