[adm5120] fix of the board specific initialization of the GPIO pins
[openwrt/svn-archive/archive.git] / target / linux / adm5120-2.6 / 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@freemail.hu>
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 struct mtd_partition easy83000_partitions[] = {
48 {
49 .name = "admboot",
50 .offset = 0,
51 .size = 64*1024,
52 .mask_flags = MTD_WRITEABLE,
53 } , {
54 .name = "boardcfg",
55 .offset = MTDPART_OFS_APPEND,
56 .size = 64*1024,
57 } , {
58 .name = "firmware",
59 .offset = MTDPART_OFS_APPEND,
60 .size = MTDPART_SIZ_FULL,
61 }
62 };
63
64 static struct platform_device *easy83000_devices[] __initdata = {
65 &adm5120_flash0_device,
66 };
67
68 static void __init easy83000_setup(void)
69 {
70 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for flash A20 line */
71 gpio_direction_output(ADM5120_GPIO_PIN3, 0);
72
73 /* setup data for flash0 device */
74 adm5120_flash0_data.switch_bank = switch_bank_gpio3;
75 adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy83000_partitions);
76 adm5120_flash0_data.parts = easy83000_partitions;
77
78 /* TODO: setup mac addresses */
79 }
80
81 static struct adm5120_board easy83000_board __initdata = {
82 .mach_type = MACH_ADM5120_EASY83000,
83 .name = "Infineon EASY-83000",
84 .board_setup = easy83000_setup,
85 .num_eth_ports = 6,
86 .num_devices = ARRAY_SIZE(easy83000_devices),
87 .devices = easy83000_devices,
88 };
89
90 static int __init register_boards(void)
91 {
92 adm5120_board_register(&easy83000_board);
93 return 0;
94 }
95
96 pure_initcall(register_boards);