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/gpio.h>
32 #include <mach/sh7377.h>
33 #include <mach/common.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
38 static struct mtd_partition nor_flash_partitions[] = {
46 .offset = MTDPART_OFS_APPEND,
51 .offset = MTDPART_OFS_APPEND,
52 .size = 8 * 1024 * 1024,
53 .mask_flags = MTD_WRITEABLE,
57 .offset = MTDPART_OFS_APPEND,
58 .size = 8 * 1024 * 1024,
62 .offset = MTDPART_OFS_APPEND,
63 .size = MTDPART_SIZ_FULL,
67 static struct physmap_flash_data nor_flash_data = {
69 .parts = nor_flash_partitions,
70 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
73 static struct resource nor_flash_resources[] = {
76 .end = 0x08000000 - 1,
77 .flags = IORESOURCE_MEM,
81 static struct platform_device nor_flash_device = {
82 .name = "physmap-flash",
84 .platform_data = &nor_flash_data,
86 .num_resources = ARRAY_SIZE(nor_flash_resources),
87 .resource = nor_flash_resources,
91 void usb_host_port_power(int port, int power)
93 if (!power) /* only power-on supported for now */
96 /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
97 __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
100 static struct r8a66597_platdata usb_host_data = {
102 .port_power = usb_host_port_power,
105 static struct resource usb_host_resources[] = {
110 .flags = IORESOURCE_MEM,
115 .flags = IORESOURCE_IRQ,
119 static struct platform_device usb_host_device = {
120 .name = "r8a66597_hcd",
123 .platform_data = &usb_host_data,
125 .coherent_dma_mask = 0xffffffff,
127 .num_resources = ARRAY_SIZE(usb_host_resources),
128 .resource = usb_host_resources,
131 static struct platform_device *g4evm_devices[] __initdata = {
136 static struct map_desc g4evm_io_desc[] __initdata = {
137 /* create a 1:1 entity map for 0xe6xxxxxx
138 * used by CPGA, INTC and PFC.
141 .virtual = 0xe6000000,
142 .pfn = __phys_to_pfn(0xe6000000),
144 .type = MT_DEVICE_NONSHARED
148 static void __init g4evm_map_io(void)
150 iotable_init(g4evm_io_desc, ARRAY_SIZE(g4evm_io_desc));
152 /* setup early devices, clocks and console here as well */
153 sh7377_add_early_devices();
154 sh7367_clock_init(); /* use g3 clocks for now */
155 shmobile_setup_console();
158 static void __init g4evm_init(void)
160 sh7377_pinmux_init();
163 gpio_request(GPIO_PORT109, NULL);
164 gpio_direction_output(GPIO_PORT109, 1);
165 gpio_export(GPIO_PORT109, 1);
168 gpio_request(GPIO_PORT110, NULL);
169 gpio_direction_output(GPIO_PORT110, 1);
170 gpio_export(GPIO_PORT110, 1);
173 gpio_request(GPIO_PORT112, NULL);
174 gpio_direction_output(GPIO_PORT112, 1);
175 gpio_export(GPIO_PORT112, 1);
178 gpio_request(GPIO_PORT113, NULL);
179 gpio_direction_output(GPIO_PORT113, 1);
180 gpio_export(GPIO_PORT113, 1);
183 gpio_request(GPIO_FN_VBUS_0, NULL);
184 gpio_request(GPIO_FN_PWEN, NULL);
185 gpio_request(GPIO_FN_OVCN, NULL);
186 gpio_request(GPIO_FN_OVCN2, NULL);
187 gpio_request(GPIO_FN_EXTLP, NULL);
188 gpio_request(GPIO_FN_IDIN, NULL);
190 /* enable clock in SMSTPCR3 */
191 __raw_writel(__raw_readl(0xe615013c) & ~(1 << 22), 0xe615013c);
194 __raw_writew(0x0200, 0xe605810a); /* USBCR1 */
195 __raw_writew(0x00e0, 0xe60581c0); /* CPFCH */
196 __raw_writew(0x6010, 0xe60581c6); /* CGPOSR */
197 __raw_writew(0x8a0a, 0xe605810c); /* USBCR2 */
199 sh7377_add_standard_devices();
201 platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
204 MACHINE_START(G4EVM, "g4evm")
205 .phys_io = 0xe6000000,
206 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
207 .map_io = g4evm_map_io,
208 .init_irq = sh7377_init_irq,
209 .init_machine = g4evm_init,
210 .timer = &shmobile_timer,