8ef01e6e68c66189d20664c597b57b814da8f99b
[librecmc/librecmc.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,2008 Gabor Juhos <juhosg at openwrt.org>
8  *
9  *  This program is free software; you can redistribute it and/or modify it
10  *  under the terms of the GNU General Public License version 2 as published
11  *  by the Free Software Foundation.
12  *
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17
18 #include <asm/bootinfo.h>
19 #include <asm/gpio.h>
20
21 #include <adm5120_defs.h>
22 #include <adm5120_irq.h>
23 #include <adm5120_board.h>
24 #include <adm5120_platform.h>
25 #include <adm5120_info.h>
26
27 static void switch_bank_gpio3(unsigned bank)
28 {
29         switch (bank) {
30         case 0:
31                 gpio_set_value(ADM5120_GPIO_PIN3, 0);
32                 break;
33         case 1:
34                 gpio_set_value(ADM5120_GPIO_PIN3, 1);
35                 break;
36         }
37 }
38
39 static void switch_bank_gpio5(unsigned bank)
40 {
41         switch (bank) {
42         case 0:
43                 gpio_set_value(ADM5120_GPIO_PIN5, 0);
44                 break;
45         case 1:
46                 gpio_set_value(ADM5120_GPIO_PIN5, 1);
47                 break;
48         }
49 }
50
51 static struct mtd_partition easy_partitions[] = {
52         {
53                 .name   = "admboot",
54                 .offset = 0,
55                 .size   = 64*1024,
56                 .mask_flags = MTD_WRITEABLE,
57         } , {
58                 .name   = "boardcfg",
59                 .offset = MTDPART_OFS_APPEND,
60                 .size   = 64*1024,
61         } , {
62                 .name   = "firmware",
63                 .offset = MTDPART_OFS_APPEND,
64                 .size   = MTDPART_SIZ_FULL,
65         }
66 };
67
68 static struct adm5120_pci_irq easy5120rt_pci_irqs[] __initdata = {
69         PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
70 };
71
72 static struct platform_device *easy5120pata_devices[] __initdata = {
73         &adm5120_flash0_device,
74         /* TODO: add VINETIC2 device? */
75 };
76
77 static struct platform_device *easy5120rt_devices[] __initdata = {
78         &adm5120_flash0_device,
79         &adm5120_hcd_device,
80 };
81
82 static struct platform_device *easy5120wvoip_devices[] __initdata = {
83         &adm5120_flash0_device,
84         /* TODO: add VINETIC2 device? */
85 };
86
87 static struct platform_device *easy83000_devices[] __initdata = {
88         &adm5120_flash0_device,
89         /* TODO: add VINAX device? */
90 };
91
92 static void __init easy_setup_pqfp(void)
93 {
94         gpio_request(ADM5120_GPIO_PIN3, NULL); /* for flash A20 line */
95         gpio_direction_output(ADM5120_GPIO_PIN3, 0);
96
97         /* setup data for flash0 device */
98         adm5120_flash0_data.switch_bank = switch_bank_gpio3;
99         adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
100         adm5120_flash0_data.parts = easy_partitions;
101
102         /* TODO: setup mac addresses */
103 }
104
105 static void __init easy_setup_bga(void)
106 {
107         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
108         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
109
110         /* setup data for flash0 device */
111         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
112         adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
113         adm5120_flash0_data.parts = easy_partitions;
114
115         /* TODO: setup mac addresses */
116 }
117
118 unsigned char easy5120rt_vlans[6] = {
119         0x41, 0x42, 0x44, 0x48, 0x50, 0x00
120 };
121
122 /*--------------------------------------------------------------------------*/
123
124 ADM5120_BOARD_START(EASY5120PATA, "Infineon EASY 5120P-ATA Reference Board")
125         .board_setup    = easy_setup_pqfp,
126         .eth_num_ports  = 6,
127         .num_devices    = ARRAY_SIZE(easy5120pata_devices),
128         .devices        = easy5120pata_devices,
129 ADM5120_BOARD_END
130
131 ADM5120_BOARD_START(EASY5120RT, "Infineon EASY 5120-RT Reference Board")
132         .board_setup    = easy_setup_bga,
133         .eth_num_ports  = 5,
134         .eth_vlans      = easy5120rt_vlans,
135         .num_devices    = ARRAY_SIZE(easy5120rt_devices),
136         .devices        = easy5120rt_devices,
137         .pci_nr_irqs    = ARRAY_SIZE(easy5120rt_pci_irqs),
138         .pci_irq_map    = easy5120rt_pci_irqs,
139 ADM5120_BOARD_END
140
141 ADM5120_BOARD_START(EASY5120WVOIP, "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 ADM5120_BOARD_END
147
148 ADM5120_BOARD_START(EASY83000, "Infineon EASY 83000 Reference Board")
149         .board_setup    = easy_setup_pqfp,
150         .eth_num_ports  = 6,
151         .num_devices    = ARRAY_SIZE(easy83000_devices),
152         .devices        = easy83000_devices,
153 ADM5120_BOARD_END