setup.c 7.1 KB

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