blob: ce56381e0077ef16082816d64e2eed04439d5d1d [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>
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 Morimotoca7bb302013-04-17 05:17:56 +000021#include <linux/mfd/tmio.h>
22#include <linux/mmc/host.h>
Kuninori Morimotoc06a1642013-06-11 19:11:41 -070023#include <linux/mtd/partitions.h>
Kuninori Morimoto111ea172013-04-12 05:38:03 +000024#include <linux/pinctrl/machine.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070025#include <linux/platform_device.h>
Kuninori Morimoto741440e2013-04-09 02:37:15 -070026#include <linux/regulator/fixed.h>
27#include <linux/regulator/machine.h>
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070028#include <linux/smsc911x.h>
Kuninori Morimotoc06a1642013-06-11 19:11:41 -070029#include <linux/spi/spi.h>
30#include <linux/spi/flash.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070031#include <mach/common.h>
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070032#include <mach/irqs.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070033#include <mach/r8a7778.h>
34#include <asm/mach/arch.h>
35
Kuninori Morimotod998cef2013-04-08 23:54:16 -070036/*
37 * CN9(Upper side) SCIF/RCAN selection
38 *
39 * 1,4 3,6
40 * SW40 SCIF RCAN
41 * SW41 SCIF RCAN
42 */
43
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -070044/*
45 * MMC (CN26) pin
46 *
47 * SW6 (D2) 3 pin
48 * SW7 (D5) ON
49 * SW8 (D3) 3 pin
50 * SW10 (D4) 1 pin
51 * SW12 (CLK) 1 pin
52 * SW13 (D6) 3 pin
53 * SW14 (CMD) ON
54 * SW15 (D6) 1 pin
55 * SW16 (D0) ON
56 * SW17 (D1) ON
57 * SW18 (D7) 3 pin
58 * SW19 (MMC) 1 pin
59 */
60
Kuninori Morimoto741440e2013-04-09 02:37:15 -070061/* Dummy supplies, where voltage doesn't matter */
62static struct regulator_consumer_supply dummy_supplies[] = {
63 REGULATOR_SUPPLY("vddvario", "smsc911x"),
64 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
65};
66
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070067static struct smsc911x_platform_config smsc911x_data = {
68 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
69 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
70 .flags = SMSC911X_USE_32BIT,
71 .phy_interface = PHY_INTERFACE_MODE_MII,
72};
73
74static struct resource smsc911x_resources[] = {
75 DEFINE_RES_MEM(0x18300000, 0x1000),
76 DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
77};
78
Kuninori Morimotoca7bb302013-04-17 05:17:56 +000079/* SDHI */
80static struct sh_mobile_sdhi_info sdhi0_info = {
81 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
82 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
83 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
84};
85
Sergei Shtylyov9aa38532013-06-02 02:40:55 +040086static 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
Kuninori Morimotoed17be92013-06-11 19:11:17 -0700100/* I2C */
101static struct i2c_board_info i2c0_devices[] = {
102 {
103 I2C_BOARD_INFO("rx8581", 0x51),
104 },
105};
106
Kuninori Morimotoc06a1642013-06-11 19:11:41 -0700107/* HSPI*/
108static struct mtd_partition m25p80_spi_flash_partitions[] = {
109 {
110 .name = "data(spi)",
111 .size = 0x0100000,
112 .offset = 0,
113 },
114};
115
116static struct flash_platform_data spi_flash_data = {
117 .name = "m25p80",
118 .type = "s25fl008k",
119 .parts = m25p80_spi_flash_partitions,
120 .nr_parts = ARRAY_SIZE(m25p80_spi_flash_partitions),
121};
122
123static struct spi_board_info spi_board_info[] __initdata = {
124 {
125 .modalias = "m25p80",
126 .max_speed_hz = 104000000,
127 .chip_select = 0,
128 .bus_num = 0,
129 .mode = SPI_MODE_0,
130 .platform_data = &spi_flash_data,
131 },
132};
133
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -0700134/* MMC */
135static struct sh_mmcif_plat_data sh_mmcif_plat = {
136 .sup_pclk = 0,
137 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
138 .caps = MMC_CAP_4_BIT_DATA |
139 MMC_CAP_8_BIT_DATA |
140 MMC_CAP_NEEDS_POLL,
141};
142
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000143static const struct pinctrl_map bockw_pinctrl_map[] = {
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400144 /* Ether */
Sergei Shtylyov2c833222013-06-17 23:39:44 +0400145 PIN_MAP_MUX_GROUP_DEFAULT("r8a777x-ether", "pfc-r8a7778",
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400146 "ether_rmii", "ether"),
Kuninori Morimotoc06a1642013-06-11 19:11:41 -0700147 /* HSPI0 */
148 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7778",
149 "hspi0_a", "hspi0"),
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -0700150 /* MMC */
151 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
152 "mmc_data8", "mmc"),
153 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif", "pfc-r8a7778",
154 "mmc_ctrl", "mmc"),
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000155 /* SCIF0 */
156 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
157 "scif0_data_a", "scif0"),
158 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
159 "scif0_ctrl", "scif0"),
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000160 /* SDHI0 */
161 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
162 "sdhi0", "sdhi0"),
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000163};
164
Kuninori Morimoto44bfe682013-04-16 22:17:42 -0700165#define FPGA 0x18200000
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700166#define IRQ0MR 0x30
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000167#define PFC 0xfffc0000
168#define PUPR4 0x110
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700169static void __init bockw_init(void)
170{
Kuninori Morimoto44bfe682013-04-16 22:17:42 -0700171 void __iomem *base;
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700172
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700173 r8a7778_clock_init();
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700174 r8a7778_init_irq_extpin(1);
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700175 r8a7778_add_standard_devices();
Sergei Shtylyov9aa38532013-06-02 02:40:55 +0400176 r8a7778_add_ether_device(&ether_platform_data);
Kuninori Morimotoed17be92013-06-11 19:11:17 -0700177 r8a7778_add_i2c_device(0);
Kuninori Morimotoc06a1642013-06-11 19:11:41 -0700178 r8a7778_add_hspi_device(0);
Kuninori Morimoto1e0edb72013-06-11 19:12:06 -0700179 r8a7778_add_mmc_device(&sh_mmcif_plat);
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700180
Kuninori Morimotoed17be92013-06-11 19:11:17 -0700181 i2c_register_board_info(0, i2c0_devices,
182 ARRAY_SIZE(i2c0_devices));
Kuninori Morimotoc06a1642013-06-11 19:11:41 -0700183 spi_register_board_info(spi_board_info,
184 ARRAY_SIZE(spi_board_info));
Kuninori Morimoto111ea172013-04-12 05:38:03 +0000185 pinctrl_register_mappings(bockw_pinctrl_map,
186 ARRAY_SIZE(bockw_pinctrl_map));
187 r8a7778_pinmux_init();
188
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000189 /* for SMSC */
Kuninori Morimoto44bfe682013-04-16 22:17:42 -0700190 base = ioremap_nocache(FPGA, SZ_1M);
191 if (base) {
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700192 /*
193 * CAUTION
194 *
195 * IRQ0/1 is cascaded interrupt from FPGA.
196 * it should be cared in the future
197 * Now, it is assuming IRQ0 was used only from SMSC.
198 */
Kuninori Morimoto44bfe682013-04-16 22:17:42 -0700199 u16 val = ioread16(base + IRQ0MR);
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700200 val &= ~(1 << 4); /* enable SMSC911x */
Kuninori Morimoto44bfe682013-04-16 22:17:42 -0700201 iowrite16(val, base + IRQ0MR);
202 iounmap(base);
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700203
Kuninori Morimoto741440e2013-04-09 02:37:15 -0700204 regulator_register_fixed(0, dummy_supplies,
205 ARRAY_SIZE(dummy_supplies));
206
Kuninori Morimoto27d5f272013-04-01 21:20:02 -0700207 platform_device_register_resndata(
208 &platform_bus, "smsc911x", -1,
209 smsc911x_resources, ARRAY_SIZE(smsc911x_resources),
210 &smsc911x_data, sizeof(smsc911x_data));
211 }
Kuninori Morimotoca7bb302013-04-17 05:17:56 +0000212
213 /* for SDHI */
214 base = ioremap_nocache(PFC, 0x200);
215 if (base) {
216 /*
217 * FIXME
218 *
219 * SDHI CD/WP pin needs pull-up
220 */
221 iowrite32(ioread32(base + PUPR4) | (3 << 26), base + PUPR4);
222 iounmap(base);
223
224 r8a7778_sdhi_init(0, &sdhi0_info);
225 }
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700226}
227
228static const char *bockw_boards_compat_dt[] __initdata = {
229 "renesas,bockw",
230 NULL,
231};
232
233DT_MACHINE_START(BOCKW_DT, "bockw")
234 .init_early = r8a7778_init_delay,
235 .init_irq = r8a7778_init_irq_dt,
236 .init_machine = bockw_init,
237 .init_time = shmobile_timer_init,
238 .dt_compat = bockw_boards_compat_dt,
239MACHINE_END