blob: ef4b0f59af4924a29c71193f6ffc5cbe1948ad03 [file] [log] [blame]
Magnus Dammf2aaf662010-02-05 11:15:07 +00001/*
2 * G4EVM 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>
NISHIMOTO Hiroki276b4f62010-02-12 08:10:06 +000030#include <linux/gpio.h>
31#include <mach/sh7377.h>
Magnus Dammf2aaf662010-02-05 11:15:07 +000032#include <mach/common.h>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36
37static struct mtd_partition nor_flash_partitions[] = {
38 {
39 .name = "loader",
40 .offset = 0x00000000,
41 .size = 512 * 1024,
42 },
43 {
44 .name = "bootenv",
45 .offset = MTDPART_OFS_APPEND,
46 .size = 512 * 1024,
47 },
48 {
49 .name = "kernel_ro",
50 .offset = MTDPART_OFS_APPEND,
51 .size = 8 * 1024 * 1024,
52 .mask_flags = MTD_WRITEABLE,
53 },
54 {
55 .name = "kernel",
56 .offset = MTDPART_OFS_APPEND,
57 .size = 8 * 1024 * 1024,
58 },
59 {
60 .name = "data",
61 .offset = MTDPART_OFS_APPEND,
62 .size = MTDPART_SIZ_FULL,
63 },
64};
65
66static struct physmap_flash_data nor_flash_data = {
67 .width = 2,
68 .parts = nor_flash_partitions,
69 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
70};
71
72static struct resource nor_flash_resources[] = {
73 [0] = {
74 .start = 0x00000000,
75 .end = 0x08000000 - 1,
76 .flags = IORESOURCE_MEM,
77 }
78};
79
80static struct platform_device nor_flash_device = {
81 .name = "physmap-flash",
82 .dev = {
83 .platform_data = &nor_flash_data,
84 },
85 .num_resources = ARRAY_SIZE(nor_flash_resources),
86 .resource = nor_flash_resources,
87};
88
89
90static struct platform_device *g4evm_devices[] __initdata = {
91 &nor_flash_device,
92};
93
94static struct map_desc g4evm_io_desc[] __initdata = {
95 /* create a 1:1 entity map for 0xe6xxxxxx
96 * used by CPGA, INTC and PFC.
97 */
98 {
99 .virtual = 0xe6000000,
100 .pfn = __phys_to_pfn(0xe6000000),
101 .length = 256 << 20,
102 .type = MT_DEVICE_NONSHARED
103 },
104};
105
106static void __init g4evm_map_io(void)
107{
108 iotable_init(g4evm_io_desc, ARRAY_SIZE(g4evm_io_desc));
109
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000110 /* setup early devices, clocks and console here as well */
Magnus Dammf2aaf662010-02-05 11:15:07 +0000111 sh7377_add_early_devices();
112 sh7367_clock_init(); /* use g3 clocks for now */
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000113 shmobile_setup_console();
Magnus Dammf2aaf662010-02-05 11:15:07 +0000114}
115
116static void __init g4evm_init(void)
117{
NISHIMOTO Hiroki276b4f62010-02-12 08:10:06 +0000118 sh7377_pinmux_init();
119
120 /* Lit DS14 LED */
121 gpio_request(GPIO_PORT109, NULL);
122 gpio_direction_output(GPIO_PORT109, 1);
123 gpio_export(GPIO_PORT109, 1);
124
125 /* Lit DS15 LED */
126 gpio_request(GPIO_PORT110, NULL);
127 gpio_direction_output(GPIO_PORT110, 1);
128 gpio_export(GPIO_PORT110, 1);
129
130 /* Lit DS16 LED */
131 gpio_request(GPIO_PORT112, NULL);
132 gpio_direction_output(GPIO_PORT112, 1);
133 gpio_export(GPIO_PORT112, 1);
134
135 /* Lit DS17 LED */
136 gpio_request(GPIO_PORT113, NULL);
137 gpio_direction_output(GPIO_PORT113, 1);
138 gpio_export(GPIO_PORT113, 1);
139
Magnus Dammf2aaf662010-02-05 11:15:07 +0000140 sh7377_add_standard_devices();
141
142 platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
143}
144
145MACHINE_START(G4EVM, "g4evm")
146 .phys_io = 0xe6000000,
147 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
148 .map_io = g4evm_map_io,
149 .init_irq = sh7377_init_irq,
150 .init_machine = g4evm_init,
151 .timer = &shmobile_timer,
152MACHINE_END