Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[pandora-kernel.git] / arch / mips / emma2rh / 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 #include <asm/debug.h>
39
40 #include <asm/emma2rh/emma2rh.h>
41
42
43 #define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */
44
45 static struct resource i2c_emma_resources_0[] = {
46         {
47                 .name   = NULL,
48                 .start  = EMMA2RH_IRQ_PIIC0,
49                 .end    = EMMA2RH_IRQ_PIIC0,
50                 .flags  = IORESOURCE_IRQ
51         }, {
52                 .name   = NULL,
53                 .start  = EMMA2RH_PIIC0_BASE,
54                 .end    = EMMA2RH_PIIC0_BASE + 0x1000,
55                 .flags  = 0
56         },
57 };
58
59 struct resource i2c_emma_resources_1[] = {
60         {
61                 .name   = NULL,
62                 .start  = EMMA2RH_IRQ_PIIC1,
63                 .end    = EMMA2RH_IRQ_PIIC1,
64                 .flags  = IORESOURCE_IRQ
65         }, {
66                 .name   = NULL,
67                 .start  = EMMA2RH_PIIC1_BASE,
68                 .end    = EMMA2RH_PIIC1_BASE + 0x1000,
69                 .flags  = 0
70         },
71 };
72
73 struct resource i2c_emma_resources_2[] = {
74         {
75                 .name   = NULL,
76                 .start  = EMMA2RH_IRQ_PIIC2,
77                 .end    = EMMA2RH_IRQ_PIIC2,
78                 .flags  = IORESOURCE_IRQ
79         }, {
80                 .name   = NULL,
81                 .start  = EMMA2RH_PIIC2_BASE,
82                 .end    = EMMA2RH_PIIC2_BASE + 0x1000,
83                 .flags  = 0
84         },
85 };
86
87 struct platform_device i2c_emma_devices[] = {
88         [0] = {
89                 .name = I2C_EMMA2RH,
90                 .id = 0,
91                 .resource = i2c_emma_resources_0,
92                 .num_resources = ARRAY_SIZE(i2c_emma_resources_0),
93         },
94         [1] = {
95                 .name = I2C_EMMA2RH,
96                 .id = 1,
97                 .resource = i2c_emma_resources_1,
98                 .num_resources = ARRAY_SIZE(i2c_emma_resources_1),
99         },
100         [2] = {
101                 .name = I2C_EMMA2RH,
102                 .id = 2,
103                 .resource = i2c_emma_resources_2,
104                 .num_resources = ARRAY_SIZE(i2c_emma_resources_2),
105         },
106 };
107
108 #define EMMA2RH_SERIAL_CLOCK 18544000
109 #define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST
110
111 static struct  plat_serial8250_port platform_serial_ports[] = {
112         [0] = {
113                 .membase= (void __iomem*)KSEG1ADDR(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                 .irq = EMMA2RH_IRQ_PFUR1,
122                 .uartclk = EMMA2RH_SERIAL_CLOCK,
123                 .regshift = 4,
124                 .iotype = UPIO_MEM,
125                 .flags = EMMA2RH_SERIAL_FLAGS,
126        }, [2] = {
127                 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3),
128                 .irq = EMMA2RH_IRQ_PFUR2,
129                 .uartclk = EMMA2RH_SERIAL_CLOCK,
130                 .regshift = 4,
131                 .iotype = UPIO_MEM,
132                 .flags = EMMA2RH_SERIAL_FLAGS,
133        }, [3] = {
134                 .flags = 0,
135        },
136 };
137
138 static struct  platform_device serial_emma = {
139         .name = "serial8250",
140         .dev = {
141                 .platform_data = &platform_serial_ports,
142         },
143 };
144
145 static struct platform_device *devices[] = {
146         &i2c_emma_devices[0],
147         &i2c_emma_devices[1],
148         &i2c_emma_devices[2],
149         &serial_emma,
150 };
151
152 static struct mtd_partition markeins_parts[] = {
153         [0] = {
154                 .name = "RootFS",
155                 .offset = 0x00000000,
156                 .size = 0x00c00000,
157         },
158         [1] = {
159                 .name = "boot code area",
160                 .offset = MTDPART_OFS_APPEND,
161                 .size = 0x00100000,
162         },
163         [2] = {
164                 .name = "kernel image",
165                 .offset = MTDPART_OFS_APPEND,
166                 .size = 0x00300000,
167         },
168         [3] = {
169                 .name = "RootFS2",
170                 .offset = MTDPART_OFS_APPEND,
171                 .size = 0x00c00000,
172         },
173         [4] = {
174                 .name = "boot code area2",
175                 .offset = MTDPART_OFS_APPEND,
176                 .size = 0x00100000,
177         },
178         [5] = {
179                 .name = "kernel image2",
180                 .offset = MTDPART_OFS_APPEND,
181                 .size = MTDPART_SIZ_FULL,
182         },
183 };
184
185 static int __init platform_devices_setup(void)
186 {
187         physmap_set_partitions(markeins_parts, ARRAY_SIZE(markeins_parts));
188         return platform_add_devices(devices, ARRAY_SIZE(devices));
189 }
190
191 arch_initcall(platform_devices_setup);
192