blob: 8a6b85a52cb74ab4c5175ecfe19d245e5926270e [file] [log] [blame]
Magnus Damm28626632011-08-18 05:44:07 +00001/*
2 * kota2 board support
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Magnus Damm
6 * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
7 * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/interrupt.h>
26#include <linux/irq.h>
27#include <linux/platform_device.h>
28#include <linux/delay.h>
29#include <linux/io.h>
30#include <linux/smsc911x.h>
31#include <linux/gpio.h>
Magnus Dammef4f9942011-08-18 05:44:16 +000032#include <linux/input.h>
33#include <linux/input/sh_keysc.h>
Magnus Damm28626632011-08-18 05:44:07 +000034#include <mach/hardware.h>
35#include <mach/sh73a0.h>
36#include <mach/common.h>
37#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40#include <asm/mach/time.h>
41#include <asm/hardware/gic.h>
42#include <asm/hardware/cache-l2x0.h>
43#include <asm/traps.h>
44
45static struct resource smsc9220_resources[] = {
46 [0] = {
47 .start = 0x14000000, /* CS5A */
48 .end = 0x140000ff, /* A1->A7 */
49 .flags = IORESOURCE_MEM,
50 },
51 [1] = {
52 .start = gic_spi(33), /* PINTA2 @ PORT144 */
53 .flags = IORESOURCE_IRQ,
54 },
55};
56
57static struct smsc911x_platform_config smsc9220_platdata = {
58 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
59 .phy_interface = PHY_INTERFACE_MODE_MII,
60 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
61 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
62};
63
64static struct platform_device eth_device = {
65 .name = "smsc911x",
66 .id = 0,
67 .dev = {
68 .platform_data = &smsc9220_platdata,
69 },
70 .resource = smsc9220_resources,
71 .num_resources = ARRAY_SIZE(smsc9220_resources),
72};
73
Magnus Dammef4f9942011-08-18 05:44:16 +000074static struct sh_keysc_info keysc_platdata = {
75 .mode = SH_KEYSC_MODE_6,
76 .scan_timing = 3,
77 .delay = 100,
78 .keycodes = {
79 KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
80 0, 0, 0, 0, 0,
81 KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
82 0, KEY_DOWN, 0, 0, 0,
83 KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
84 KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
85 KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
86 0, KEY_UP, 0, 0, 0,
87 0, 0, 0, 0, 0, 0, 0, 0,
88 0, 0, 0, 0, 0, 0, 0, 0,
89 0, 0, 0, 0, 0, 0, 0, 0,
90 0, 0, 0, 0, 0, 0, 0, 0,
91 },
92};
93
94static struct resource keysc_resources[] = {
95 [0] = {
96 .name = "KEYSC",
97 .start = 0xe61b0000,
98 .end = 0xe61b0098 - 1,
99 .flags = IORESOURCE_MEM,
100 },
101 [1] = {
102 .start = gic_spi(71),
103 .flags = IORESOURCE_IRQ,
104 },
105};
106
107static struct platform_device keysc_device = {
108 .name = "sh_keysc",
109 .id = 0,
110 .num_resources = ARRAY_SIZE(keysc_resources),
111 .resource = keysc_resources,
112 .dev = {
113 .platform_data = &keysc_platdata,
114 },
115};
116
Magnus Damm28626632011-08-18 05:44:07 +0000117static struct platform_device *kota2_devices[] __initdata = {
118 &eth_device,
Magnus Dammef4f9942011-08-18 05:44:16 +0000119 &keysc_device,
Magnus Damm28626632011-08-18 05:44:07 +0000120};
121
122static struct map_desc kota2_io_desc[] __initdata = {
123 /* create a 1:1 entity map for 0xe6xxxxxx
124 * used by CPGA, INTC and PFC.
125 */
126 {
127 .virtual = 0xe6000000,
128 .pfn = __phys_to_pfn(0xe6000000),
129 .length = 256 << 20,
130 .type = MT_DEVICE_NONSHARED
131 },
132};
133
134static void __init kota2_map_io(void)
135{
136 iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
137
138 /* setup early devices and console here as well */
139 sh73a0_add_early_devices();
140 shmobile_setup_console();
141}
142
143#define PINTER0A 0xe69000a0
144#define PINTCR0A 0xe69000b0
145
146void __init kota2_init_irq(void)
147{
148 sh73a0_init_irq();
149
150 /* setup PINT: enable PINTA2 as active low */
151 __raw_writel(1 << 29, PINTER0A);
152 __raw_writew(2 << 10, PINTCR0A);
153}
154
155static void __init kota2_init(void)
156{
157 sh73a0_pinmux_init();
158
159 /* SCIFA2 (UART2) */
160 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
161 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
162 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
163 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
164
165 /* SMSC911X */
166 gpio_request(GPIO_FN_D0_NAF0, NULL);
167 gpio_request(GPIO_FN_D1_NAF1, NULL);
168 gpio_request(GPIO_FN_D2_NAF2, NULL);
169 gpio_request(GPIO_FN_D3_NAF3, NULL);
170 gpio_request(GPIO_FN_D4_NAF4, NULL);
171 gpio_request(GPIO_FN_D5_NAF5, NULL);
172 gpio_request(GPIO_FN_D6_NAF6, NULL);
173 gpio_request(GPIO_FN_D7_NAF7, NULL);
174 gpio_request(GPIO_FN_D8_NAF8, NULL);
175 gpio_request(GPIO_FN_D9_NAF9, NULL);
176 gpio_request(GPIO_FN_D10_NAF10, NULL);
177 gpio_request(GPIO_FN_D11_NAF11, NULL);
178 gpio_request(GPIO_FN_D12_NAF12, NULL);
179 gpio_request(GPIO_FN_D13_NAF13, NULL);
180 gpio_request(GPIO_FN_D14_NAF14, NULL);
181 gpio_request(GPIO_FN_D15_NAF15, NULL);
182 gpio_request(GPIO_FN_CS5A_, NULL);
183 gpio_request(GPIO_FN_WE0__FWE, NULL);
184 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
185 gpio_direction_input(GPIO_PORT144);
186 gpio_request(GPIO_PORT145, NULL); /* RESET */
187 gpio_direction_output(GPIO_PORT145, 1);
188
Magnus Dammef4f9942011-08-18 05:44:16 +0000189 /* KEYSC */
190 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
191 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
192 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
193 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
194 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
195 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
196 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
197 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
198 gpio_request(GPIO_FN_KEYOUT0, NULL);
199 gpio_request(GPIO_FN_KEYOUT1, NULL);
200 gpio_request(GPIO_FN_KEYOUT2, NULL);
201 gpio_request(GPIO_FN_KEYOUT3, NULL);
202 gpio_request(GPIO_FN_KEYOUT4, NULL);
203 gpio_request(GPIO_FN_KEYOUT5, NULL);
204 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
205 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
206 gpio_request(GPIO_FN_KEYOUT8, NULL);
207
Magnus Damm28626632011-08-18 05:44:07 +0000208#ifdef CONFIG_CACHE_L2X0
209 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
210 l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
211#endif
212 sh73a0_add_standard_devices();
213 platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
214}
215
216static void __init kota2_timer_init(void)
217{
218 sh73a0_clock_init();
219 shmobile_timer.init();
220 return;
221}
222
223struct sys_timer kota2_timer = {
224 .init = kota2_timer_init,
225};
226
227MACHINE_START(KOTA2, "kota2")
228 .map_io = kota2_map_io,
229 .init_irq = kota2_init_irq,
230 .handle_irq = shmobile_handle_irq_gic,
231 .init_machine = kota2_init,
232 .timer = &kota2_timer,
233MACHINE_END