blob: 3b2e88ae26be9ed84ca9fd0501a8b7c4eeb7ba69 [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>
Magnus Dammdb5eb992011-12-14 01:36:51 +090030#include <linux/smsc911x.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090031#include <mach/hardware.h>
32#include <mach/r8a7779.h>
33#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060034#include <mach/irqs.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090035#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
38#include <asm/mach/time.h>
39#include <asm/hardware/gic.h>
40#include <asm/traps.h>
41
Magnus Dammdb5eb992011-12-14 01:36:51 +090042/* SMSC LAN89218 */
43static struct resource smsc911x_resources[] = {
44 [0] = {
45 .start = 0x18000000, /* ExCS0 */
46 .end = 0x180000ff, /* A1->A7 */
47 .flags = IORESOURCE_MEM,
48 },
49 [1] = {
50 .start = gic_spi(28), /* IRQ 1 */
51 .flags = IORESOURCE_IRQ,
52 },
53};
54
55static struct smsc911x_platform_config smsc911x_platdata = {
56 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
57 .phy_interface = PHY_INTERFACE_MODE_MII,
58 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
59 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
60};
61
62static struct platform_device eth_device = {
63 .name = "smsc911x",
64 .id = 0,
65 .dev = {
66 .platform_data = &smsc911x_platdata,
67 },
68 .resource = smsc911x_resources,
69 .num_resources = ARRAY_SIZE(smsc911x_resources),
70};
71
Magnus Dammf411fad2011-12-14 01:36:12 +090072static struct platform_device *marzen_devices[] __initdata = {
Magnus Dammdb5eb992011-12-14 01:36:51 +090073 &eth_device,
Magnus Dammf411fad2011-12-14 01:36:12 +090074};
75
76static struct map_desc marzen_io_desc[] __initdata = {
77 /* 2M entity map for 0xf0000000 (MPCORE) */
78 {
79 .virtual = 0xf0000000,
80 .pfn = __phys_to_pfn(0xf0000000),
81 .length = SZ_2M,
82 .type = MT_DEVICE_NONSHARED
83 },
84 /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
85 {
86 .virtual = 0xfe000000,
87 .pfn = __phys_to_pfn(0xfe000000),
88 .length = SZ_16M,
89 .type = MT_DEVICE_NONSHARED
90 },
91};
92
93static void __init marzen_map_io(void)
94{
95 iotable_init(marzen_io_desc, ARRAY_SIZE(marzen_io_desc));
96}
97
98static void __init marzen_init_early(void)
99{
100 r8a7779_add_early_devices();
101
102 /* Early serial console setup is not included here due to
103 * memory map collisions. The SCIF serial ports in r8a7779
104 * are difficult to entity map 1:1 due to collision with the
105 * virtual memory range used by the coherent DMA code on ARM.
106 *
107 * Anyone wanting to debug early can remove UPF_IOREMAP from
108 * the sh-sci serial console platform data, adjust mapbase
109 * to a static M:N virt:phys mapping that needs to be added to
110 * the mappings passed with iotable_init() above.
111 *
112 * Then add a call to shmobile_setup_console() from this function.
113 *
114 * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
115 * command line.
116 */
117}
118
119static void __init marzen_init(void)
120{
Magnus Damm19c43fc2011-12-14 01:36:22 +0900121 r8a7779_pinmux_init();
122
Magnus Damm14f691c2011-12-14 01:36:42 +0900123 /* SCIF2 (CN18: DEBUG0) */
124 gpio_request(GPIO_FN_TX2_C, NULL);
125 gpio_request(GPIO_FN_RX2_C, NULL);
126
127 /* SCIF4 (CN19: DEBUG1) */
128 gpio_request(GPIO_FN_TX4, NULL);
129 gpio_request(GPIO_FN_RX4, NULL);
130
Magnus Dammdb5eb992011-12-14 01:36:51 +0900131 /* LAN89218 */
132 gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
133 gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
134
Magnus Dammf411fad2011-12-14 01:36:12 +0900135 r8a7779_add_standard_devices();
136 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
137}
138
139static void __init marzen_timer_init(void)
140{
141 r8a7779_clock_init();
142 shmobile_timer.init();
143 return;
144}
145
146struct sys_timer marzen_timer = {
147 .init = marzen_timer_init,
148};
149
150MACHINE_START(MARZEN, "marzen")
151 .map_io = marzen_map_io,
152 .init_early = marzen_init_early,
153 .nr_irqs = NR_IRQS_LEGACY,
154 .init_irq = r8a7779_init_irq,
Paul Mundt77761b62012-01-10 13:33:23 +0900155 .handle_irq = gic_handle_irq,
Magnus Dammf411fad2011-12-14 01:36:12 +0900156 .init_machine = marzen_init,
157 .timer = &marzen_timer,
158MACHINE_END