setup.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 + 0x08 - 1,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. [1] = {
  47. .start = PA_AREA5_IO + 0x80c,
  48. .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
  49. .flags = IORESOURCE_MEM,
  50. },
  51. [2] = {
  52. .start = IRQ_CF_IDE,
  53. .flags = IORESOURCE_IRQ,
  54. },
  55. };
  56. static struct pata_platform_info pata_info = {
  57. .ioport_shift = 1,
  58. };
  59. static struct platform_device cf_ide_device = {
  60. .name = "pata_platform",
  61. .id = -1,
  62. .num_resources = ARRAY_SIZE(cf_ide_resources),
  63. .resource = cf_ide_resources,
  64. .dev = {
  65. .platform_data = &pata_info,
  66. },
  67. };
  68. static struct plat_serial8250_port uart_platform_data[] = {
  69. {
  70. .membase = (void __iomem *)VOYAGER_UART_BASE,
  71. .mapbase = VOYAGER_UART_BASE,
  72. .iotype = UPIO_MEM,
  73. .irq = IRQ_SM501_U0,
  74. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  75. .regshift = 2,
  76. .uartclk = (9600 * 16),
  77. },
  78. { 0 },
  79. };
  80. static struct platform_device uart_device = {
  81. .name = "serial8250",
  82. .id = PLAT8250_DEV_PLATFORM,
  83. .dev = {
  84. .platform_data = uart_platform_data,
  85. },
  86. };
  87. static struct resource heartbeat_resources[] = {
  88. [0] = {
  89. .start = PA_OUTPORT,
  90. .end = PA_OUTPORT + 8 - 1,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. };
  94. static struct platform_device heartbeat_device = {
  95. .name = "heartbeat",
  96. .id = -1,
  97. .num_resources = ARRAY_SIZE(heartbeat_resources),
  98. .resource = heartbeat_resources,
  99. };
  100. static struct resource sm501_resources[] = {
  101. [0] = {
  102. .start = 0x10000000,
  103. .end = 0x13e00000 - 1,
  104. .flags = IORESOURCE_MEM,
  105. },
  106. [1] = {
  107. .start = 0x13e00000,
  108. .end = 0x13ffffff,
  109. .flags = IORESOURCE_MEM,
  110. },
  111. [2] = {
  112. .start = IRQ_SM501_CV,
  113. .flags = IORESOURCE_IRQ,
  114. },
  115. };
  116. static struct platform_device sm501_device = {
  117. .name = "sm501",
  118. .id = -1,
  119. .num_resources = ARRAY_SIZE(sm501_resources),
  120. .resource = sm501_resources,
  121. };
  122. static struct platform_device *rts7751r2d_devices[] __initdata = {
  123. &uart_device,
  124. &heartbeat_device,
  125. &sm501_device,
  126. };
  127. static int __init rts7751r2d_devices_setup(void)
  128. {
  129. int ret;
  130. if (ctrl_inw(PA_BVERREG) == 0x10) { /* R2D-PLUS */
  131. ret = platform_device_register(&cf_ide_device);
  132. if (ret)
  133. return ret;
  134. }
  135. return platform_add_devices(rts7751r2d_devices,
  136. ARRAY_SIZE(rts7751r2d_devices));
  137. }
  138. __initcall(rts7751r2d_devices_setup);
  139. static void rts7751r2d_power_off(void)
  140. {
  141. ctrl_outw(0x0001, PA_POWOFF);
  142. }
  143. /*
  144. * Initialize the board
  145. */
  146. static void __init rts7751r2d_setup(char **cmdline_p)
  147. {
  148. u16 ver = ctrl_inw(PA_VERREG);
  149. printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
  150. printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
  151. (ver >> 4) & 0xf, ver & 0xf);
  152. ctrl_outw(0x0000, PA_OUTPORT);
  153. pm_power_off = rts7751r2d_power_off;
  154. voyagergx_serial_init();
  155. }
  156. /*
  157. * The Machine Vector
  158. */
  159. static struct sh_machine_vector mv_rts7751r2d __initmv = {
  160. .mv_name = "RTS7751R2D",
  161. .mv_setup = rts7751r2d_setup,
  162. .mv_init_irq = init_rts7751r2d_IRQ,
  163. .mv_irq_demux = rts7751r2d_irq_demux,
  164. #ifdef CONFIG_USB_SM501
  165. .mv_consistent_alloc = voyagergx_consistent_alloc,
  166. .mv_consistent_free = voyagergx_consistent_free,
  167. #endif
  168. };