setup.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * arch/sh/boards/renesas/r7780rp/setup.c
  3. *
  4. * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
  5. * Copyright (C) 2005 - 2007 Paul Mundt
  6. *
  7. * Renesas Solutions Highlander R7780RP-1 Support.
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/pata_platform.h>
  16. #include <asm/machvec.h>
  17. #include <asm/r7780rp.h>
  18. #include <asm/clock.h>
  19. #include <asm/io.h>
  20. extern void init_r7780rp_IRQ(void);
  21. static struct resource m66596_usb_host_resources[] = {
  22. [0] = {
  23. .start = 0xa4800000,
  24. .end = 0xa4ffffff,
  25. .flags = IORESOURCE_MEM,
  26. },
  27. [1] = {
  28. .start = 6, /* irq number */
  29. .end = 6,
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. };
  33. static struct platform_device m66596_usb_host_device = {
  34. .name = "m66596-hcd",
  35. .id = 0,
  36. .dev = {
  37. .dma_mask = NULL, /* don't use dma */
  38. .coherent_dma_mask = 0xffffffff,
  39. },
  40. .num_resources = ARRAY_SIZE(m66596_usb_host_resources),
  41. .resource = m66596_usb_host_resources,
  42. };
  43. static struct resource cf_ide_resources[] = {
  44. [0] = {
  45. .start = PA_AREA5_IO + 0x1000,
  46. .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
  47. .flags = IORESOURCE_MEM,
  48. },
  49. [1] = {
  50. .start = PA_AREA5_IO + 0x80c,
  51. .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
  52. .flags = IORESOURCE_MEM,
  53. },
  54. [2] = {
  55. #ifdef CONFIG_SH_R7780MP
  56. .start = 1,
  57. #else
  58. .start = 4,
  59. #endif
  60. .flags = IORESOURCE_IRQ,
  61. },
  62. };
  63. static struct pata_platform_info pata_info = {
  64. .ioport_shift = 1,
  65. };
  66. static struct platform_device cf_ide_device = {
  67. .name = "pata_platform",
  68. .id = -1,
  69. .num_resources = ARRAY_SIZE(cf_ide_resources),
  70. .resource = cf_ide_resources,
  71. .dev = {
  72. .platform_data = &pata_info,
  73. },
  74. };
  75. static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
  76. static struct resource heartbeat_resources[] = {
  77. [0] = {
  78. .start = PA_OBLED,
  79. .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
  80. .flags = IORESOURCE_MEM,
  81. },
  82. };
  83. static struct platform_device heartbeat_device = {
  84. .name = "heartbeat",
  85. .id = -1,
  86. .dev = {
  87. .platform_data = heartbeat_bit_pos,
  88. },
  89. .num_resources = ARRAY_SIZE(heartbeat_resources),
  90. .resource = heartbeat_resources,
  91. };
  92. static struct platform_device *r7780rp_devices[] __initdata = {
  93. &m66596_usb_host_device,
  94. &cf_ide_device,
  95. &heartbeat_device,
  96. };
  97. static int __init r7780rp_devices_setup(void)
  98. {
  99. return platform_add_devices(r7780rp_devices,
  100. ARRAY_SIZE(r7780rp_devices));
  101. }
  102. /*
  103. * Platform specific clocks
  104. */
  105. static void ivdr_clk_enable(struct clk *clk)
  106. {
  107. ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
  108. }
  109. static void ivdr_clk_disable(struct clk *clk)
  110. {
  111. ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
  112. }
  113. static struct clk_ops ivdr_clk_ops = {
  114. .enable = ivdr_clk_enable,
  115. .disable = ivdr_clk_disable,
  116. };
  117. static struct clk ivdr_clk = {
  118. .name = "ivdr_clk",
  119. .ops = &ivdr_clk_ops,
  120. };
  121. static struct clk *r7780rp_clocks[] = {
  122. &ivdr_clk,
  123. };
  124. static void r7780rp_power_off(void)
  125. {
  126. #ifdef CONFIG_SH_R7780MP
  127. ctrl_outw(0x0001, PA_POFF);
  128. #endif
  129. }
  130. /*
  131. * Initialize the board
  132. */
  133. static void __init r7780rp_setup(char **cmdline_p)
  134. {
  135. u16 ver = ctrl_inw(PA_VERREG);
  136. int i;
  137. device_initcall(r7780rp_devices_setup);
  138. printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n");
  139. printk(KERN_INFO "Board version: %d (revision %d), "
  140. "FPGA version: %d (revision %d)\n",
  141. (ver >> 12) & 0xf, (ver >> 8) & 0xf,
  142. (ver >> 4) & 0xf, ver & 0xf);
  143. /*
  144. * Enable the important clocks right away..
  145. */
  146. for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
  147. struct clk *clk = r7780rp_clocks[i];
  148. clk_register(clk);
  149. clk_enable(clk);
  150. }
  151. ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
  152. #ifndef CONFIG_SH_R7780MP
  153. ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
  154. #endif
  155. ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
  156. pm_power_off = r7780rp_power_off;
  157. }
  158. /*
  159. * The Machine Vector
  160. */
  161. struct sh_machine_vector mv_r7780rp __initmv = {
  162. .mv_name = "Highlander R7780RP-1",
  163. .mv_setup = r7780rp_setup,
  164. .mv_nr_irqs = 109,
  165. .mv_init_irq = init_r7780rp_IRQ,
  166. };
  167. ALIAS_MV(r7780rp)