blob: f3027295f60ca411f326f89c5115923d74a17e4b [file] [log] [blame]
Magnus Dammf411fad2011-12-14 01:36:12 +09001/*
2 * marzen board support
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Magnus Damm
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
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/interrupt.h>
24#include <linux/irq.h>
25#include <linux/platform_device.h>
26#include <linux/delay.h>
27#include <linux/io.h>
Laurent Pinchart48b1e3e2013-03-10 03:43:32 +010028#include <linux/leds.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090029#include <linux/dma-mapping.h>
Laurent Pinchart4a655ec2013-03-06 14:22:11 +010030#include <linux/pinctrl/machine.h>
Laurent Pinchart5fcf4a32013-04-08 12:05:32 +020031#include <linux/platform_data/gpio-rcar.h>
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +020032#include <linux/regulator/fixed.h>
33#include <linux/regulator/machine.h>
Magnus Dammdb5eb992011-12-14 01:36:51 +090034#include <linux/smsc911x.h>
Kuninori Morimotob82573e2012-10-10 19:57:02 -070035#include <linux/spi/spi.h>
36#include <linux/spi/sh_hspi.h>
Simon Horman44e9ac42013-02-13 09:45:50 +000037#include <linux/mmc/host.h>
Phil Edworthy894cda12012-08-06 13:31:05 +010038#include <linux/mmc/sh_mobile_sdhi.h>
39#include <linux/mfd/tmio.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090040#include <mach/hardware.h>
41#include <mach/r8a7779.h>
42#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060043#include <mach/irqs.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090044#include <asm/mach-types.h>
45#include <asm/mach/arch.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090046#include <asm/traps.h>
47
Phil Edworthy894cda12012-08-06 13:31:05 +010048/* Fixed 3.3V regulator to be used by SDHI0 */
49static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
50 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
51 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
52};
53
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +020054/* Dummy supplies, where voltage doesn't matter */
55static struct regulator_consumer_supply dummy_supplies[] = {
56 REGULATOR_SUPPLY("vddvario", "smsc911x"),
57 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
58};
59
Sergei Shtylyov2437b272013-06-02 01:55:04 +040060static struct rcar_phy_platform_data usb_phy_platform_data __initdata;
61
Magnus Dammdb5eb992011-12-14 01:36:51 +090062/* SMSC LAN89218 */
63static struct resource smsc911x_resources[] = {
64 [0] = {
65 .start = 0x18000000, /* ExCS0 */
66 .end = 0x180000ff, /* A1->A7 */
67 .flags = IORESOURCE_MEM,
68 },
69 [1] = {
Simon Horman6e267032013-04-18 21:21:09 +090070 .start = irq_pin(1), /* IRQ 1 */
Magnus Dammdb5eb992011-12-14 01:36:51 +090071 .flags = IORESOURCE_IRQ,
72 },
73};
74
75static struct smsc911x_platform_config smsc911x_platdata = {
76 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
77 .phy_interface = PHY_INTERFACE_MODE_MII,
78 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
79 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
80};
81
82static struct platform_device eth_device = {
83 .name = "smsc911x",
Kuninori Morimoto497dcf62012-08-29 18:58:01 -070084 .id = -1,
Magnus Dammdb5eb992011-12-14 01:36:51 +090085 .dev = {
86 .platform_data = &smsc911x_platdata,
87 },
88 .resource = smsc911x_resources,
89 .num_resources = ARRAY_SIZE(smsc911x_resources),
90};
91
Phil Edworthy894cda12012-08-06 13:31:05 +010092static struct resource sdhi0_resources[] = {
93 [0] = {
94 .name = "sdhi0",
95 .start = 0xffe4c000,
96 .end = 0xffe4c0ff,
97 .flags = IORESOURCE_MEM,
98 },
99 [1] = {
Kuninori Morimoto0b6794e2013-02-25 01:39:44 -0800100 .start = gic_iid(0x88),
Phil Edworthy894cda12012-08-06 13:31:05 +0100101 .flags = IORESOURCE_IRQ,
102 },
103};
104
105static struct sh_mobile_sdhi_info sdhi0_platform_data = {
106 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
107 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
108};
109
110static struct platform_device sdhi0_device = {
111 .name = "sh_mobile_sdhi",
112 .num_resources = ARRAY_SIZE(sdhi0_resources),
113 .resource = sdhi0_resources,
114 .id = 0,
115 .dev = {
116 .platform_data = &sdhi0_platform_data,
117 }
118};
119
Kuninori Morimotoeb8ca942012-08-27 19:00:15 -0700120/* Thermal */
121static struct resource thermal_resources[] = {
122 [0] = {
123 .start = 0xFFC48000,
124 .end = 0xFFC48038 - 1,
125 .flags = IORESOURCE_MEM,
126 },
127};
128
129static struct platform_device thermal_device = {
130 .name = "rcar_thermal",
131 .resource = thermal_resources,
132 .num_resources = ARRAY_SIZE(thermal_resources),
133};
134
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700135/* HSPI */
136static struct resource hspi_resources[] = {
137 [0] = {
138 .start = 0xFFFC7000,
139 .end = 0xFFFC7018 - 1,
140 .flags = IORESOURCE_MEM,
141 },
142};
143
144static struct platform_device hspi_device = {
145 .name = "sh-hspi",
146 .id = 0,
147 .resource = hspi_resources,
148 .num_resources = ARRAY_SIZE(hspi_resources),
149};
150
Laurent Pinchart48b1e3e2013-03-10 03:43:32 +0100151/* LEDS */
152static struct gpio_led marzen_leds[] = {
153 {
154 .name = "led2",
Laurent Pinchart5fcf4a32013-04-08 12:05:32 +0200155 .gpio = RCAR_GP_PIN(4, 29),
Laurent Pinchart48b1e3e2013-03-10 03:43:32 +0100156 .default_state = LEDS_GPIO_DEFSTATE_ON,
157 }, {
158 .name = "led3",
Laurent Pinchart5fcf4a32013-04-08 12:05:32 +0200159 .gpio = RCAR_GP_PIN(4, 30),
Laurent Pinchart48b1e3e2013-03-10 03:43:32 +0100160 .default_state = LEDS_GPIO_DEFSTATE_ON,
161 }, {
162 .name = "led4",
Laurent Pinchart5fcf4a32013-04-08 12:05:32 +0200163 .gpio = RCAR_GP_PIN(4, 31),
Laurent Pinchart48b1e3e2013-03-10 03:43:32 +0100164 .default_state = LEDS_GPIO_DEFSTATE_ON,
165 },
166};
167
168static struct gpio_led_platform_data marzen_leds_pdata = {
169 .leds = marzen_leds,
170 .num_leds = ARRAY_SIZE(marzen_leds),
171};
172
173static struct platform_device leds_device = {
174 .name = "leds-gpio",
175 .id = 0,
176 .dev = {
177 .platform_data = &marzen_leds_pdata,
178 },
179};
180
Magnus Dammf411fad2011-12-14 01:36:12 +0900181static struct platform_device *marzen_devices[] __initdata = {
Magnus Dammdb5eb992011-12-14 01:36:51 +0900182 &eth_device,
Phil Edworthy894cda12012-08-06 13:31:05 +0100183 &sdhi0_device,
Kuninori Morimotoeb8ca942012-08-27 19:00:15 -0700184 &thermal_device,
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700185 &hspi_device,
Laurent Pinchart48b1e3e2013-03-10 03:43:32 +0100186 &leds_device,
Magnus Dammf411fad2011-12-14 01:36:12 +0900187};
188
Laurent Pinchart4a655ec2013-03-06 14:22:11 +0100189static const struct pinctrl_map marzen_pinctrl_map[] = {
Laurent Pincharta3217472013-03-06 14:22:11 +0100190 /* HSPI0 */
191 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
192 "hspi0", "hspi0"),
Laurent Pincharte9cd49f2013-03-06 14:22:11 +0100193 /* SCIF2 (CN18: DEBUG0) */
194 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
195 "scif2_data_c", "scif2"),
196 /* SCIF4 (CN19: DEBUG1) */
197 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
198 "scif4_data", "scif4"),
Laurent Pinchart4a655ec2013-03-06 14:22:11 +0100199 /* SDHI0 */
200 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
201 "sdhi0_data4", "sdhi0"),
202 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
203 "sdhi0_ctrl", "sdhi0"),
204 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
205 "sdhi0_cd", "sdhi0"),
206 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
207 "sdhi0_wp", "sdhi0"),
Laurent Pinchartf423df82013-03-07 13:46:02 +0100208 /* SMSC */
209 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
Laurent Pinchartee097e62013-03-07 13:46:02 +0100210 "intc_irq1_b", "intc"),
211 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
Laurent Pinchartf423df82013-03-07 13:46:02 +0100212 "lbsc_ex_cs0", "lbsc"),
Laurent Pincharta00f6e52013-03-07 13:46:02 +0100213 /* USB0 */
214 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
215 "usb0", "usb0"),
216 /* USB1 */
217 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
218 "usb1", "usb1"),
219 /* USB2 */
220 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
221 "usb2", "usb2"),
Laurent Pinchart4a655ec2013-03-06 14:22:11 +0100222};
223
Magnus Dammf411fad2011-12-14 01:36:12 +0900224static void __init marzen_init(void)
225{
Phil Edworthy894cda12012-08-06 13:31:05 +0100226 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
227 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
Kuninori Morimoto90b85af2012-08-29 18:58:15 -0700228 regulator_register_fixed(1, dummy_supplies,
Phil Edworthy894cda12012-08-06 13:31:05 +0100229 ARRAY_SIZE(dummy_supplies));
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +0200230
Laurent Pinchart4a655ec2013-03-06 14:22:11 +0100231 pinctrl_register_mappings(marzen_pinctrl_map,
232 ARRAY_SIZE(marzen_pinctrl_map));
Magnus Damm19c43fc2011-12-14 01:36:22 +0900233 r8a7779_pinmux_init();
Simon Horman6e267032013-04-18 21:21:09 +0900234 r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
Magnus Damm19c43fc2011-12-14 01:36:22 +0900235
Magnus Dammf411fad2011-12-14 01:36:12 +0900236 r8a7779_add_standard_devices();
Sergei Shtylyov2437b272013-06-02 01:55:04 +0400237 r8a7779_add_usb_phy_device(&usb_phy_platform_data);
Magnus Dammf411fad2011-12-14 01:36:12 +0900238 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
239}
240
Magnus Damm7ebbb4a2013-07-24 16:30:42 +0900241static const char *marzen_boards_compat_dt[] __initdata = {
242 "renesas,marzen",
243 NULL,
244};
245
246DT_MACHINE_START(MARZEN, "marzen")
Marc Zyngiera62580e2011-09-08 13:15:22 +0100247 .smp = smp_ops(r8a7779_smp_ops),
Magnus Damm3e353b872012-02-29 21:37:43 +0900248 .map_io = r8a7779_map_io,
249 .init_early = r8a7779_add_early_devices,
Kuninori Morimoto693ac412013-08-01 23:39:34 -0700250 .init_irq = r8a7779_init_irq_dt,
Magnus Dammf411fad2011-12-14 01:36:12 +0900251 .init_machine = marzen_init,
Sergei Shtylyov2c8788b2013-06-02 01:30:15 +0400252 .init_late = r8a7779_init_late,
Magnus Damm7ebbb4a2013-07-24 16:30:42 +0900253 .dt_compat = marzen_boards_compat_dt,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700254 .init_time = r8a7779_earlytimer_init,
Magnus Dammf411fad2011-12-14 01:36:12 +0900255MACHINE_END