1 --- a/arch/mips/ar7/platform.c
2 +++ b/arch/mips/ar7/platform.c
3 @@ -712,26 +712,23 @@ static int __init ar7_register_devices(v
6 if (ar7_has_high_cpmac()) {
7 + cpmac_get_mac(0, cpmac_high_data.dev_addr);
9 res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status);
11 - cpmac_get_mac(1, cpmac_high_data.dev_addr);
13 + pr_warning("unable to register fixed phy for cpmac-high: %d\n", res);
15 - res = platform_device_register(&cpmac_high);
17 - pr_warning("unable to register cpmac-high: %d\n", res);
19 - pr_warning("unable to add cpmac-high phy: %d\n", res);
21 + res = platform_device_register(&cpmac_high);
23 + pr_warning("unable to register cpmac-high: %d\n", res);
24 + cpmac_get_mac(1, cpmac_low_data.dev_addr);
26 cpmac_low_data.phy_mask = 0xffffffff;
28 - res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status);
30 cpmac_get_mac(0, cpmac_low_data.dev_addr);
31 - res = platform_device_register(&cpmac_low);
33 - pr_warning("unable to register cpmac-low: %d\n", res);
35 - pr_warning("unable to add cpmac-low phy: %d\n", res);
37 + res = platform_device_register(&cpmac_low);
39 + pr_warning("unable to register cpmac-low: %d\n", res);
42 res = platform_device_register(&ar7_gpio_leds);
43 --- a/arch/mips/include/asm/mach-ar7/ar7.h
44 +++ b/arch/mips/include/asm/mach-ar7/ar7.h
46 #define AR7_REGS_PINSEL (AR7_REGS_BASE + 0x160C)
47 #define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800)
48 #define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00)
49 +#define AR7_REGS_MII (AR7_REGS_BASE + 0x1a08)
50 #define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00)
51 #define AR7_REGS_MDIO (AR7_REGS_BASE + 0x1e00)
52 #define AR7_REGS_IRQ (AR7_REGS_BASE + 0x2400)
53 --- a/drivers/net/ethernet/ti/cpmac.c
54 +++ b/drivers/net/ethernet/ti/cpmac.c
56 #include <linux/skbuff.h>
57 #include <linux/mii.h>
58 #include <linux/phy.h>
59 -#include <linux/phy_fixed.h>
60 #include <linux/platform_device.h>
61 #include <linux/dma-mapping.h>
62 #include <linux/clk.h>
63 @@ -48,14 +47,11 @@ MODULE_LICENSE("GPL");
64 MODULE_ALIAS("platform:cpmac");
66 static int debug_level = 8;
67 -static int dumb_switch;
69 -/* Next 2 are only used in cpmac_probe, so it's pointless to change them */
70 +/* Next is only used in cpmac_probe, so it's pointless to change them */
71 module_param(debug_level, int, 0444);
72 -module_param(dumb_switch, int, 0444);
74 MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable");
75 -MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus");
77 #define CPMAC_VERSION "0.5.2"
78 /* frame size + 802.1q tag + FCS size */
79 @@ -674,9 +670,8 @@ static void cpmac_hw_start(struct net_de
80 for (i = 0; i < 8; i++)
81 cpmac_write(priv->regs, CPMAC_MAC_ADDR_LO(i), dev->dev_addr[5]);
82 cpmac_write(priv->regs, CPMAC_MAC_ADDR_MID, dev->dev_addr[4]);
83 - cpmac_write(priv->regs, CPMAC_MAC_ADDR_HI, dev->dev_addr[0] |
84 - (dev->dev_addr[1] << 8) | (dev->dev_addr[2] << 16) |
85 - (dev->dev_addr[3] << 24));
86 + cpmac_write(priv->regs, CPMAC_MAC_ADDR_HI, be32_to_cpu(*(u32 *)
88 cpmac_write(priv->regs, CPMAC_MAX_LENGTH, CPMAC_SKB_SIZE);
89 cpmac_write(priv->regs, CPMAC_UNICAST_CLEAR, 0xff);
90 cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 0xff);
91 @@ -1120,25 +1115,19 @@ static int cpmac_probe(struct platform_d
93 pdata = pdev->dev.platform_data;
95 - if (external_switch || dumb_switch) {
96 - strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */
99 - for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
100 - if (!(pdata->phy_mask & (1 << phy_id)))
102 - if (!cpmac_mii->phy_map[phy_id])
104 - strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE);
107 + for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
108 + if (!(pdata->phy_mask & (1 << phy_id)))
110 + if (!cpmac_mii->phy_map[phy_id])
112 + strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE);
116 - if (phy_id == PHY_MAX_ADDR) {
117 - dev_err(&pdev->dev, "no PHY present, falling back "
118 - "to switch on MDIO bus 0\n");
119 - strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */
120 + if (phy_id == PHY_MAX_ADDR && pdev->id == 1) {
121 + printk(KERN_ERR "cpmac: No PHY present, using fixed PHY\n");
123 + strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE);
126 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
127 @@ -1174,6 +1163,13 @@ static int cpmac_probe(struct platform_d
128 snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT,
129 mdio_bus_id, phy_id);
131 + rc = register_netdev(dev);
133 + printk(KERN_ERR "cpmac: error %i registering device %s\n", rc,
138 priv->phy = phy_connect(dev, priv->phy_name, cpmac_adjust_link,
139 PHY_INTERFACE_MODE_MII);
141 @@ -1185,13 +1181,6 @@ static int cpmac_probe(struct platform_d
145 - rc = register_netdev(dev);
147 - printk(KERN_ERR "cpmac: error %i registering device %s\n", rc,
152 if (netif_msg_probe(priv)) {
154 "cpmac: device %s (regs: %p, irq: %d, phy: %s, "
155 @@ -1224,6 +1213,7 @@ int cpmac_init(void)
159 + void __iomem *mii_reg;
161 cpmac_mii = mdiobus_alloc();
162 if (cpmac_mii == NULL)
163 @@ -1247,31 +1237,51 @@ int cpmac_init(void)
164 ar7_gpio_disable(26);
165 ar7_gpio_disable(27);
167 - if (!ar7_is_titan()) {
168 + if (ar7_is_titan()) {
169 + ar7_device_reset(AR7_RESET_BIT_EPHY);
170 + ar7_device_reset(TITAN_RESET_BIT_EPHY1);
172 + ar7_device_reset(AR7_RESET_BIT_EPHY);
173 ar7_device_reset(AR7_RESET_BIT_CPMAC_LO);
174 ar7_device_reset(AR7_RESET_BIT_CPMAC_HI);
176 - ar7_device_reset(AR7_RESET_BIT_EPHY);
178 - if (ar7_is_titan())
179 - ar7_device_reset(TITAN_RESET_BIT_EPHY1);
181 cpmac_mii->reset(cpmac_mii);
183 for (i = 0; i < 300; i++) {
184 mask = cpmac_read(cpmac_mii->priv, CPMAC_MDIO_ALIVE);
185 + mask &= ar7_is_titan()? ~(0x80000000 | 0x40000000) : ~(0x80000000);
192 - mask &= 0x7fffffff;
193 if (mask & (mask - 1)) {
196 + if (!ar7_has_high_cpmac()) {
197 + if (ar7_is_titan()) {
198 + ar7_device_disable(AR7_RESET_BIT_EPHY);
199 + ar7_device_disable(TITAN_RESET_BIT_EPHY1);
201 + ar7_device_disable(AR7_RESET_BIT_EPHY);
203 + //Titan remap might be different
204 + mii_reg = ioremap(AR7_REGS_MII, 4);
206 + writel(readl(mii_reg) | 1, mii_reg);
212 + if (external_switch)
213 + printk(KERN_INFO "EXTERNAL SWITCH!!!\n");
215 + printk(KERN_INFO "EXTERNAL PHY!!!\n");
217 + printk(KERN_INFO "INTERNAL PHY!!!\n");
220 cpmac_mii->phy_mask = ~(mask | 0x80000000 | 0x40000000);