diff mbox

[U-Boot,1/3] net: ravb: Add OF probing support

Message ID 20170721212035.25910-1-marek.vasut+renesas@gmail.com
State Accepted
Commit 5ee8b4d7f5e52e2ace15ca6bfbb35593d908af0f
Delegated to: Nobuhiro Iwamatsu
Headers show

Commit Message

Marek Vasut July 21, 2017, 9:20 p.m. UTC
Add support for probing the RAVB Ethernet block from device tree.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
---
 drivers/net/ravb.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

Joe Hershberger July 27, 2017, 9:27 p.m. UTC | #1
On Fri, Jul 21, 2017 at 4:20 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> Add support for probing the RAVB Ethernet block from device tree.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Nobuhiro Iwamatsu Aug. 2, 2017, 11:16 p.m. UTC | #2
Applied to rmobile branch, thanks!

2017-07-22 6:20 GMT+09:00 Marek Vasut <marek.vasut@gmail.com>:
> Add support for probing the RAVB Ethernet block from device tree.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> ---
>  drivers/net/ravb.c | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
> index ab45a31d6a..7f0e2568b7 100644
> --- a/drivers/net/ravb.c
> +++ b/drivers/net/ravb.c
> @@ -589,9 +589,46 @@ static const struct eth_ops ravb_ops = {
>         .write_hwaddr           = ravb_write_hwaddr,
>  };
>
> +int ravb_ofdata_to_platdata(struct udevice *dev)
> +{
> +       struct eth_pdata *pdata = dev_get_platdata(dev);
> +       const char *phy_mode;
> +       const fdt32_t *cell;
> +       int ret = 0;
> +
> +       pdata->iobase = devfdt_get_addr(dev);
> +       pdata->phy_interface = -1;
> +       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
> +                              NULL);
> +       if (phy_mode)
> +               pdata->phy_interface = phy_get_interface_by_name(phy_mode);
> +       if (pdata->phy_interface == -1) {
> +               debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
> +               return -EINVAL;
> +       }
> +
> +       pdata->max_speed = 1000;
> +       cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL);
> +       if (cell)
> +               pdata->max_speed = fdt32_to_cpu(*cell);
> +
> +       sprintf(bb_miiphy_buses[0].name, dev->name);
> +
> +       return ret;
> +}
> +
> +static const struct udevice_id ravb_ids[] = {
> +       { .compatible = "renesas,etheravb-r8a7795" },
> +       { .compatible = "renesas,etheravb-r8a7796" },
> +       { .compatible = "renesas,etheravb-rcar-gen3" },
> +       { }
> +};
> +
>  U_BOOT_DRIVER(eth_ravb) = {
>         .name           = "ravb",
>         .id             = UCLASS_ETH,
> +       .of_match       = ravb_ids,
> +       .ofdata_to_platdata = ravb_ofdata_to_platdata,
>         .probe          = ravb_probe,
>         .remove         = ravb_remove,
>         .ops            = &ravb_ops,
> --
> 2.11.0
>
diff mbox

Patch

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index ab45a31d6a..7f0e2568b7 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -589,9 +589,46 @@  static const struct eth_ops ravb_ops = {
 	.write_hwaddr		= ravb_write_hwaddr,
 };
 
+int ravb_ofdata_to_platdata(struct udevice *dev)
+{
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+	const char *phy_mode;
+	const fdt32_t *cell;
+	int ret = 0;
+
+	pdata->iobase = devfdt_get_addr(dev);
+	pdata->phy_interface = -1;
+	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+			       NULL);
+	if (phy_mode)
+		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
+	if (pdata->phy_interface == -1) {
+		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+		return -EINVAL;
+	}
+
+	pdata->max_speed = 1000;
+	cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL);
+	if (cell)
+		pdata->max_speed = fdt32_to_cpu(*cell);
+
+	sprintf(bb_miiphy_buses[0].name, dev->name);
+
+	return ret;
+}
+
+static const struct udevice_id ravb_ids[] = {
+	{ .compatible = "renesas,etheravb-r8a7795" },
+	{ .compatible = "renesas,etheravb-r8a7796" },
+	{ .compatible = "renesas,etheravb-rcar-gen3" },
+	{ }
+};
+
 U_BOOT_DRIVER(eth_ravb) = {
 	.name		= "ravb",
 	.id		= UCLASS_ETH,
+	.of_match	= ravb_ids,
+	.ofdata_to_platdata = ravb_ofdata_to_platdata,
 	.probe		= ravb_probe,
 	.remove		= ravb_remove,
 	.ops		= &ravb_ops,