[adm5120] checkin a new, experimental USB driver
[15.05/openwrt.git] / target / linux / adm5120 / files / arch / mips / adm5120 / boards / infineon.c
1 /*
2  *  $Id$
3  *
4  *  Infineon boards
5  *
6  *  Copyright (C) 2007 OpenWrt.org
7  *  Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
8  *
9  *  This program is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU General Public License
11  *  as published by the Free Software Foundation; either version 2
12  *  of the License, or (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
21  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA  02110-1301, USA.
23  *
24  */
25
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28
29 #include <asm/bootinfo.h>
30 #include <asm/gpio.h>
31
32 #include <asm/mach-adm5120/adm5120_board.h>
33 #include <asm/mach-adm5120/adm5120_platform.h>
34
35 static void switch_bank_gpio3(unsigned bank)
36 {
37         switch (bank) {
38         case 0:
39                 gpio_set_value(ADM5120_GPIO_PIN3, 0);
40                 break;
41         case 1:
42                 gpio_set_value(ADM5120_GPIO_PIN3, 1);
43                 break;
44         }
45 }
46
47 static void switch_bank_gpio5(unsigned bank)
48 {
49         switch (bank) {
50         case 0:
51                 gpio_set_value(ADM5120_GPIO_PIN5, 0);
52                 break;
53         case 1:
54                 gpio_set_value(ADM5120_GPIO_PIN5, 1);
55                 break;
56         }
57 }
58
59 static struct mtd_partition easy_partitions[] = {
60         {
61                 .name   = "admboot",
62                 .offset = 0,
63                 .size   = 64*1024,
64                 .mask_flags = MTD_WRITEABLE,
65         } , {
66                 .name   = "boardcfg",
67                 .offset = MTDPART_OFS_APPEND,
68                 .size   = 64*1024,
69         } , {
70                 .name   = "firmware",
71                 .offset = MTDPART_OFS_APPEND,
72                 .size   = MTDPART_SIZ_FULL,
73         }
74 };
75
76 static struct platform_device *easy5120pata_devices[] __initdata = {
77         &adm5120_flash0_device,
78         /* TODO: add VINETIC2 device? */
79 };
80
81 static struct platform_device *easy5120rt_devices[] __initdata = {
82         &adm5120_flash0_device,
83 };
84
85 static struct platform_device *easy5120wvoip_devices[] __initdata = {
86         &adm5120_flash0_device,
87         /* TODO: add VINETIC2 device? */
88 };
89
90 static struct platform_device *easy83000_devices[] __initdata = {
91         &adm5120_flash0_device,
92         /* TODO: add VINAX device? */
93 };
94
95 static void __init easy_setup_pqfp(void)
96 {
97         gpio_request(ADM5120_GPIO_PIN3, NULL); /* for flash A20 line */
98         gpio_direction_output(ADM5120_GPIO_PIN3, 0);
99
100         /* setup data for flash0 device */
101         adm5120_flash0_data.switch_bank = switch_bank_gpio3;
102         adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
103         adm5120_flash0_data.parts = easy_partitions;
104
105         /* TODO: setup mac addresses */
106 }
107
108 static void __init easy_setup_bga(void)
109 {
110         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
111         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
112
113         /* setup data for flash0 device */
114         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
115         adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
116         adm5120_flash0_data.parts = easy_partitions;
117
118         /* TODO: setup mac addresses */
119 }
120
121 static struct adm5120_board easy5120pata_board __initdata = {
122         .mach_type      = MACH_ADM5120_EASY5120PATA,
123         .name           = "Infineon EASY 5120P-ATA Reference Board",
124         .board_setup    = easy_setup_pqfp,
125         .eth_num_ports  = 6,
126         .num_devices    = ARRAY_SIZE(easy5120pata_devices),
127         .devices        = easy5120pata_devices,
128 };
129
130 static struct adm5120_board easy5120rt_board __initdata = {
131         .mach_type      = MACH_ADM5120_EASY5120RT,
132         .name           = "Infineon EASY 5120-RT Reference Board",
133         .board_setup    = easy_setup_bga,
134         .eth_num_ports  = 5,
135         .num_devices    = ARRAY_SIZE(easy5120rt_devices),
136         .devices        = easy5120rt_devices,
137 };
138
139 static struct adm5120_board easy5120wvoip_board __initdata = {
140         .mach_type      = MACH_ADM5120_EASY5120WVOIP,
141         .name           = "Infineon EASY 5120-WVoIP Reference Board",
142         .board_setup    = easy_setup_bga,
143         .eth_num_ports  = 6,
144         .num_devices    = ARRAY_SIZE(easy5120wvoip_devices),
145         .devices        = easy5120wvoip_devices,
146 };
147
148 static struct adm5120_board easy83000_board __initdata = {
149         .mach_type      = MACH_ADM5120_EASY83000,
150         .name           = "Infineon EASY 83000 Reference Board",
151         .board_setup    = easy_setup_pqfp,
152         .eth_num_ports  = 6,
153         .num_devices    = ARRAY_SIZE(easy83000_devices),
154         .devices        = easy83000_devices,
155 };
156
157 static int __init register_boards(void)
158 {
159         adm5120_board_register(&easy5120pata_board);
160         adm5120_board_register(&easy5120rt_board);
161         adm5120_board_register(&easy5120wvoip_board);
162         adm5120_board_register(&easy83000_board);
163         return 0;
164 }
165
166 pure_initcall(register_boards);