| 1 |
/* |
|---|
| 2 |
* $Id: compex.c 9423 2007-10-24 08:19:16Z juhosg $ |
|---|
| 3 |
* |
|---|
| 4 |
* Compex 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 <adm5120_board.h> |
|---|
| 33 |
#include <adm5120_platform.h> |
|---|
| 34 |
#include <adm5120_irq.h> |
|---|
| 35 |
|
|---|
| 36 |
static struct adm5120_pci_irq wp54_pci_irqs[] __initdata = { |
|---|
| 37 |
PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0), |
|---|
| 38 |
}; |
|---|
| 39 |
|
|---|
| 40 |
static struct adm5120_pci_irq np28g_pci_irqs[] __initdata = { |
|---|
| 41 |
PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0), |
|---|
| 42 |
PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI0), |
|---|
| 43 |
PCIIRQ(3, 1, 2, ADM5120_IRQ_PCI1), |
|---|
| 44 |
PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2) |
|---|
| 45 |
}; |
|---|
| 46 |
|
|---|
| 47 |
static struct mtd_partition wp54g_wrt_partitions[] = { |
|---|
| 48 |
{ |
|---|
| 49 |
.name = "cfe", |
|---|
| 50 |
.offset = 0, |
|---|
| 51 |
.size = 0x050000, |
|---|
| 52 |
.mask_flags = MTD_WRITEABLE, |
|---|
| 53 |
} , { |
|---|
| 54 |
.name = "trx", |
|---|
| 55 |
.offset = MTDPART_OFS_APPEND, |
|---|
| 56 |
.size = 0x3A0000, |
|---|
| 57 |
} , { |
|---|
| 58 |
.name = "nvram", |
|---|
| 59 |
.offset = MTDPART_OFS_APPEND, |
|---|
| 60 |
.size = 0x010000, |
|---|
| 61 |
} |
|---|
| 62 |
}; |
|---|
| 63 |
|
|---|
| 64 |
static struct platform_device *np2xg_devices[] __initdata = { |
|---|
| 65 |
&adm5120_flash0_device, |
|---|
| 66 |
&adm5120_hcd_device, |
|---|
| 67 |
}; |
|---|
| 68 |
|
|---|
| 69 |
static struct platform_device *wp54_devices[] __initdata = { |
|---|
| 70 |
&adm5120_flash0_device, |
|---|
| 71 |
}; |
|---|
| 72 |
|
|---|
| 73 |
unsigned char np27g_vlans[6] __initdata = { |
|---|
| 74 |
/* FIXME: untested */ |
|---|
| 75 |
0x41, 0x42, 0x44, 0x48, 0x50, 0x00 |
|---|
| 76 |
}; |
|---|
| 77 |
|
|---|
| 78 |
unsigned char np28g_vlans[6] __initdata = { |
|---|
| 79 |
0x50, 0x42, 0x44, 0x48, 0x00, 0x00 |
|---|
| 80 |
}; |
|---|
| 81 |
|
|---|
| 82 |
unsigned char wp54_vlans[6] __initdata = { |
|---|
| 83 |
0x41, 0x42, 0x00, 0x00, 0x00, 0x00 |
|---|
| 84 |
}; |
|---|
| 85 |
|
|---|
| 86 |
/*--------------------------------------------------------------------------*/ |
|---|
| 87 |
|
|---|
| 88 |
static void switch_bank_gpio5(unsigned bank) |
|---|
| 89 |
{ |
|---|
| 90 |
switch (bank) { |
|---|
| 91 |
case 0: |
|---|
| 92 |
gpio_set_value(ADM5120_GPIO_PIN5, 0); |
|---|
| 93 |
break; |
|---|
| 94 |
case 1: |
|---|
| 95 |
gpio_set_value(ADM5120_GPIO_PIN5, 1); |
|---|
| 96 |
break; |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
static void wp54_reset(void) |
|---|
| 101 |
{ |
|---|
| 102 |
gpio_set_value(ADM5120_GPIO_PIN3, 0); |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
static void __init np2xg_setup(void) |
|---|
| 106 |
{ |
|---|
| 107 |
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */ |
|---|
| 108 |
gpio_direction_output(ADM5120_GPIO_PIN5, 0); |
|---|
| 109 |
|
|---|
| 110 |
gpio_request(ADM5120_GPIO_PIN4, NULL); |
|---|
| 111 |
gpio_direction_output(ADM5120_GPIO_PIN4, 1); |
|---|
| 112 |
|
|---|
| 113 |
/* setup data for flash0 device */ |
|---|
| 114 |
adm5120_flash0_data.switch_bank = switch_bank_gpio5; |
|---|
| 115 |
|
|---|
| 116 |
/* TODO: setup mac address */ |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
static void __init wp54_setup(void) |
|---|
| 120 |
{ |
|---|
| 121 |
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */ |
|---|
| 122 |
gpio_direction_output(ADM5120_GPIO_PIN5, 0); |
|---|
| 123 |
|
|---|
| 124 |
gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */ |
|---|
| 125 |
gpio_direction_output(ADM5120_GPIO_PIN3, 1); |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
/* setup data for flash0 device */ |
|---|
| 129 |
adm5120_flash0_data.switch_bank = switch_bank_gpio5; |
|---|
| 130 |
|
|---|
| 131 |
/* TODO: setup mac address */ |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
static void __init wp54_wrt_setup(void) |
|---|
| 135 |
{ |
|---|
| 136 |
gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */ |
|---|
| 137 |
gpio_direction_output(ADM5120_GPIO_PIN5, 0); |
|---|
| 138 |
|
|---|
| 139 |
gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */ |
|---|
| 140 |
gpio_direction_output(ADM5120_GPIO_PIN3, 1); |
|---|
| 141 |
|
|---|
| 142 |
/* setup data for flash0 device */ |
|---|
| 143 |
adm5120_flash0_data.switch_bank = switch_bank_gpio5; |
|---|
| 144 |
adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions); |
|---|
| 145 |
adm5120_flash0_data.parts = wp54g_wrt_partitions; |
|---|
| 146 |
|
|---|
| 147 |
/* TODO: setup mac address */ |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
/*--------------------------------------------------------------------------*/ |
|---|
| 151 |
|
|---|
| 152 |
ADM5120_BOARD_START(NP27G, "Compex NetPassage 27G") |
|---|
| 153 |
.board_setup = np2xg_setup, |
|---|
| 154 |
.eth_num_ports = 5, |
|---|
| 155 |
.eth_vlans = np27g_vlans, |
|---|
| 156 |
.num_devices = ARRAY_SIZE(np2xg_devices), |
|---|
| 157 |
.devices = np2xg_devices, |
|---|
| 158 |
ADM5120_BOARD_END |
|---|
| 159 |
|
|---|
| 160 |
ADM5120_BOARD_START(NP28G, "Compex NetPassage 28G") |
|---|
| 161 |
.board_setup = np2xg_setup, |
|---|
| 162 |
.eth_num_ports = 4, |
|---|
| 163 |
.eth_vlans = np28g_vlans, |
|---|
| 164 |
.num_devices = ARRAY_SIZE(np2xg_devices), |
|---|
| 165 |
.devices = np2xg_devices, |
|---|
| 166 |
.pci_nr_irqs = ARRAY_SIZE(np28g_pci_irqs), |
|---|
| 167 |
.pci_irq_map = np28g_pci_irqs, |
|---|
| 168 |
ADM5120_BOARD_END |
|---|
| 169 |
|
|---|
| 170 |
ADM5120_BOARD_START(WP54AG, "Compex WP54AG") |
|---|
| 171 |
.board_setup = wp54_setup, |
|---|
| 172 |
.board_reset = wp54_reset, |
|---|
| 173 |
.eth_num_ports = 2, |
|---|
| 174 |
.eth_vlans = wp54_vlans, |
|---|
| 175 |
.num_devices = ARRAY_SIZE(wp54_devices), |
|---|
| 176 |
.devices = wp54_devices, |
|---|
| 177 |
.pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs), |
|---|
| 178 |
.pci_irq_map = wp54_pci_irqs, |
|---|
| 179 |
ADM5120_BOARD_END |
|---|
| 180 |
|
|---|
| 181 |
ADM5120_BOARD_START(WP54G, "Compex WP54G") |
|---|
| 182 |
.board_setup = wp54_setup, |
|---|
| 183 |
.board_reset = wp54_reset, |
|---|
| 184 |
.eth_num_ports = 2, |
|---|
| 185 |
.eth_vlans = wp54_vlans, |
|---|
| 186 |
.num_devices = ARRAY_SIZE(wp54_devices), |
|---|
| 187 |
.devices = wp54_devices, |
|---|
| 188 |
.pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs), |
|---|
| 189 |
.pci_irq_map = wp54_pci_irqs, |
|---|
| 190 |
ADM5120_BOARD_END |
|---|
| 191 |
|
|---|
| 192 |
ADM5120_BOARD_START(WP54G_WRT, "Compex WP54G-WRT") |
|---|
| 193 |
.board_setup = wp54_wrt_setup, |
|---|
| 194 |
.board_reset = wp54_reset, |
|---|
| 195 |
.eth_num_ports = 2, |
|---|
| 196 |
.eth_vlans = wp54_vlans, |
|---|
| 197 |
.num_devices = ARRAY_SIZE(wp54_devices), |
|---|
| 198 |
.devices = wp54_devices, |
|---|
| 199 |
.pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs), |
|---|
| 200 |
.pci_irq_map = wp54_pci_irqs, |
|---|
| 201 |
ADM5120_BOARD_END |
|---|
| 202 |
|
|---|
| 203 |
ADM5120_BOARD_START(WPP54AG, "Compex WPP54AG") |
|---|
| 204 |
.board_setup = wp54_setup, |
|---|
| 205 |
.board_reset = wp54_reset, |
|---|
| 206 |
.eth_num_ports = 2, |
|---|
| 207 |
.eth_vlans = wp54_vlans, |
|---|
| 208 |
.num_devices = ARRAY_SIZE(wp54_devices), |
|---|
| 209 |
.devices = wp54_devices, |
|---|
| 210 |
.pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs), |
|---|
| 211 |
.pci_irq_map = wp54_pci_irqs, |
|---|
| 212 |
ADM5120_BOARD_END |
|---|
| 213 |
|
|---|
| 214 |
ADM5120_BOARD_START(WPP54G, "Compex WPP54G") |
|---|
| 215 |
.board_setup = wp54_setup, |
|---|
| 216 |
.board_reset = wp54_reset, |
|---|
| 217 |
.eth_num_ports = 2, |
|---|
| 218 |
.eth_vlans = wp54_vlans, |
|---|
| 219 |
.num_devices = ARRAY_SIZE(wp54_devices), |
|---|
| 220 |
.devices = wp54_devices, |
|---|
| 221 |
.pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs), |
|---|
| 222 |
.pci_irq_map = wp54_pci_irqs, |
|---|
| 223 |
ADM5120_BOARD_END |
|---|