blob: f00677fcc78a0c8e4a8de33e8839b7c8b9df3c2c [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>
Magnus Damm14f691c2011-12-14 01:36:42 +090028#include <linux/gpio.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>
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +020031#include <linux/regulator/fixed.h>
32#include <linux/regulator/machine.h>
Magnus Dammdb5eb992011-12-14 01:36:51 +090033#include <linux/smsc911x.h>
Kuninori Morimotob82573e2012-10-10 19:57:02 -070034#include <linux/spi/spi.h>
35#include <linux/spi/sh_hspi.h>
Simon Horman44e9ac42013-02-13 09:45:50 +000036#include <linux/mmc/host.h>
Phil Edworthy894cda12012-08-06 13:31:05 +010037#include <linux/mmc/sh_mobile_sdhi.h>
38#include <linux/mfd/tmio.h>
Kuninori Morimoto94e1f7f2012-10-29 01:15:34 -070039#include <linux/usb/otg.h>
40#include <linux/usb/ehci_pdriver.h>
Kuninori Morimotoac7c4ea2012-10-29 01:15:43 -070041#include <linux/usb/ohci_pdriver.h>
Kuninori Morimoto94e1f7f2012-10-29 01:15:34 -070042#include <linux/pm_runtime.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090043#include <mach/hardware.h>
44#include <mach/r8a7779.h>
45#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060046#include <mach/irqs.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090047#include <asm/mach-types.h>
48#include <asm/mach/arch.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090049#include <asm/traps.h>
50
Phil Edworthy894cda12012-08-06 13:31:05 +010051/* Fixed 3.3V regulator to be used by SDHI0 */
52static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
53 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
54 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
55};
56
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +020057/* Dummy supplies, where voltage doesn't matter */
58static struct regulator_consumer_supply dummy_supplies[] = {
59 REGULATOR_SUPPLY("vddvario", "smsc911x"),
60 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
61};
62
Magnus Dammdb5eb992011-12-14 01:36:51 +090063/* SMSC LAN89218 */
64static struct resource smsc911x_resources[] = {
65 [0] = {
66 .start = 0x18000000, /* ExCS0 */
67 .end = 0x180000ff, /* A1->A7 */
68 .flags = IORESOURCE_MEM,
69 },
70 [1] = {
71 .start = gic_spi(28), /* IRQ 1 */
72 .flags = IORESOURCE_IRQ,
73 },
74};
75
76static struct smsc911x_platform_config smsc911x_platdata = {
77 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
78 .phy_interface = PHY_INTERFACE_MODE_MII,
79 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
80 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
81};
82
83static struct platform_device eth_device = {
84 .name = "smsc911x",
Kuninori Morimoto497dcf62012-08-29 18:58:01 -070085 .id = -1,
Magnus Dammdb5eb992011-12-14 01:36:51 +090086 .dev = {
87 .platform_data = &smsc911x_platdata,
88 },
89 .resource = smsc911x_resources,
90 .num_resources = ARRAY_SIZE(smsc911x_resources),
91};
92
Phil Edworthy894cda12012-08-06 13:31:05 +010093static struct resource sdhi0_resources[] = {
94 [0] = {
95 .name = "sdhi0",
96 .start = 0xffe4c000,
97 .end = 0xffe4c0ff,
98 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
101 .start = gic_spi(104),
102 .flags = IORESOURCE_IRQ,
103 },
104};
105
106static struct sh_mobile_sdhi_info sdhi0_platform_data = {
107 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
108 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
109};
110
111static struct platform_device sdhi0_device = {
112 .name = "sh_mobile_sdhi",
113 .num_resources = ARRAY_SIZE(sdhi0_resources),
114 .resource = sdhi0_resources,
115 .id = 0,
116 .dev = {
117 .platform_data = &sdhi0_platform_data,
118 }
119};
120
Kuninori Morimotoeb8ca942012-08-27 19:00:15 -0700121/* Thermal */
122static struct resource thermal_resources[] = {
123 [0] = {
124 .start = 0xFFC48000,
125 .end = 0xFFC48038 - 1,
126 .flags = IORESOURCE_MEM,
127 },
128};
129
130static struct platform_device thermal_device = {
131 .name = "rcar_thermal",
132 .resource = thermal_resources,
133 .num_resources = ARRAY_SIZE(thermal_resources),
134};
135
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700136/* HSPI */
137static struct resource hspi_resources[] = {
138 [0] = {
139 .start = 0xFFFC7000,
140 .end = 0xFFFC7018 - 1,
141 .flags = IORESOURCE_MEM,
142 },
143};
144
145static struct platform_device hspi_device = {
146 .name = "sh-hspi",
147 .id = 0,
148 .resource = hspi_resources,
149 .num_resources = ARRAY_SIZE(hspi_resources),
150};
151
Kuninori Morimotob5ce6352012-10-29 01:15:25 -0700152/* USB PHY */
153static struct resource usb_phy_resources[] = {
154 [0] = {
155 .start = 0xffe70000,
156 .end = 0xffe70900 - 1,
157 .flags = IORESOURCE_MEM,
158 },
159 [1] = {
160 .start = 0xfff70000,
161 .end = 0xfff70900 - 1,
162 .flags = IORESOURCE_MEM,
163 },
164};
165
166static struct platform_device usb_phy_device = {
167 .name = "rcar_usb_phy",
168 .resource = usb_phy_resources,
169 .num_resources = ARRAY_SIZE(usb_phy_resources),
170};
171
Magnus Dammf411fad2011-12-14 01:36:12 +0900172static struct platform_device *marzen_devices[] __initdata = {
Magnus Dammdb5eb992011-12-14 01:36:51 +0900173 &eth_device,
Phil Edworthy894cda12012-08-06 13:31:05 +0100174 &sdhi0_device,
Kuninori Morimotoeb8ca942012-08-27 19:00:15 -0700175 &thermal_device,
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700176 &hspi_device,
Kuninori Morimotob5ce6352012-10-29 01:15:25 -0700177 &usb_phy_device,
Magnus Dammf411fad2011-12-14 01:36:12 +0900178};
179
Kuninori Morimoto94e1f7f2012-10-29 01:15:34 -0700180/* USB */
181static struct usb_phy *phy;
182static int usb_power_on(struct platform_device *pdev)
183{
184 if (!phy)
185 return -EIO;
186
187 pm_runtime_enable(&pdev->dev);
188 pm_runtime_get_sync(&pdev->dev);
189
190 usb_phy_init(phy);
191
192 return 0;
193}
194
195static void usb_power_off(struct platform_device *pdev)
196{
197 if (!phy)
198 return;
199
200 usb_phy_shutdown(phy);
201
202 pm_runtime_put_sync(&pdev->dev);
203 pm_runtime_disable(&pdev->dev);
204}
205
206static struct usb_ehci_pdata ehcix_pdata = {
207 .power_on = usb_power_on,
208 .power_off = usb_power_off,
209 .power_suspend = usb_power_off,
210};
211
212static struct resource ehci0_resources[] = {
213 [0] = {
214 .start = 0xffe70000,
215 .end = 0xffe70400 - 1,
216 .flags = IORESOURCE_MEM,
217 },
218 [1] = {
219 .start = gic_spi(44),
220 .flags = IORESOURCE_IRQ,
221 },
222};
223
224static struct platform_device ehci0_device = {
225 .name = "ehci-platform",
226 .id = 0,
227 .dev = {
228 .dma_mask = &ehci0_device.dev.coherent_dma_mask,
229 .coherent_dma_mask = 0xffffffff,
230 .platform_data = &ehcix_pdata,
231 },
232 .num_resources = ARRAY_SIZE(ehci0_resources),
233 .resource = ehci0_resources,
234};
235
236static struct resource ehci1_resources[] = {
237 [0] = {
238 .start = 0xfff70000,
239 .end = 0xfff70400 - 1,
240 .flags = IORESOURCE_MEM,
241 },
242 [1] = {
243 .start = gic_spi(45),
244 .flags = IORESOURCE_IRQ,
245 },
246};
247
248static struct platform_device ehci1_device = {
249 .name = "ehci-platform",
250 .id = 1,
251 .dev = {
252 .dma_mask = &ehci1_device.dev.coherent_dma_mask,
253 .coherent_dma_mask = 0xffffffff,
254 .platform_data = &ehcix_pdata,
255 },
256 .num_resources = ARRAY_SIZE(ehci1_resources),
257 .resource = ehci1_resources,
258};
259
Kuninori Morimotoac7c4ea2012-10-29 01:15:43 -0700260static struct usb_ohci_pdata ohcix_pdata = {
261 .power_on = usb_power_on,
262 .power_off = usb_power_off,
263 .power_suspend = usb_power_off,
264};
265
266static struct resource ohci0_resources[] = {
267 [0] = {
268 .start = 0xffe70400,
269 .end = 0xffe70800 - 1,
270 .flags = IORESOURCE_MEM,
271 },
272 [1] = {
273 .start = gic_spi(44),
274 .flags = IORESOURCE_IRQ,
275 },
276};
277
278static struct platform_device ohci0_device = {
279 .name = "ohci-platform",
280 .id = 0,
281 .dev = {
282 .dma_mask = &ohci0_device.dev.coherent_dma_mask,
283 .coherent_dma_mask = 0xffffffff,
284 .platform_data = &ohcix_pdata,
285 },
286 .num_resources = ARRAY_SIZE(ohci0_resources),
287 .resource = ohci0_resources,
288};
289
290static struct resource ohci1_resources[] = {
291 [0] = {
292 .start = 0xfff70400,
293 .end = 0xfff70800 - 1,
294 .flags = IORESOURCE_MEM,
295 },
296 [1] = {
297 .start = gic_spi(45),
298 .flags = IORESOURCE_IRQ,
299 },
300};
301
302static struct platform_device ohci1_device = {
303 .name = "ohci-platform",
304 .id = 1,
305 .dev = {
306 .dma_mask = &ohci1_device.dev.coherent_dma_mask,
307 .coherent_dma_mask = 0xffffffff,
308 .platform_data = &ohcix_pdata,
309 },
310 .num_resources = ARRAY_SIZE(ohci1_resources),
311 .resource = ohci1_resources,
312};
313
Kuninori Morimoto94e1f7f2012-10-29 01:15:34 -0700314static struct platform_device *marzen_late_devices[] __initdata = {
315 &ehci0_device,
316 &ehci1_device,
Kuninori Morimotoac7c4ea2012-10-29 01:15:43 -0700317 &ohci0_device,
318 &ohci1_device,
Kuninori Morimoto94e1f7f2012-10-29 01:15:34 -0700319};
320
321void __init marzen_init_late(void)
322{
323 /* get usb phy */
324 phy = usb_get_phy(USB_PHY_TYPE_USB2);
325
326 shmobile_init_late();
327 platform_add_devices(marzen_late_devices,
328 ARRAY_SIZE(marzen_late_devices));
329}
330
Laurent Pinchart4a655ec2013-03-06 14:22:11 +0100331static const struct pinctrl_map marzen_pinctrl_map[] = {
332 /* SDHI0 */
333 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
334 "sdhi0_data4", "sdhi0"),
335 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
336 "sdhi0_ctrl", "sdhi0"),
337 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
338 "sdhi0_cd", "sdhi0"),
339 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
340 "sdhi0_wp", "sdhi0"),
341};
342
Magnus Dammf411fad2011-12-14 01:36:12 +0900343static void __init marzen_init(void)
344{
Phil Edworthy894cda12012-08-06 13:31:05 +0100345 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
346 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
Kuninori Morimoto90b85af2012-08-29 18:58:15 -0700347 regulator_register_fixed(1, dummy_supplies,
Phil Edworthy894cda12012-08-06 13:31:05 +0100348 ARRAY_SIZE(dummy_supplies));
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +0200349
Laurent Pinchart4a655ec2013-03-06 14:22:11 +0100350 pinctrl_register_mappings(marzen_pinctrl_map,
351 ARRAY_SIZE(marzen_pinctrl_map));
Magnus Damm19c43fc2011-12-14 01:36:22 +0900352 r8a7779_pinmux_init();
353
Magnus Damm14f691c2011-12-14 01:36:42 +0900354 /* SCIF2 (CN18: DEBUG0) */
355 gpio_request(GPIO_FN_TX2_C, NULL);
356 gpio_request(GPIO_FN_RX2_C, NULL);
357
358 /* SCIF4 (CN19: DEBUG1) */
359 gpio_request(GPIO_FN_TX4, NULL);
360 gpio_request(GPIO_FN_RX4, NULL);
361
Magnus Dammdb5eb992011-12-14 01:36:51 +0900362 /* LAN89218 */
363 gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
364 gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
365
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700366 /* HSPI 0 */
367 gpio_request(GPIO_FN_HSPI_CLK0, NULL);
368 gpio_request(GPIO_FN_HSPI_CS0, NULL);
369 gpio_request(GPIO_FN_HSPI_TX0, NULL);
370 gpio_request(GPIO_FN_HSPI_RX0, NULL);
371
Kuninori Morimoto94e1f7f2012-10-29 01:15:34 -0700372 /* USB (CN21) */
373 gpio_request(GPIO_FN_USB_OVC0, NULL);
374 gpio_request(GPIO_FN_USB_OVC1, NULL);
375 gpio_request(GPIO_FN_USB_OVC2, NULL);
376
377 /* USB (CN22) */
378 gpio_request(GPIO_FN_USB_PENC2, NULL);
379
Magnus Dammf411fad2011-12-14 01:36:12 +0900380 r8a7779_add_standard_devices();
381 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
382}
383
Magnus Dammf411fad2011-12-14 01:36:12 +0900384MACHINE_START(MARZEN, "marzen")
Marc Zyngiera62580e2011-09-08 13:15:22 +0100385 .smp = smp_ops(r8a7779_smp_ops),
Magnus Damm3e353b872012-02-29 21:37:43 +0900386 .map_io = r8a7779_map_io,
387 .init_early = r8a7779_add_early_devices,
Magnus Dammf411fad2011-12-14 01:36:12 +0900388 .nr_irqs = NR_IRQS_LEGACY,
389 .init_irq = r8a7779_init_irq,
Magnus Dammf411fad2011-12-14 01:36:12 +0900390 .init_machine = marzen_init,
Kuninori Morimoto94e1f7f2012-10-29 01:15:34 -0700391 .init_late = marzen_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700392 .init_time = r8a7779_earlytimer_init,
Magnus Dammf411fad2011-12-14 01:36:12 +0900393MACHINE_END