setup.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/init.h>
  3. #include <linux/platform_device.h>
  4. #include <linux/mtd/physmap.h>
  5. #include <linux/serial_8250.h>
  6. #include <linux/serial_reg.h>
  7. #include <linux/usb/isp116x.h>
  8. #include <linux/delay.h>
  9. #include <linux/irqdomain.h>
  10. #include <asm/machvec.h>
  11. #include <mach-se/mach/se7343.h>
  12. #include <asm/heartbeat.h>
  13. #include <asm/irq.h>
  14. #include <asm/io.h>
  15. static struct resource heartbeat_resource = {
  16. .start = PA_LED,
  17. .end = PA_LED,
  18. .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
  19. };
  20. static struct platform_device heartbeat_device = {
  21. .name = "heartbeat",
  22. .id = -1,
  23. .num_resources = 1,
  24. .resource = &heartbeat_resource,
  25. };
  26. static struct mtd_partition nor_flash_partitions[] = {
  27. {
  28. .name = "loader",
  29. .offset = 0x00000000,
  30. .size = 128 * 1024,
  31. },
  32. {
  33. .name = "rootfs",
  34. .offset = MTDPART_OFS_APPEND,
  35. .size = 31 * 1024 * 1024,
  36. },
  37. {
  38. .name = "data",
  39. .offset = MTDPART_OFS_APPEND,
  40. .size = MTDPART_SIZ_FULL,
  41. },
  42. };
  43. static struct physmap_flash_data nor_flash_data = {
  44. .width = 2,
  45. .parts = nor_flash_partitions,
  46. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  47. };
  48. static struct resource nor_flash_resources[] = {
  49. [0] = {
  50. .start = 0x00000000,
  51. .end = 0x01ffffff,
  52. .flags = IORESOURCE_MEM,
  53. }
  54. };
  55. static struct platform_device nor_flash_device = {
  56. .name = "physmap-flash",
  57. .dev = {
  58. .platform_data = &nor_flash_data,
  59. },
  60. .num_resources = ARRAY_SIZE(nor_flash_resources),
  61. .resource = nor_flash_resources,
  62. };
  63. #define ST16C2550C_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP)
  64. static struct plat_serial8250_port serial_platform_data[] = {
  65. [0] = {
  66. .iotype = UPIO_MEM,
  67. .mapbase = 0x16000000,
  68. .regshift = 1,
  69. .flags = ST16C2550C_FLAGS,
  70. .uartclk = 7372800,
  71. },
  72. [1] = {
  73. .iotype = UPIO_MEM,
  74. .mapbase = 0x17000000,
  75. .regshift = 1,
  76. .flags = ST16C2550C_FLAGS,
  77. .uartclk = 7372800,
  78. },
  79. { },
  80. };
  81. static struct platform_device uart_device = {
  82. .name = "serial8250",
  83. .id = PLAT8250_DEV_PLATFORM,
  84. .dev = {
  85. .platform_data = serial_platform_data,
  86. },
  87. };
  88. static void isp116x_delay(struct device *dev, int delay)
  89. {
  90. ndelay(delay);
  91. }
  92. static struct resource usb_resources[] = {
  93. [0] = {
  94. .start = 0x11800000,
  95. .end = 0x11800001,
  96. .flags = IORESOURCE_MEM,
  97. },
  98. [1] = {
  99. .start = 0x11800002,
  100. .end = 0x11800003,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. [2] = {
  104. /* Filled in later */
  105. .flags = IORESOURCE_IRQ,
  106. },
  107. };
  108. static struct isp116x_platform_data usb_platform_data = {
  109. .sel15Kres = 1,
  110. .oc_enable = 1,
  111. .int_act_high = 0,
  112. .int_edge_triggered = 0,
  113. .remote_wakeup_enable = 0,
  114. .delay = isp116x_delay,
  115. };
  116. static struct platform_device usb_device = {
  117. .name = "isp116x-hcd",
  118. .id = -1,
  119. .num_resources = ARRAY_SIZE(usb_resources),
  120. .resource = usb_resources,
  121. .dev = {
  122. .platform_data = &usb_platform_data,
  123. },
  124. };
  125. static struct platform_device *sh7343se_platform_devices[] __initdata = {
  126. &heartbeat_device,
  127. &nor_flash_device,
  128. &uart_device,
  129. &usb_device,
  130. };
  131. static int __init sh7343se_devices_setup(void)
  132. {
  133. /* Wire-up dynamic vectors */
  134. serial_platform_data[0].irq = irq_find_mapping(se7343_irq_domain,
  135. SE7343_FPGA_IRQ_UARTA);
  136. serial_platform_data[1].irq = irq_find_mapping(se7343_irq_domain,
  137. SE7343_FPGA_IRQ_UARTB);
  138. usb_resources[2].start = usb_resources[2].end =
  139. irq_find_mapping(se7343_irq_domain, SE7343_FPGA_IRQ_USB);
  140. return platform_add_devices(sh7343se_platform_devices,
  141. ARRAY_SIZE(sh7343se_platform_devices));
  142. }
  143. device_initcall(sh7343se_devices_setup);
  144. /*
  145. * Initialize the board
  146. */
  147. static void __init sh7343se_setup(char **cmdline_p)
  148. {
  149. __raw_writew(0xf900, FPGA_OUT); /* FPGA */
  150. __raw_writew(0x0002, PORT_PECR); /* PORT E 1 = IRQ5 */
  151. __raw_writew(0x0020, PORT_PSELD);
  152. printk(KERN_INFO "MS7343CP01 Setup...done\n");
  153. }
  154. /*
  155. * The Machine Vector
  156. */
  157. static struct sh_machine_vector mv_7343se __initmv = {
  158. .mv_name = "SolutionEngine 7343",
  159. .mv_setup = sh7343se_setup,
  160. .mv_init_irq = init_7343se_IRQ,
  161. };