4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
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.
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.
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
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/interrupt.h>
23 #include <linux/irq.h>
24 #include <linux/platform_device.h>
25 #include <linux/delay.h>
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/usb/r8a66597.h>
31 #include <linux/input.h>
32 #include <linux/input/sh_keysc.h>
33 #include <linux/gpio.h>
34 #include <mach/sh7377.h>
35 #include <mach/common.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
40 static struct mtd_partition nor_flash_partitions
[] = {
48 .offset
= MTDPART_OFS_APPEND
,
53 .offset
= MTDPART_OFS_APPEND
,
54 .size
= 8 * 1024 * 1024,
55 .mask_flags
= MTD_WRITEABLE
,
59 .offset
= MTDPART_OFS_APPEND
,
60 .size
= 8 * 1024 * 1024,
64 .offset
= MTDPART_OFS_APPEND
,
65 .size
= MTDPART_SIZ_FULL
,
69 static struct physmap_flash_data nor_flash_data
= {
71 .parts
= nor_flash_partitions
,
72 .nr_parts
= ARRAY_SIZE(nor_flash_partitions
),
75 static struct resource nor_flash_resources
[] = {
78 .end
= 0x08000000 - 1,
79 .flags
= IORESOURCE_MEM
,
83 static struct platform_device nor_flash_device
= {
84 .name
= "physmap-flash",
86 .platform_data
= &nor_flash_data
,
88 .num_resources
= ARRAY_SIZE(nor_flash_resources
),
89 .resource
= nor_flash_resources
,
93 void usb_host_port_power(int port
, int power
)
95 if (!power
) /* only power-on supported for now */
98 /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
99 __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
102 static struct r8a66597_platdata usb_host_data
= {
104 .port_power
= usb_host_port_power
,
107 static struct resource usb_host_resources
[] = {
112 .flags
= IORESOURCE_MEM
,
117 .flags
= IORESOURCE_IRQ
,
121 static struct platform_device usb_host_device
= {
122 .name
= "r8a66597_hcd",
125 .platform_data
= &usb_host_data
,
127 .coherent_dma_mask
= 0xffffffff,
129 .num_resources
= ARRAY_SIZE(usb_host_resources
),
130 .resource
= usb_host_resources
,
134 static struct sh_keysc_info keysc_info
= {
135 .mode
= SH_KEYSC_MODE_5
,
139 KEY_A
, KEY_B
, KEY_C
, KEY_D
, KEY_E
, KEY_F
,
140 KEY_G
, KEY_H
, KEY_I
, KEY_J
, KEY_K
, KEY_L
,
141 KEY_M
, KEY_N
, KEY_U
, KEY_P
, KEY_Q
, KEY_R
,
142 KEY_S
, KEY_T
, KEY_U
, KEY_V
, KEY_W
, KEY_X
,
143 KEY_Y
, KEY_Z
, KEY_HOME
, KEY_SLEEP
, KEY_WAKEUP
, KEY_COFFEE
,
144 KEY_0
, KEY_1
, KEY_2
, KEY_3
, KEY_4
, KEY_5
,
145 KEY_6
, KEY_7
, KEY_8
, KEY_9
, KEY_STOP
, KEY_COMPUTER
,
149 static struct resource keysc_resources
[] = {
154 .flags
= IORESOURCE_MEM
,
158 .flags
= IORESOURCE_IRQ
,
162 static struct platform_device keysc_device
= {
164 .id
= 0, /* keysc0 clock */
165 .num_resources
= ARRAY_SIZE(keysc_resources
),
166 .resource
= keysc_resources
,
168 .platform_data
= &keysc_info
,
172 static struct platform_device
*g4evm_devices
[] __initdata
= {
178 static struct map_desc g4evm_io_desc
[] __initdata
= {
179 /* create a 1:1 entity map for 0xe6xxxxxx
180 * used by CPGA, INTC and PFC.
183 .virtual = 0xe6000000,
184 .pfn
= __phys_to_pfn(0xe6000000),
186 .type
= MT_DEVICE_NONSHARED
190 static void __init
g4evm_map_io(void)
192 iotable_init(g4evm_io_desc
, ARRAY_SIZE(g4evm_io_desc
));
194 /* setup early devices, clocks and console here as well */
195 sh7377_add_early_devices();
196 sh7367_clock_init(); /* use g3 clocks for now */
197 shmobile_setup_console();
200 static void __init
g4evm_init(void)
202 sh7377_pinmux_init();
205 gpio_request(GPIO_PORT109
, NULL
);
206 gpio_direction_output(GPIO_PORT109
, 1);
207 gpio_export(GPIO_PORT109
, 1);
210 gpio_request(GPIO_PORT110
, NULL
);
211 gpio_direction_output(GPIO_PORT110
, 1);
212 gpio_export(GPIO_PORT110
, 1);
215 gpio_request(GPIO_PORT112
, NULL
);
216 gpio_direction_output(GPIO_PORT112
, 1);
217 gpio_export(GPIO_PORT112
, 1);
220 gpio_request(GPIO_PORT113
, NULL
);
221 gpio_direction_output(GPIO_PORT113
, 1);
222 gpio_export(GPIO_PORT113
, 1);
225 gpio_request(GPIO_FN_VBUS_0
, NULL
);
226 gpio_request(GPIO_FN_PWEN
, NULL
);
227 gpio_request(GPIO_FN_OVCN
, NULL
);
228 gpio_request(GPIO_FN_OVCN2
, NULL
);
229 gpio_request(GPIO_FN_EXTLP
, NULL
);
230 gpio_request(GPIO_FN_IDIN
, NULL
);
232 /* enable clock in SMSTPCR3 */
233 __raw_writel(__raw_readl(0xe615013c) & ~(1 << 22), 0xe615013c);
236 __raw_writew(0x0200, 0xe605810a); /* USBCR1 */
237 __raw_writew(0x00e0, 0xe60581c0); /* CPFCH */
238 __raw_writew(0x6010, 0xe60581c6); /* CGPOSR */
239 __raw_writew(0x8a0a, 0xe605810c); /* USBCR2 */
242 gpio_request(GPIO_FN_PORT60_KEYOUT5
, NULL
);
243 gpio_request(GPIO_FN_PORT61_KEYOUT4
, NULL
);
244 gpio_request(GPIO_FN_PORT62_KEYOUT3
, NULL
);
245 gpio_request(GPIO_FN_PORT63_KEYOUT2
, NULL
);
246 gpio_request(GPIO_FN_PORT64_KEYOUT1
, NULL
);
247 gpio_request(GPIO_FN_PORT65_KEYOUT0
, NULL
);
248 gpio_request(GPIO_FN_PORT66_KEYIN0_PU
, NULL
);
249 gpio_request(GPIO_FN_PORT67_KEYIN1_PU
, NULL
);
250 gpio_request(GPIO_FN_PORT68_KEYIN2_PU
, NULL
);
251 gpio_request(GPIO_FN_PORT69_KEYIN3_PU
, NULL
);
252 gpio_request(GPIO_FN_PORT70_KEYIN4_PU
, NULL
);
253 gpio_request(GPIO_FN_PORT71_KEYIN5_PU
, NULL
);
254 gpio_request(GPIO_FN_PORT72_KEYIN6_PU
, NULL
);
256 sh7377_add_standard_devices();
258 platform_add_devices(g4evm_devices
, ARRAY_SIZE(g4evm_devices
));
261 MACHINE_START(G4EVM
, "g4evm")
262 .phys_io
= 0xe6000000,
263 .io_pg_offst
= ((0xe6000000) >> 18) & 0xfffc,
264 .map_io
= g4evm_map_io
,
265 .init_irq
= sh7377_init_irq
,
266 .init_machine
= g4evm_init
,
267 .timer
= &shmobile_timer
,