Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <nikita.shubin@maquefel.me>
Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Nikita Shubin and committed by
Arnd Bergmann
770e709e 099747ce

+32 -31
+32 -31
drivers/net/ethernet/cirrus/ep93xx_eth.c
··· 16 16 #include <linux/ethtool.h> 17 17 #include <linux/interrupt.h> 18 18 #include <linux/moduleparam.h> 19 + #include <linux/of.h> 19 20 #include <linux/platform_device.h> 20 21 #include <linux/delay.h> 21 22 #include <linux/io.h> 22 23 #include <linux/slab.h> 23 - 24 - #include <linux/platform_data/eth-ep93xx.h> 25 24 26 25 #define DRV_MODULE_NAME "ep93xx-eth" 27 26 ··· 737 738 .ndo_set_mac_address = eth_mac_addr, 738 739 }; 739 740 740 - static struct net_device *ep93xx_dev_alloc(struct ep93xx_eth_data *data) 741 - { 742 - struct net_device *dev; 743 - 744 - dev = alloc_etherdev(sizeof(struct ep93xx_priv)); 745 - if (dev == NULL) 746 - return NULL; 747 - 748 - eth_hw_addr_set(dev, data->dev_addr); 749 - 750 - dev->ethtool_ops = &ep93xx_ethtool_ops; 751 - dev->netdev_ops = &ep93xx_netdev_ops; 752 - 753 - dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; 754 - 755 - return dev; 756 - } 757 - 758 - 759 741 static void ep93xx_eth_remove(struct platform_device *pdev) 760 742 { 761 743 struct net_device *dev; ··· 766 786 767 787 static int ep93xx_eth_probe(struct platform_device *pdev) 768 788 { 769 - struct ep93xx_eth_data *data; 770 789 struct net_device *dev; 771 790 struct ep93xx_priv *ep; 772 791 struct resource *mem; 792 + void __iomem *base_addr; 793 + struct device_node *np; 794 + u32 phy_id; 773 795 int irq; 774 796 int err; 775 797 776 798 if (pdev == NULL) 777 799 return -ENODEV; 778 - data = dev_get_platdata(&pdev->dev); 779 800 780 801 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 781 802 irq = platform_get_irq(pdev, 0); 782 803 if (!mem || irq < 0) 783 804 return -ENXIO; 784 805 785 - dev = ep93xx_dev_alloc(data); 806 + base_addr = ioremap(mem->start, resource_size(mem)); 807 + if (!base_addr) 808 + return dev_err_probe(&pdev->dev, -EIO, "Failed to ioremap ethernet registers\n"); 809 + 810 + np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); 811 + if (!np) 812 + return dev_err_probe(&pdev->dev, -ENODEV, "Please provide \"phy-handle\"\n"); 813 + 814 + err = of_property_read_u32(np, "reg", &phy_id); 815 + of_node_put(np); 816 + if (err) 817 + return dev_err_probe(&pdev->dev, -ENOENT, "Failed to locate \"phy_id\"\n"); 818 + 819 + dev = alloc_etherdev(sizeof(struct ep93xx_priv)); 786 820 if (dev == NULL) { 787 821 err = -ENOMEM; 788 822 goto err_out; 789 823 } 824 + 825 + eth_hw_addr_set(dev, base_addr + 0x50); 826 + dev->ethtool_ops = &ep93xx_ethtool_ops; 827 + dev->netdev_ops = &ep93xx_netdev_ops; 828 + dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; 829 + 790 830 ep = netdev_priv(dev); 791 831 ep->dev = dev; 792 832 SET_NETDEV_DEV(dev, &pdev->dev); ··· 822 822 goto err_out; 823 823 } 824 824 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; 831 826 ep->irq = irq; 832 827 833 - ep->mii.phy_id = data->phy_id; 828 + ep->mii.phy_id = phy_id; 834 829 ep->mii.phy_id_mask = 0x1f; 835 830 ep->mii.reg_num_mask = 0x1f; 836 831 ep->mii.dev = dev; ··· 852 857 return err; 853 858 } 854 859 860 + static const struct of_device_id ep93xx_eth_of_ids[] = { 861 + { .compatible = "cirrus,ep9301-eth" }, 862 + { /* sentinel */ } 863 + }; 864 + MODULE_DEVICE_TABLE(of, ep93xx_eth_of_ids); 855 865 856 866 static struct platform_driver ep93xx_eth_driver = { 857 867 .probe = ep93xx_eth_probe, 858 868 .remove_new = ep93xx_eth_remove, 859 869 .driver = { 860 870 .name = "ep93xx-eth", 871 + .of_match_table = ep93xx_eth_of_ids, 861 872 }, 862 873 }; 863 874