diff mbox

[U-Boot,4/7] net/ethoc: support device tree

Message ID 1470137470-6051-5-git-send-email-jcmvbkbc@gmail.com
State Accepted
Commit 2de18c8d77b026115dbe6b3e1a35446e31d3dbad
Delegated to: Joe Hershberger
Headers show

Commit Message

Max Filippov Aug. 2, 2016, 11:31 a.m. UTC
Add .of_match table and .ofdata_to_platdata callback to allow for ethoc
device configuration from the device tree.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 drivers/net/ethoc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Joe Hershberger Aug. 4, 2016, 6:01 p.m. UTC | #1
On Tue, Aug 2, 2016 at 6:31 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> Add .of_match table and .ofdata_to_platdata callback to allow for ethoc
> device configuration from the device tree.
>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox

Patch

diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 0225595..8cb15c7 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -600,6 +600,14 @@  static void ethoc_stop(struct udevice *dev)
 	ethoc_disable_rx_and_tx(priv);
 }
 
+static int ethoc_ofdata_to_platdata(struct udevice *dev)
+{
+	struct ethoc_eth_pdata *pdata = dev_get_platdata(dev);
+
+	pdata->eth_pdata.iobase = dev_get_addr(dev);
+	return 0;
+}
+
 static int ethoc_probe(struct udevice *dev)
 {
 	struct ethoc_eth_pdata *pdata = dev_get_platdata(dev);
@@ -626,9 +634,16 @@  static const struct eth_ops ethoc_ops = {
 	.write_hwaddr	= ethoc_write_hwaddr,
 };
 
+static const struct udevice_id ethoc_ids[] = {
+	{ .compatible = "opencores,ethoc" },
+	{ }
+};
+
 U_BOOT_DRIVER(ethoc) = {
 	.name				= "ethoc",
 	.id				= UCLASS_ETH,
+	.of_match			= ethoc_ids,
+	.ofdata_to_platdata		= ethoc_ofdata_to_platdata,
 	.probe				= ethoc_probe,
 	.remove				= ethoc_remove,
 	.ops				= &ethoc_ops,