]> Pileus Git - ~andy/linux/blob - arch/arm/mach-shmobile/board-ap4evb.c
ARM: mach-shmobile: ap4evb: Add tiny document
[~andy/linux] / arch / arm / mach-shmobile / board-ap4evb.c
1 /*
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>
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>
37
38 /*
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
80 /* MTD */
81 static 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
110 static 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
116 static struct resource nor_flash_resources[] = {
117         [0]     = {
118                 .start  = 0x00000000,
119                 .end    = 0x08000000 - 1,
120                 .flags  = IORESOURCE_MEM,
121         }
122 };
123
124 static 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
133 /* SMSC 9220 */
134 static 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
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,
149 };
150
151 static 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 };
160
161 static struct platform_device *ap4evb_devices[] __initdata = {
162         &nor_flash_device,
163         &smc911x_device,
164 };
165
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.
169          */
170         {
171                 .virtual        = 0xe6000000,
172                 .pfn            = __phys_to_pfn(0xe6000000),
173                 .length         = 256 << 20,
174                 .type           = MT_DEVICE_NONSHARED
175         },
176 };
177
178 static void __init ap4evb_map_io(void)
179 {
180         iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
181
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();
186 }
187
188 static void __init ap4evb_init(void)
189 {
190         sh7372_pinmux_init();
191
192         /* enable SCIFA0 */
193         gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
194         gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
195
196         /* enable SMSC911X */
197         gpio_request(GPIO_FN_CS5A,      NULL);
198         gpio_request(GPIO_FN_IRQ6_39,   NULL);
199
200         sh7372_add_standard_devices();
201
202         platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
203 }
204
205 MACHINE_START(AP4EVB, "ap4evb")
206         .phys_io        = 0xe6000000,
207         .io_pg_offst    = ((0xe6000000) >> 18) & 0xfffc,
208         .map_io         = ap4evb_map_io,
209         .init_irq       = sh7372_init_irq,
210         .init_machine   = ap4evb_init,
211         .timer          = &shmobile_timer,
212 MACHINE_END