blob: dec3ffc9df09bbc3f50544ef0117c7a423123c83 [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>
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +020030#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
Magnus Dammdb5eb992011-12-14 01:36:51 +090032#include <linux/smsc911x.h>
Phil Edworthy894cda12012-08-06 13:31:05 +010033#include <linux/mmc/sh_mobile_sdhi.h>
34#include <linux/mfd/tmio.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090035#include <mach/hardware.h>
36#include <mach/r8a7779.h>
37#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060038#include <mach/irqs.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090039#include <asm/mach-types.h>
40#include <asm/mach/arch.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090041#include <asm/hardware/gic.h>
42#include <asm/traps.h>
43
Phil Edworthy894cda12012-08-06 13:31:05 +010044/* Fixed 3.3V regulator to be used by SDHI0 */
45static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
46 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
47 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
48};
49
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +020050/* Dummy supplies, where voltage doesn't matter */
51static struct regulator_consumer_supply dummy_supplies[] = {
52 REGULATOR_SUPPLY("vddvario", "smsc911x"),
53 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
54};
55
Magnus Dammdb5eb992011-12-14 01:36:51 +090056/* SMSC LAN89218 */
57static struct resource smsc911x_resources[] = {
58 [0] = {
59 .start = 0x18000000, /* ExCS0 */
60 .end = 0x180000ff, /* A1->A7 */
61 .flags = IORESOURCE_MEM,
62 },
63 [1] = {
64 .start = gic_spi(28), /* IRQ 1 */
65 .flags = IORESOURCE_IRQ,
66 },
67};
68
69static struct smsc911x_platform_config smsc911x_platdata = {
70 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
71 .phy_interface = PHY_INTERFACE_MODE_MII,
72 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
73 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
74};
75
76static struct platform_device eth_device = {
77 .name = "smsc911x",
78 .id = 0,
79 .dev = {
80 .platform_data = &smsc911x_platdata,
81 },
82 .resource = smsc911x_resources,
83 .num_resources = ARRAY_SIZE(smsc911x_resources),
84};
85
Phil Edworthy894cda12012-08-06 13:31:05 +010086static struct resource sdhi0_resources[] = {
87 [0] = {
88 .name = "sdhi0",
89 .start = 0xffe4c000,
90 .end = 0xffe4c0ff,
91 .flags = IORESOURCE_MEM,
92 },
93 [1] = {
94 .start = gic_spi(104),
95 .flags = IORESOURCE_IRQ,
96 },
97};
98
99static struct sh_mobile_sdhi_info sdhi0_platform_data = {
100 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
101 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
102};
103
104static struct platform_device sdhi0_device = {
105 .name = "sh_mobile_sdhi",
106 .num_resources = ARRAY_SIZE(sdhi0_resources),
107 .resource = sdhi0_resources,
108 .id = 0,
109 .dev = {
110 .platform_data = &sdhi0_platform_data,
111 }
112};
113
Magnus Dammf411fad2011-12-14 01:36:12 +0900114static struct platform_device *marzen_devices[] __initdata = {
Magnus Dammdb5eb992011-12-14 01:36:51 +0900115 &eth_device,
Phil Edworthy894cda12012-08-06 13:31:05 +0100116 &sdhi0_device,
Magnus Dammf411fad2011-12-14 01:36:12 +0900117};
118
Magnus Dammf411fad2011-12-14 01:36:12 +0900119static void __init marzen_init(void)
120{
Phil Edworthy894cda12012-08-06 13:31:05 +0100121 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
122 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
123 regulator_register_fixed(0, dummy_supplies,
124 ARRAY_SIZE(dummy_supplies));
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +0200125
Magnus Damm19c43fc2011-12-14 01:36:22 +0900126 r8a7779_pinmux_init();
127
Magnus Damm14f691c2011-12-14 01:36:42 +0900128 /* SCIF2 (CN18: DEBUG0) */
129 gpio_request(GPIO_FN_TX2_C, NULL);
130 gpio_request(GPIO_FN_RX2_C, NULL);
131
132 /* SCIF4 (CN19: DEBUG1) */
133 gpio_request(GPIO_FN_TX4, NULL);
134 gpio_request(GPIO_FN_RX4, NULL);
135
Magnus Dammdb5eb992011-12-14 01:36:51 +0900136 /* LAN89218 */
137 gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
138 gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
139
Phil Edworthy894cda12012-08-06 13:31:05 +0100140 /* SD0 (CN20) */
141 gpio_request(GPIO_FN_SD0_CLK, NULL);
142 gpio_request(GPIO_FN_SD0_CMD, NULL);
143 gpio_request(GPIO_FN_SD0_DAT0, NULL);
144 gpio_request(GPIO_FN_SD0_DAT1, NULL);
145 gpio_request(GPIO_FN_SD0_DAT2, NULL);
146 gpio_request(GPIO_FN_SD0_DAT3, NULL);
147 gpio_request(GPIO_FN_SD0_CD, NULL);
148 gpio_request(GPIO_FN_SD0_WP, NULL);
149
Magnus Dammf411fad2011-12-14 01:36:12 +0900150 r8a7779_add_standard_devices();
151 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
152}
153
Magnus Dammf411fad2011-12-14 01:36:12 +0900154MACHINE_START(MARZEN, "marzen")
Magnus Damm3e353b872012-02-29 21:37:43 +0900155 .map_io = r8a7779_map_io,
156 .init_early = r8a7779_add_early_devices,
Magnus Dammf411fad2011-12-14 01:36:12 +0900157 .nr_irqs = NR_IRQS_LEGACY,
158 .init_irq = r8a7779_init_irq,
Paul Mundt77761b62012-01-10 13:33:23 +0900159 .handle_irq = gic_handle_irq,
Magnus Dammf411fad2011-12-14 01:36:12 +0900160 .init_machine = marzen_init,
Shawn Guo21cc1b72012-04-26 21:58:41 +0800161 .init_late = shmobile_init_late,
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900162 .timer = &shmobile_timer,
Magnus Dammf411fad2011-12-14 01:36:12 +0900163MACHINE_END