From 6617f87668dec898470224fe9fb22c0807649a1c Mon Sep 17 00:00:00 2001 From: Sylvain Lemieux Date: Wed, 9 Sep 2015 16:29:51 -0400 Subject: net: phy: micrel: add support for KSZ8021RNL & KSZ8031RNL This patch adds support for Micrel KSZ8021RNL & KSZ8031RNL. Signed-off-by: Sylvain Lemieux Acked-by: Joe Hershberger --- drivers/net/phy/micrel.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/net') diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 49f444a..cbec928 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -22,6 +22,16 @@ static struct phy_driver KSZ804_driver = { .shutdown = &genphy_shutdown, }; +static struct phy_driver KSZ8031_driver = { + .name = "Micrel KSZ8021/KSZ8031", + .uid = 0x221550, + .mask = 0xfffff0, + .features = PHY_BASIC_FEATURES, + .config = &genphy_config, + .startup = &genphy_startup, + .shutdown = &genphy_shutdown, +}; + static struct phy_driver KSZ8081_driver = { .name = "Micrel KSZ8081", .uid = 0x221560, @@ -282,6 +292,7 @@ static struct phy_driver ksz9031_driver = { int phy_micrel_init(void) { phy_register(&KSZ804_driver); + phy_register(&KSZ8031_driver); phy_register(&KSZ8081_driver); #ifdef CONFIG_PHY_MICREL_KSZ9021 phy_register(&ksz9021_driver); -- cgit v1.1 From f3ba55235dddb11bbb615669b43688f4c1b73f69 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Fri, 2 Oct 2015 17:44:34 -0600 Subject: net: rtl8169: Build warning fixes for 64-bit Casting from dev->priv to pci_dev_t changes the value's size on a 64-bit system. This causes the compiler to complain about casting a pointer to an integer of a different (smaller) size. To avoid this, cast to an integer of matching size first, then perform an int->int cast to perform the size change. This signals explicitly that we do want to change the size, and avoids the compiler warning. This is legitimate since we know the pointer actually stores a small integer, not a pointer value. Signed-off-by: Stephen Warren Acked-by: Joe Hershberger --- drivers/net/rtl8169.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/net') diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index ebd46b2..19422c4 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -581,7 +581,8 @@ int rtl8169_eth_recv(struct udevice *dev, int flags, uchar **packetp) #else static int rtl_recv(struct eth_device *dev) { - return rtl_recv_common((pci_dev_t)dev->priv, dev->iobase, NULL); + return rtl_recv_common((pci_dev_t)(unsigned long)dev->priv, + dev->iobase, NULL); } #endif /* nCONFIG_DM_ETH */ @@ -666,8 +667,8 @@ int rtl8169_eth_send(struct udevice *dev, void *packet, int length) #else static int rtl_send(struct eth_device *dev, void *packet, int length) { - return rtl_send_common((pci_dev_t)dev->priv, dev->iobase, packet, - length); + return rtl_send_common((pci_dev_t)(unsigned long)dev->priv, + dev->iobase, packet, length); } #endif @@ -846,7 +847,8 @@ RESET - Finish setting up the ethernet interface ***************************************************************************/ static int rtl_reset(struct eth_device *dev, bd_t *bis) { - rtl8169_common_start((pci_dev_t)dev->priv, dev->enetaddr); + rtl8169_common_start((pci_dev_t)(unsigned long)dev->priv, + dev->enetaddr); return 0; } -- cgit v1.1 From 4f485150cfdc1cbbf841e46236dd5052fbe5c542 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Wed, 7 Oct 2015 22:54:22 +0200 Subject: net: phy: micrel: disable NAND-tree for KSZ8051 NAND-tree is used to check wiring between MAC and PHY using NAND gates on the PHY side, hence the name. NAND-tree initial status is latched at reset by probing the IRQ pin. However some devices are sharing the PHY IRQ pin with other peripherals such as Atmel SAMA5D[34]x-EK boards when using the optional TM7000 display module, therefore they are switching the PHY in NAND-tree test mode depending on the current IRQ line status at reset. This patch ensure PHY is not in NAND-tree test mode only for the Micrel KSZ8051 PHY used by Atmel. There are other Micrel PHY affected but I doubt they are used on such weird hardware design. Signed-off-by: Sylvain Rochet Acked-by: Joe Hershberger --- drivers/net/phy/micrel.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'drivers/net') diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index cbec928..5e49666 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -32,6 +32,34 @@ static struct phy_driver KSZ8031_driver = { .shutdown = &genphy_shutdown, }; +/** + * KSZ8051 + */ +#define MII_KSZ8051_PHY_OMSO 0x16 +#define MII_KSZ8051_PHY_OMSO_NAND_TREE_ON (1 << 5) + +static int ksz8051_config(struct phy_device *phydev) +{ + unsigned val; + + /* Disable NAND-tree */ + val = phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZ8051_PHY_OMSO); + val &= ~MII_KSZ8051_PHY_OMSO_NAND_TREE_ON; + phy_write(phydev, MDIO_DEVAD_NONE, MII_KSZ8051_PHY_OMSO, val); + + return genphy_config(phydev); +} + +static struct phy_driver KSZ8051_driver = { + .name = "Micrel KSZ8051", + .uid = 0x221550, + .mask = 0xfffff0, + .features = PHY_BASIC_FEATURES, + .config = &ksz8051_config, + .startup = &genphy_startup, + .shutdown = &genphy_shutdown, +}; + static struct phy_driver KSZ8081_driver = { .name = "Micrel KSZ8081", .uid = 0x221560, @@ -293,6 +321,7 @@ int phy_micrel_init(void) { phy_register(&KSZ804_driver); phy_register(&KSZ8031_driver); + phy_register(&KSZ8051_driver); phy_register(&KSZ8081_driver); #ifdef CONFIG_PHY_MICREL_KSZ9021 phy_register(&ksz9021_driver); -- cgit v1.1 From 0132b9ab6e6593d1fd259cdd26261f184c436fdd Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 7 Oct 2015 21:19:29 -0700 Subject: net: phy: Don't create phy device when there is no phy In get_phy_device_by_mask(), when no phy is found, we should not create any phy device. Signed-off-by: Bin Meng Acked-by: Joe Hershberger --- drivers/net/phy/phy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index a6023f1..4063894 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -672,7 +672,8 @@ static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus, return phydev; } printf("Phy %d not found\n", ffs(phy_mask) - 1); - return phy_device_create(bus, ffs(phy_mask) - 1, 0xffffffff, interface); + + return NULL; } /** -- cgit v1.1 From 3e1949d77463b062a4f8d380128abb7854f4907b Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 7 Oct 2015 21:19:30 -0700 Subject: net: phy: Change to print all phys that are not found In get_phy_device_by_mask(), when no phy is found, currently we only print a message to show the first phy address that is not found. But this is not always the case as multiple phys can be specified by phy_mask. Change to print all phys that are not found, and to reduce the console boot log, change to use 'debug' instead of 'printf'. Signed-off-by: Bin Meng Acked-by: Joe Hershberger --- drivers/net/phy/phy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/net') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 4063894..d0b3e85 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -671,7 +671,14 @@ static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus, if (phydev) return phydev; } - printf("Phy %d not found\n", ffs(phy_mask) - 1); + + debug("\n%s PHY: ", bus->name); + while (phy_mask) { + int addr = ffs(phy_mask) - 1; + debug("%d ", addr); + phy_mask &= ~(1 << addr); + } + debug("not found\n"); return NULL; } -- cgit v1.1 From 17ecfa9b45db7964f6a20cd710a87decd2f2e1f5 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 7 Oct 2015 21:19:31 -0700 Subject: net: phy: Test previous phydev->dev against new mac dev In phy_connect_dev(), if the phy device has an accociated mac device before, a warning message will be printed. But we should test the old device against the new one, if they are actually the same one, don't print the warning message. Signed-off-by: Bin Meng Acked-by: Joe Hershberger --- drivers/net/phy/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index d0b3e85..d7364ff 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -789,7 +789,7 @@ void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev) { /* Soft Reset the PHY */ phy_reset(phydev); - if (phydev->dev) { + if (phydev->dev && phydev->dev != dev) { printf("%s:%d is connected to %s. Reconnecting to %s\n", phydev->bus->name, phydev->addr, phydev->dev->name, dev->name); -- cgit v1.1 From 5d2459fd466ebf86c717ccb28a8f56707a29724a Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 7 Oct 2015 21:32:38 -0700 Subject: net: designware: Add driver remove support In designware_eth_probe(), some additional resources are allocated (eg: mdio, phy). We should free these in the driver remove phase. Add designware_eth_remove() to clean it up. Signed-off-by: Bin Meng Acked-by: Simon Glass --- drivers/net/designware.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/net') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 6433896..a6c39c3 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -613,6 +613,17 @@ static int designware_eth_probe(struct udevice *dev) return ret; } +static int designware_eth_remove(struct udevice *dev) +{ + struct dw_eth_dev *priv = dev_get_priv(dev); + + free(priv->phydev); + mdio_unregister(priv->bus); + mdio_free(priv->bus); + + return 0; +} + static const struct eth_ops designware_eth_ops = { .start = designware_eth_start, .send = designware_eth_send, @@ -653,6 +664,7 @@ U_BOOT_DRIVER(eth_designware) = { .ofdata_to_platdata = designware_eth_ofdata_to_platdata, .bind = designware_eth_bind, .probe = designware_eth_probe, + .remove = designware_eth_remove, .ops = &designware_eth_ops, .priv_auto_alloc_size = sizeof(struct dw_eth_dev), .platdata_auto_alloc_size = sizeof(struct eth_pdata), -- cgit v1.1 From 3f616b6053517927f564fc8ed6dc4a87bd39e857 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 7 Oct 2015 21:32:39 -0700 Subject: net: pch_gbe: Add driver remove support In pch_gbe_probe(), some additional resources are allocated (eg: mdio, phy). We should free these in the driver remove phase. Add pch_gbe_remove() to clean it up. Signed-off-by: Bin Meng Reviewed-by: Simon Glass Acked-by: Joe Hershberger --- drivers/net/pch_gbe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/net') diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 004fcf8..dfc0100 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -452,6 +452,17 @@ int pch_gbe_probe(struct udevice *dev) return pch_gbe_phy_init(dev); } +int pch_gbe_remove(struct udevice *dev) +{ + struct pch_gbe_priv *priv = dev_get_priv(dev); + + free(priv->phydev); + mdio_unregister(priv->bus); + mdio_free(priv->bus); + + return 0; +} + static const struct eth_ops pch_gbe_ops = { .start = pch_gbe_start, .send = pch_gbe_send, @@ -470,6 +481,7 @@ U_BOOT_DRIVER(eth_pch_gbe) = { .id = UCLASS_ETH, .of_match = pch_gbe_ids, .probe = pch_gbe_probe, + .remove = pch_gbe_remove, .ops = &pch_gbe_ops, .priv_auto_alloc_size = sizeof(struct pch_gbe_priv), .platdata_auto_alloc_size = sizeof(struct eth_pdata), -- cgit v1.1