blob: d9a46d0ce01c431cbac9c447ecd8075009598f6c [file] [log] [blame]
Magnus Damm2b7eda62010-02-05 11:14:58 +00001/*
2 * AP4EVB board support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
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#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/io.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000030#include <linux/smsc911x.h>
31#include <linux/gpio.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000032#include <mach/common.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000033#include <mach/sh7372.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000034#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37
Kuninori Morimoto02624a12010-02-18 17:58:19 +090038/*
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 -
47 * 0x1A00_0000 -
48 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
49 */
50
51/*
52 * NOR Flash ROM
53 *
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
59 */
60
61/*
62 * NAND Flash ROM
63 *
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
69 */
70
71/*
72 * SMSC 9220
73 *
74 * SW1 SMSC 9220
75 * -----------------------
76 * ON access disable
77 * OFF access enable
78 */
79
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000080/* MTD */
Magnus Damm2b7eda62010-02-05 11:14:58 +000081static struct mtd_partition nor_flash_partitions[] = {
82 {
83 .name = "loader",
84 .offset = 0x00000000,
85 .size = 512 * 1024,
86 },
87 {
88 .name = "bootenv",
89 .offset = MTDPART_OFS_APPEND,
90 .size = 512 * 1024,
91 },
92 {
93 .name = "kernel_ro",
94 .offset = MTDPART_OFS_APPEND,
95 .size = 8 * 1024 * 1024,
96 .mask_flags = MTD_WRITEABLE,
97 },
98 {
99 .name = "kernel",
100 .offset = MTDPART_OFS_APPEND,
101 .size = 8 * 1024 * 1024,
102 },
103 {
104 .name = "data",
105 .offset = MTDPART_OFS_APPEND,
106 .size = MTDPART_SIZ_FULL,
107 },
108};
109
110static struct physmap_flash_data nor_flash_data = {
111 .width = 2,
112 .parts = nor_flash_partitions,
113 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
114};
115
116static struct resource nor_flash_resources[] = {
117 [0] = {
118 .start = 0x00000000,
119 .end = 0x08000000 - 1,
120 .flags = IORESOURCE_MEM,
121 }
122};
123
124static struct platform_device nor_flash_device = {
125 .name = "physmap-flash",
126 .dev = {
127 .platform_data = &nor_flash_data,
128 },
129 .num_resources = ARRAY_SIZE(nor_flash_resources),
130 .resource = nor_flash_resources,
131};
132
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000133/* SMSC 9220 */
134static struct resource smc911x_resources[] = {
135 {
136 .start = 0x14000000,
137 .end = 0x16000000 - 1,
138 .flags = IORESOURCE_MEM,
139 }, {
140 .start = 6,
141 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
142 },
143};
144
145static 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,
149};
150
151static struct platform_device smc911x_device = {
152 .name = "smsc911x",
153 .id = -1,
154 .num_resources = ARRAY_SIZE(smc911x_resources),
155 .resource = smc911x_resources,
156 .dev = {
157 .platform_data = &smsc911x_info,
158 },
159};
Magnus Damm2b7eda62010-02-05 11:14:58 +0000160
161static struct platform_device *ap4evb_devices[] __initdata = {
162 &nor_flash_device,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000163 &smc911x_device,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000164};
165
166static struct map_desc ap4evb_io_desc[] __initdata = {
167 /* create a 1:1 entity map for 0xe6xxxxxx
168 * used by CPGA, INTC and PFC.
169 */
170 {
171 .virtual = 0xe6000000,
172 .pfn = __phys_to_pfn(0xe6000000),
173 .length = 256 << 20,
174 .type = MT_DEVICE_NONSHARED
175 },
176};
177
178static void __init ap4evb_map_io(void)
179{
180 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
181
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000182 /* setup early devices, clocks and console here as well */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000183 sh7372_add_early_devices();
184 sh7367_clock_init(); /* use g3 clocks for now */
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000185 shmobile_setup_console();
Magnus Damm2b7eda62010-02-05 11:14:58 +0000186}
187
188static void __init ap4evb_init(void)
189{
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000190 sh7372_pinmux_init();
191
Kuninori Morimotob228b482010-02-18 16:44:41 +0900192 /* enable SCIFA0 */
193 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
194 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
195
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000196 /* enable SMSC911X */
197 gpio_request(GPIO_FN_CS5A, NULL);
198 gpio_request(GPIO_FN_IRQ6_39, NULL);
199
Kuninori Morimoto50982802010-02-22 09:20:39 +0000200 /* 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);
213
Kuninori Morimoto8cb3a2e2010-02-22 09:30:12 +0000214 /* 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);
227
Magnus Damm2b7eda62010-02-05 11:14:58 +0000228 sh7372_add_standard_devices();
229
230 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
231}
232
233MACHINE_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,
240MACHINE_END