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/leds.h>
16 #include <linux/i2c-gpio.h>
17 #include <asm/types.h>
18 #include <asm/setup.h>
20 #define AVILA_SDA_PIN 7
21 #define AVILA_SCL_PIN 6
24 +#define AVILA_GW23XX_LED_USER_GPIO 3
25 +#define AVILA_GW23X7_LED_USER_GPIO 4
27 +/* gpio mask used by platform device */
28 +#define AVILA_GPIO_MASK (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9)
30 +struct avila_board_info {
31 + unsigned char *model;
32 + void (*setup)(void);
35 +static struct avila_board_info *avila_info __initdata;
37 static struct flash_platform_data avila_flash_data = {
38 .map_name = "cfi_probe",
40 @@ -133,16 +153,277 @@ static struct platform_device avila_pata
41 .resource = avila_pata_resources,
44 +/* Built-in 10/100 Ethernet MAC interfaces */
45 +static struct eth_plat_info avila_npeb_data = {
51 +static struct eth_plat_info avila_npec_data = {
57 +static struct platform_device avila_npeb_device = {
58 + .name = "ixp4xx_eth",
59 + .id = IXP4XX_ETH_NPEB,
60 + .dev.platform_data = &avila_npeb_data,
63 +static struct platform_device avila_npec_device = {
64 + .name = "ixp4xx_eth",
65 + .id = IXP4XX_ETH_NPEC,
66 + .dev.platform_data = &avila_npec_data,
69 +static struct gpio_led avila_gpio_leds[] = {
71 + .name = "user", /* green led */
72 + .gpio = AVILA_GW23XX_LED_USER_GPIO,
77 +static struct gpio_led_platform_data avila_gpio_leds_data = {
79 + .leds = avila_gpio_leds,
82 +static struct platform_device avila_gpio_leds_device = {
83 + .name = "leds-gpio",
85 + .dev.platform_data = &avila_gpio_leds_data,
88 +static struct latch_led avila_latch_leds[] = {
90 + .name = "led0", /* green led */
94 + .name = "led1", /* green led */
98 + .name = "led2", /* green led */
102 + .name = "led3", /* green led */
106 + .name = "led4", /* green led */
110 + .name = "led5", /* green led */
114 + .name = "led6", /* green led */
118 + .name = "led7", /* green led */
123 +static struct latch_led_platform_data avila_latch_leds_data = {
125 + .leds = avila_latch_leds,
129 +static struct platform_device avila_latch_leds_device = {
130 + .name = "leds-latch",
132 + .dev.platform_data = &avila_latch_leds_data,
135 static struct platform_device *avila_devices[] __initdata = {
141 +static void __init avila_gw23xx_setup(void)
143 + platform_device_register(&avila_npeb_device);
144 + platform_device_register(&avila_npec_device);
146 + platform_device_register(&avila_gpio_leds_device);
149 +static void __init avila_gw2342_setup(void)
151 + platform_device_register(&avila_npeb_device);
152 + platform_device_register(&avila_npec_device);
154 + platform_device_register(&avila_gpio_leds_device);
157 +static void __init avila_gw2345_setup(void)
159 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
160 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
161 + platform_device_register(&avila_npeb_device);
163 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
164 + platform_device_register(&avila_npec_device);
166 + platform_device_register(&avila_gpio_leds_device);
169 +static void __init avila_gw2347_setup(void)
171 + platform_device_register(&avila_npeb_device);
173 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
174 + platform_device_register(&avila_gpio_leds_device);
177 +static void __init avila_gw2348_setup(void)
179 + platform_device_register(&avila_npeb_device);
180 + platform_device_register(&avila_npec_device);
182 + platform_device_register(&avila_gpio_leds_device);
185 +static void __init avila_gw2353_setup(void)
187 + platform_device_register(&avila_npeb_device);
188 + platform_device_register(&avila_gpio_leds_device);
191 +static void __init avila_gw2355_setup(void)
193 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
194 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
195 + platform_device_register(&avila_npeb_device);
197 + avila_npec_data.phy = 16;
198 + platform_device_register(&avila_npec_device);
200 + platform_device_register(&avila_gpio_leds_device);
202 + *IXP4XX_EXP_CS4 |= 0xbfff3c03;
203 + avila_latch_leds[0].name = "RXD";
204 + avila_latch_leds[1].name = "TXD";
205 + avila_latch_leds[2].name = "POL";
206 + avila_latch_leds[3].name = "LNK";
207 + avila_latch_leds[4].name = "ERR";
208 + avila_latch_leds_data.num_leds = 5;
209 + avila_latch_leds_data.mem = 0x54000000;
210 + platform_device_register(&avila_latch_leds_device);
213 +static void __init avila_gw2357_setup(void)
215 + platform_device_register(&avila_npeb_device);
217 + avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
218 + platform_device_register(&avila_gpio_leds_device);
220 + *IXP4XX_EXP_CS1 |= 0xbfff3c03;
221 + platform_device_register(&avila_latch_leds_device);
224 +static struct avila_board_info avila_boards[] __initdata = {
227 + .setup = avila_gw2342_setup,
230 + .setup = avila_gw2345_setup,
233 + .setup = avila_gw2347_setup,
236 + .setup = avila_gw2348_setup,
239 + .setup = avila_gw2353_setup,
242 + .setup = avila_gw2355_setup,
245 + .setup = avila_gw2357_setup,
249 +static struct avila_board_info * __init avila_find_board_info(char *model)
254 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
255 + struct avila_board_info *info = &avila_boards[i];
256 + if (strcmp(info->model, model) == 0)
263 +static struct memory_accessor *at24_mem_acc;
265 +static void at24_setup(struct memory_accessor *mem_acc, void *context)
267 + char mac_addr[ETH_ALEN];
270 + at24_mem_acc = mem_acc;
272 + /* Read MAC addresses */
273 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
274 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
276 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
277 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
280 + /* Read the first 6 bytes of the model number */
281 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
282 + avila_info = avila_find_board_info(model);
287 +static struct at24_platform_data avila_eeprom_info = {
290 + .flags = AT24_FLAG_READONLY,
291 + .setup = at24_setup,
294 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
296 + I2C_BOARD_INFO("ds1672", 0x68),
299 + I2C_BOARD_INFO("ad7418", 0x28),
302 + I2C_BOARD_INFO("24c08", 0x51),
303 + .platform_data = &avila_eeprom_info
307 static void __init avila_init(void)
312 + * These devices are present on all Avila models and don't need any
313 + * model specific setup.
315 avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
316 avila_flash_resource.end =
317 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
318 @@ -160,7 +441,28 @@ static void __init avila_init(void)
320 platform_device_register(&avila_pata);
322 + i2c_register_board_info(0, avila_i2c_board_info,
323 + ARRAY_SIZE(avila_i2c_board_info));
326 +static int __init avila_model_setup(void)
328 + if (!machine_is_avila())
332 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
333 + avila_info->model);
334 + avila_info->setup();
336 + printk(KERN_INFO "Unknown/missing Avila model number"
337 + " -- defaults will be used\n");
338 + avila_gw23xx_setup();
343 +late_initcall(avila_model_setup);
345 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
346 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */