Merge branch 'for-2.6.38' into for-2.6.39
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-shmobile / board-ag5evm.c
1 /*
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>
33 #include <linux/input.h>
34 #include <linux/input/sh_keysc.h>
35 #include <linux/mmc/host.h>
36 #include <linux/mmc/sh_mmcif.h>
37
38 #include <sound/sh_fsi.h>
39
40 #include <mach/hardware.h>
41 #include <mach/sh73a0.h>
42 #include <mach/common.h>
43 #include <asm/mach-types.h>
44 #include <asm/mach/arch.h>
45 #include <asm/mach/map.h>
46 #include <asm/mach/time.h>
47 #include <asm/hardware/gic.h>
48 #include <asm/hardware/cache-l2x0.h>
49 #include <asm/traps.h>
50
51 static struct resource smsc9220_resources[] = {
52         [0] = {
53                 .start          = 0x14000000,
54                 .end            = 0x14000000 + SZ_64K - 1,
55                 .flags          = IORESOURCE_MEM,
56         },
57         [1] = {
58                 .start          = gic_spi(33), /* PINT1 */
59                 .flags          = IORESOURCE_IRQ,
60         },
61 };
62
63 static struct smsc911x_platform_config smsc9220_platdata = {
64         .flags          = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
65         .phy_interface  = PHY_INTERFACE_MODE_MII,
66         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
67         .irq_type       = SMSC911X_IRQ_TYPE_PUSH_PULL,
68 };
69
70 static struct platform_device eth_device = {
71         .name           = "smsc911x",
72         .id             = 0,
73         .dev  = {
74                 .platform_data = &smsc9220_platdata,
75         },
76         .resource       = smsc9220_resources,
77         .num_resources  = ARRAY_SIZE(smsc9220_resources),
78 };
79
80 static struct sh_keysc_info keysc_platdata = {
81         .mode           = SH_KEYSC_MODE_6,
82         .scan_timing    = 3,
83         .delay          = 100,
84         .keycodes       = {
85                 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
86                 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
87                 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
88                 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
89                 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
90                 KEY_COFFEE,
91                 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
92                 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
93                 KEY_COMPUTER,
94         },
95 };
96
97 static struct resource keysc_resources[] = {
98         [0] = {
99                 .name   = "KEYSC",
100                 .start  = 0xe61b0000,
101                 .end    = 0xe61b0098 - 1,
102                 .flags  = IORESOURCE_MEM,
103         },
104         [1] = {
105                 .start  = gic_spi(71),
106                 .flags  = IORESOURCE_IRQ,
107         },
108 };
109
110 static struct platform_device keysc_device = {
111         .name           = "sh_keysc",
112         .id             = 0,
113         .num_resources  = ARRAY_SIZE(keysc_resources),
114         .resource       = keysc_resources,
115         .dev            = {
116                 .platform_data  = &keysc_platdata,
117         },
118 };
119
120 /* FSI A */
121 static struct resource fsi_resources[] = {
122         [0] = {
123                 .name   = "FSI",
124                 .start  = 0xEC230000,
125                 .end    = 0xEC230400 - 1,
126                 .flags  = IORESOURCE_MEM,
127         },
128         [1] = {
129                 .start  = gic_spi(146),
130                 .flags  = IORESOURCE_IRQ,
131         },
132 };
133
134 static struct platform_device fsi_device = {
135         .name           = "sh_fsi2",
136         .id             = -1,
137         .num_resources  = ARRAY_SIZE(fsi_resources),
138         .resource       = fsi_resources,
139 };
140
141 static struct resource sh_mmcif_resources[] = {
142         [0] = {
143                 .name   = "MMCIF",
144                 .start  = 0xe6bd0000,
145                 .end    = 0xe6bd00ff,
146                 .flags  = IORESOURCE_MEM,
147         },
148         [1] = {
149                 .start  = gic_spi(141),
150                 .flags  = IORESOURCE_IRQ,
151         },
152         [2] = {
153                 .start  = gic_spi(140),
154                 .flags  = IORESOURCE_IRQ,
155         },
156 };
157
158 static struct sh_mmcif_plat_data sh_mmcif_platdata = {
159         .sup_pclk       = 0,
160         .ocr            = MMC_VDD_165_195,
161         .caps           = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
162 };
163
164 static struct platform_device mmc_device = {
165         .name           = "sh_mmcif",
166         .id             = 0,
167         .dev            = {
168                 .dma_mask               = NULL,
169                 .coherent_dma_mask      = 0xffffffff,
170                 .platform_data          = &sh_mmcif_platdata,
171         },
172         .num_resources  = ARRAY_SIZE(sh_mmcif_resources),
173         .resource       = sh_mmcif_resources,
174 };
175
176 static struct platform_device *ag5evm_devices[] __initdata = {
177         &eth_device,
178         &keysc_device,
179         &fsi_device,
180         &mmc_device,
181 };
182
183 static struct map_desc ag5evm_io_desc[] __initdata = {
184         /* create a 1:1 entity map for 0xe6xxxxxx
185          * used by CPGA, INTC and PFC.
186          */
187         {
188                 .virtual        = 0xe6000000,
189                 .pfn            = __phys_to_pfn(0xe6000000),
190                 .length         = 256 << 20,
191                 .type           = MT_DEVICE_NONSHARED
192         },
193 };
194
195 static void __init ag5evm_map_io(void)
196 {
197         iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
198
199         /* setup early devices and console here as well */
200         sh73a0_add_early_devices();
201         shmobile_setup_console();
202 }
203
204 #define PINTC_ADDR      0xe6900000
205 #define PINTER0A        (PINTC_ADDR + 0xa0)
206 #define PINTCR0A        (PINTC_ADDR + 0xb0)
207
208 void __init ag5evm_init_irq(void)
209 {
210         sh73a0_init_irq();
211
212         /* setup PINT: enable PINTA2 as active low */
213         __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
214         __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
215 }
216
217 static void __init ag5evm_init(void)
218 {
219         sh73a0_pinmux_init();
220
221         /* enable SCIFA2 */
222         gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
223         gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
224         gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
225         gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
226
227         /* enable KEYSC */
228         gpio_request(GPIO_FN_KEYIN0_PU, NULL);
229         gpio_request(GPIO_FN_KEYIN1_PU, NULL);
230         gpio_request(GPIO_FN_KEYIN2_PU, NULL);
231         gpio_request(GPIO_FN_KEYIN3_PU, NULL);
232         gpio_request(GPIO_FN_KEYIN4_PU, NULL);
233         gpio_request(GPIO_FN_KEYIN5_PU, NULL);
234         gpio_request(GPIO_FN_KEYIN6_PU, NULL);
235         gpio_request(GPIO_FN_KEYIN7_PU, NULL);
236         gpio_request(GPIO_FN_KEYOUT0, NULL);
237         gpio_request(GPIO_FN_KEYOUT1, NULL);
238         gpio_request(GPIO_FN_KEYOUT2, NULL);
239         gpio_request(GPIO_FN_KEYOUT3, NULL);
240         gpio_request(GPIO_FN_KEYOUT4, NULL);
241         gpio_request(GPIO_FN_KEYOUT5, NULL);
242         gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
243         gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
244         gpio_request(GPIO_FN_KEYOUT8, NULL);
245         gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
246
247         /* enable I2C channel 2 and 3 */
248         gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
249         gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
250         gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
251         gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
252
253         /* enable MMCIF */
254         gpio_request(GPIO_FN_MMCCLK0, NULL);
255         gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
256         gpio_request(GPIO_FN_MMCD0_0, NULL);
257         gpio_request(GPIO_FN_MMCD0_1, NULL);
258         gpio_request(GPIO_FN_MMCD0_2, NULL);
259         gpio_request(GPIO_FN_MMCD0_3, NULL);
260         gpio_request(GPIO_FN_MMCD0_4, NULL);
261         gpio_request(GPIO_FN_MMCD0_5, NULL);
262         gpio_request(GPIO_FN_MMCD0_6, NULL);
263         gpio_request(GPIO_FN_MMCD0_7, NULL);
264         gpio_request(GPIO_PORT208, NULL); /* Reset */
265         gpio_direction_output(GPIO_PORT208, 1);
266
267         /* enable SMSC911X */
268         gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
269         gpio_direction_input(GPIO_PORT144);
270         gpio_request(GPIO_PORT145, NULL); /* RESET */
271         gpio_direction_output(GPIO_PORT145, 1);
272
273         /* FSI A */
274         gpio_request(GPIO_FN_FSIACK, NULL);
275         gpio_request(GPIO_FN_FSIAILR, NULL);
276         gpio_request(GPIO_FN_FSIAIBT, NULL);
277         gpio_request(GPIO_FN_FSIAISLD, NULL);
278         gpio_request(GPIO_FN_FSIAOSLD, NULL);
279
280 #ifdef CONFIG_CACHE_L2X0
281         /* Shared attribute override enable, 64K*8way */
282         l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
283 #endif
284         sh73a0_add_standard_devices();
285         platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
286 }
287
288 static void __init ag5evm_timer_init(void)
289 {
290         sh73a0_clock_init();
291         shmobile_timer.init();
292         return;
293 }
294
295 struct sys_timer ag5evm_timer = {
296         .init   = ag5evm_timer_init,
297 };
298
299 MACHINE_START(AG5EVM, "ag5evm")
300         .map_io         = ag5evm_map_io,
301         .init_irq       = ag5evm_init_irq,
302         .handle_irq     = shmobile_handle_irq_gic,
303         .init_machine   = ag5evm_init,
304         .timer          = &ag5evm_timer,
305 MACHINE_END