setup.c 3.8 KB

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