Skip to content

Commit 770e709

Browse files
maquefelarndb
authored andcommitted
net: cirrus: add DT support for Cirrus EP93xx
- add OF ID match table - get phy_id from the device tree, as part of mdio - copy_addr is now always used, as there is no SoC/board that aren't - dropped platform header Signed-off-by: Nikita Shubin <[email protected]> Tested-by: Alexander Sverdlin <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Acked-by: Miquel Raynal <[email protected]> Acked-by: Vinod Koul <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 099747c commit 770e709

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

drivers/net/ethernet/cirrus/ep93xx_eth.c

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
#include <linux/ethtool.h>
1717
#include <linux/interrupt.h>
1818
#include <linux/moduleparam.h>
19+
#include <linux/of.h>
1920
#include <linux/platform_device.h>
2021
#include <linux/delay.h>
2122
#include <linux/io.h>
2223
#include <linux/slab.h>
2324

24-
#include <linux/platform_data/eth-ep93xx.h>
25-
2625
#define DRV_MODULE_NAME "ep93xx-eth"
2726

2827
#define RX_QUEUE_ENTRIES 64
@@ -738,25 +737,6 @@ static const struct net_device_ops ep93xx_netdev_ops = {
738737
.ndo_set_mac_address = eth_mac_addr,
739738
};
740739

741-
static struct net_device *ep93xx_dev_alloc(struct ep93xx_eth_data *data)
742-
{
743-
struct net_device *dev;
744-
745-
dev = alloc_etherdev(sizeof(struct ep93xx_priv));
746-
if (dev == NULL)
747-
return NULL;
748-
749-
eth_hw_addr_set(dev, data->dev_addr);
750-
751-
dev->ethtool_ops = &ep93xx_ethtool_ops;
752-
dev->netdev_ops = &ep93xx_netdev_ops;
753-
754-
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
755-
756-
return dev;
757-
}
758-
759-
760740
static void ep93xx_eth_remove(struct platform_device *pdev)
761741
{
762742
struct net_device *dev;
@@ -786,27 +766,47 @@ static void ep93xx_eth_remove(struct platform_device *pdev)
786766

787767
static int ep93xx_eth_probe(struct platform_device *pdev)
788768
{
789-
struct ep93xx_eth_data *data;
790769
struct net_device *dev;
791770
struct ep93xx_priv *ep;
792771
struct resource *mem;
772+
void __iomem *base_addr;
773+
struct device_node *np;
774+
u32 phy_id;
793775
int irq;
794776
int err;
795777

796778
if (pdev == NULL)
797779
return -ENODEV;
798-
data = dev_get_platdata(&pdev->dev);
799780

800781
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
801782
irq = platform_get_irq(pdev, 0);
802783
if (!mem || irq < 0)
803784
return -ENXIO;
804785

805-
dev = ep93xx_dev_alloc(data);
786+
base_addr = ioremap(mem->start, resource_size(mem));
787+
if (!base_addr)
788+
return dev_err_probe(&pdev->dev, -EIO, "Failed to ioremap ethernet registers\n");
789+
790+
np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
791+
if (!np)
792+
return dev_err_probe(&pdev->dev, -ENODEV, "Please provide \"phy-handle\"\n");
793+
794+
err = of_property_read_u32(np, "reg", &phy_id);
795+
of_node_put(np);
796+
if (err)
797+
return dev_err_probe(&pdev->dev, -ENOENT, "Failed to locate \"phy_id\"\n");
798+
799+
dev = alloc_etherdev(sizeof(struct ep93xx_priv));
806800
if (dev == NULL) {
807801
err = -ENOMEM;
808802
goto err_out;
809803
}
804+
805+
eth_hw_addr_set(dev, base_addr + 0x50);
806+
dev->ethtool_ops = &ep93xx_ethtool_ops;
807+
dev->netdev_ops = &ep93xx_netdev_ops;
808+
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
809+
810810
ep = netdev_priv(dev);
811811
ep->dev = dev;
812812
SET_NETDEV_DEV(dev, &pdev->dev);
@@ -822,15 +822,10 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
822822
goto err_out;
823823
}
824824

825-
ep->base_addr = ioremap(mem->start, resource_size(mem));
826-
if (ep->base_addr == NULL) {
827-
dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n");
828-
err = -EIO;
829-
goto err_out;
830-
}
825+
ep->base_addr = base_addr;
831826
ep->irq = irq;
832827

833-
ep->mii.phy_id = data->phy_id;
828+
ep->mii.phy_id = phy_id;
834829
ep->mii.phy_id_mask = 0x1f;
835830
ep->mii.reg_num_mask = 0x1f;
836831
ep->mii.dev = dev;
@@ -857,12 +852,18 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
857852
return err;
858853
}
859854

855+
static const struct of_device_id ep93xx_eth_of_ids[] = {
856+
{ .compatible = "cirrus,ep9301-eth" },
857+
{ /* sentinel */ }
858+
};
859+
MODULE_DEVICE_TABLE(of, ep93xx_eth_of_ids);
860860

861861
static struct platform_driver ep93xx_eth_driver = {
862862
.probe = ep93xx_eth_probe,
863863
.remove_new = ep93xx_eth_remove,
864864
.driver = {
865865
.name = "ep93xx-eth",
866+
.of_match_table = ep93xx_eth_of_ids,
866867
},
867868
};
868869

0 commit comments

Comments
 (0)