setup.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. static struct plat_serial8250_port uart_platform_data[] = {
  102. {
  103. .membase = (void __iomem *)0xb3e30000,
  104. .mapbase = 0xb3e30000,
  105. .iotype = UPIO_MEM,
  106. .irq = IRQ_VOYAGER,
  107. .flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
  108. .regshift = 2,
  109. .uartclk = (9600 * 16),
  110. },
  111. { 0 },
  112. };
  113. static struct platform_device uart_device = {
  114. .name = "serial8250",
  115. .id = PLAT8250_DEV_PLATFORM,
  116. .dev = {
  117. .platform_data = uart_platform_data,
  118. },
  119. };
  120. static struct resource sm501_resources[] = {
  121. [0] = {
  122. .start = 0x10000000,
  123. .end = 0x13e00000 - 1,
  124. .flags = IORESOURCE_MEM,
  125. },
  126. [1] = {
  127. .start = 0x13e00000,
  128. .end = 0x13ffffff,
  129. .flags = IORESOURCE_MEM,
  130. },
  131. [2] = {
  132. .start = IRQ_VOYAGER,
  133. .flags = IORESOURCE_IRQ,
  134. },
  135. };
  136. static struct fb_videomode sm501_default_mode = {
  137. .pixclock = 35714,
  138. .xres = 640,
  139. .yres = 480,
  140. .left_margin = 105,
  141. .right_margin = 50,
  142. .upper_margin = 35,
  143. .lower_margin = 0,
  144. .hsync_len = 96,
  145. .vsync_len = 2,
  146. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  147. };
  148. static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
  149. .def_bpp = 16,
  150. .def_mode = &sm501_default_mode,
  151. .flags = SM501FB_FLAG_USE_INIT_MODE |
  152. SM501FB_FLAG_USE_HWCURSOR |
  153. SM501FB_FLAG_USE_HWACCEL |
  154. SM501FB_FLAG_DISABLE_AT_EXIT,
  155. };
  156. static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
  157. .flags = (SM501FB_FLAG_USE_INIT_MODE |
  158. SM501FB_FLAG_USE_HWCURSOR |
  159. SM501FB_FLAG_USE_HWACCEL |
  160. SM501FB_FLAG_DISABLE_AT_EXIT),
  161. };
  162. static struct sm501_platdata_fb sm501_fb_pdata = {
  163. .fb_route = SM501_FB_OWN,
  164. .fb_crt = &sm501_pdata_fbsub_crt,
  165. .fb_pnl = &sm501_pdata_fbsub_pnl,
  166. .flags = SM501_FBPD_SWAP_FB_ENDIAN,
  167. };
  168. static struct sm501_initdata sm501_initdata = {
  169. .gpio_high = {
  170. .set = 0x00001fe0,
  171. .mask = 0x0,
  172. },
  173. .devices = SM501_USE_USB_HOST,
  174. };
  175. static struct sm501_platdata sm501_platform_data = {
  176. .init = &sm501_initdata,
  177. .fb = &sm501_fb_pdata,
  178. };
  179. static struct platform_device sm501_device = {
  180. .name = "sm501",
  181. .id = -1,
  182. .dev = {
  183. .platform_data = &sm501_platform_data,
  184. },
  185. .num_resources = ARRAY_SIZE(sm501_resources),
  186. .resource = sm501_resources,
  187. };
  188. static struct platform_device *rts7751r2d_devices[] __initdata = {
  189. &uart_device,
  190. &sm501_device,
  191. &heartbeat_device,
  192. &spi_sh_sci_device,
  193. };
  194. /*
  195. * The CF is connected with a 16-bit bus where 8-bit operations are
  196. * unsupported. The linux ata driver is however using 8-bit operations, so
  197. * insert a trapped io filter to convert 8-bit operations into 16-bit.
  198. */
  199. static struct trapped_io cf_trapped_io = {
  200. .resource = cf_ide_resources,
  201. .num_resources = 2,
  202. .minimum_bus_width = 16,
  203. };
  204. static int __init rts7751r2d_devices_setup(void)
  205. {
  206. if (register_trapped_io(&cf_trapped_io) == 0)
  207. platform_device_register(&cf_ide_device);
  208. spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
  209. return platform_add_devices(rts7751r2d_devices,
  210. ARRAY_SIZE(rts7751r2d_devices));
  211. }
  212. __initcall(rts7751r2d_devices_setup);
  213. static void rts7751r2d_power_off(void)
  214. {
  215. ctrl_outw(0x0001, PA_POWOFF);
  216. }
  217. /*
  218. * Initialize the board
  219. */
  220. static void __init rts7751r2d_setup(char **cmdline_p)
  221. {
  222. void __iomem *sm501_reg;
  223. u16 ver = ctrl_inw(PA_VERREG);
  224. printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
  225. printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
  226. (ver >> 4) & 0xf, ver & 0xf);
  227. ctrl_outw(0x0000, PA_OUTPORT);
  228. pm_power_off = rts7751r2d_power_off;
  229. /* sm501 dram configuration:
  230. * ColSizeX = 11 - External Memory Column Size: 256 words.
  231. * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
  232. * RstX = 1 - External Memory Reset: Normal.
  233. * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
  234. * BwC = 1 - Local Memory Block Write Cycle Time: 2 clocks.
  235. * BwP = 1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
  236. * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
  237. * Rst = 1 - Internal Memory Reset: Normal.
  238. * RA = 1 - Internal Memory Remain in Active State: Do not remain.
  239. */
  240. sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
  241. writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
  242. /*
  243. * Power Mode Gate - Enable UART0
  244. */
  245. sm501_reg = (void __iomem *)0xb3e00000 + SM501_POWER_MODE_0_GATE;
  246. writel(readl(sm501_reg) | (1 << SM501_GATE_UART0), sm501_reg);
  247. sm501_reg = (void __iomem *)0xb3e00000 + SM501_POWER_MODE_1_GATE;
  248. writel(readl(sm501_reg) | (1 << SM501_GATE_UART0), sm501_reg);
  249. }
  250. /*
  251. * The Machine Vector
  252. */
  253. static struct sh_machine_vector mv_rts7751r2d __initmv = {
  254. .mv_name = "RTS7751R2D",
  255. .mv_setup = rts7751r2d_setup,
  256. .mv_init_irq = init_rts7751r2d_IRQ,
  257. .mv_irq_demux = rts7751r2d_irq_demux,
  258. };