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/slab.h>
14 +#include <linux/i2c.h>
15 +#include <linux/i2c/at24.h>
17 #include <linux/i2c-gpio.h>
19 #include <asm/types.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach/flash.h>
24 +struct avila_board_info {
25 + unsigned char *model;
26 + void (*setup)(void);
29 +static struct avila_board_info *avila_info __initdata;
31 static struct flash_platform_data avila_flash_data = {
32 .map_name = "cfi_probe",
34 @@ -132,16 +145,181 @@ static struct platform_device avila_pata
35 .resource = avila_pata_resources,
38 +/* Built-in 10/100 Ethernet MAC interfaces */
39 +static struct eth_plat_info avila_npeb_data = {
45 +static struct eth_plat_info avila_npec_data = {
51 +static struct platform_device avila_npeb_device = {
52 + .name = "ixp4xx_eth",
53 + .id = IXP4XX_ETH_NPEB,
54 + .dev.platform_data = &avila_npeb_data,
57 +static struct platform_device avila_npec_device = {
58 + .name = "ixp4xx_eth",
59 + .id = IXP4XX_ETH_NPEC,
60 + .dev.platform_data = &avila_npec_data,
63 static struct platform_device *avila_devices[] __initdata = {
69 +static void __init avila_gw23xx_setup(void)
71 + platform_device_register(&avila_npeb_device);
72 + platform_device_register(&avila_npec_device);
75 +static void __init avila_gw2342_setup(void)
77 + platform_device_register(&avila_npeb_device);
78 + platform_device_register(&avila_npec_device);
81 +static void __init avila_gw2345_setup(void)
83 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
84 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
85 + platform_device_register(&avila_npeb_device);
87 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
88 + platform_device_register(&avila_npec_device);
91 +static void __init avila_gw2347_setup(void)
93 + platform_device_register(&avila_npeb_device);
96 +static void __init avila_gw2348_setup(void)
98 + platform_device_register(&avila_npeb_device);
99 + platform_device_register(&avila_npec_device);
102 +static void __init avila_gw2353_setup(void)
104 + platform_device_register(&avila_npeb_device);
107 +static void __init avila_gw2355_setup(void)
109 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
110 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
111 + platform_device_register(&avila_npeb_device);
113 + avila_npec_data.phy = 16;
114 + platform_device_register(&avila_npec_device);
117 +static void __init avila_gw2357_setup(void)
119 + platform_device_register(&avila_npeb_device);
122 +static struct avila_board_info avila_boards[] __initdata = {
125 + .setup = avila_gw2342_setup,
128 + .setup = avila_gw2345_setup,
131 + .setup = avila_gw2347_setup,
134 + .setup = avila_gw2348_setup,
137 + .setup = avila_gw2353_setup,
140 + .setup = avila_gw2355_setup,
143 + .setup = avila_gw2357_setup,
147 +static struct avila_board_info * __init avila_find_board_info(char *model)
151 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
152 + struct avila_board_info *info = &avila_boards[i];
153 + if (strcmp(info->model, model) == 0)
160 +static struct at24_iface *at24_if;
162 +static int at24_setup(struct at24_iface *iface, void *context)
164 + char mac_addr[ETH_ALEN];
169 + /* Read MAC addresses */
170 + if (at24_if->read(at24_if, mac_addr, 0x0, 6) == 6) {
171 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
173 + if (at24_if->read(at24_if, mac_addr, 0x6, 6) == 6) {
174 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
177 + /* Read the first 6 bytes of the model number */
178 + if (at24_if->read(at24_if, model, 0x20, 6) == 6) {
179 + avila_info = avila_find_board_info(model);
185 +static struct at24_platform_data avila_eeprom_info = {
188 + .flags = AT24_FLAG_READONLY,
189 + .setup = at24_setup,
192 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
194 + I2C_BOARD_INFO("ds1672", 0x68),
197 + I2C_BOARD_INFO("ad7418", 0x28),
200 + I2C_BOARD_INFO("24c08", 0x51),
201 + .platform_data = &avila_eeprom_info
205 static void __init avila_init(void)
210 + * These devices are present on all Avila models and don't need any
211 + * model specific setup.
213 avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
214 avila_flash_resource.end =
215 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
216 @@ -159,7 +337,28 @@ static void __init avila_init(void)
218 platform_device_register(&avila_pata);
220 + i2c_register_board_info(0, avila_i2c_board_info,
221 + ARRAY_SIZE(avila_i2c_board_info));
224 +static int __init avila_model_setup(void)
226 + if (!machine_is_avila())
230 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
231 + avila_info->model);
232 + avila_info->setup();
234 + printk(KERN_INFO "Unknown/missing Avila model number"
235 + " -- defaults will be used\n");
236 + avila_gw23xx_setup();
241 +late_initcall(avila_model_setup);
243 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
244 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */