setup.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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/pata_platform.h>
  14. #include <linux/serial_8250.h>
  15. #include <linux/sm501.h>
  16. #include <linux/pm.h>
  17. #include <asm/machvec.h>
  18. #include <asm/rts7751r2d.h>
  19. #include <asm/voyagergx.h>
  20. #include <asm/io.h>
  21. static void __init voyagergx_serial_init(void)
  22. {
  23. unsigned long val;
  24. /*
  25. * GPIO Control
  26. */
  27. val = readl((void __iomem *)GPIO_MUX_HIGH);
  28. val |= 0x00001fe0;
  29. writel(val, (void __iomem *)GPIO_MUX_HIGH);
  30. /*
  31. * Power Mode Gate
  32. */
  33. val = readl((void __iomem *)POWER_MODE0_GATE);
  34. val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
  35. writel(val, (void __iomem *)POWER_MODE0_GATE);
  36. val = readl((void __iomem *)POWER_MODE1_GATE);
  37. val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
  38. writel(val, (void __iomem *)POWER_MODE1_GATE);
  39. }
  40. static struct resource cf_ide_resources[] = {
  41. [0] = {
  42. .start = PA_AREA5_IO + 0x1000,
  43. .end = PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. [1] = {
  47. .start = PA_AREA5_IO + 0x80c,
  48. .end = PA_AREA5_IO + 0x80c,
  49. .flags = IORESOURCE_MEM,
  50. },
  51. #ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
  52. [2] = {
  53. .start = IRQ_CF_IDE,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. #endif
  57. };
  58. static struct pata_platform_info pata_info = {
  59. .ioport_shift = 1,
  60. };
  61. static struct platform_device cf_ide_device = {
  62. .name = "pata_platform",
  63. .id = -1,
  64. .num_resources = ARRAY_SIZE(cf_ide_resources),
  65. .resource = cf_ide_resources,
  66. .dev = {
  67. .platform_data = &pata_info,
  68. },
  69. };
  70. static struct resource heartbeat_resources[] = {
  71. [0] = {
  72. .start = PA_OUTPORT,
  73. .end = PA_OUTPORT,
  74. .flags = IORESOURCE_MEM,
  75. },
  76. };
  77. static struct platform_device heartbeat_device = {
  78. .name = "heartbeat",
  79. .id = -1,
  80. .num_resources = ARRAY_SIZE(heartbeat_resources),
  81. .resource = heartbeat_resources,
  82. };
  83. #ifdef CONFIG_MFD_SM501
  84. static struct plat_serial8250_port uart_platform_data[] = {
  85. {
  86. .membase = (void __iomem *)VOYAGER_UART_BASE,
  87. .mapbase = VOYAGER_UART_BASE,
  88. .iotype = UPIO_MEM,
  89. .irq = IRQ_SM501_U0,
  90. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  91. .regshift = 2,
  92. .uartclk = (9600 * 16),
  93. },
  94. { 0 },
  95. };
  96. static struct platform_device uart_device = {
  97. .name = "serial8250",
  98. .id = PLAT8250_DEV_PLATFORM,
  99. .dev = {
  100. .platform_data = uart_platform_data,
  101. },
  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_SM501_CV,
  116. .flags = IORESOURCE_IRQ,
  117. },
  118. };
  119. static struct platform_device sm501_device = {
  120. .name = "sm501",
  121. .id = -1,
  122. .num_resources = ARRAY_SIZE(sm501_resources),
  123. .resource = sm501_resources,
  124. };
  125. #endif /* CONFIG_MFD_SM501 */
  126. static struct platform_device *rts7751r2d_devices[] __initdata = {
  127. #ifdef CONFIG_MFD_SM501
  128. &uart_device,
  129. &sm501_device,
  130. #endif
  131. &cf_ide_device,
  132. &heartbeat_device,
  133. };
  134. static int __init rts7751r2d_devices_setup(void)
  135. {
  136. return platform_add_devices(rts7751r2d_devices,
  137. ARRAY_SIZE(rts7751r2d_devices));
  138. }
  139. __initcall(rts7751r2d_devices_setup);
  140. static void rts7751r2d_power_off(void)
  141. {
  142. ctrl_outw(0x0001, PA_POWOFF);
  143. }
  144. static inline unsigned char is_ide_ioaddr(unsigned long addr)
  145. {
  146. return ((cf_ide_resources[0].start <= addr &&
  147. addr <= cf_ide_resources[0].end) ||
  148. (cf_ide_resources[1].start <= addr &&
  149. addr <= cf_ide_resources[1].end));
  150. }
  151. void rts7751r2d_writeb(u8 b, void __iomem *addr)
  152. {
  153. unsigned long tmp = (unsigned long __force)addr;
  154. if (is_ide_ioaddr(tmp))
  155. ctrl_outw((u16)b, tmp);
  156. else
  157. ctrl_outb(b, tmp);
  158. }
  159. u8 rts7751r2d_readb(void __iomem *addr)
  160. {
  161. unsigned long tmp = (unsigned long __force)addr;
  162. if (is_ide_ioaddr(tmp))
  163. return ctrl_inw(tmp) & 0xff;
  164. else
  165. return ctrl_inb(tmp);
  166. }
  167. /*
  168. * Initialize the board
  169. */
  170. static void __init rts7751r2d_setup(char **cmdline_p)
  171. {
  172. u16 ver = ctrl_inw(PA_VERREG);
  173. printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
  174. printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
  175. (ver >> 4) & 0xf, ver & 0xf);
  176. ctrl_outw(0x0000, PA_OUTPORT);
  177. pm_power_off = rts7751r2d_power_off;
  178. voyagergx_serial_init();
  179. }
  180. /*
  181. * The Machine Vector
  182. */
  183. static struct sh_machine_vector mv_rts7751r2d __initmv = {
  184. .mv_name = "RTS7751R2D",
  185. .mv_setup = rts7751r2d_setup,
  186. .mv_init_irq = init_rts7751r2d_IRQ,
  187. .mv_irq_demux = rts7751r2d_irq_demux,
  188. .mv_writeb = rts7751r2d_writeb,
  189. .mv_readb = rts7751r2d_readb,
  190. #if defined(CONFIG_MFD_SM501) && defined(CONFIG_USB_OHCI_HCD)
  191. .mv_consistent_alloc = voyagergx_consistent_alloc,
  192. .mv_consistent_free = voyagergx_consistent_free,
  193. #endif
  194. };