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