aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx/files
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-11-12 12:50:16 +0000
committerGabor Juhos <juhosg@openwrt.org>2011-11-12 12:50:16 +0000
commit2d684997e3a6e1fc44c83787a5dac13f3d0649c2 (patch)
tree2666ea415776286f38b12eb9991c921cefa929b6 /target/linux/ar71xx/files
parenta680542669bc7cfd8dd1ad00bcc1f41f4a14c743 (diff)
downloadupstream-2d684997e3a6e1fc44c83787a5dac13f3d0649c2.tar.gz
upstream-2d684997e3a6e1fc44c83787a5dac13f3d0649c2.tar.bz2
upstream-2d684997e3a6e1fc44c83787a5dac13f3d0649c2.zip
ar71xx: move phy interface setup into a separate function
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@28987 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/files')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/devices.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c
index 86b615ea87..0091ac276c 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/devices.c
@@ -585,58 +585,73 @@ static void __init ar71xx_init_eth_pll_data(unsigned int id)
pll_data->pll_1000 = pll_1000;
}
-static int ar71xx_eth_instance __initdata;
-void __init ar71xx_add_device_eth(unsigned int id)
+static int __init ar71xx_setup_phy_if_mode(unsigned int id,
+ struct ag71xx_platform_data *pdata)
{
- struct platform_device *pdev;
- struct ag71xx_platform_data *pdata;
-
- ar71xx_init_eth_pll_data(id);
-
switch (id) {
case 0:
- switch (ar71xx_eth0_data.phy_if_mode) {
+ switch (pdata->phy_if_mode) {
case PHY_INTERFACE_MODE_MII:
- ar71xx_eth0_data.mii_if = MII0_CTRL_IF_MII;
+ pdata->mii_if = MII0_CTRL_IF_MII;
break;
case PHY_INTERFACE_MODE_GMII:
- ar71xx_eth0_data.mii_if = MII0_CTRL_IF_GMII;
+ pdata->mii_if = MII0_CTRL_IF_GMII;
break;
case PHY_INTERFACE_MODE_RGMII:
- ar71xx_eth0_data.mii_if = MII0_CTRL_IF_RGMII;
+ pdata->mii_if = MII0_CTRL_IF_RGMII;
break;
case PHY_INTERFACE_MODE_RMII:
- ar71xx_eth0_data.mii_if = MII0_CTRL_IF_RMII;
+ pdata->mii_if = MII0_CTRL_IF_RMII;
break;
default:
- printk(KERN_ERR "ar71xx: invalid PHY interface mode "
- "for eth0\n");
- return;
+ return -EINVAL;
}
- pdev = &ar71xx_eth0_device;
break;
case 1:
- switch (ar71xx_eth1_data.phy_if_mode) {
+ switch (pdata->phy_if_mode) {
case PHY_INTERFACE_MODE_RMII:
- ar71xx_eth1_data.mii_if = MII1_CTRL_IF_RMII;
+ pdata->mii_if = MII1_CTRL_IF_RMII;
break;
case PHY_INTERFACE_MODE_RGMII:
- ar71xx_eth1_data.mii_if = MII1_CTRL_IF_RGMII;
+ pdata->mii_if = MII1_CTRL_IF_RGMII;
break;
default:
- printk(KERN_ERR "ar71xx: invalid PHY interface mode "
- "for eth1\n");
- return;
+ return -EINVAL;
}
- pdev = &ar71xx_eth1_device;
break;
- default:
+ }
+
+ return 0;
+}
+
+static int ar71xx_eth_instance __initdata;
+void __init ar71xx_add_device_eth(unsigned int id)
+{
+ struct platform_device *pdev;
+ struct ag71xx_platform_data *pdata;
+ int err;
+
+ if (id > 1) {
printk(KERN_ERR "ar71xx: invalid ethernet id %d\n", id);
return;
}
+ ar71xx_init_eth_pll_data(id);
+
+ if (id == 0)
+ pdev = &ar71xx_eth0_device;
+ else
+ pdev = &ar71xx_eth1_device;
+
pdata = pdev->dev.platform_data;
+ err = ar71xx_setup_phy_if_mode(id, pdata);
+ if (err) {
+ printk(KERN_ERR
+ "ar71xx: invalid PHY interface mode for GE%u\n", id);
+ return;
+ }
+
switch (ar71xx_soc) {
case AR71XX_SOC_AR7130:
pdata->ddr_flush = id ? ar71xx_ddr_flush_ge1