1 --- a/arch/arm/mach-ixp4xx/avila-setup.c
2 +++ b/arch/arm/mach-ixp4xx/avila-setup.c
4 #include <linux/kernel.h>
5 #include <linux/init.h>
6 #include <linux/device.h>
7 +#include <linux/if_ether.h>
8 +#include <linux/socket.h>
9 +#include <linux/netdevice.h>
10 #include <linux/serial.h>
11 #include <linux/tty.h>
12 #include <linux/serial_8250.h>
13 +#include <linux/i2c.h>
14 +#include <linux/i2c/at24.h>
15 #include <linux/i2c-gpio.h>
16 #include <asm/types.h>
17 #include <asm/setup.h>
19 #define AVILA_SDA_PIN 7
20 #define AVILA_SCL_PIN 6
22 +struct avila_board_info {
23 + unsigned char *model;
24 + void (*setup)(void);
27 +static struct avila_board_info *avila_info __initdata;
29 static struct flash_platform_data avila_flash_data = {
30 .map_name = "cfi_probe",
32 @@ -133,16 +145,181 @@ static struct platform_device avila_pata
33 .resource = avila_pata_resources,
36 +/* Built-in 10/100 Ethernet MAC interfaces */
37 +static struct eth_plat_info avila_npeb_data = {
43 +static struct eth_plat_info avila_npec_data = {
49 +static struct platform_device avila_npeb_device = {
50 + .name = "ixp4xx_eth",
51 + .id = IXP4XX_ETH_NPEB,
52 + .dev.platform_data = &avila_npeb_data,
55 +static struct platform_device avila_npec_device = {
56 + .name = "ixp4xx_eth",
57 + .id = IXP4XX_ETH_NPEC,
58 + .dev.platform_data = &avila_npec_data,
61 static struct platform_device *avila_devices[] __initdata = {
67 +static void __init avila_gw23xx_setup(void)
69 + platform_device_register(&avila_npeb_device);
70 + platform_device_register(&avila_npec_device);
73 +static void __init avila_gw2342_setup(void)
75 + platform_device_register(&avila_npeb_device);
76 + platform_device_register(&avila_npec_device);
79 +static void __init avila_gw2345_setup(void)
81 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
82 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
83 + platform_device_register(&avila_npeb_device);
85 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
86 + platform_device_register(&avila_npec_device);
89 +static void __init avila_gw2347_setup(void)
91 + platform_device_register(&avila_npeb_device);
94 +static void __init avila_gw2348_setup(void)
96 + platform_device_register(&avila_npeb_device);
97 + platform_device_register(&avila_npec_device);
100 +static void __init avila_gw2353_setup(void)
102 + platform_device_register(&avila_npeb_device);
105 +static void __init avila_gw2355_setup(void)
107 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
108 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
109 + platform_device_register(&avila_npeb_device);
111 + avila_npec_data.phy = 16;
112 + platform_device_register(&avila_npec_device);
115 +static void __init avila_gw2357_setup(void)
117 + platform_device_register(&avila_npeb_device);
120 +static struct avila_board_info avila_boards[] __initdata = {
123 + .setup = avila_gw2342_setup,
126 + .setup = avila_gw2345_setup,
129 + .setup = avila_gw2347_setup,
132 + .setup = avila_gw2348_setup,
135 + .setup = avila_gw2353_setup,
138 + .setup = avila_gw2355_setup,
141 + .setup = avila_gw2357_setup,
145 +static struct avila_board_info * __init avila_find_board_info(char *model)
150 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
151 + struct avila_board_info *info = &avila_boards[i];
152 + if (strcmp(info->model, model) == 0)
159 +static struct memory_accessor *at24_mem_acc;
161 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
163 + char mac_addr[ETH_ALEN];
166 + at24_mem_acc = mem_acc;
168 + /* Read MAC addresses */
169 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
170 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
172 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
173 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
176 + /* Read the first 6 bytes of the model number */
177 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
178 + avila_info = avila_find_board_info(model);
183 +static struct at24_platform_data avila_eeprom_info = {
186 + .flags = AT24_FLAG_READONLY,
187 + .setup = at24_setup,
190 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
192 + I2C_BOARD_INFO("ds1672", 0x68),
195 + I2C_BOARD_INFO("ad7418", 0x28),
198 + I2C_BOARD_INFO("24c08", 0x51),
199 + .platform_data = &avila_eeprom_info
203 static void __init avila_init(void)
208 + * These devices are present on all Avila models and don't need any
209 + * model specific setup.
211 avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
212 avila_flash_resource.end =
213 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
214 @@ -160,7 +337,28 @@ static void __init avila_init(void)
216 platform_device_register(&avila_pata);
218 + i2c_register_board_info(0, avila_i2c_board_info,
219 + ARRAY_SIZE(avila_i2c_board_info));
222 +static int __init avila_model_setup(void)
224 + if (!machine_is_avila())
228 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
229 + avila_info->model);
230 + avila_info->setup();
232 + printk(KERN_INFO "Unknown/missing Avila model number"
233 + " -- defaults will be used\n");
234 + avila_gw23xx_setup();
239 +late_initcall(avila_model_setup);
241 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
242 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */