Skip to content
Snippets Groups Projects
Commit c0eaffa0 authored by Hannes Schmelzer's avatar Hannes Schmelzer Committed by Jagan Teki
Browse files

spi: omap3: fix claim/release bus within DM


The claim/release bus function must not reset the whole SPI core because
settings regarding wordlen, clock-frequency and so on made by
set_wordlen, set_mode, set_speed get lost with this action. Resulting in
a non-functional SPI.

Without DM the failure didn't came up since after the spi_reset within
claim bus all the setup (wordlen, mode, ...) was called, in DM they are
called by the spi uclass.

We change now the things as following for having a working SPI instance
in DM:

- move the spi_reset(...) to the probe call in DM for having a known
hardware state after probe. Without DM we don't have a probe call, so we
issue the reset as before during the claim_bus call.

- in release bus we just reset the modulctrl to the reset-value (spi-
slave)

Signed-off-by: default avatarHannes Schmelzer <oe5hpm@oevsv.at>
Reviewed-by: default avatarJagan Teki <jagan@openedev.com>
parent 51dce7d2
No related branches found
No related tags found
No related merge requests found
...@@ -443,9 +443,6 @@ static void spi_reset(struct mcspi *regs) ...@@ -443,9 +443,6 @@ static void spi_reset(struct mcspi *regs)
static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv) static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv)
{ {
unsigned int conf; unsigned int conf;
spi_reset(priv->regs);
/* /*
* setup when switching from (reset default) slave mode * setup when switching from (reset default) slave mode
* to single-channel master mode * to single-channel master mode
...@@ -480,6 +477,8 @@ int spi_claim_bus(struct spi_slave *slave) ...@@ -480,6 +477,8 @@ int spi_claim_bus(struct spi_slave *slave)
{ {
struct omap3_spi_priv *priv = to_omap3_spi(slave); struct omap3_spi_priv *priv = to_omap3_spi(slave);
spi_reset(priv->regs);
_omap3_spi_claim_bus(priv); _omap3_spi_claim_bus(priv);
_omap3_spi_set_wordlen(priv); _omap3_spi_set_wordlen(priv);
_omap3_spi_set_mode(priv); _omap3_spi_set_mode(priv);
...@@ -492,8 +491,7 @@ void spi_release_bus(struct spi_slave *slave) ...@@ -492,8 +491,7 @@ void spi_release_bus(struct spi_slave *slave)
{ {
struct omap3_spi_priv *priv = to_omap3_spi(slave); struct omap3_spi_priv *priv = to_omap3_spi(slave);
/* Reset the SPI hardware */ writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
spi_reset(priv->regs);
} }
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
...@@ -602,8 +600,7 @@ static int omap3_spi_release_bus(struct udevice *dev) ...@@ -602,8 +600,7 @@ static int omap3_spi_release_bus(struct udevice *dev)
struct udevice *bus = dev->parent; struct udevice *bus = dev->parent;
struct omap3_spi_priv *priv = dev_get_priv(bus); struct omap3_spi_priv *priv = dev_get_priv(bus);
/* Reset the SPI hardware */ writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
spi_reset(priv->regs);
return 0; return 0;
} }
...@@ -636,6 +633,9 @@ static int omap3_spi_probe(struct udevice *dev) ...@@ -636,6 +633,9 @@ static int omap3_spi_probe(struct udevice *dev)
else else
priv->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT; priv->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT;
priv->wordlen = SPI_DEFAULT_WORDLEN; priv->wordlen = SPI_DEFAULT_WORDLEN;
spi_reset(priv->regs);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment