Changeset 20400
- Timestamp:
- 2010-03-24T16:53:05+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/target/linux/ifxmips/patches-2.6.30/130-ethernet.patch
r18082 r20400 30 30 Index: linux-2.6.30.8/drivers/net/ifxmips_mii0.c 31 31 =================================================================== 32 --- /dev/null 1970-01-01 00:00:00.000000000 +000033 +++ linux-2.6.30. 8/drivers/net/ifxmips_mii0.c 2009-10-19 21:41:10.000000000 +020034 @@ -0,0 +1, 389 @@32 --- /dev/null 2010-01-25 20:01:36.843225078 +0100 33 +++ linux-2.6.30.10/drivers/net/ifxmips_mii0.c 2010-03-13 19:04:25.000000000 +0100 34 @@ -0,0 +1,489 @@ 35 35 +/* 36 36 + * This program is free software; you can redistribute it and/or modify … … 61 61 +#include <linux/netdevice.h> 62 62 +#include <linux/etherdevice.h> 63 +#include <linux/phy.h> 63 64 +#include <linux/ip.h> 64 65 +#include <linux/tcp.h> … … 80 81 + struct dma_device_info *dma_device; 81 82 + struct sk_buff *skb; 83 + 84 + struct mii_bus *mii_bus; 85 + struct phy_device *phydev; 86 + int oldlink, oldspeed, oldduplex; 82 87 +}; 83 88 + … … 85 90 +static unsigned char mac_addr[MAX_ADDR_LEN]; 86 91 + 87 +void ifxmips_write_mdio(u32 phy_addr, u32 phy_reg, u16 phy_data) 92 +static int ifxmips_mdiobus_write(struct mii_bus *bus, int phy_addr, 93 + int phy_reg, u16 phy_data) 88 94 +{ 89 95 + u32 val = MDIO_ACC_REQUEST | … … 95 101 + ; 96 102 + ifxmips_w32(val, IFXMIPS_PPE32_MDIO_ACC); 97 +} 98 +EXPORT_SYMBOL(ifxmips_write_mdio); 99 + 100 +unsigned short ifxmips_read_mdio(u32 phy_addr, u32 phy_reg) 103 + 104 + return 0; 105 +} 106 + 107 +static int ifxmips_mdiobus_read(struct mii_bus *bus, int phy_addr, int phy_reg) 101 108 +{ 102 109 + u32 val = MDIO_ACC_REQUEST | MDIO_ACC_READ | … … 112 119 + return val; 113 120 +} 114 +EXPORT_SYMBOL(ifxmips_read_mdio);115 121 + 116 122 +int ifxmips_ifxmips_mii_open(struct net_device *dev) … … 301 307 +} 302 308 + 309 +static void 310 +ifxmips_adjust_link(struct net_device *dev) 311 +{ 312 + struct ifxmips_mii_priv *priv = netdev_priv(dev); 313 + struct phy_device *phydev = priv->phydev; 314 + int new_state = 0; 315 + 316 + /* Did anything change? */ 317 + if (priv->oldlink != phydev->link || 318 + priv->oldduplex != phydev->duplex || 319 + priv->oldspeed != phydev->speed) { 320 + /* Yes, so update status and mark as changed */ 321 + new_state = 1; 322 + priv->oldduplex = phydev->duplex; 323 + priv->oldspeed = phydev->speed; 324 + priv->oldlink = phydev->link; 325 + } 326 + 327 + /* If link status changed, show new status */ 328 + if (new_state) 329 + phy_print_status(phydev); 330 +} 331 + 332 +static int mii_probe(struct net_device *dev) 333 +{ 334 + struct ifxmips_mii_priv *priv = netdev_priv(dev); 335 + struct phy_device *phydev = NULL; 336 + int phy_addr; 337 + 338 + priv->oldlink = 0; 339 + priv->oldspeed = 0; 340 + priv->oldduplex = -1; 341 + 342 + /* find the first (lowest address) PHY on the current MAC's MII bus */ 343 + for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { 344 + if (priv->mii_bus->phy_map[phy_addr]) { 345 + phydev = priv->mii_bus->phy_map[phy_addr]; 346 + break; /* break out with first one found */ 347 + } 348 + } 349 + 350 + if (!phydev) { 351 + printk (KERN_ERR "%s: no PHY found\n", dev->name); 352 + return -ENODEV; 353 + } 354 + 355 + /* now we are supposed to have a proper phydev, to attach to... */ 356 + BUG_ON(!phydev); 357 + BUG_ON(phydev->attached_dev); 358 + 359 + phydev = phy_connect(dev, dev_name(&phydev->dev), &ifxmips_adjust_link, 360 + 0, PHY_INTERFACE_MODE_MII); 361 + 362 + if (IS_ERR(phydev)) { 363 + printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 364 + return PTR_ERR(phydev); 365 + } 366 + 367 + /* mask with MAC supported features */ 368 + phydev->supported &= (SUPPORTED_10baseT_Half 369 + | SUPPORTED_10baseT_Full 370 + | SUPPORTED_100baseT_Half 371 + | SUPPORTED_100baseT_Full 372 + | SUPPORTED_Autoneg 373 + /* | SUPPORTED_Pause | SUPPORTED_Asym_Pause */ 374 + | SUPPORTED_MII 375 + | SUPPORTED_TP); 376 + 377 + phydev->advertising = phydev->supported; 378 + 379 + priv->phydev = phydev; 380 + 381 + printk(KERN_INFO "%s: attached PHY driver [%s] " 382 + "(mii_bus:phy_addr=%s, irq=%d)\n", 383 + dev->name, phydev->drv->name, dev_name(&phydev->dev), phydev->irq); 384 + 385 + return 0; 386 +} 387 + 388 + 303 389 +static int ifxmips_mii_dev_init(struct net_device *dev) 304 390 +{ … … 306 392 + struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv *)netdev_priv(dev); 307 393 + ether_setup(dev); 308 + printk(KERN_INFO "ifxmips_mii0: %s is up\n", dev->name);309 394 + dev->open = ifxmips_ifxmips_mii_open; 310 395 + dev->stop = ifxmips_mii_release; … … 337 422 + dma_device_register(priv->dma_device); 338 423 + 339 + printk(KERN_INFO " ifxmips_mii0: using mac=");424 + printk(KERN_INFO "%s: using mac=", dev->name); 340 425 + for (i = 0; i < 6; i++) { 341 426 + dev->dev_addr[i] = mac_addr[i]; 342 427 + printk("%02X%c", dev->dev_addr[i], (i == 5) ? ('\n') : (':')); 343 428 + } 344 + return 0; 429 + 430 + priv->mii_bus = mdiobus_alloc(); 431 + if (priv->mii_bus == NULL) 432 + return -ENOMEM; 433 + 434 + priv->mii_bus->priv = dev; 435 + priv->mii_bus->read = ifxmips_mdiobus_read; 436 + priv->mii_bus->write = ifxmips_mdiobus_write; 437 + priv->mii_bus->name = "ifxmips_mii"; 438 + snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%x", 0); 439 + priv->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); 440 + for(i = 0; i < PHY_MAX_ADDR; ++i) 441 + priv->mii_bus->irq[i] = PHY_POLL; 442 + 443 + mdiobus_register(priv->mii_bus); 444 + 445 + return mii_probe(dev); 345 446 +} 346 447 +
Note: See TracChangeset
for help on using the changeset viewer.