[ar71xx] create firmware image for the Ubiquiti LS-SR71 board
[openwrt/svn-archive/archive.git] / target / linux / ar7 / patches-2.6.25 / 150-cpmac_up_and_running.diff
1 From 0daaa095cefd9d7091a7ccce2ff89f1ff4feae7a Mon Sep 17 00:00:00 2001
2 From: Anton Vorontsov <avorontsov@ru.mvista.com>
3 Date: Wed, 5 Mar 2008 14:52:26 +0300
4 Subject: [PATCH] AR7/cpmac: convert to new fixed phy infrastructure, now for real
5
6 This patch converts platform code to register fixed phys early.
7 cpmac driver modified to blindly accept fixed phy id (that is equal
8 to platform device id).
9
10 Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
11 ---
12 arch/mips/ar7/platform.c | 17 +++++++++++++++++
13 drivers/net/cpmac.c | 19 +++----------------
14 2 files changed, 20 insertions(+), 16 deletions(-)
15
16 --- a/arch/mips/ar7/platform.c
17 +++ b/arch/mips/ar7/platform.c
18 @@ -33,6 +33,8 @@
19 #include <linux/vlynq.h>
20 #include <linux/leds.h>
21 #include <linux/string.h>
22 +#include <linux/phy.h>
23 +#include <linux/phy_fixed.h>
24
25 #include <asm/addrspace.h>
26 #include <asm/ar7/ar7.h>
27 @@ -205,6 +207,13 @@
28 .width = 2,
29 };
30
31 +/* lets assume this is suitable for both high and low cpmacs links */
32 +static struct fixed_phy_status fixed_phy_status __initdata = {
33 + .link = 1,
34 + .speed = 100,
35 + .duplex = 1,
36 +};
37 +
38 static struct plat_cpmac_data cpmac_low_data = {
39 .reset_bit = 17,
40 .power_bit = 20,
41 @@ -506,6 +515,10 @@
42 }
43
44 if (ar7_has_high_cpmac()) {
45 + res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status);
46 + if (res && res != -ENODEV)
47 + return res;
48 +
49 cpmac_get_mac(1, cpmac_high_data.dev_addr);
50 res = platform_device_register(&cpmac_high);
51 if (res)
52 @@ -514,6 +527,10 @@
53 cpmac_low_data.phy_mask = 0xffffffff;
54 }
55
56 + res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status);
57 + if (res && res != -ENODEV)
58 + return res;
59 +
60 cpmac_get_mac(0, cpmac_low_data.dev_addr);
61 res = platform_device_register(&cpmac_low);
62 if (res)
63 --- a/drivers/net/cpmac.c
64 +++ b/drivers/net/cpmac.c
65 @@ -1035,23 +1035,10 @@
66
67 if (phy_id == PHY_MAX_ADDR) {
68 if (external_switch || dumb_switch) {
69 - struct fixed_phy_status status = {};
70 -
71 - mdio_bus_id = 0;
72 -
73 - /*
74 - * FIXME: this should be in the platform code!
75 - * Since there is not platform code at all (that is,
76 - * no mainline users of that driver), place it here
77 - * for now.
78 - */
79 - phy_id = 0;
80 - status.link = 1;
81 - status.duplex = 1;
82 - status.speed = 100;
83 - fixed_phy_add(PHY_POLL, phy_id, &status);
84 + mdio_bus_id = 0; /* fixed phys bus */
85 + phy_id = pdev->id;
86 } else {
87 - printk(KERN_ERR "cpmac: no PHY present\n");
88 + dev_err(&pdev->dev, "no PHY present\n");
89 return -ENODEV;
90 }
91 }