setup.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * linux/arch/sh/boards/se/7722/setup.c
  3. *
  4. * Copyright (C) 2007 Nobuhiro Iwamatsu
  5. * Copyright (C) 2012 Paul Mundt
  6. *
  7. * Hitachi UL SolutionEngine 7722 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. */
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/ata_platform.h>
  17. #include <linux/input.h>
  18. #include <linux/input/sh_keysc.h>
  19. #include <linux/irqdomain.h>
  20. #include <linux/smc91x.h>
  21. #include <linux/sh_intc.h>
  22. #include <mach-se/mach/se7722.h>
  23. #include <mach-se/mach/mrshpc.h>
  24. #include <asm/machvec.h>
  25. #include <asm/clock.h>
  26. #include <asm/io.h>
  27. #include <asm/heartbeat.h>
  28. #include <cpu/sh7722.h>
  29. /* Heartbeat */
  30. static struct resource heartbeat_resource = {
  31. .start = PA_LED,
  32. .end = PA_LED,
  33. .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
  34. };
  35. static struct platform_device heartbeat_device = {
  36. .name = "heartbeat",
  37. .id = -1,
  38. .num_resources = 1,
  39. .resource = &heartbeat_resource,
  40. };
  41. /* SMC91x */
  42. static struct smc91x_platdata smc91x_info = {
  43. .flags = SMC91X_USE_16BIT,
  44. };
  45. static struct resource smc91x_eth_resources[] = {
  46. [0] = {
  47. .name = "smc91x-regs" ,
  48. .start = PA_LAN + 0x300,
  49. .end = PA_LAN + 0x300 + 0x10 ,
  50. .flags = IORESOURCE_MEM,
  51. },
  52. [1] = {
  53. /* Filled in later */
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. };
  57. static struct platform_device smc91x_eth_device = {
  58. .name = "smc91x",
  59. .id = 0,
  60. .dev = {
  61. .dma_mask = NULL, /* don't use dma */
  62. .coherent_dma_mask = 0xffffffff,
  63. .platform_data = &smc91x_info,
  64. },
  65. .num_resources = ARRAY_SIZE(smc91x_eth_resources),
  66. .resource = smc91x_eth_resources,
  67. };
  68. static struct resource cf_ide_resources[] = {
  69. [0] = {
  70. .start = PA_MRSHPC_IO + 0x1f0,
  71. .end = PA_MRSHPC_IO + 0x1f0 + 8 ,
  72. .flags = IORESOURCE_IO,
  73. },
  74. [1] = {
  75. .start = PA_MRSHPC_IO + 0x1f0 + 0x206,
  76. .end = PA_MRSHPC_IO + 0x1f0 +8 + 0x206 + 8,
  77. .flags = IORESOURCE_IO,
  78. },
  79. [2] = {
  80. /* Filled in later */
  81. .flags = IORESOURCE_IRQ,
  82. },
  83. };
  84. static struct platform_device cf_ide_device = {
  85. .name = "pata_platform",
  86. .id = -1,
  87. .num_resources = ARRAY_SIZE(cf_ide_resources),
  88. .resource = cf_ide_resources,
  89. };
  90. static struct sh_keysc_info sh_keysc_info = {
  91. .mode = SH_KEYSC_MODE_1, /* KEYOUT0->5, KEYIN0->4 */
  92. .scan_timing = 3,
  93. .delay = 5,
  94. .keycodes = { /* SW1 -> SW30 */
  95. KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
  96. KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
  97. KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
  98. KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
  99. KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y,
  100. KEY_Z,
  101. KEY_HOME, KEY_SLEEP, KEY_WAKEUP, KEY_COFFEE, /* life */
  102. },
  103. };
  104. static struct resource sh_keysc_resources[] = {
  105. [0] = {
  106. .start = 0x044b0000,
  107. .end = 0x044b000f,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. [1] = {
  111. .start = evt2irq(0xbe0),
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static struct platform_device sh_keysc_device = {
  116. .name = "sh_keysc",
  117. .id = 0, /* "keysc0" clock */
  118. .num_resources = ARRAY_SIZE(sh_keysc_resources),
  119. .resource = sh_keysc_resources,
  120. .dev = {
  121. .platform_data = &sh_keysc_info,
  122. },
  123. };
  124. static struct platform_device *se7722_devices[] __initdata = {
  125. &heartbeat_device,
  126. &smc91x_eth_device,
  127. &cf_ide_device,
  128. &sh_keysc_device,
  129. };
  130. static int __init se7722_devices_setup(void)
  131. {
  132. mrshpc_setup_windows();
  133. /* Wire-up dynamic vectors */
  134. cf_ide_resources[2].start = cf_ide_resources[2].end =
  135. irq_find_mapping(se7722_irq_domain, SE7722_FPGA_IRQ_MRSHPC0);
  136. smc91x_eth_resources[1].start = smc91x_eth_resources[1].end =
  137. irq_find_mapping(se7722_irq_domain, SE7722_FPGA_IRQ_SMC);
  138. return platform_add_devices(se7722_devices, ARRAY_SIZE(se7722_devices));
  139. }
  140. device_initcall(se7722_devices_setup);
  141. static void __init se7722_setup(char **cmdline_p)
  142. {
  143. __raw_writew(0x010D, FPGA_OUT); /* FPGA */
  144. __raw_writew(0x0000, PORT_PECR); /* PORT E 1 = IRQ5 ,E 0 = BS */
  145. __raw_writew(0x1000, PORT_PJCR); /* PORT J 1 = IRQ1,J 0 =IRQ0 */
  146. /* LCDC I/O */
  147. __raw_writew(0x0020, PORT_PSELD);
  148. /* SIOF1*/
  149. __raw_writew(0x0003, PORT_PSELB);
  150. __raw_writew(0xe000, PORT_PSELC);
  151. __raw_writew(0x0000, PORT_PKCR);
  152. /* LCDC */
  153. __raw_writew(0x4020, PORT_PHCR);
  154. __raw_writew(0x0000, PORT_PLCR);
  155. __raw_writew(0x0000, PORT_PMCR);
  156. __raw_writew(0x0002, PORT_PRCR);
  157. __raw_writew(0x0000, PORT_PXCR); /* LCDC,CS6A */
  158. /* KEYSC */
  159. __raw_writew(0x0A10, PORT_PSELA); /* BS,SHHID2 */
  160. __raw_writew(0x0000, PORT_PYCR);
  161. __raw_writew(0x0000, PORT_PZCR);
  162. __raw_writew(__raw_readw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
  163. __raw_writew(__raw_readw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
  164. }
  165. /*
  166. * The Machine Vector
  167. */
  168. static struct sh_machine_vector mv_se7722 __initmv = {
  169. .mv_name = "Solution Engine 7722" ,
  170. .mv_setup = se7722_setup ,
  171. .mv_init_irq = init_se7722_IRQ,
  172. };