setup.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Copyright (C) 2009 Renesas Solutions Corp.
  3. *
  4. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/device.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/gpio.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/io.h>
  17. #include <linux/delay.h>
  18. #include <linux/usb/r8a66597.h>
  19. #include <asm/heartbeat.h>
  20. #include <asm/sh_eth.h>
  21. #include <cpu/sh7724.h>
  22. /*
  23. * Address Interface BusWidth
  24. *-----------------------------------------
  25. * 0x0000_0000 uboot 16bit
  26. * 0x0004_0000 Linux romImage 16bit
  27. * 0x0014_0000 MTD for Linux 16bit
  28. * 0x0400_0000 Internal I/O 16/32bit
  29. * 0x0800_0000 DRAM 32bit
  30. * 0x1800_0000 MFI 16bit
  31. */
  32. /* Heartbeat */
  33. static unsigned char led_pos[] = { 0, 1, 2, 3 };
  34. static struct heartbeat_data heartbeat_data = {
  35. .regsize = 8,
  36. .nr_bits = 4,
  37. .bit_pos = led_pos,
  38. };
  39. static struct resource heartbeat_resources[] = {
  40. [0] = {
  41. .start = 0xA405012C, /* PTG */
  42. .end = 0xA405012E - 1,
  43. .flags = IORESOURCE_MEM,
  44. },
  45. };
  46. static struct platform_device heartbeat_device = {
  47. .name = "heartbeat",
  48. .id = -1,
  49. .dev = {
  50. .platform_data = &heartbeat_data,
  51. },
  52. .num_resources = ARRAY_SIZE(heartbeat_resources),
  53. .resource = heartbeat_resources,
  54. };
  55. /* MTD */
  56. static struct mtd_partition nor_flash_partitions[] = {
  57. {
  58. .name = "boot loader",
  59. .offset = 0,
  60. .size = (5 * 1024 * 1024),
  61. .mask_flags = MTD_CAP_ROM,
  62. }, {
  63. .name = "free-area",
  64. .offset = MTDPART_OFS_APPEND,
  65. .size = MTDPART_SIZ_FULL,
  66. },
  67. };
  68. static struct physmap_flash_data nor_flash_data = {
  69. .width = 2,
  70. .parts = nor_flash_partitions,
  71. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  72. };
  73. static struct resource nor_flash_resources[] = {
  74. [0] = {
  75. .name = "NOR Flash",
  76. .start = 0x00000000,
  77. .end = 0x03ffffff,
  78. .flags = IORESOURCE_MEM,
  79. }
  80. };
  81. static struct platform_device nor_flash_device = {
  82. .name = "physmap-flash",
  83. .resource = nor_flash_resources,
  84. .num_resources = ARRAY_SIZE(nor_flash_resources),
  85. .dev = {
  86. .platform_data = &nor_flash_data,
  87. },
  88. };
  89. /* SH Eth */
  90. #define SH_ETH_ADDR (0xA4600000)
  91. #define SH_ETH_MAHR (SH_ETH_ADDR + 0x1C0)
  92. #define SH_ETH_MALR (SH_ETH_ADDR + 0x1C8)
  93. static struct resource sh_eth_resources[] = {
  94. [0] = {
  95. .start = SH_ETH_ADDR,
  96. .end = SH_ETH_ADDR + 0x1FC,
  97. .flags = IORESOURCE_MEM,
  98. },
  99. [1] = {
  100. .start = 91,
  101. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  102. },
  103. };
  104. struct sh_eth_plat_data sh_eth_plat = {
  105. .phy = 0x1f, /* SMSC LAN8700 */
  106. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  107. };
  108. static struct platform_device sh_eth_device = {
  109. .name = "sh-eth",
  110. .id = 0,
  111. .dev = {
  112. .platform_data = &sh_eth_plat,
  113. },
  114. .num_resources = ARRAY_SIZE(sh_eth_resources),
  115. .resource = sh_eth_resources,
  116. };
  117. /* USB0 host */
  118. void usb0_port_power(int port, int power)
  119. {
  120. gpio_set_value(GPIO_PTB4, power);
  121. }
  122. static struct r8a66597_platdata usb0_host_data = {
  123. .on_chip = 1,
  124. .port_power = usb0_port_power,
  125. };
  126. static struct resource usb0_host_resources[] = {
  127. [0] = {
  128. .start = 0xa4d80000,
  129. .end = 0xa4d80124 - 1,
  130. .flags = IORESOURCE_MEM,
  131. },
  132. [1] = {
  133. .start = 65,
  134. .end = 65,
  135. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  136. },
  137. };
  138. static struct platform_device usb0_host_device = {
  139. .name = "r8a66597_hcd",
  140. .id = 0,
  141. .dev = {
  142. .dma_mask = NULL, /* not use dma */
  143. .coherent_dma_mask = 0xffffffff,
  144. .platform_data = &usb0_host_data,
  145. },
  146. .num_resources = ARRAY_SIZE(usb0_host_resources),
  147. .resource = usb0_host_resources,
  148. };
  149. /*
  150. * USB1
  151. *
  152. * CN5 can use both host/function,
  153. * and we can determine it by checking PTB[3]
  154. *
  155. * This time only USB1 host is supported.
  156. */
  157. void usb1_port_power(int port, int power)
  158. {
  159. if (!gpio_get_value(GPIO_PTB3)) {
  160. printk(KERN_ERR "USB1 function is not supported\n");
  161. return;
  162. }
  163. gpio_set_value(GPIO_PTB5, power);
  164. }
  165. static struct r8a66597_platdata usb1_host_data = {
  166. .on_chip = 1,
  167. .port_power = usb1_port_power,
  168. };
  169. static struct resource usb1_host_resources[] = {
  170. [0] = {
  171. .start = 0xa4d90000,
  172. .end = 0xa4d90124 - 1,
  173. .flags = IORESOURCE_MEM,
  174. },
  175. [1] = {
  176. .start = 66,
  177. .end = 66,
  178. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  179. },
  180. };
  181. static struct platform_device usb1_host_device = {
  182. .name = "r8a66597_hcd",
  183. .id = 1,
  184. .dev = {
  185. .dma_mask = NULL, /* not use dma */
  186. .coherent_dma_mask = 0xffffffff,
  187. .platform_data = &usb1_host_data,
  188. },
  189. .num_resources = ARRAY_SIZE(usb1_host_resources),
  190. .resource = usb1_host_resources,
  191. };
  192. static struct platform_device *ecovec_devices[] __initdata = {
  193. &heartbeat_device,
  194. &nor_flash_device,
  195. &sh_eth_device,
  196. &usb0_host_device,
  197. &usb1_host_device, /* USB1 host support */
  198. };
  199. static int __init devices_setup(void)
  200. {
  201. /* enable SCIFA0 */
  202. gpio_request(GPIO_FN_SCIF0_TXD, NULL);
  203. gpio_request(GPIO_FN_SCIF0_RXD, NULL);
  204. /* enable debug LED */
  205. gpio_request(GPIO_PTG0, NULL);
  206. gpio_request(GPIO_PTG1, NULL);
  207. gpio_request(GPIO_PTG2, NULL);
  208. gpio_request(GPIO_PTG3, NULL);
  209. gpio_direction_output(GPIO_PTG0, 0);
  210. gpio_direction_output(GPIO_PTG1, 0);
  211. gpio_direction_output(GPIO_PTG2, 0);
  212. gpio_direction_output(GPIO_PTG3, 0);
  213. /* enable SH-Eth */
  214. gpio_request(GPIO_PTA1, NULL);
  215. gpio_direction_output(GPIO_PTA1, 1);
  216. mdelay(20);
  217. gpio_request(GPIO_FN_RMII_RXD0, NULL);
  218. gpio_request(GPIO_FN_RMII_RXD1, NULL);
  219. gpio_request(GPIO_FN_RMII_TXD0, NULL);
  220. gpio_request(GPIO_FN_RMII_TXD1, NULL);
  221. gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
  222. gpio_request(GPIO_FN_RMII_TX_EN, NULL);
  223. gpio_request(GPIO_FN_RMII_RX_ER, NULL);
  224. gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
  225. gpio_request(GPIO_FN_MDIO, NULL);
  226. gpio_request(GPIO_FN_MDC, NULL);
  227. gpio_request(GPIO_FN_LNKSTA, NULL);
  228. /* enable USB */
  229. gpio_request(GPIO_PTB3, NULL);
  230. gpio_request(GPIO_PTB4, NULL);
  231. gpio_request(GPIO_PTB5, NULL);
  232. gpio_direction_input(GPIO_PTB3);
  233. gpio_direction_output(GPIO_PTB4, 0);
  234. gpio_direction_output(GPIO_PTB5, 0);
  235. ctrl_outw(0x0600, 0xa40501d4);
  236. ctrl_outw(0x0600, 0xa4050192);
  237. return platform_add_devices(ecovec_devices,
  238. ARRAY_SIZE(ecovec_devices));
  239. }
  240. device_initcall(devices_setup);
  241. static struct sh_machine_vector mv_ecovec __initmv = {
  242. .mv_name = "R0P7724 (EcoVec)",
  243. };