mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
spi: omap3_spi: Fix speed and mode selection
McSPI IP provides per CS specific speed and mode selection. Therefore it is possible to apply these settings only after CS is known. But set_speed and set_mode can be called without bus being claimed, this would lead driver to set up wrong CS (or previously used CS). Fix this by apply set_speed and set_mode only if bus is already claimed. Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com> Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
parent
705082d4b1
commit
f3f83ad4ca
1 changed files with 14 additions and 3 deletions
|
@ -37,6 +37,8 @@ struct omap3_spi_priv {
|
|||
unsigned int mode;
|
||||
unsigned int wordlen;
|
||||
unsigned int pin_dir:1;
|
||||
|
||||
bool bus_claimed;
|
||||
};
|
||||
|
||||
static void omap3_spi_write_chconf(struct omap3_spi_priv *priv, int val)
|
||||
|
@ -372,6 +374,8 @@ static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv)
|
|||
conf |= OMAP3_MCSPI_MODULCTRL_SINGLE;
|
||||
|
||||
writel(conf, &priv->regs->modulctrl);
|
||||
|
||||
priv->bus_claimed = true;
|
||||
}
|
||||
|
||||
static int omap3_spi_claim_bus(struct udevice *dev)
|
||||
|
@ -381,9 +385,12 @@ static int omap3_spi_claim_bus(struct udevice *dev)
|
|||
struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
|
||||
|
||||
priv->cs = slave_plat->cs;
|
||||
if (!priv->freq)
|
||||
priv->freq = slave_plat->max_hz;
|
||||
|
||||
_omap3_spi_claim_bus(priv);
|
||||
_omap3_spi_set_speed(priv);
|
||||
_omap3_spi_set_mode(priv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -395,6 +402,8 @@ static int omap3_spi_release_bus(struct udevice *dev)
|
|||
|
||||
writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
|
||||
|
||||
priv->bus_claimed = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -440,6 +449,7 @@ static int omap3_spi_set_speed(struct udevice *dev, unsigned int speed)
|
|||
struct omap3_spi_priv *priv = dev_get_priv(dev);
|
||||
|
||||
priv->freq = speed;
|
||||
if (priv->bus_claimed)
|
||||
_omap3_spi_set_speed(priv);
|
||||
|
||||
return 0;
|
||||
|
@ -451,6 +461,7 @@ static int omap3_spi_set_mode(struct udevice *dev, uint mode)
|
|||
|
||||
priv->mode = mode;
|
||||
|
||||
if (priv->bus_claimed)
|
||||
_omap3_spi_set_mode(priv);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue