turned ifxmips mtd driver into a platform device
[openwrt-10.03/.git] / target / linux / ifxmips / files / arch / mips / ifxmips / board.c
1 /*
2  *   arch/mips/ifxmips/board.c
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 2 of the License, or
7  *   (at your option) any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *   GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program; if not, write to the Free Software
16  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17  *
18  *   Copyright (C) 2007 John Crispin <blogic@openwrt.org> 
19  *
20  */
21
22 #include <linux/autoconf.h>
23 #include <linux/init.h>
24 #include <linux/module.h>
25 #include <linux/types.h>
26 #include <linux/string.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/kernel.h>
29 #include <linux/reboot.h>
30 #include <linux/platform_device.h> 
31 #include <asm/bootinfo.h>
32 #include <asm/reboot.h>
33 #include <asm/time.h>
34 #include <asm/irq.h>
35 #include <asm/io.h>
36 #include <asm/ifxmips/ifxmips.h>
37
38 #define MAX_IFXMIPS_DEVS                5
39
40 #define BOARD_DANUBE                    "Danube"
41 #define BOARD_DANUBE_CHIPID             0x10129083
42
43 #define BOARD_TWINPASS                  "Twinpass"
44
45 #define BOARD_DANUBE                    "Danube"
46
47 static unsigned int chiprev;
48
49 static struct platform_device *ifxmips_devs[MAX_IFXMIPS_DEVS];
50
51 static struct platform_device ifxmips_led[] =
52 {
53         {
54                 .id = 0,
55                 .name = "ifxmips_led",
56         },
57 };
58
59 static struct platform_device ifxmips_gpio[] =
60 {
61         {
62                 .id = 0,
63                 .name = "ifxmips_gpio",
64         },
65 };
66
67 static struct platform_device ifxmips_mii[] =
68 {
69         {
70                 .id = 0,
71                 .name = "ifxmips_mii0",
72         },
73 };
74         
75 static struct physmap_flash_data ifxmips_mtd_data = {
76         .width    = 2,
77 };
78
79 static struct resource ifxmips_mtd_resource = {
80         .start  = IFXMIPS_FLASH_START,
81         .end    = IFXMIPS_FLASH_START + IFXMIPS_FLASH_MAX - 1,
82         .flags  = IORESOURCE_MEM,
83 };
84
85 static struct platform_device ifxmips_mtd[] =
86 {
87         {
88                 .id = 0,
89                 .name = "ifxmips_mtd",
90                 .dev = {
91                         .platform_data = &ifxmips_mtd_data,
92                 },
93                 .num_resources  = 1,
94                 .resource   = &ifxmips_mtd_resource,
95         },
96 };
97
98 const char*
99 get_system_type (void)
100 {
101         chiprev = readl(IFXMIPS_MPS_CHIPID);
102         switch(chiprev)
103         {
104         case BOARD_DANUBE_CHIPID:
105                 return BOARD_DANUBE;
106         }
107
108         return BOARD_SYSTEM_TYPE;
109 }
110
111 int __init ifxmips_init_devices(void)
112 {
113         /*
114         *       This is where we detect what chip we are running on
115         *       Currently we support 3 chips
116         *       1.) Danube
117         *       2.) Twinpass (Danube without dsl phy)
118         *       3.) KDbg74 (used for debuging)
119         */
120
121         int dev = 0;
122
123         /* the following devices are generic for all targets */
124
125         ifxmips_devs[dev++] = ifxmips_led;
126         ifxmips_devs[dev++] = ifxmips_gpio;
127         ifxmips_devs[dev++] = ifxmips_mii;
128         ifxmips_devs[dev++] = ifxmips_mtd;
129
130         return platform_add_devices(ifxmips_devs, dev);
131 }
132
133 arch_initcall(ifxmips_init_devices);