board-bockw.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Bock-W board support
  3. *
  4. * Copyright (C) 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  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/mfd/tmio.h>
  21. #include <linux/mmc/host.h>
  22. #include <linux/mmc/sh_mmcif.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/pinctrl/machine.h>
  25. #include <linux/platform_data/usb-rcar-phy.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/regulator/fixed.h>
  28. #include <linux/regulator/machine.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/spi/flash.h>
  32. #include <mach/common.h>
  33. #include <mach/irqs.h>
  34. #include <mach/r8a7778.h>
  35. #include <asm/mach/arch.h>
  36. /*
  37. * CN9(Upper side) SCIF/RCAN selection
  38. *
  39. * 1,4 3,6
  40. * SW40 SCIF RCAN
  41. * SW41 SCIF RCAN
  42. */
  43. /*
  44. * MMC (CN26) pin
  45. *
  46. * SW6 (D2) 3 pin
  47. * SW7 (D5) ON
  48. * SW8 (D3) 3 pin
  49. * SW10 (D4) 1 pin
  50. * SW12 (CLK) 1 pin
  51. * SW13 (D6) 3 pin
  52. * SW14 (CMD) ON
  53. * SW15 (D6) 1 pin
  54. * SW16 (D0) ON
  55. * SW17 (D1) ON
  56. * SW18 (D7) 3 pin
  57. * SW19 (MMC) 1 pin
  58. */
  59. /* Dummy supplies, where voltage doesn't matter */
  60. static struct regulator_consumer_supply dummy_supplies[] = {
  61. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  62. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  63. };
  64. static struct smsc911x_platform_config smsc911x_data = {
  65. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  66. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  67. .flags = SMSC911X_USE_32BIT,
  68. .phy_interface = PHY_INTERFACE_MODE_MII,
  69. };
  70. static struct resource smsc911x_resources[] = {
  71. DEFINE_RES_MEM(0x18300000, 0x1000),
  72. DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
  73. };
  74. /* USB */
  75. static struct resource usb_phy_resources[] __initdata = {
  76. DEFINE_RES_MEM(0xffe70800, 0x100),
  77. DEFINE_RES_MEM(0xffe76000, 0x100),
  78. };
  79. static struct rcar_phy_platform_data usb_phy_platform_data __initdata;
  80. /* SDHI */
  81. static struct sh_mobile_sdhi_info sdhi0_info = {
  82. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  83. .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  84. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  85. };
  86. static struct sh_eth_plat_data ether_platform_data __initdata = {
  87. .phy = 0x01,
  88. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  89. .register_type = SH_ETH_REG_FAST_RCAR,
  90. .phy_interface = PHY_INTERFACE_MODE_RMII,
  91. /*
  92. * Although the LINK signal is available on the board, it's connected to
  93. * the link/activity LED output of the PHY, thus the link disappears and
  94. * reappears after each packet. We'd be better off ignoring such signal
  95. * and getting the link state from the PHY indirectly.
  96. */
  97. .no_ether_link = 1,
  98. };
  99. /* I2C */
  100. static struct i2c_board_info i2c0_devices[] = {
  101. {
  102. I2C_BOARD_INFO("rx8581", 0x51),
  103. },
  104. };
  105. /* HSPI*/
  106. static struct mtd_partition m25p80_spi_flash_partitions[] = {
  107. {
  108. .name = "data(spi)",
  109. .size = 0x0100000,
  110. .offset = 0,
  111. },
  112. };
  113. static struct flash_platform_data spi_flash_data = {
  114. .name = "m25p80",
  115. .type = "s25fl008k",
  116. .parts = m25p80_spi_flash_partitions,
  117. .nr_parts = ARRAY_SIZE(m25p80_spi_flash_partitions),
  118. };
  119. static struct spi_board_info spi_board_info[] __initdata = {
  120. {
  121. .modalias = "m25p80",
  122. .max_speed_hz = 104000000,
  123. .chip_select = 0,
  124. .bus_num = 0,
  125. .mode = SPI_MODE_0,
  126. .platform_data = &spi_flash_data,
  127. },
  128. };
  129. /* MMC */
  130. static struct resource mmc_resources[] __initdata = {
  131. DEFINE_RES_MEM(0xffe4e000, 0x100),
  132. DEFINE_RES_IRQ(gic_iid(0x5d)),
  133. };
  134. static struct sh_mmcif_plat_data sh_mmcif_plat = {
  135. .sup_pclk = 0,
  136. .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  137. .caps = MMC_CAP_4_BIT_DATA |
  138. MMC_CAP_8_BIT_DATA |
  139. MMC_CAP_NEEDS_POLL,
  140. };
  141. static const struct pinctrl_map bockw_pinctrl_map[] = {
  142. /* Ether */
  143. PIN_MAP_MUX_GROUP_DEFAULT("r8a777x-ether", "pfc-r8a7778",
  144. "ether_rmii", "ether"),
  145. /* HSPI0 */
  146. PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7778",
  147. "hspi0_a", "hspi0"),
  148. /* MMC */
  149. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
  150. "mmc_data8", "mmc"),
  151. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
  152. "mmc_ctrl", "mmc"),
  153. /* SCIF0 */
  154. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
  155. "scif0_data_a", "scif0"),
  156. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
  157. "scif0_ctrl", "scif0"),
  158. /* USB */
  159. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778",
  160. "usb0", "usb0"),
  161. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778",
  162. "usb1", "usb1"),
  163. /* SDHI0 */
  164. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
  165. "sdhi0", "sdhi0"),
  166. };
  167. #define FPGA 0x18200000
  168. #define IRQ0MR 0x30
  169. #define PFC 0xfffc0000
  170. #define PUPR4 0x110
  171. static void __init bockw_init(void)
  172. {
  173. void __iomem *base;
  174. r8a7778_clock_init();
  175. r8a7778_init_irq_extpin(1);
  176. r8a7778_add_standard_devices();
  177. r8a7778_add_ether_device(&ether_platform_data);
  178. r8a7778_add_i2c_device(0);
  179. r8a7778_add_hspi_device(0);
  180. i2c_register_board_info(0, i2c0_devices,
  181. ARRAY_SIZE(i2c0_devices));
  182. spi_register_board_info(spi_board_info,
  183. ARRAY_SIZE(spi_board_info));
  184. pinctrl_register_mappings(bockw_pinctrl_map,
  185. ARRAY_SIZE(bockw_pinctrl_map));
  186. r8a7778_pinmux_init();
  187. platform_device_register_resndata(
  188. &platform_bus, "sh_mmcif", -1,
  189. mmc_resources, ARRAY_SIZE(mmc_resources),
  190. &sh_mmcif_plat, sizeof(struct sh_mmcif_plat_data));
  191. platform_device_register_resndata(
  192. &platform_bus, "rcar_usb_phy", -1,
  193. usb_phy_resources,
  194. ARRAY_SIZE(usb_phy_resources),
  195. &usb_phy_platform_data,
  196. sizeof(struct rcar_phy_platform_data));
  197. /* for SMSC */
  198. base = ioremap_nocache(FPGA, SZ_1M);
  199. if (base) {
  200. /*
  201. * CAUTION
  202. *
  203. * IRQ0/1 is cascaded interrupt from FPGA.
  204. * it should be cared in the future
  205. * Now, it is assuming IRQ0 was used only from SMSC.
  206. */
  207. u16 val = ioread16(base + IRQ0MR);
  208. val &= ~(1 << 4); /* enable SMSC911x */
  209. iowrite16(val, base + IRQ0MR);
  210. iounmap(base);
  211. regulator_register_fixed(0, dummy_supplies,
  212. ARRAY_SIZE(dummy_supplies));
  213. platform_device_register_resndata(
  214. &platform_bus, "smsc911x", -1,
  215. smsc911x_resources, ARRAY_SIZE(smsc911x_resources),
  216. &smsc911x_data, sizeof(smsc911x_data));
  217. }
  218. /* for SDHI */
  219. base = ioremap_nocache(PFC, 0x200);
  220. if (base) {
  221. /*
  222. * FIXME
  223. *
  224. * SDHI CD/WP pin needs pull-up
  225. */
  226. iowrite32(ioread32(base + PUPR4) | (3 << 26), base + PUPR4);
  227. iounmap(base);
  228. r8a7778_sdhi_init(0, &sdhi0_info);
  229. }
  230. }
  231. static const char *bockw_boards_compat_dt[] __initdata = {
  232. "renesas,bockw",
  233. NULL,
  234. };
  235. DT_MACHINE_START(BOCKW_DT, "bockw")
  236. .init_early = r8a7778_init_delay,
  237. .init_irq = r8a7778_init_irq_dt,
  238. .init_machine = bockw_init,
  239. .init_time = shmobile_timer_init,
  240. .dt_compat = bockw_boards_compat_dt,
  241. .init_late = r8a7778_init_late,
  242. MACHINE_END