diff options
author | Vignesh R <vigneshr@ti.com> | 2016-08-02 04:44:27 (GMT) |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-08-08 17:32:54 (GMT) |
commit | 2e205ef7eb9e7793e922d0b6cd0fe4181309c058 (patch) | |
tree | 8e7d0037527602e72feb703fd028b4b9f9d98cfa /drivers/net | |
parent | 06974ea0e3357823d38da0e18921c5ed5fe6d510 (diff) | |
download | u-boot-2e205ef7eb9e7793e922d0b6cd0fe4181309c058.tar.xz |
net: cpsw: Add support to drive gpios for ethernet to be functional
On DRA72 EVM, cpsw slaves may be muxed with other modules. This
selection is controlled by a pcf gpio line. Add support for cpsw driver
to acquire mode-gpios and select the appropriate slave using gpio APIs.
Signed-off-by: Vignesh R <vigneshr@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/cpsw.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index 2ce4ec6..774b021 100644 --- a/drivers/net/cpsw.c +++ b/drivers/net/cpsw.c @@ -22,6 +22,7 @@ #include <netdev.h> #include <cpsw.h> #include <asm/errno.h> +#include <asm/gpio.h> #include <asm/io.h> #include <phy.h> #include <asm/arch/cpu.h> @@ -1152,12 +1153,14 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); struct cpsw_priv *priv = dev_get_priv(dev); + struct gpio_desc *mode_gpios; const char *phy_mode; const void *fdt = gd->fdt_blob; int node = dev->of_offset; int subnode; int slave_index = 0; int active_slave; + int num_mode_gpios; int ret; pdata->iobase = dev_get_addr(dev); @@ -1203,6 +1206,15 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) return -ENOENT; } + num_mode_gpios = gpio_get_list_count(dev, "mode-gpios"); + if (num_mode_gpios > 0) { + mode_gpios = malloc(sizeof(struct gpio_desc) * + num_mode_gpios); + gpio_request_list_by_name(dev, "mode-gpios", mode_gpios, + num_mode_gpios, GPIOD_IS_OUT); + free(mode_gpios); + } + active_slave = fdtdec_get_int(fdt, node, "active_slave", 0); priv->data.active_slave = active_slave; |