Message ID | 20210629170839.2583797-5-olteanv@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Priyanka Jain |
Headers | show |
Series | Call phy_config at port probe time for the Felix DSA driver | expand |
On Tue, Jun 29, 2021 at 8:09 PM Vladimir Oltean <olteanv@gmail.com> wrote: > > From: Vladimir Oltean <vladimir.oltean@nxp.com> > > Some drivers might want to execute code for each port at probe time, as > opposed to executing code just-in-time for the port selected for > networking. > > To cater to that use case, introduce a .port_probe() callback method > into the DSA switch operations which is called for each available port, > at the end of dsa_port_probe(). > > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> > --- > include/net/dsa.h | 5 ++++- > net/dsa-uclass.c | 7 +++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/include/net/dsa.h b/include/net/dsa.h > index 0f31a908c9d1..ab2a9dfbea2d 100644 > --- a/include/net/dsa.h > +++ b/include/net/dsa.h > @@ -57,7 +57,8 @@ > /** > * struct dsa_ops - DSA operations > * > - * @port_enable: Initialize a switch port for I/O. > + * @port_probe: Initialize a switch port. > + * @port_enable: Enable I/O for a port. > * @port_disable: Disable I/O for a port. > * @xmit: Insert the DSA tag for transmission. > * DSA drivers receive a copy of the packet with headroom and > @@ -69,6 +70,8 @@ > * master including any additional headers. > */ > struct dsa_ops { > + int (*port_probe)(struct udevice *dev, int port, > + struct phy_device *phy); > int (*port_enable)(struct udevice *dev, int port, > struct phy_device *phy); > void (*port_disable)(struct udevice *dev, int port, > diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c > index e23da2ed0e95..1db723573e6c 100644 > --- a/net/dsa-uclass.c > +++ b/net/dsa-uclass.c > @@ -263,6 +263,7 @@ static void dsa_port_set_hwaddr(struct udevice *pdev, struct udevice *master) > static int dsa_port_probe(struct udevice *pdev) > { > struct udevice *dev = dev_get_parent(pdev); > + struct dsa_ops *ops = dsa_get_ops(dev); > struct dsa_port_pdata *port_pdata; > struct dsa_priv *dsa_priv; > struct udevice *master; > @@ -292,6 +293,12 @@ static int dsa_port_probe(struct udevice *pdev) > > dsa_port_set_hwaddr(pdev, master); > > + if (ops->port_probe) { > + err = ops->port_probe(dev, port_pdata->index, > + port_pdata->phy); > + if (err) > + return err; > + } > > return 0; > } > -- > 2.25.1 > Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff --git a/include/net/dsa.h b/include/net/dsa.h index 0f31a908c9d1..ab2a9dfbea2d 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -57,7 +57,8 @@ /** * struct dsa_ops - DSA operations * - * @port_enable: Initialize a switch port for I/O. + * @port_probe: Initialize a switch port. + * @port_enable: Enable I/O for a port. * @port_disable: Disable I/O for a port. * @xmit: Insert the DSA tag for transmission. * DSA drivers receive a copy of the packet with headroom and @@ -69,6 +70,8 @@ * master including any additional headers. */ struct dsa_ops { + int (*port_probe)(struct udevice *dev, int port, + struct phy_device *phy); int (*port_enable)(struct udevice *dev, int port, struct phy_device *phy); void (*port_disable)(struct udevice *dev, int port, diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c index e23da2ed0e95..1db723573e6c 100644 --- a/net/dsa-uclass.c +++ b/net/dsa-uclass.c @@ -263,6 +263,7 @@ static void dsa_port_set_hwaddr(struct udevice *pdev, struct udevice *master) static int dsa_port_probe(struct udevice *pdev) { struct udevice *dev = dev_get_parent(pdev); + struct dsa_ops *ops = dsa_get_ops(dev); struct dsa_port_pdata *port_pdata; struct dsa_priv *dsa_priv; struct udevice *master; @@ -292,6 +293,12 @@ static int dsa_port_probe(struct udevice *pdev) dsa_port_set_hwaddr(pdev, master); + if (ops->port_probe) { + err = ops->port_probe(dev, port_pdata->index, + port_pdata->phy); + if (err) + return err; + } return 0; }