Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / arch / mips / emma / markeins / platform.c
1 /*
2  *  arch/mips/emma2rh/markeins/platofrm.c
3  *      This file sets up platform devices for EMMA2RH Mark-eins.
4  *
5  *  Copyright(C) MontaVista Software Inc, 2006
6  *
7  *  Author: dmitry pervushin <dpervushin@ru.mvista.com>
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23 #include <linux/init.h>
24 #include <linux/kernel.h>
25 #include <linux/types.h>
26 #include <linux/ioport.h>
27 #include <linux/serial_8250.h>
28 #include <linux/mtd/physmap.h>
29
30 #include <asm/cpu.h>
31 #include <asm/bootinfo.h>
32 #include <asm/addrspace.h>
33 #include <asm/time.h>
34 #include <asm/bcache.h>
35 #include <asm/irq.h>
36 #include <asm/reboot.h>
37 #include <asm/traps.h>
38
39 #include <asm/emma/emma2rh.h>
40
41
42 #define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */
43
44 static struct resource i2c_emma_resources_0[] = {
45         {
46                 .name   = NULL,
47                 .start  = EMMA2RH_IRQ_PIIC0,
48                 .end    = EMMA2RH_IRQ_PIIC0,
49                 .flags  = IORESOURCE_IRQ
50         }, {
51                 .name   = NULL,
52                 .start  = EMMA2RH_PIIC0_BASE,
53                 .end    = EMMA2RH_PIIC0_BASE + 0x1000,
54                 .flags  = 0
55         },
56 };
57
58 struct resource i2c_emma_resources_1[] = {
59         {
60                 .name   = NULL,
61                 .start  = EMMA2RH_IRQ_PIIC1,
62                 .end    = EMMA2RH_IRQ_PIIC1,
63                 .flags  = IORESOURCE_IRQ
64         }, {
65                 .name   = NULL,
66                 .start  = EMMA2RH_PIIC1_BASE,
67                 .end    = EMMA2RH_PIIC1_BASE + 0x1000,
68                 .flags  = 0
69         },
70 };
71
72 struct resource i2c_emma_resources_2[] = {
73         {
74                 .name   = NULL,
75                 .start  = EMMA2RH_IRQ_PIIC2,
76                 .end    = EMMA2RH_IRQ_PIIC2,
77                 .flags  = IORESOURCE_IRQ
78         }, {
79                 .name   = NULL,
80                 .start  = EMMA2RH_PIIC2_BASE,
81                 .end    = EMMA2RH_PIIC2_BASE + 0x1000,
82                 .flags  = 0
83         },
84 };
85
86 struct platform_device i2c_emma_devices[] = {
87         [0] = {
88                 .name = I2C_EMMA2RH,
89                 .id = 0,
90                 .resource = i2c_emma_resources_0,
91                 .num_resources = ARRAY_SIZE(i2c_emma_resources_0),
92         },
93         [1] = {
94                 .name = I2C_EMMA2RH,
95                 .id = 1,
96                 .resource = i2c_emma_resources_1,
97                 .num_resources = ARRAY_SIZE(i2c_emma_resources_1),
98         },
99         [2] = {
100                 .name = I2C_EMMA2RH,
101                 .id = 2,
102                 .resource = i2c_emma_resources_2,
103                 .num_resources = ARRAY_SIZE(i2c_emma_resources_2),
104         },
105 };
106
107 #define EMMA2RH_SERIAL_CLOCK 18544000
108 #define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST
109
110 static struct  plat_serial8250_port platform_serial_ports[] = {
111         [0] = {
112                 .membase= (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3),
113                 .mapbase = EMMA2RH_PFUR0_BASE + 3,
114                 .irq = EMMA2RH_IRQ_PFUR0,
115                 .uartclk = EMMA2RH_SERIAL_CLOCK,
116                 .regshift = 4,
117                 .iotype = UPIO_MEM,
118                 .flags = EMMA2RH_SERIAL_FLAGS,
119        }, [1] = {
120                 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3),
121                 .mapbase = EMMA2RH_PFUR1_BASE + 3,
122                 .irq = EMMA2RH_IRQ_PFUR1,
123                 .uartclk = EMMA2RH_SERIAL_CLOCK,
124                 .regshift = 4,
125                 .iotype = UPIO_MEM,
126                 .flags = EMMA2RH_SERIAL_FLAGS,
127        }, [2] = {
128                 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3),
129                 .mapbase = EMMA2RH_PFUR2_BASE + 3,
130                 .irq = EMMA2RH_IRQ_PFUR2,
131                 .uartclk = EMMA2RH_SERIAL_CLOCK,
132                 .regshift = 4,
133                 .iotype = UPIO_MEM,
134                 .flags = EMMA2RH_SERIAL_FLAGS,
135        }, [3] = {
136                 .flags = 0,
137        },
138 };
139
140 static struct  platform_device serial_emma = {
141         .name = "serial8250",
142         .dev = {
143                 .platform_data = &platform_serial_ports,
144         },
145 };
146
147 static struct mtd_partition markeins_parts[] = {
148         [0] = {
149                 .name = "RootFS",
150                 .offset = 0x00000000,
151                 .size = 0x00c00000,
152         },
153         [1] = {
154                 .name = "boot code area",
155                 .offset = MTDPART_OFS_APPEND,
156                 .size = 0x00100000,
157         },
158         [2] = {
159                 .name = "kernel image",
160                 .offset = MTDPART_OFS_APPEND,
161                 .size = 0x00300000,
162         },
163         [3] = {
164                 .name = "RootFS2",
165                 .offset = MTDPART_OFS_APPEND,
166                 .size = 0x00c00000,
167         },
168         [4] = {
169                 .name = "boot code area2",
170                 .offset = MTDPART_OFS_APPEND,
171                 .size = 0x00100000,
172         },
173         [5] = {
174                 .name = "kernel image2",
175                 .offset = MTDPART_OFS_APPEND,
176                 .size = MTDPART_SIZ_FULL,
177         },
178 };
179
180 static struct physmap_flash_data markeins_flash_data = {
181         .width          = 2,
182         .nr_parts       = ARRAY_SIZE(markeins_parts),
183         .parts          = markeins_parts
184 };
185
186 static struct resource markeins_flash_resource = {
187         .start          = 0x1e000000,
188         .end            = 0x02000000,
189         .flags          = IORESOURCE_MEM
190 };
191
192 static struct platform_device markeins_flash_device = {
193         .name           = "physmap-flash",
194         .id             = 0,
195         .dev            = {
196                 .platform_data  = &markeins_flash_data,
197         },
198         .num_resources  = 1,
199         .resource       = &markeins_flash_resource,
200 };
201
202 static struct platform_device *devices[] = {
203         i2c_emma_devices,
204         i2c_emma_devices + 1,
205         i2c_emma_devices + 2,
206         &serial_emma,
207         &markeins_flash_device,
208 };
209
210 static int __init platform_devices_setup(void)
211 {
212         return platform_add_devices(devices, ARRAY_SIZE(devices));
213 }
214
215 arch_initcall(platform_devices_setup);