blob: 4d65715901355e871496bc956545eb2c712073a7 [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 Morimoto111ea172013-04-12 05:38:03 +000021#include <linux/pinctrl/machine.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070022#include <linux/platform_device.h>
Kuninori Morimoto741440e2013-04-09 02:37:15 -070023#include <linux/regulator/fixed.h>
24#include <linux/regulator/machine.h>
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070025#include <linux/smsc911x.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070026#include <mach/common.h>
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070027#include <mach/irqs.h>
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070028#include <mach/r8a7778.h>
29#include <asm/mach/arch.h>
30
Kuninori Morimotod998cef2013-04-08 23:54:16 -070031/*
32 * CN9(Upper side) SCIF/RCAN selection
33 *
34 * 1,4 3,6
35 * SW40 SCIF RCAN
36 * SW41 SCIF RCAN
37 */
38
Kuninori Morimoto741440e2013-04-09 02:37:15 -070039/* Dummy supplies, where voltage doesn't matter */
40static struct regulator_consumer_supply dummy_supplies[] = {
41 REGULATOR_SUPPLY("vddvario", "smsc911x"),
42 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
43};
44
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070045static struct smsc911x_platform_config smsc911x_data = {
46 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
47 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
48 .flags = SMSC911X_USE_32BIT,
49 .phy_interface = PHY_INTERFACE_MODE_MII,
50};
51
52static struct resource smsc911x_resources[] = {
53 DEFINE_RES_MEM(0x18300000, 0x1000),
54 DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
55};
56
Kuninori Morimoto111ea172013-04-12 05:38:03 +000057static const struct pinctrl_map bockw_pinctrl_map[] = {
58 /* SCIF0 */
59 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
60 "scif0_data_a", "scif0"),
61 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778",
62 "scif0_ctrl", "scif0"),
63};
64
Kuninori Morimoto44bfe682013-04-16 22:17:42 -070065#define FPGA 0x18200000
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070066#define IRQ0MR 0x30
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070067static void __init bockw_init(void)
68{
Kuninori Morimoto44bfe682013-04-16 22:17:42 -070069 void __iomem *base;
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070070
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070071 r8a7778_clock_init();
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070072 r8a7778_init_irq_extpin(1);
Kuninori Morimoto53e42c22013-03-21 03:03:38 -070073 r8a7778_add_standard_devices();
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070074
Kuninori Morimoto111ea172013-04-12 05:38:03 +000075 pinctrl_register_mappings(bockw_pinctrl_map,
76 ARRAY_SIZE(bockw_pinctrl_map));
77 r8a7778_pinmux_init();
78
Kuninori Morimoto44bfe682013-04-16 22:17:42 -070079 base = ioremap_nocache(FPGA, SZ_1M);
80 if (base) {
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070081 /*
82 * CAUTION
83 *
84 * IRQ0/1 is cascaded interrupt from FPGA.
85 * it should be cared in the future
86 * Now, it is assuming IRQ0 was used only from SMSC.
87 */
Kuninori Morimoto44bfe682013-04-16 22:17:42 -070088 u16 val = ioread16(base + IRQ0MR);
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070089 val &= ~(1 << 4); /* enable SMSC911x */
Kuninori Morimoto44bfe682013-04-16 22:17:42 -070090 iowrite16(val, base + IRQ0MR);
91 iounmap(base);
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070092
Kuninori Morimoto741440e2013-04-09 02:37:15 -070093 regulator_register_fixed(0, dummy_supplies,
94 ARRAY_SIZE(dummy_supplies));
95
Kuninori Morimoto27d5f272013-04-01 21:20:02 -070096 platform_device_register_resndata(
97 &platform_bus, "smsc911x", -1,
98 smsc911x_resources, ARRAY_SIZE(smsc911x_resources),
99 &smsc911x_data, sizeof(smsc911x_data));
100 }
Kuninori Morimoto53e42c22013-03-21 03:03:38 -0700101}
102
103static const char *bockw_boards_compat_dt[] __initdata = {
104 "renesas,bockw",
105 NULL,
106};
107
108DT_MACHINE_START(BOCKW_DT, "bockw")
109 .init_early = r8a7778_init_delay,
110 .init_irq = r8a7778_init_irq_dt,
111 .init_machine = bockw_init,
112 .init_time = shmobile_timer_init,
113 .dt_compat = bockw_boards_compat_dt,
114MACHINE_END