board-bockw.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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/pinctrl/machine.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/regulator/fixed.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/smsc911x.h>
  27. #include <mach/common.h>
  28. #include <mach/irqs.h>
  29. #include <mach/r8a7778.h>
  30. #include <asm/mach/arch.h>
  31. /*
  32. * CN9(Upper side) SCIF/RCAN selection
  33. *
  34. * 1,4 3,6
  35. * SW40 SCIF RCAN
  36. * SW41 SCIF RCAN
  37. */
  38. /* Dummy supplies, where voltage doesn't matter */
  39. static struct regulator_consumer_supply dummy_supplies[] = {
  40. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  41. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  42. };
  43. static struct smsc911x_platform_config smsc911x_data = {
  44. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  45. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  46. .flags = SMSC911X_USE_32BIT,
  47. .phy_interface = PHY_INTERFACE_MODE_MII,
  48. };
  49. static struct resource smsc911x_resources[] = {
  50. DEFINE_RES_MEM(0x18300000, 0x1000),
  51. DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
  52. };
  53. /* SDHI */
  54. static struct sh_mobile_sdhi_info sdhi0_info = {
  55. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  56. .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
  57. .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
  58. };
  59. static const struct pinctrl_map bockw_pinctrl_map[] = {
  60. /* SCIF0 */
  61. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
  62. "scif0_data_a", "scif0"),
  63. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
  64. "scif0_ctrl", "scif0"),
  65. /* SDHI0 */
  66. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
  67. "sdhi0", "sdhi0"),
  68. };
  69. #define FPGA 0x18200000
  70. #define IRQ0MR 0x30
  71. #define PFC 0xfffc0000
  72. #define PUPR4 0x110
  73. static void __init bockw_init(void)
  74. {
  75. void __iomem *base;
  76. r8a7778_clock_init();
  77. r8a7778_init_irq_extpin(1);
  78. r8a7778_add_standard_devices();
  79. pinctrl_register_mappings(bockw_pinctrl_map,
  80. ARRAY_SIZE(bockw_pinctrl_map));
  81. r8a7778_pinmux_init();
  82. /* for SMSC */
  83. base = ioremap_nocache(FPGA, SZ_1M);
  84. if (base) {
  85. /*
  86. * CAUTION
  87. *
  88. * IRQ0/1 is cascaded interrupt from FPGA.
  89. * it should be cared in the future
  90. * Now, it is assuming IRQ0 was used only from SMSC.
  91. */
  92. u16 val = ioread16(base + IRQ0MR);
  93. val &= ~(1 << 4); /* enable SMSC911x */
  94. iowrite16(val, base + IRQ0MR);
  95. iounmap(base);
  96. regulator_register_fixed(0, dummy_supplies,
  97. ARRAY_SIZE(dummy_supplies));
  98. platform_device_register_resndata(
  99. &platform_bus, "smsc911x", -1,
  100. smsc911x_resources, ARRAY_SIZE(smsc911x_resources),
  101. &smsc911x_data, sizeof(smsc911x_data));
  102. }
  103. /* for SDHI */
  104. base = ioremap_nocache(PFC, 0x200);
  105. if (base) {
  106. /*
  107. * FIXME
  108. *
  109. * SDHI CD/WP pin needs pull-up
  110. */
  111. iowrite32(ioread32(base + PUPR4) | (3 << 26), base + PUPR4);
  112. iounmap(base);
  113. r8a7778_sdhi_init(0, &sdhi0_info);
  114. }
  115. }
  116. static const char *bockw_boards_compat_dt[] __initdata = {
  117. "renesas,bockw",
  118. NULL,
  119. };
  120. DT_MACHINE_START(BOCKW_DT, "bockw")
  121. .init_early = r8a7778_init_delay,
  122. .init_irq = r8a7778_init_irq_dt,
  123. .init_machine = bockw_init,
  124. .init_time = shmobile_timer_init,
  125. .dt_compat = bockw_boards_compat_dt,
  126. MACHINE_END