Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 21:07, Andrew Lunn wrote: >> Since the former alternative is prefered, we may want to remove the >> latter soon from DSA. If this phy_port_map is needed for that case, it'd >> be preferable not to add it. > > O.K, so maybe we should solve it the device tree way: > > > {

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 21:07, Andrew Lunn wrote: >> Since the former alternative is prefered, we may want to remove the >> latter soon from DSA. If this phy_port_map is needed for that case, it'd >> be preferable not to add it. > > O.K, so maybe we should solve it the device tree way: > > > {

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Andrew Lunn
> Since the former alternative is prefered, we may want to remove the > latter soon from DSA. If this phy_port_map is needed for that case, it'd > be preferable not to add it. O.K, so maybe we should solve it the device tree way: { phy_port1: phy@0 {

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Andrew Lunn
> Since the former alternative is prefered, we may want to remove the > latter soon from DSA. If this phy_port_map is needed for that case, it'd > be preferable not to add it. O.K, so maybe we should solve it the device tree way: { phy_port1: phy@0 {

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Florian Fainelli
On 09/13/2016 11:07 AM, John Crispin wrote: > > > On 13/09/2016 19:09, Florian Fainelli wrote: >> On 09/13/2016 08:59 AM, Andrew Lunn wrote: Hi Andrew, this function does indeed duplicate the functionality of phy_ethtool_get_eee() with the small difference, that e->eee_active

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Florian Fainelli
On 09/13/2016 11:07 AM, John Crispin wrote: > > > On 13/09/2016 19:09, Florian Fainelli wrote: >> On 09/13/2016 08:59 AM, Andrew Lunn wrote: Hi Andrew, this function does indeed duplicate the functionality of phy_ethtool_get_eee() with the small difference, that e->eee_active

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 19:09, Florian Fainelli wrote: > On 09/13/2016 08:59 AM, Andrew Lunn wrote: >>> Hi Andrew, >>> >>> this function does indeed duplicate the functionality of >>> phy_ethtool_get_eee() with the small difference, that e->eee_active is >>> also set which phy_ethtool_get_eee() does not

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 19:09, Florian Fainelli wrote: > On 09/13/2016 08:59 AM, Andrew Lunn wrote: >>> Hi Andrew, >>> >>> this function does indeed duplicate the functionality of >>> phy_ethtool_get_eee() with the small difference, that e->eee_active is >>> also set which phy_ethtool_get_eee() does not

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Vivien Didelot
Hi Andrew, Andrew Lunn writes: >> ok, i will simply substract 1 from the phy_addr inside the mdio >> callbacks. this would make the code more readable and make the DT >> binding compliant with the ePAPR spec. > > It does however need well commenting. It is setting a trap for

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Vivien Didelot
Hi Andrew, Andrew Lunn writes: >> ok, i will simply substract 1 from the phy_addr inside the mdio >> callbacks. this would make the code more readable and make the DT >> binding compliant with the ePAPR spec. > > It does however need well commenting. It is setting a trap for anybody > who puts

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Florian Fainelli
On 09/13/2016 08:59 AM, Andrew Lunn wrote: >> Hi Andrew, >> >> this function does indeed duplicate the functionality of >> phy_ethtool_get_eee() with the small difference, that e->eee_active is >> also set which phy_ethtool_get_eee() does not set. >> >> dsa_slave_get_eee() will call

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Florian Fainelli
On 09/13/2016 08:59 AM, Andrew Lunn wrote: >> Hi Andrew, >> >> this function does indeed duplicate the functionality of >> phy_ethtool_get_eee() with the small difference, that e->eee_active is >> also set which phy_ethtool_get_eee() does not set. >> >> dsa_slave_get_eee() will call

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Andrew Lunn
> Hi Andrew, > > this function does indeed duplicate the functionality of > phy_ethtool_get_eee() with the small difference, that e->eee_active is > also set which phy_ethtool_get_eee() does not set. > > dsa_slave_get_eee() will call phy_ethtool_get_eee() right after the > get_eee() op has been

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Andrew Lunn
> Hi Andrew, > > this function does indeed duplicate the functionality of > phy_ethtool_get_eee() with the small difference, that e->eee_active is > also set which phy_ethtool_get_eee() does not set. > > dsa_slave_get_eee() will call phy_ethtool_get_eee() right after the > get_eee() op has been

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Andrew Lunn
On Tue, Sep 13, 2016 at 11:40:43AM +0200, John Crispin wrote: > > > On 13/09/2016 03:23, Andrew Lunn wrote: > > So lets see if i have this right. > > > > Port 0 has no internal phy. > > Port 1 has an internal PHY at MDIO address 0. > > Port 2 has an internal PHY at MDIO address 1. > > ... > >

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread Andrew Lunn
On Tue, Sep 13, 2016 at 11:40:43AM +0200, John Crispin wrote: > > > On 13/09/2016 03:23, Andrew Lunn wrote: > > So lets see if i have this right. > > > > Port 0 has no internal phy. > > Port 1 has an internal PHY at MDIO address 0. > > Port 2 has an internal PHY at MDIO address 1. > > ... > >

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 03:23, Andrew Lunn wrote: > So lets see if i have this right. > > Port 0 has no internal phy. > Port 1 has an internal PHY at MDIO address 0. > Port 2 has an internal PHY at MDIO address 1. > ... > Port 5 has an internal PHY ad MDIO address 4. > Port 6 has no internal PHY. Hi

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 03:23, Andrew Lunn wrote: > So lets see if i have this right. > > Port 0 has no internal phy. > Port 1 has an internal PHY at MDIO address 0. > Port 2 has an internal PHY at MDIO address 1. > ... > Port 5 has an internal PHY ad MDIO address 4. > Port 6 has no internal PHY. Hi

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 02:40, Andrew Lunn wrote: >> > +static int >> > +qca8k_get_eee(struct dsa_switch *ds, int port, >> > +struct ethtool_eee *e) >> > +{ >> > + struct qca8k_priv *priv = qca8k_to_priv(ds); >> > + struct ethtool_eee *p = >port_sts[qca8k_phy_to_port(port)].eee; >> > + u32 lp,

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-13 Thread John Crispin
On 13/09/2016 02:40, Andrew Lunn wrote: >> > +static int >> > +qca8k_get_eee(struct dsa_switch *ds, int port, >> > +struct ethtool_eee *e) >> > +{ >> > + struct qca8k_priv *priv = qca8k_to_priv(ds); >> > + struct ethtool_eee *p = >port_sts[qca8k_phy_to_port(port)].eee; >> > + u32 lp,

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
> +static int > +qca8k_setup(struct dsa_switch *ds) > +{ > + struct qca8k_priv *priv = qca8k_to_priv(ds); > + int ret, i, phy_mode = -1; > + > + /* Keep track of which port is the connected to the cpu. This can be > + * phy 11 / port 0 or phy 5 / port 6. > + */ > + switch

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
> +static int > +qca8k_setup(struct dsa_switch *ds) > +{ > + struct qca8k_priv *priv = qca8k_to_priv(ds); > + int ret, i, phy_mode = -1; > + > + /* Keep track of which port is the connected to the cpu. This can be > + * phy 11 / port 0 or phy 5 / port 6. > + */ > + switch

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
Hi John > +static u16 > +qca8k_phy_mmd_read(struct qca8k_priv *priv, int phy_addr, u16 addr, u16 reg) > +{ > + u16 data; > + > + mutex_lock(>bus->mdio_lock); > + > + priv->bus->write(priv->bus, phy_addr, MII_ATH_MMD_ADDR, addr); > + priv->bus->write(priv->bus, phy_addr,

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
Hi John > +static u16 > +qca8k_phy_mmd_read(struct qca8k_priv *priv, int phy_addr, u16 addr, u16 reg) > +{ > + u16 data; > + > + mutex_lock(>bus->mdio_lock); > + > + priv->bus->write(priv->bus, phy_addr, MII_ATH_MMD_ADDR, addr); > + priv->bus->write(priv->bus, phy_addr,

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
Hi John > +#include > +#include > +#include > +#include > +#include > +#include One linux/phy.h is enough. > + /* Setup connection between CPU ports & PHYs */ > + for (i = 0; i < DSA_MAX_PORTS; i++) { > + /* CPU port gets connected to all PHYs in the switch */ > +

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
Hi John > +#include > +#include > +#include > +#include > +#include > +#include One linux/phy.h is enough. > + /* Setup connection between CPU ports & PHYs */ > + for (i = 0; i < DSA_MAX_PORTS; i++) { > + /* CPU port gets connected to all PHYs in the switch */ > +

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
> +static u32 > +qca8k_mii_read32(struct mii_bus *bus, int phy_id, u32 regnum) > +{ > + u16 lo, hi; > + > + lo = bus->read(bus, phy_id, regnum); > + hi = bus->read(bus, phy_id, regnum + 1); > + > + return (hi << 16) | lo; > +} > + > +static void > +qca8k_mii_write32(struct mii_bus

Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread Andrew Lunn
> +static u32 > +qca8k_mii_read32(struct mii_bus *bus, int phy_id, u32 regnum) > +{ > + u16 lo, hi; > + > + lo = bus->read(bus, phy_id, regnum); > + hi = bus->read(bus, phy_id, regnum + 1); > + > + return (hi << 16) | lo; > +} > + > +static void > +qca8k_mii_write32(struct mii_bus

[PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread John Crispin
This patch contains initial support for the QCA8337 switch. It will detect a QCA8337 switch, if present and declared in the DT. Each port will be represented through a standalone net_device interface, as for other DSA switches. CPU can communicate with any of the ports by setting an IP@ on ethN

[PATCH 3/3] net-next: dsa: add new driver for qca8xxx family

2016-09-12 Thread John Crispin
This patch contains initial support for the QCA8337 switch. It will detect a QCA8337 switch, if present and declared in the DT. Each port will be represented through a standalone net_device interface, as for other DSA switches. CPU can communicate with any of the ports by setting an IP@ on ethN