blob: 70277e07380831d929a71f9d084d3b6aca75f73b [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 Morimoto1b7e0672010-02-17 09:30:14 +000038/* MTD */
Magnus Damm2b7eda62010-02-05 11:14:58 +000039static struct mtd_partition nor_flash_partitions[] = {
40 {
41 .name = "loader",
42 .offset = 0x00000000,
43 .size = 512 * 1024,
44 },
45 {
46 .name = "bootenv",
47 .offset = MTDPART_OFS_APPEND,
48 .size = 512 * 1024,
49 },
50 {
51 .name = "kernel_ro",
52 .offset = MTDPART_OFS_APPEND,
53 .size = 8 * 1024 * 1024,
54 .mask_flags = MTD_WRITEABLE,
55 },
56 {
57 .name = "kernel",
58 .offset = MTDPART_OFS_APPEND,
59 .size = 8 * 1024 * 1024,
60 },
61 {
62 .name = "data",
63 .offset = MTDPART_OFS_APPEND,
64 .size = MTDPART_SIZ_FULL,
65 },
66};
67
68static struct physmap_flash_data nor_flash_data = {
69 .width = 2,
70 .parts = nor_flash_partitions,
71 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
72};
73
74static struct resource nor_flash_resources[] = {
75 [0] = {
76 .start = 0x00000000,
77 .end = 0x08000000 - 1,
78 .flags = IORESOURCE_MEM,
79 }
80};
81
82static struct platform_device nor_flash_device = {
83 .name = "physmap-flash",
84 .dev = {
85 .platform_data = &nor_flash_data,
86 },
87 .num_resources = ARRAY_SIZE(nor_flash_resources),
88 .resource = nor_flash_resources,
89};
90
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000091/* SMSC 9220 */
92static struct resource smc911x_resources[] = {
93 {
94 .start = 0x14000000,
95 .end = 0x16000000 - 1,
96 .flags = IORESOURCE_MEM,
97 }, {
98 .start = 6,
99 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
100 },
101};
102
103static struct smsc911x_platform_config smsc911x_info = {
104 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
105 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
106 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
107};
108
109static struct platform_device smc911x_device = {
110 .name = "smsc911x",
111 .id = -1,
112 .num_resources = ARRAY_SIZE(smc911x_resources),
113 .resource = smc911x_resources,
114 .dev = {
115 .platform_data = &smsc911x_info,
116 },
117};
Magnus Damm2b7eda62010-02-05 11:14:58 +0000118
119static struct platform_device *ap4evb_devices[] __initdata = {
120 &nor_flash_device,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000121 &smc911x_device,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000122};
123
124static struct map_desc ap4evb_io_desc[] __initdata = {
125 /* create a 1:1 entity map for 0xe6xxxxxx
126 * used by CPGA, INTC and PFC.
127 */
128 {
129 .virtual = 0xe6000000,
130 .pfn = __phys_to_pfn(0xe6000000),
131 .length = 256 << 20,
132 .type = MT_DEVICE_NONSHARED
133 },
134};
135
136static void __init ap4evb_map_io(void)
137{
138 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
139
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000140 /* setup early devices, clocks and console here as well */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000141 sh7372_add_early_devices();
142 sh7367_clock_init(); /* use g3 clocks for now */
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000143 shmobile_setup_console();
Magnus Damm2b7eda62010-02-05 11:14:58 +0000144}
145
146static void __init ap4evb_init(void)
147{
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000148 sh7372_pinmux_init();
149
150 /* enable SMSC911X */
151 gpio_request(GPIO_FN_CS5A, NULL);
152 gpio_request(GPIO_FN_IRQ6_39, NULL);
153
Magnus Damm2b7eda62010-02-05 11:14:58 +0000154 sh7372_add_standard_devices();
155
156 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
157}
158
159MACHINE_START(AP4EVB, "ap4evb")
160 .phys_io = 0xe6000000,
161 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
162 .map_io = ap4evb_map_io,
163 .init_irq = sh7372_init_irq,
164 .init_machine = ap4evb_init,
165 .timer = &shmobile_timer,
166MACHINE_END