enable start-stop-daemon by default, i want to use this to clean up a few init script...
[15.05/openwrt.git] / target / linux / adm5120-2.6 / files / arch / mips / adm5120 / boards / zyxel.c
1 /*
2  *  $Id$
3  *
4  *  ZyXEL Prestige P-334/P-335 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_gpio5(unsigned bank)
36 {
37         switch (bank) {
38         case 0:
39                 gpio_set_value(ADM5120_GPIO_PIN5, 0);
40                 break;
41         case 1:
42                 gpio_set_value(ADM5120_GPIO_PIN5, 1);
43                 break;
44         }
45 }
46
47 static struct mtd_partition p33x_partitions[] = {
48         {
49                 .name   = "bootbase",
50                 .offset = 0,
51                 .size   = 16*1024,
52                 .mask_flags = MTD_WRITEABLE,
53         } , {
54                 .name   = "rom",
55                 .offset = MTDPART_OFS_APPEND,
56                 .size   = 16*1024,
57         } , {
58                 .name   = "bootext",
59                 .offset = MTDPART_OFS_APPEND,
60                 .size   = 96*1024,
61                 .mask_flags = MTD_WRITEABLE,
62         } , {
63                 .name   = "trx",
64                 .offset = MTDPART_OFS_APPEND,
65                 .size   = MTDPART_SIZ_FULL,
66         } , {
67                 .name   = "firmware",
68                 .offset = 32*1024,
69                 .size   = MTDPART_SIZ_FULL,
70         }
71 };
72
73 static struct platform_device *p334_devices[] __initdata = {
74         &adm5120_flash0_device,
75 };
76
77 static struct platform_device *p335_devices[] __initdata = {
78         &adm5120_flash0_device,
79         &adm5120_usbc_device,
80 };
81
82 static void __init p33x_setup(void)
83 {
84         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
85         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
86
87         /* setup data for flash0 device */
88         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
89         adm5120_flash0_data.nr_parts = ARRAY_SIZE(p33x_partitions);
90         adm5120_flash0_data.parts = p33x_partitions;
91
92         /* TODO: setup mac address */
93 }
94
95 unsigned char p33x_vlans[6] __initdata = {
96         /* FIXME: untested */
97         0x50, 0x48, 0x44, 0x42, 0x41, 0x00
98 };
99
100 static struct adm5120_board p334wt_board __initdata = {
101         .mach_type      = MACH_ADM5120_P334WT,
102         .name           = "ZyXEL Prestige 334WT",
103         .board_setup    = p33x_setup,
104         .eth_num_ports  = 5,
105         .eth_vlans      = p33x_vlans,
106         .num_devices    = ARRAY_SIZE(p334_devices),
107         .devices        = p334_devices,
108 };
109
110 static struct adm5120_board p335_board __initdata = {
111         .mach_type      = MACH_ADM5120_P335,
112         .name           = "ZyXEL Prestige 335/335WT",
113         .board_setup    = p33x_setup,
114         .eth_num_ports  = 5,
115         .eth_vlans      = p33x_vlans,
116         .num_devices    = ARRAY_SIZE(p335_devices),
117         .devices        = p335_devices,
118 };
119
120 static int __init register_boards(void)
121 {
122         adm5120_board_register(&p334wt_board);
123         adm5120_board_register(&p335_board);
124         return 0;
125 }
126
127 pure_initcall(register_boards);