blob: 4758690ea421e5516ad336cfeb85083f1ed230fa [file] [log] [blame]
Magnus Damm6d9598e2010-11-17 10:59:31 +00001/*
2 * arch/arm/mach-shmobile/board-ag5evm.c
3 *
4 * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
5 * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@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 */
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/irq.h>
26#include <linux/platform_device.h>
27#include <linux/delay.h>
28#include <linux/io.h>
29#include <linux/dma-mapping.h>
30#include <linux/serial_sci.h>
31#include <linux/smsc911x.h>
32#include <linux/gpio.h>
Yoshii Takashi2d22d482010-11-19 13:15:46 +000033#include <linux/input.h>
34#include <linux/input/sh_keysc.h>
35
Magnus Damm6d9598e2010-11-17 10:59:31 +000036#include <mach/hardware.h>
37#include <mach/sh73a0.h>
38#include <mach/common.h>
39#include <asm/mach-types.h>
40#include <asm/mach/arch.h>
41#include <asm/mach/map.h>
42#include <asm/mach/time.h>
43#include <asm/hardware/gic.h>
44#include <asm/hardware/cache-l2x0.h>
45#include <asm/traps.h>
46
47static struct resource smsc9220_resources[] = {
48 [0] = {
49 .start = 0x14000000,
50 .end = 0x14000000 + SZ_64K - 1,
51 .flags = IORESOURCE_MEM,
52 },
53 [1] = {
54 .start = gic_spi(33), /* PINT1 */
55 .flags = IORESOURCE_IRQ,
56 },
57};
58
59static struct smsc911x_platform_config smsc9220_platdata = {
60 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
61 .phy_interface = PHY_INTERFACE_MODE_MII,
62 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
63 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
64};
65
66static struct platform_device eth_device = {
67 .name = "smsc911x",
68 .id = 0,
69 .dev = {
70 .platform_data = &smsc9220_platdata,
71 },
72 .resource = smsc9220_resources,
73 .num_resources = ARRAY_SIZE(smsc9220_resources),
74};
75
Yoshii Takashi2d22d482010-11-19 13:15:46 +000076static struct sh_keysc_info keysc_platdata = {
77 .mode = SH_KEYSC_MODE_6,
78 .scan_timing = 3,
79 .delay = 100,
80 .keycodes = {
81 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
82 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
83 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
84 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
85 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
86 KEY_COFFEE,
87 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
88 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
89 KEY_COMPUTER,
90 },
91};
92
93static struct resource keysc_resources[] = {
94 [0] = {
95 .name = "KEYSC",
96 .start = 0xe61b0000,
97 .end = 0xe61b0098 - 1,
98 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
101 .start = gic_spi(71),
102 .flags = IORESOURCE_IRQ,
103 },
104};
105
106static struct platform_device keysc_device = {
107 .name = "sh_keysc",
108 .id = 0,
109 .num_resources = ARRAY_SIZE(keysc_resources),
110 .resource = keysc_resources,
111 .dev = {
112 .platform_data = &keysc_platdata,
113 },
114};
115
Magnus Damm6d9598e2010-11-17 10:59:31 +0000116static struct platform_device *ag5evm_devices[] __initdata = {
117 &eth_device,
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000118 &keysc_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000119};
120
121static struct map_desc ag5evm_io_desc[] __initdata = {
122 /* create a 1:1 entity map for 0xe6xxxxxx
123 * used by CPGA, INTC and PFC.
124 */
125 {
126 .virtual = 0xe6000000,
127 .pfn = __phys_to_pfn(0xe6000000),
128 .length = 256 << 20,
129 .type = MT_DEVICE_NONSHARED
130 },
131};
132
133static void __init ag5evm_map_io(void)
134{
135 iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
136
137 /* setup early devices and console here as well */
138 sh73a0_add_early_devices();
139 shmobile_setup_console();
140}
141
142#define PINTC_ADDR 0xe6900000
143#define PINTER0A (PINTC_ADDR + 0xa0)
144#define PINTCR0A (PINTC_ADDR + 0xb0)
145
146void __init ag5evm_init_irq(void)
147{
148 /* setup PINT: enable PINTA2 as active low */
149 __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
150 __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
151
152 gic_dist_init(0, __io(0xf0001000), 29);
153 gic_cpu_init(0, __io(0xf0000100));
154}
155
156#define PORT144CR 0xe6052090
157#define PORT145CR 0xe6052091
158
159#define PORT154CR 0xe605209a
160#define PORT155CR 0xe605209b
161#define PORT156CR 0xe605209c
162#define PORT157CR 0xe605209d
163
164#define PORTR159_128DR 0xe6056004
165
166static void __init ag5evm_init(void)
167{
Takashi YOSHII3256c782010-11-19 16:49:38 +0900168 sh73a0_pinmux_init();
169
Magnus Damm6d9598e2010-11-17 10:59:31 +0000170 /* enable SCIFA2 */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900171 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
172 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
173 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
174 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000175
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000176 /* enable KEYSC */
177 gpio_request(GPIO_FN_KEYIN0, NULL);
178 gpio_request(GPIO_FN_KEYIN1, NULL);
179 gpio_request(GPIO_FN_KEYIN2, NULL);
180 gpio_request(GPIO_FN_KEYIN3, NULL);
181 gpio_request(GPIO_FN_KEYIN4, NULL);
182 gpio_request(GPIO_FN_KEYIN5, NULL);
183 gpio_request(GPIO_FN_KEYIN6, NULL);
184 gpio_request(GPIO_FN_KEYIN7, NULL);
185 gpio_request(GPIO_FN_KEYOUT0, NULL);
186 gpio_request(GPIO_FN_KEYOUT1, NULL);
187 gpio_request(GPIO_FN_KEYOUT2, NULL);
188 gpio_request(GPIO_FN_KEYOUT3, NULL);
189 gpio_request(GPIO_FN_KEYOUT4, NULL);
190 gpio_request(GPIO_FN_KEYOUT5, NULL);
191 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
192 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
193 gpio_request(GPIO_FN_KEYOUT8, NULL);
194 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
195
Magnus Damm6d9598e2010-11-17 10:59:31 +0000196 /* enable SMSC911X */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900197 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
198 gpio_direction_input(GPIO_PORT144);
199 gpio_request(GPIO_PORT145, NULL); /* RESET */
200 gpio_direction_output(GPIO_PORT145, 1);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000201
202#ifdef CONFIG_CACHE_L2X0
203 /* Shared attribute override enable, 64K*8way */
204 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
205#endif
206 sh73a0_add_standard_devices();
207 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
208}
209
210static void __init ag5evm_timer_init(void)
211{
212 sh73a0_clock_init();
213 shmobile_timer.init();
214 return;
215}
216
217struct sys_timer ag5evm_timer = {
218 .init = ag5evm_timer_init,
219};
220
221MACHINE_START(AG5EVM, "ag5evm")
222 .map_io = ag5evm_map_io,
223 .init_irq = ag5evm_init_irq,
224 .init_machine = ag5evm_init,
225 .timer = &ag5evm_timer,
226MACHINE_END