ar71xx: move dsa switch device support into a separate file
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / dev-dsa.c
1 /*
2  *  Atheros AR71xx DSA switch device support
3  *
4  *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6  *
7  *  This program is free software; you can redistribute it and/or modify it
8  *  under the terms of the GNU General Public License version 2 as published
9  *  by the Free Software Foundation.
10  */
11
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14
15 #include <asm/mach-ar71xx/ar71xx.h>
16
17 #include "devices.h"
18 #include "dev-dsa.h"
19
20 static struct platform_device ar71xx_dsa_switch_device = {
21         .name           = "dsa",
22         .id             = 0,
23 };
24
25 void __init ar71xx_add_device_dsa(unsigned int id,
26                                   struct dsa_platform_data *d)
27 {
28         int i;
29
30         switch (id) {
31         case 0:
32                 d->netdev = &ar71xx_eth0_device.dev;
33                 break;
34         case 1:
35                 d->netdev = &ar71xx_eth1_device.dev;
36                 break;
37         default:
38                 printk(KERN_ERR
39                         "ar71xx: invalid ethernet id %d for DSA switch\n",
40                         id);
41                 return;
42         }
43
44         for (i = 0; i < d->nr_chips; i++)
45                 d->chip[i].mii_bus = &ar71xx_mdio_device.dev;
46
47         ar71xx_dsa_switch_device.dev.platform_data = d;
48
49         platform_device_register(&ar71xx_dsa_switch_device);
50 }