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

net: micrel : ks8851-ml: add dt support

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jean-Christophe PLAGNIOL-VILLARD and committed by
David S. Miller
87227b8b 51047840

+35 -7
+9
Documentation/devicetree/bindings/net/micrel-ks8851.txt
··· 1 + Micrel KS8851 Ethernet mac 2 + 3 + Required properties: 4 + - compatible = "micrel,ks8851-ml" of parallel interface 5 + - reg : 2 physical address and size of registers for data and command 6 + - interrupts : interrupt connection 7 + 8 + Optional properties: 9 + - local-mac-address : Ethernet mac address to use
+26 -7
drivers/net/ethernet/micrel/ks8851_mll.c
··· 35 35 #include <linux/delay.h> 36 36 #include <linux/slab.h> 37 37 #include <linux/ks8851_mll.h> 38 + #include <linux/of.h> 39 + #include <linux/of_device.h> 40 + #include <linux/of_net.h> 38 41 39 42 #define DRV_NAME "ks8851_mll" 40 43 ··· 1527 1524 return true; 1528 1525 } 1529 1526 1527 + #if defined(CONFIG_OF) 1528 + static const struct of_device_id ks8851_ml_dt_ids[] = { 1529 + { .compatible = "micrel,ks8851-mll" }, 1530 + { /* sentinel */ } 1531 + }; 1532 + MODULE_DEVICE_TABLE(of, ks8851_ml_dt_ids); 1533 + #endif 1530 1534 1531 1535 static int ks8851_probe(struct platform_device *pdev) 1532 1536 { ··· 1542 1532 struct net_device *netdev; 1543 1533 struct ks_net *ks; 1544 1534 u16 id, data; 1545 - struct ks8851_mll_platform_data *pdata; 1535 + const char *mac; 1546 1536 1547 1537 io_d = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1548 1538 io_c = platform_get_resource(pdev, IORESOURCE_MEM, 1); ··· 1629 1619 ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16MA); 1630 1620 1631 1621 /* overwriting the default MAC address */ 1632 - pdata = pdev->dev.platform_data; 1633 - if (!pdata) { 1634 - netdev_err(netdev, "No platform data\n"); 1635 - err = -ENODEV; 1636 - goto err_pdata; 1622 + if (pdev->dev.of_node) { 1623 + mac = of_get_mac_address(pdev->dev.of_node); 1624 + if (mac) 1625 + memcpy(ks->mac_addr, mac, ETH_ALEN); 1626 + } else { 1627 + struct ks8851_mll_platform_data *pdata; 1628 + 1629 + pdata = pdev->dev.platform_data; 1630 + if (!pdata) { 1631 + netdev_err(netdev, "No platform data\n"); 1632 + err = -ENODEV; 1633 + goto err_pdata; 1634 + } 1635 + memcpy(ks->mac_addr, pdata->mac_addr, ETH_ALEN); 1637 1636 } 1638 - memcpy(ks->mac_addr, pdata->mac_addr, 6); 1639 1637 if (!is_valid_ether_addr(ks->mac_addr)) { 1640 1638 /* Use random MAC address if none passed */ 1641 1639 eth_random_addr(ks->mac_addr); ··· 1697 1679 .driver = { 1698 1680 .name = DRV_NAME, 1699 1681 .owner = THIS_MODULE, 1682 + .of_match_table = of_match_ptr(ks8851_ml_dt_ids), 1700 1683 }, 1701 1684 .probe = ks8851_probe, 1702 1685 .remove = ks8851_remove,