setup.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Renesas Technology Sales RTS7751R2D Support.
  3. *
  4. * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
  5. * Copyright (C) 2004 - 2006 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/serial_8250.h>
  14. #include <linux/pm.h>
  15. #include <asm/machvec.h>
  16. #include <asm/mach/rts7751r2d.h>
  17. #include <asm/io.h>
  18. #include <asm/voyagergx.h>
  19. extern void heartbeat_rts7751r2d(void);
  20. extern void init_rts7751r2d_IRQ(void);
  21. extern int rts7751r2d_irq_demux(int irq);
  22. extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t);
  23. extern int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t);
  24. static struct plat_serial8250_port uart_platform_data[] = {
  25. {
  26. .membase = (void *)VOYAGER_UART_BASE,
  27. .mapbase = VOYAGER_UART_BASE,
  28. .iotype = UPIO_MEM,
  29. .irq = VOYAGER_UART0_IRQ,
  30. .flags = UPF_BOOT_AUTOCONF,
  31. .regshift = 2,
  32. .uartclk = (9600 * 16),
  33. }, {
  34. .flags = 0,
  35. },
  36. };
  37. static void __init voyagergx_serial_init(void)
  38. {
  39. unsigned long val;
  40. /*
  41. * GPIO Control
  42. */
  43. val = inl(GPIO_MUX_HIGH);
  44. val |= 0x00001fe0;
  45. outl(val, GPIO_MUX_HIGH);
  46. /*
  47. * Power Mode Gate
  48. */
  49. val = inl(POWER_MODE0_GATE);
  50. val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
  51. outl(val, POWER_MODE0_GATE);
  52. val = inl(POWER_MODE1_GATE);
  53. val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
  54. outl(val, POWER_MODE1_GATE);
  55. }
  56. static struct platform_device uart_device = {
  57. .name = "serial8250",
  58. .id = -1,
  59. .dev = {
  60. .platform_data = uart_platform_data,
  61. },
  62. };
  63. static struct resource heartbeat_resources[] = {
  64. [0] = {
  65. .start = PA_OUTPORT,
  66. .end = PA_OUTPORT + 8 - 1,
  67. .flags = IORESOURCE_MEM,
  68. },
  69. };
  70. static struct platform_device heartbeat_device = {
  71. .name = "heartbeat",
  72. .id = -1,
  73. .num_resources = ARRAY_SIZE(heartbeat_resources),
  74. .resource = heartbeat_resources,
  75. };
  76. static struct platform_device *rts7751r2d_devices[] __initdata = {
  77. &uart_device,
  78. &heartbeat_device,
  79. };
  80. static int __init rts7751r2d_devices_setup(void)
  81. {
  82. return platform_add_devices(rts7751r2d_devices,
  83. ARRAY_SIZE(rts7751r2d_devices));
  84. }
  85. static void rts7751r2d_power_off(void)
  86. {
  87. ctrl_outw(0x0001, PA_POWOFF);
  88. }
  89. /*
  90. * Initialize the board
  91. */
  92. static void __init rts7751r2d_setup(char **cmdline_p)
  93. {
  94. device_initcall(rts7751r2d_devices_setup);
  95. ctrl_outw(0x0000, PA_OUTPORT);
  96. pm_power_off = rts7751r2d_power_off;
  97. voyagergx_serial_init();
  98. printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
  99. }
  100. /*
  101. * The Machine Vector
  102. */
  103. struct sh_machine_vector mv_rts7751r2d __initmv = {
  104. .mv_name = "RTS7751R2D",
  105. .mv_setup = rts7751r2d_setup,
  106. .mv_nr_irqs = 72,
  107. .mv_inb = rts7751r2d_inb,
  108. .mv_inw = rts7751r2d_inw,
  109. .mv_inl = rts7751r2d_inl,
  110. .mv_outb = rts7751r2d_outb,
  111. .mv_outw = rts7751r2d_outw,
  112. .mv_outl = rts7751r2d_outl,
  113. .mv_inb_p = rts7751r2d_inb_p,
  114. .mv_inw_p = rts7751r2d_inw,
  115. .mv_inl_p = rts7751r2d_inl,
  116. .mv_outb_p = rts7751r2d_outb_p,
  117. .mv_outw_p = rts7751r2d_outw,
  118. .mv_outl_p = rts7751r2d_outl,
  119. .mv_insb = rts7751r2d_insb,
  120. .mv_insw = rts7751r2d_insw,
  121. .mv_insl = rts7751r2d_insl,
  122. .mv_outsb = rts7751r2d_outsb,
  123. .mv_outsw = rts7751r2d_outsw,
  124. .mv_outsl = rts7751r2d_outsl,
  125. .mv_init_irq = init_rts7751r2d_IRQ,
  126. .mv_irq_demux = rts7751r2d_irq_demux,
  127. #ifdef CONFIG_USB_SM501
  128. .mv_consistent_alloc = voyagergx_consistent_alloc,
  129. .mv_consistent_free = voyagergx_consistent_free,
  130. #endif
  131. };
  132. ALIAS_MV(rts7751r2d)