Commit 87227b8b authored by Jean-Christophe PLAGNIOL-VILLARD's avatar Jean-Christophe PLAGNIOL-VILLARD Committed by David S. Miller

net: micrel : ks8851-ml: add dt support

Signed-off-by: default avatarJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 51047840
Micrel KS8851 Ethernet mac
Required properties:
- compatible = "micrel,ks8851-ml" of parallel interface
- reg : 2 physical address and size of registers for data and command
- interrupts : interrupt connection
Optional properties:
- local-mac-address : Ethernet mac address to use
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/ks8851_mll.h> #include <linux/ks8851_mll.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_net.h>
#define DRV_NAME "ks8851_mll" #define DRV_NAME "ks8851_mll"
...@@ -1524,6 +1527,13 @@ static int ks_hw_init(struct ks_net *ks) ...@@ -1524,6 +1527,13 @@ static int ks_hw_init(struct ks_net *ks)
return true; return true;
} }
#if defined(CONFIG_OF)
static const struct of_device_id ks8851_ml_dt_ids[] = {
{ .compatible = "micrel,ks8851-mll" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, ks8851_ml_dt_ids);
#endif
static int ks8851_probe(struct platform_device *pdev) static int ks8851_probe(struct platform_device *pdev)
{ {
...@@ -1532,7 +1542,7 @@ static int ks8851_probe(struct platform_device *pdev) ...@@ -1532,7 +1542,7 @@ static int ks8851_probe(struct platform_device *pdev)
struct net_device *netdev; struct net_device *netdev;
struct ks_net *ks; struct ks_net *ks;
u16 id, data; u16 id, data;
struct ks8851_mll_platform_data *pdata; const char *mac;
io_d = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_d = platform_get_resource(pdev, IORESOURCE_MEM, 0);
io_c = platform_get_resource(pdev, IORESOURCE_MEM, 1); io_c = platform_get_resource(pdev, IORESOURCE_MEM, 1);
...@@ -1619,13 +1629,21 @@ static int ks8851_probe(struct platform_device *pdev) ...@@ -1619,13 +1629,21 @@ static int ks8851_probe(struct platform_device *pdev)
ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16MA); ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16MA);
/* overwriting the default MAC address */ /* overwriting the default MAC address */
pdata = pdev->dev.platform_data; if (pdev->dev.of_node) {
if (!pdata) { mac = of_get_mac_address(pdev->dev.of_node);
netdev_err(netdev, "No platform data\n"); if (mac)
err = -ENODEV; memcpy(ks->mac_addr, mac, ETH_ALEN);
goto err_pdata; } else {
struct ks8851_mll_platform_data *pdata;
pdata = pdev->dev.platform_data;
if (!pdata) {
netdev_err(netdev, "No platform data\n");
err = -ENODEV;
goto err_pdata;
}
memcpy(ks->mac_addr, pdata->mac_addr, ETH_ALEN);
} }
memcpy(ks->mac_addr, pdata->mac_addr, 6);
if (!is_valid_ether_addr(ks->mac_addr)) { if (!is_valid_ether_addr(ks->mac_addr)) {
/* Use random MAC address if none passed */ /* Use random MAC address if none passed */
eth_random_addr(ks->mac_addr); eth_random_addr(ks->mac_addr);
...@@ -1679,6 +1697,7 @@ static struct platform_driver ks8851_platform_driver = { ...@@ -1679,6 +1697,7 @@ static struct platform_driver ks8851_platform_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = of_match_ptr(ks8851_ml_dt_ids),
}, },
.probe = ks8851_probe, .probe = ks8851_probe,
.remove = ks8851_remove, .remove = ks8851_remove,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment