blob: 8c7529cc486039d4dad9b2741deb35788cb3df9a [file] [log] [blame]
Magnus Damm78ded162013-03-29 17:00:02 +09001/*
2 * APE6EVM board support
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 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
Magnus Damm15351a7a2013-03-29 17:00:21 +090021#include <linux/gpio.h>
Magnus Damm78ded162013-03-29 17:00:02 +090022#include <linux/interrupt.h>
Magnus Damm78ded162013-03-29 17:00:02 +090023#include <linux/kernel.h>
Guennadi Liakhovetski87116132013-07-10 10:13:08 +020024#include <linux/mmc/host.h>
25#include <linux/mmc/sh_mmcif.h>
Magnus Damm2c560552013-03-29 17:00:12 +090026#include <linux/pinctrl/machine.h>
Magnus Damm78ded162013-03-29 17:00:02 +090027#include <linux/platform_device.h>
Magnus Damm15351a7a2013-03-29 17:00:21 +090028#include <linux/regulator/fixed.h>
29#include <linux/regulator/machine.h>
Kuninori Morimotob8568a02013-04-04 21:24:27 -070030#include <linux/sh_clk.h>
Magnus Damm15351a7a2013-03-29 17:00:21 +090031#include <linux/smsc911x.h>
Magnus Damm78ded162013-03-29 17:00:02 +090032#include <mach/common.h>
Magnus Damm15351a7a2013-03-29 17:00:21 +090033#include <mach/irqs.h>
Magnus Damm78ded162013-03-29 17:00:02 +090034#include <mach/r8a73a4.h>
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37
Magnus Damm15351a7a2013-03-29 17:00:21 +090038/* Dummy supplies, where voltage doesn't matter */
39static struct regulator_consumer_supply dummy_supplies[] = {
40 REGULATOR_SUPPLY("vddvario", "smsc911x"),
41 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
42};
43
44/* SMSC LAN9220 */
45static const struct resource lan9220_res[] = {
46 DEFINE_RES_MEM(0x08000000, 0x1000),
47 {
48 .start = irq_pin(40), /* IRQ40 */
49 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
50 },
51};
52
53static const struct smsc911x_platform_config lan9220_data = {
54 .flags = SMSC911X_USE_32BIT,
55 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
56 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
57};
58
Guennadi Liakhovetski87116132013-07-10 10:13:08 +020059/*
60 * On APE6EVM power is supplied to MMCIF by a tps80032 regulator. For now we
61 * model a VDD supply to MMCIF, using a fixed 3.3V regulator.
62 */
63static struct regulator_consumer_supply fixed3v3_power_consumers[] =
64{
65 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
66};
67
68/* MMCIF */
69static struct sh_mmcif_plat_data mmcif0_pdata = {
70 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
71};
72
73static struct resource mmcif0_resources[] = {
74 DEFINE_RES_MEM_NAMED(0xee200000, 0x100, "MMCIF0"),
75 DEFINE_RES_IRQ(gic_spi(169)),
76};
77
Magnus Damm2c560552013-03-29 17:00:12 +090078static const struct pinctrl_map ape6evm_pinctrl_map[] = {
79 /* SCIFA0 console */
80 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a73a4",
81 "scifa0_data", "scifa0"),
Magnus Damm15351a7a2013-03-29 17:00:21 +090082 /* SMSC */
83 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a73a4",
84 "irqc_irq40", "irqc"),
Guennadi Liakhovetski87116132013-07-10 10:13:08 +020085 /* MMCIF0 */
86 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a73a4",
87 "mmc0_data8", "mmc0"),
88 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a73a4",
89 "mmc0_ctrl", "mmc0"),
Magnus Damm2c560552013-03-29 17:00:12 +090090};
91
Magnus Damm78ded162013-03-29 17:00:02 +090092static void __init ape6evm_add_standard_devices(void)
93{
Kuninori Morimotob8568a02013-04-04 21:24:27 -070094
95 struct clk *parent;
96 struct clk *mp;
97
Magnus Damm78ded162013-03-29 17:00:02 +090098 r8a73a4_clock_init();
Kuninori Morimotob8568a02013-04-04 21:24:27 -070099
100 /* MP clock parent = extal2 */
101 parent = clk_get(NULL, "extal2");
102 mp = clk_get(NULL, "mp");
103 BUG_ON(IS_ERR(parent) || IS_ERR(mp));
104
105 clk_set_parent(mp, parent);
106 clk_put(parent);
107 clk_put(mp);
108
Magnus Damm2c560552013-03-29 17:00:12 +0900109 pinctrl_register_mappings(ape6evm_pinctrl_map,
110 ARRAY_SIZE(ape6evm_pinctrl_map));
111 r8a73a4_pinmux_init();
Magnus Damm78ded162013-03-29 17:00:02 +0900112 r8a73a4_add_standard_devices();
Magnus Damm15351a7a2013-03-29 17:00:21 +0900113
114 /* LAN9220 ethernet */
115 gpio_request_one(270, GPIOF_OUT_INIT_HIGH, NULL); /* smsc9220 RESET */
116
117 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
118
119 platform_device_register_resndata(&platform_bus, "smsc911x", -1,
120 lan9220_res, ARRAY_SIZE(lan9220_res),
121 &lan9220_data, sizeof(lan9220_data));
Guennadi Liakhovetski87116132013-07-10 10:13:08 +0200122 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
123 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
124 platform_device_register_resndata(&platform_bus, "sh_mmcif", 0,
125 mmcif0_resources, ARRAY_SIZE(mmcif0_resources),
126 &mmcif0_pdata, sizeof(mmcif0_pdata));
Magnus Damm78ded162013-03-29 17:00:02 +0900127}
128
129static const char *ape6evm_boards_compat_dt[] __initdata = {
130 "renesas,ape6evm",
131 NULL,
132};
133
134DT_MACHINE_START(APE6EVM_DT, "ape6evm")
Magnus Dammb9a30ef2013-06-28 20:27:32 +0900135 .init_early = r8a73a4_init_delay,
Magnus Damm78ded162013-03-29 17:00:02 +0900136 .init_time = shmobile_timer_init,
137 .init_machine = ape6evm_add_standard_devices,
138 .dt_compat = ape6evm_boards_compat_dt,
139MACHINE_END