board-g3evm.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * G3EVM board support
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/delay.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/physmap.h>
  29. #include <linux/usb/r8a66597.h>
  30. #include <linux/io.h>
  31. #include <linux/gpio.h>
  32. #include <mach/sh7367.h>
  33. #include <mach/common.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. static struct mtd_partition nor_flash_partitions[] = {
  38. {
  39. .name = "loader",
  40. .offset = 0x00000000,
  41. .size = 512 * 1024,
  42. },
  43. {
  44. .name = "bootenv",
  45. .offset = MTDPART_OFS_APPEND,
  46. .size = 512 * 1024,
  47. },
  48. {
  49. .name = "kernel_ro",
  50. .offset = MTDPART_OFS_APPEND,
  51. .size = 8 * 1024 * 1024,
  52. .mask_flags = MTD_WRITEABLE,
  53. },
  54. {
  55. .name = "kernel",
  56. .offset = MTDPART_OFS_APPEND,
  57. .size = 8 * 1024 * 1024,
  58. },
  59. {
  60. .name = "data",
  61. .offset = MTDPART_OFS_APPEND,
  62. .size = MTDPART_SIZ_FULL,
  63. },
  64. };
  65. static struct physmap_flash_data nor_flash_data = {
  66. .width = 2,
  67. .parts = nor_flash_partitions,
  68. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  69. };
  70. static struct resource nor_flash_resources[] = {
  71. [0] = {
  72. .start = 0x00000000,
  73. .end = 0x08000000 - 1,
  74. .flags = IORESOURCE_MEM,
  75. }
  76. };
  77. static struct platform_device nor_flash_device = {
  78. .name = "physmap-flash",
  79. .dev = {
  80. .platform_data = &nor_flash_data,
  81. },
  82. .num_resources = ARRAY_SIZE(nor_flash_resources),
  83. .resource = nor_flash_resources,
  84. };
  85. /* USBHS */
  86. void usb_host_port_power(int port, int power)
  87. {
  88. if (!power) /* only power-on supported for now */
  89. return;
  90. /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
  91. __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
  92. }
  93. static struct r8a66597_platdata usb_host_data = {
  94. .on_chip = 1,
  95. .port_power = usb_host_port_power,
  96. };
  97. static struct resource usb_host_resources[] = {
  98. [0] = {
  99. .name = "USBHS",
  100. .start = 0xe6890000,
  101. .end = 0xe68900e5,
  102. .flags = IORESOURCE_MEM,
  103. },
  104. [1] = {
  105. .start = 65,
  106. .flags = IORESOURCE_IRQ,
  107. },
  108. };
  109. static struct platform_device usb_host_device = {
  110. .name = "r8a66597_hcd",
  111. .id = 0,
  112. .dev = {
  113. .platform_data = &usb_host_data,
  114. .dma_mask = NULL,
  115. .coherent_dma_mask = 0xffffffff,
  116. },
  117. .num_resources = ARRAY_SIZE(usb_host_resources),
  118. .resource = usb_host_resources,
  119. };
  120. static struct platform_device *g3evm_devices[] __initdata = {
  121. &nor_flash_device,
  122. &usb_host_device,
  123. };
  124. static struct map_desc g3evm_io_desc[] __initdata = {
  125. /* create a 1:1 entity map for 0xe6xxxxxx
  126. * used by CPGA, INTC and PFC.
  127. */
  128. {
  129. .virtual = 0xe6000000,
  130. .pfn = __phys_to_pfn(0xe6000000),
  131. .length = 256 << 20,
  132. .type = MT_DEVICE_NONSHARED
  133. },
  134. };
  135. static void __init g3evm_map_io(void)
  136. {
  137. iotable_init(g3evm_io_desc, ARRAY_SIZE(g3evm_io_desc));
  138. /* setup early devices, clocks and console here as well */
  139. sh7367_add_early_devices();
  140. sh7367_clock_init();
  141. shmobile_setup_console();
  142. }
  143. static void __init g3evm_init(void)
  144. {
  145. sh7367_pinmux_init();
  146. /* Lit DS4 LED */
  147. gpio_request(GPIO_PORT22, NULL);
  148. gpio_direction_output(GPIO_PORT22, 1);
  149. gpio_export(GPIO_PORT22, 0);
  150. /* Lit DS8 LED */
  151. gpio_request(GPIO_PORT23, NULL);
  152. gpio_direction_output(GPIO_PORT23, 1);
  153. gpio_export(GPIO_PORT23, 0);
  154. /* Lit DS3 LED */
  155. gpio_request(GPIO_PORT24, NULL);
  156. gpio_direction_output(GPIO_PORT24, 1);
  157. gpio_export(GPIO_PORT24, 0);
  158. /* SCIFA1 */
  159. gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
  160. gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
  161. gpio_request(GPIO_FN_SCIFA1_CTS, NULL);
  162. gpio_request(GPIO_FN_SCIFA1_RTS, NULL);
  163. /* USBHS */
  164. gpio_request(GPIO_FN_VBUS0, NULL);
  165. gpio_request(GPIO_FN_PWEN, NULL);
  166. gpio_request(GPIO_FN_OVCN, NULL);
  167. gpio_request(GPIO_FN_OVCN2, NULL);
  168. gpio_request(GPIO_FN_EXTLP, NULL);
  169. gpio_request(GPIO_FN_IDIN, NULL);
  170. /* enable clock in SYMSTPCR2 */
  171. __raw_writel(__raw_readl(0xe6158048) & ~(1 << 22), 0xe6158048);
  172. /* setup USB phy */
  173. __raw_writew(0x0300, 0xe605810a); /* USBCR1 */
  174. __raw_writew(0x00e0, 0xe60581c0); /* CPFCH */
  175. __raw_writew(0x6010, 0xe60581c6); /* CGPOSR */
  176. __raw_writew(0x8a0a, 0xe605810c); /* USBCR2 */
  177. sh7367_add_standard_devices();
  178. platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
  179. }
  180. MACHINE_START(G3EVM, "g3evm")
  181. .phys_io = 0xe6000000,
  182. .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
  183. .map_io = g3evm_map_io,
  184. .init_irq = sh7367_init_irq,
  185. .init_machine = g3evm_init,
  186. .timer = &shmobile_timer,
  187. MACHINE_END