[PATCH v5 12/14] net: dsa: add KSZ9477 switch SPI driver

Oleksij Rempel o.rempel at pengutronix.de
Sat Jul 30 04:27:29 PDT 2022


Hello Ahmad,

On Sat, Jul 30, 2022 at 11:10:34AM +0200, Ahmad Fatoum wrote:
> Hello Oleksij,
> 
> On 13.04.22 10:22, Oleksij Rempel wrote:
> > +static int microchip_switch_probe(struct device_d *dev)
> > +{
> > +	struct ksz_switch *priv;
> > +	int ret = 0, gpio;
> > +	struct dsa_switch *ds;
> > +
> > +	priv = xzalloc(sizeof(*priv));
> > +
> > +	dev->priv = priv;
> > +	priv->dev = dev;
> > +
> > +	priv->spi = (struct spi_device *)dev->type_data;
> > +	priv->spi->mode = SPI_MODE_0;
> 
> The kernel DSA driver configures SPI_MODE_3.
> Is it intended that you configure the barebox driver differently?

Yes. I wonted to investigate it deeper but didn't found time.
According to the KSZ9477S data sheet, SPI TIMING diagram:
we have following pictures:

FIGURE 6-9: SPI DATA INPUT TIMING

CLK ____/---\__/---\__/---\__/---\__/---\__
SDI   {-----}{-----}{-----}{-----}{-----}

This is CPOL=0 and CPHA=0 == SPI_MODE_0

And FIGURE 6-10: SPI DATA OUTPUT TIMING
CLK ____/---\__/---\__/---\__/---\__/---\__
SDO   {-----}{-----}{-----}{-----}{-----}
(LOW-SPEED MODE) This is CPOL=0 and CPHA=0 == SPI_MODE_0
SDO      {-----}{-----}{-----}{-----}{-----}
(HIGH-SPEED MODE) This is CPOL=0 and CPHA=1 == SPI_MODE_1

If I see it correctly SPI_MODE_3 is not documented at all. And
SPI_MODE_3 didn't worked for me, this is why I started investigating it
:)

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list