blob: b998c6b2a270980c35d6706f6bc15ea83206ef7f [file] [log] [blame]
Kuninori Morimoto53e42c22013-03-21 03:03:38 -07001/*
2 * Bock-W board support
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Vladimir Barinov9c439522013-08-22 17:38:50 -03006 * Copyright (C) 2013 Cogent Embedded, Inc.
Kuninori Morimoto53e42c22013-03-21 03:03:38 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
Kuninori Morimotoca7bb302013-04-17 05:17:56 +000022#include <linux/mfd/tmio.h>
23#include <linux/mmc/host.h>
Kuninori Morimotofc551902013-07-26 00:34:58 -070024#include <linux/mmc/sh_mobile_sdhi.h>
Kuninori Morimotoa66c9742013-07-26 00:33:48 -070025#include <linux/mmc/sh_mmcif.h>
Kuninori Morimotoc06a1642013-06-11 19:11:41 -070026#include <linux/mtd/partitions.h>
Kuninori Morimoto111ea172013-04-12 05:38:03 +000027#include <linux/pinctrl/machine.h>
Kuninori Morimoto044e2122013-07-26 15:54:44 +090028#include <linux/platform_data/usb-rcar-phy.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070029#include <linux/platform_device.h>
Kuninori Morimoto741440e2013-04-09 02:37:15 -070030#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -070032#include <linux/smsc911x.h>
Kuninori Morimotoc06a1642013-06-11 19:11:41 -070033#include <linux/spi/spi.h>
34#include <linux/spi/flash.h>
Vladimir Barinov9c439522013-08-22 17:38:50 -030035#include <media/soc_camera.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070036#include <mach/common.h>
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -070037#include <mach/irqs.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070038#include <mach/r8a7778.h>
39#include <asm/mach/arch.h>
40
Kuninori Morimoto71d74722013-08-26 01:52:23 -070041#define FPGA 0x18200000
42#define IRQ0MR 0x30
43static void __iomem *fpga;
44
Kuninori Morimotod998cef2013-04-08 23:54:16 -070045/*
46 * CN9(Upper side) SCIF/RCAN selection
47 *
48 * 1,4 3,6
49 * SW40 SCIF RCAN
50 * SW41 SCIF RCAN
51 */
52
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -070053/*
54 * MMC (CN26) pin
55 *
56 * SW6 (D2) 3 pin
57 * SW7 (D5) ON
58 * SW8 (D3) 3 pin
59 * SW10 (D4) 1 pin
60 * SW12 (CLK) 1 pin
61 * SW13 (D6) 3 pin
62 * SW14 (CMD) ON
63 * SW15 (D6) 1 pin
64 * SW16 (D0) ON
65 * SW17 (D1) ON
66 * SW18 (D7) 3 pin
67 * SW19 (MMC) 1 pin
68 */
69
Kuninori Morimoto741440e2013-04-09 02:37:15 -070070/* Dummy supplies, where voltage doesn't matter */
71static struct regulator_consumer_supply dummy_supplies[] = {
72 REGULATOR_SUPPLY("vddvario", "smsc911x"),
73 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
74};
75
Kuninori Morimoto8c23c7c2013-08-01 18:34:09 -070076static struct smsc911x_platform_config smsc911x_data __initdata = {
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -070077 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
78 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
79 .flags = SMSC911X_USE_32BIT,
80 .phy_interface = PHY_INTERFACE_MODE_MII,
81};
82
Kuninori Morimoto8c23c7c2013-08-01 18:34:09 -070083static struct resource smsc911x_resources[] __initdata = {
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -070084 DEFINE_RES_MEM(0x18300000, 0x1000),
85 DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
86};
87
Linus Torvalds40e71e72013-07-02 14:10:26 -070088/* USB */
Kuninori Morimoto044e2122013-07-26 15:54:44 +090089static struct resource usb_phy_resources[] __initdata = {
90 DEFINE_RES_MEM(0xffe70800, 0x100),
91 DEFINE_RES_MEM(0xffe76000, 0x100),
92};
93
Sergei Shtylyov1a87b012013-06-09 00:38:41 +040094static struct rcar_phy_platform_data usb_phy_platform_data __initdata;
95
Kuninori Morimotoca7bb302013-04-17 05:17:56 +000096/* SDHI */
Kuninori Morimoto8c23c7c2013-08-01 18:34:09 -070097static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
Kuninori Morimotoca7bb302013-04-17 05:17:56 +000098 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
99 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
100 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
101};
102
Kuninori Morimotofc551902013-07-26 00:34:58 -0700103static struct resource sdhi0_resources[] __initdata = {
104 DEFINE_RES_MEM(0xFFE4C000, 0x100),
105 DEFINE_RES_IRQ(gic_iid(0x77)),
106};
107
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400108static struct sh_eth_plat_data ether_platform_data __initdata = {
109 .phy = 0x01,
110 .edmac_endian = EDMAC_LITTLE_ENDIAN,
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400111 .phy_interface = PHY_INTERFACE_MODE_RMII,
112 /*
113 * Although the LINK signal is available on the board, it's connected to
114 * the link/activity LED output of the PHY, thus the link disappears and
115 * reappears after each packet. We'd be better off ignoring such signal
116 * and getting the link state from the PHY indirectly.
117 */
118 .no_ether_link = 1,
119};
120
Kuninori Morimotoed17be92013-06-11 19:11:17 -0700121/* I2C */
122static struct i2c_board_info i2c0_devices[] = {
123 {
124 I2C_BOARD_INFO("rx8581", 0x51),
125 },
126};
127
Kuninori Morimotoc06a1642013-06-11 19:11:41 -0700128/* HSPI*/
129static struct mtd_partition m25p80_spi_flash_partitions[] = {
130 {
131 .name = "data(spi)",
132 .size = 0x0100000,
133 .offset = 0,
134 },
135};
136
137static struct flash_platform_data spi_flash_data = {
138 .name = "m25p80",
139 .type = "s25fl008k",
140 .parts = m25p80_spi_flash_partitions,
141 .nr_parts = ARRAY_SIZE(m25p80_spi_flash_partitions),
142};
143
144static struct spi_board_info spi_board_info[] __initdata = {
145 {
146 .modalias = "m25p80",
147 .max_speed_hz = 104000000,
148 .chip_select = 0,
149 .bus_num = 0,
150 .mode = SPI_MODE_0,
151 .platform_data = &spi_flash_data,
152 },
153};
154
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -0700155/* MMC */
Kuninori Morimotoa66c9742013-07-26 00:33:48 -0700156static struct resource mmc_resources[] __initdata = {
157 DEFINE_RES_MEM(0xffe4e000, 0x100),
158 DEFINE_RES_IRQ(gic_iid(0x5d)),
159};
160
Kuninori Morimoto8c23c7c2013-08-01 18:34:09 -0700161static struct sh_mmcif_plat_data sh_mmcif_plat __initdata = {
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -0700162 .sup_pclk = 0,
163 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
164 .caps = MMC_CAP_4_BIT_DATA |
165 MMC_CAP_8_BIT_DATA |
166 MMC_CAP_NEEDS_POLL,
167};
168
Vladimir Barinov9c439522013-08-22 17:38:50 -0300169static struct rcar_vin_platform_data vin_platform_data __initdata = {
170 .flags = RCAR_VIN_BT656,
171};
172
173/* In the default configuration both decoders reside on I2C bus 0 */
174#define BOCKW_CAMERA(idx) \
175static struct i2c_board_info camera##idx##_info = { \
176 I2C_BOARD_INFO("ml86v7667", 0x41 + 2 * (idx)), \
177}; \
178 \
179static struct soc_camera_link iclink##idx##_ml86v7667 __initdata = { \
180 .bus_id = idx, \
181 .i2c_adapter_id = 0, \
182 .board_info = &camera##idx##_info, \
183}
184
185BOCKW_CAMERA(0);
186BOCKW_CAMERA(1);
187
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000188static const struct pinctrl_map bockw_pinctrl_map[] = {
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400189 /* Ether */
Sergei Shtylyov2c833222013-06-17 23:39:44 +0400190 PIN_MAP_MUX_GROUP_DEFAULT("r8a777x-ether", "pfc-r8a7778",
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400191 "ether_rmii", "ether"),
Kuninori Morimotoc06a1642013-06-11 19:11:41 -0700192 /* HSPI0 */
193 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7778",
194 "hspi0_a", "hspi0"),
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -0700195 /* MMC */
196 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
197 "mmc_data8", "mmc"),
198 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
199 "mmc_ctrl", "mmc"),
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000200 /* SCIF0 */
201 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
202 "scif0_data_a", "scif0"),
203 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
204 "scif0_ctrl", "scif0"),
Linus Torvalds40e71e72013-07-02 14:10:26 -0700205 /* USB */
Sergei Shtylyov1a87b012013-06-09 00:38:41 +0400206 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778",
207 "usb0", "usb0"),
208 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778",
209 "usb1", "usb1"),
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000210 /* SDHI0 */
211 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
Sergei Shtylyovfa3e0ce2013-07-27 03:46:33 +0400212 "sdhi0_data4", "sdhi0"),
213 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
214 "sdhi0_ctrl", "sdhi0"),
215 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
216 "sdhi0_cd", "sdhi0"),
217 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
218 "sdhi0_wp", "sdhi0"),
Vladimir Barinov9c439522013-08-22 17:38:50 -0300219 /* VIN0 */
220 PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.0", "pfc-r8a7778",
221 "vin0_clk", "vin0"),
222 PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.0", "pfc-r8a7778",
223 "vin0_data8", "vin0"),
224 /* VIN1 */
225 PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.1", "pfc-r8a7778",
226 "vin1_clk", "vin1"),
227 PIN_MAP_MUX_GROUP_DEFAULT("r8a7778-vin.1", "pfc-r8a7778",
228 "vin1_data8", "vin1"),
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000229};
230
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000231#define PFC 0xfffc0000
232#define PUPR4 0x110
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700233static void __init bockw_init(void)
234{
Kuninori Morimoto44bfe682013-04-16 22:17:42 -0700235 void __iomem *base;
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -0700236
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700237 r8a7778_clock_init();
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -0700238 r8a7778_init_irq_extpin(1);
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700239 r8a7778_add_standard_devices();
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400240 r8a7778_add_ether_device(&ether_platform_data);
Vladimir Barinov9c439522013-08-22 17:38:50 -0300241 r8a7778_add_vin_device(0, &vin_platform_data);
242 /* VIN1 has a pin conflict with Ether */
243 if (!IS_ENABLED(CONFIG_SH_ETH))
244 r8a7778_add_vin_device(1, &vin_platform_data);
245 platform_device_register_data(&platform_bus, "soc-camera-pdrv", 0,
246 &iclink0_ml86v7667,
247 sizeof(iclink0_ml86v7667));
248 platform_device_register_data(&platform_bus, "soc-camera-pdrv", 1,
249 &iclink1_ml86v7667,
250 sizeof(iclink1_ml86v7667));
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -0700251
Kuninori Morimotoed17be92013-06-11 19:11:17 -0700252 i2c_register_board_info(0, i2c0_devices,
253 ARRAY_SIZE(i2c0_devices));
Kuninori Morimotoc06a1642013-06-11 19:11:41 -0700254 spi_register_board_info(spi_board_info,
255 ARRAY_SIZE(spi_board_info));
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000256 pinctrl_register_mappings(bockw_pinctrl_map,
257 ARRAY_SIZE(bockw_pinctrl_map));
258 r8a7778_pinmux_init();
259
Kuninori Morimotoa66c9742013-07-26 00:33:48 -0700260 platform_device_register_resndata(
261 &platform_bus, "sh_mmcif", -1,
262 mmc_resources, ARRAY_SIZE(mmc_resources),
263 &sh_mmcif_plat, sizeof(struct sh_mmcif_plat_data));
264
Kuninori Morimoto044e2122013-07-26 15:54:44 +0900265 platform_device_register_resndata(
266 &platform_bus, "rcar_usb_phy", -1,
267 usb_phy_resources,
268 ARRAY_SIZE(usb_phy_resources),
269 &usb_phy_platform_data,
270 sizeof(struct rcar_phy_platform_data));
271
272
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000273 /* for SMSC */
Kuninori Morimoto71d74722013-08-26 01:52:23 -0700274 fpga = ioremap_nocache(FPGA, SZ_1M);
275 if (fpga) {
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -0700276 /*
277 * CAUTION
278 *
279 * IRQ0/1 is cascaded interrupt from FPGA.
280 * it should be cared in the future
281 * Now, it is assuming IRQ0 was used only from SMSC.
282 */
Kuninori Morimoto71d74722013-08-26 01:52:23 -0700283 u16 val = ioread16(fpga + IRQ0MR);
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -0700284 val &= ~(1 << 4); /* enable SMSC911x */
Kuninori Morimoto71d74722013-08-26 01:52:23 -0700285 iowrite16(val, fpga + IRQ0MR);
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -0700286
Kuninori Morimoto741440e2013-04-09 02:37:15 -0700287 regulator_register_fixed(0, dummy_supplies,
288 ARRAY_SIZE(dummy_supplies));
Kuninori Morimoto27d5f27e2013-04-01 21:20:02 -0700289
290 platform_device_register_resndata(
291 &platform_bus, "smsc911x", -1,
292 smsc911x_resources, ARRAY_SIZE(smsc911x_resources),
293 &smsc911x_data, sizeof(smsc911x_data));
294 }
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000295
296 /* for SDHI */
297 base = ioremap_nocache(PFC, 0x200);
298 if (base) {
299 /*
300 * FIXME
301 *
302 * SDHI CD/WP pin needs pull-up
303 */
304 iowrite32(ioread32(base + PUPR4) | (3 << 26), base + PUPR4);
305 iounmap(base);
306
Kuninori Morimotofc551902013-07-26 00:34:58 -0700307 platform_device_register_resndata(
308 &platform_bus, "sh_mobile_sdhi", 0,
309 sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
310 &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000311 }
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700312}
313
314static const char *bockw_boards_compat_dt[] __initdata = {
315 "renesas,bockw",
316 NULL,
317};
318
319DT_MACHINE_START(BOCKW_DT, "bockw")
320 .init_early = r8a7778_init_delay,
321 .init_irq = r8a7778_init_irq_dt,
322 .init_machine = bockw_init,
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700323 .dt_compat = bockw_boards_compat_dt,
Sergei Shtylyov1a87b012013-06-09 00:38:41 +0400324 .init_late = r8a7778_init_late,
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700325MACHINE_END