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>
30 #include <linux/smsc911x.h>
31 #include <linux/gpio.h>
32 #include <mach/common.h>
33 #include <mach/sh7372.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
39 * Address Interface BusWidth note
40 * ------------------------------------------------------------------
41 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
42 * 0x0800_0000 user area -
43 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
44 * 0x1400_0000 Ether (LAN9220) 16bit
45 * 0x1600_0000 user area - cannot use with NAND
46 * 0x1800_0000 user area -
48 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
54 * SW1 | SW2 | SW7 | NOR Flash ROM
55 * bit1 | bit1 bit2 | bit1 | Memory allocation
56 * ------+------------+------+------------------
57 * OFF | ON OFF | ON | Area 0
58 * OFF | ON OFF | OFF | Area 4
64 * SW1 | SW2 | SW7 | NAND Flash ROM
65 * bit1 | bit1 bit2 | bit2 | Memory allocation
66 * ------+------------+------+------------------
67 * OFF | ON OFF | ON | FCE 0
68 * OFF | ON OFF | OFF | FCE 1
75 * -----------------------
81 static struct mtd_partition nor_flash_partitions[] = {
89 .offset = MTDPART_OFS_APPEND,
94 .offset = MTDPART_OFS_APPEND,
95 .size = 8 * 1024 * 1024,
96 .mask_flags = MTD_WRITEABLE,
100 .offset = MTDPART_OFS_APPEND,
101 .size = 8 * 1024 * 1024,
105 .offset = MTDPART_OFS_APPEND,
106 .size = MTDPART_SIZ_FULL,
110 static struct physmap_flash_data nor_flash_data = {
112 .parts = nor_flash_partitions,
113 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
116 static struct resource nor_flash_resources[] = {
119 .end = 0x08000000 - 1,
120 .flags = IORESOURCE_MEM,
124 static struct platform_device nor_flash_device = {
125 .name = "physmap-flash",
127 .platform_data = &nor_flash_data,
129 .num_resources = ARRAY_SIZE(nor_flash_resources),
130 .resource = nor_flash_resources,
134 static struct resource smc911x_resources[] = {
137 .end = 0x16000000 - 1,
138 .flags = IORESOURCE_MEM,
141 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
145 static struct smsc911x_platform_config smsc911x_info = {
146 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
147 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
148 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
151 static struct platform_device smc911x_device = {
154 .num_resources = ARRAY_SIZE(smc911x_resources),
155 .resource = smc911x_resources,
157 .platform_data = &smsc911x_info,
161 static struct platform_device *ap4evb_devices[] __initdata = {
166 static struct map_desc ap4evb_io_desc[] __initdata = {
167 /* create a 1:1 entity map for 0xe6xxxxxx
168 * used by CPGA, INTC and PFC.
171 .virtual = 0xe6000000,
172 .pfn = __phys_to_pfn(0xe6000000),
174 .type = MT_DEVICE_NONSHARED
178 static void __init ap4evb_map_io(void)
180 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
182 /* setup early devices, clocks and console here as well */
183 sh7372_add_early_devices();
184 sh7367_clock_init(); /* use g3 clocks for now */
185 shmobile_setup_console();
188 static void __init ap4evb_init(void)
190 sh7372_pinmux_init();
193 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
194 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
196 /* enable SMSC911X */
197 gpio_request(GPIO_FN_CS5A, NULL);
198 gpio_request(GPIO_FN_IRQ6_39, NULL);
200 /* enable LED 1 - 4 */
201 gpio_request(GPIO_PORT185, NULL);
202 gpio_request(GPIO_PORT186, NULL);
203 gpio_request(GPIO_PORT187, NULL);
204 gpio_request(GPIO_PORT188, NULL);
205 gpio_direction_output(GPIO_PORT185, 1);
206 gpio_direction_output(GPIO_PORT186, 1);
207 gpio_direction_output(GPIO_PORT187, 1);
208 gpio_direction_output(GPIO_PORT188, 1);
209 gpio_export(GPIO_PORT185, 0);
210 gpio_export(GPIO_PORT186, 0);
211 gpio_export(GPIO_PORT187, 0);
212 gpio_export(GPIO_PORT188, 0);
214 /* enable Debug switch (S6) */
215 gpio_request(GPIO_PORT32, NULL);
216 gpio_request(GPIO_PORT33, NULL);
217 gpio_request(GPIO_PORT34, NULL);
218 gpio_request(GPIO_PORT35, NULL);
219 gpio_direction_input(GPIO_PORT32);
220 gpio_direction_input(GPIO_PORT33);
221 gpio_direction_input(GPIO_PORT34);
222 gpio_direction_input(GPIO_PORT35);
223 gpio_export(GPIO_PORT32, 0);
224 gpio_export(GPIO_PORT33, 0);
225 gpio_export(GPIO_PORT34, 0);
226 gpio_export(GPIO_PORT35, 0);
228 sh7372_add_standard_devices();
230 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
233 MACHINE_START(AP4EVB, "ap4evb")
234 .phys_io = 0xe6000000,
235 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
236 .map_io = ap4evb_map_io,
237 .init_irq = sh7372_init_irq,
238 .init_machine = ap4evb_init,
239 .timer = &shmobile_timer,