All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM
@ 2018-06-26 14:08 Hannes Schmelzer
  2018-06-27 11:53 ` Jagan Teki
  2018-06-28 14:26 ` Jagan Teki
  0 siblings, 2 replies; 6+ messages in thread
From: Hannes Schmelzer @ 2018-06-26 14:08 UTC (permalink / raw)
  To: u-boot

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: Hannes Schmelzer <oe5hpm@oevsv.at>

---

 drivers/spi/omap3_spi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index 4169abd..41bdab7 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -443,9 +443,6 @@ static void spi_reset(struct mcspi *regs)
 static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv)
 {
 	unsigned int conf;
-
-	spi_reset(priv->regs);
-
 	/*
 	 * setup when switching from (reset default) slave mode
 	 * to single-channel master mode
@@ -480,6 +477,8 @@ int spi_claim_bus(struct spi_slave *slave)
 {
 	struct omap3_spi_priv *priv = to_omap3_spi(slave);
 
+	spi_reset(priv->regs);
+
 	_omap3_spi_claim_bus(priv);
 	_omap3_spi_set_wordlen(priv);
 	_omap3_spi_set_mode(priv);
@@ -492,8 +491,7 @@ void spi_release_bus(struct spi_slave *slave)
 {
 	struct omap3_spi_priv *priv = to_omap3_spi(slave);
 
-	/* Reset the SPI hardware */
-	spi_reset(priv->regs);
+	writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
 }
 
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
@@ -600,8 +598,7 @@ static int omap3_spi_release_bus(struct udevice *dev)
 	struct udevice *bus = dev->parent;
 	struct omap3_spi_priv *priv = dev_get_priv(bus);
 
-	/* Reset the SPI hardware */
-	spi_reset(priv->regs);
+	writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
 
 	return 0;
 }
@@ -634,6 +631,9 @@ static int omap3_spi_probe(struct udevice *dev)
 	else
 		priv->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT;
 	priv->wordlen = SPI_DEFAULT_WORDLEN;
+
+	spi_reset(priv->regs);
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM
  2018-06-26 14:08 [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM Hannes Schmelzer
@ 2018-06-27 11:53 ` Jagan Teki
  2018-06-27 19:57   ` Hannes Schmelzer
  2018-06-28 14:26 ` Jagan Teki
  1 sibling, 1 reply; 6+ messages in thread
From: Jagan Teki @ 2018-06-27 11:53 UTC (permalink / raw)
  To: u-boot

On Tue, Jun 26, 2018 at 7:38 PM, Hannes Schmelzer <oe5hpm@oevsv.at> wrote:
> 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: Hannes Schmelzer <oe5hpm@oevsv.at>
>
> ---
>
>  drivers/spi/omap3_spi.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
> index 4169abd..41bdab7 100644
> --- a/drivers/spi/omap3_spi.c
> +++ b/drivers/spi/omap3_spi.c
> @@ -443,9 +443,6 @@ static void spi_reset(struct mcspi *regs)
>  static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv)
>  {
>         unsigned int conf;
> -
> -       spi_reset(priv->regs);
> -
>         /*
>          * setup when switching from (reset default) slave mode
>          * to single-channel master mode
> @@ -480,6 +477,8 @@ int spi_claim_bus(struct spi_slave *slave)
>  {
>         struct omap3_spi_priv *priv = to_omap3_spi(slave);
>
> +       spi_reset(priv->regs);
> +
>         _omap3_spi_claim_bus(priv);
>         _omap3_spi_set_wordlen(priv);
>         _omap3_spi_set_mode(priv);
> @@ -492,8 +491,7 @@ void spi_release_bus(struct spi_slave *slave)
>  {
>         struct omap3_spi_priv *priv = to_omap3_spi(slave);
>
> -       /* Reset the SPI hardware */
> -       spi_reset(priv->regs);
> +       writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
>  }
>
>  struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
> @@ -600,8 +598,7 @@ static int omap3_spi_release_bus(struct udevice *dev)
>         struct udevice *bus = dev->parent;
>         struct omap3_spi_priv *priv = dev_get_priv(bus);
>
> -       /* Reset the SPI hardware */
> -       spi_reset(priv->regs);
> +       writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);

This change look compared to what patch is trying to fix. so release
doen't require reset?  are you sure we need to write only this bit
release the bus or do we need to clear?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM
  2018-06-27 11:53 ` Jagan Teki
@ 2018-06-27 19:57   ` Hannes Schmelzer
  0 siblings, 0 replies; 6+ messages in thread
From: Hannes Schmelzer @ 2018-06-27 19:57 UTC (permalink / raw)
  To: u-boot


On 06/27/2018 01:53 PM, Jagan Teki wrote:
> On Tue, Jun 26, 2018 at 7:38 PM, Hannes Schmelzer <oe5hpm@oevsv.at> wrote:
>> 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: Hannes Schmelzer <oe5hpm@oevsv.at>
>>
>> ---
>>
>>   drivers/spi/omap3_spi.c | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
>> index 4169abd..41bdab7 100644
>> --- a/drivers/spi/omap3_spi.c
>> +++ b/drivers/spi/omap3_spi.c
>> @@ -443,9 +443,6 @@ static void spi_reset(struct mcspi *regs)
>>   static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv)
>>   {
>>          unsigned int conf;
>> -
>> -       spi_reset(priv->regs);
>> -
>>          /*
>>           * setup when switching from (reset default) slave mode
>>           * to single-channel master mode
>> @@ -480,6 +477,8 @@ int spi_claim_bus(struct spi_slave *slave)
>>   {
>>          struct omap3_spi_priv *priv = to_omap3_spi(slave);
>>
>> +       spi_reset(priv->regs);
>> +
>>          _omap3_spi_claim_bus(priv);
>>          _omap3_spi_set_wordlen(priv);
>>          _omap3_spi_set_mode(priv);
>> @@ -492,8 +491,7 @@ void spi_release_bus(struct spi_slave *slave)
>>   {
>>          struct omap3_spi_priv *priv = to_omap3_spi(slave);
>>
>> -       /* Reset the SPI hardware */
>> -       spi_reset(priv->regs);
>> +       writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
>>   }
>>
>>   struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>> @@ -600,8 +598,7 @@ static int omap3_spi_release_bus(struct udevice *dev)
>>          struct udevice *bus = dev->parent;
>>          struct omap3_spi_priv *priv = dev_get_priv(bus);
>>
>> -       /* Reset the SPI hardware */
>> -       spi_reset(priv->regs);
>> +       writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
> This change look compared to what patch is trying to fix. so release
> doen't require reset?  are you sure we need to write only this bit
> release the bus or do we need to clear?

Yes, this bit switches the mcspi ip core into slave mode, meaning be 
high impedance on the spi lines, what is exactly the meaning/sense of a 
bus release.

I know the mcspi ip core very good since i've made already some vxworks 
driver and even now the
fixes in u-boot for running it with dm.

cheers,
Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM
  2018-06-26 14:08 [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM Hannes Schmelzer
  2018-06-27 11:53 ` Jagan Teki
@ 2018-06-28 14:26 ` Jagan Teki
  2018-06-28 20:37   ` Hannes Schmelzer
  1 sibling, 1 reply; 6+ messages in thread
From: Jagan Teki @ 2018-06-28 14:26 UTC (permalink / raw)
  To: u-boot

On Tue, Jun 26, 2018 at 7:38 PM, Hannes Schmelzer <oe5hpm@oevsv.at> wrote:
> 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: Hannes Schmelzer <oe5hpm@oevsv.at>
>
> ---

Applied to u-boot-spi/master

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM
  2018-06-28 14:26 ` Jagan Teki
@ 2018-06-28 20:37   ` Hannes Schmelzer
  2018-06-28 21:52     ` Tom Rini
  0 siblings, 1 reply; 6+ messages in thread
From: Hannes Schmelzer @ 2018-06-28 20:37 UTC (permalink / raw)
  To: u-boot


On 06/28/2018 04:26 PM, Jagan Teki wrote:
> On Tue, Jun 26, 2018 at 7:38 PM, Hannes Schmelzer <oe5hpm@oevsv.at> wrote:
>> 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: Hannes Schmelzer <oe5hpm@oevsv.at>
>>
>> ---
> Applied to u-boot-spi/master
do we have a chance to get into rc3 with this?

cheers,
Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM
  2018-06-28 20:37   ` Hannes Schmelzer
@ 2018-06-28 21:52     ` Tom Rini
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2018-06-28 21:52 UTC (permalink / raw)
  To: u-boot

On Thu, Jun 28, 2018 at 10:37:10PM +0200, Hannes Schmelzer wrote:
> 
> On 06/28/2018 04:26 PM, Jagan Teki wrote:
> >On Tue, Jun 26, 2018 at 7:38 PM, Hannes Schmelzer <oe5hpm@oevsv.at> wrote:
> >>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: Hannes Schmelzer <oe5hpm@oevsv.at>
> >>
> >>---
> >Applied to u-boot-spi/master
> do we have a chance to get into rc3 with this?

I would like to see this and the other fixes in for that, yes, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180628/cb6e7553/attachment.sig>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-28 21:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-26 14:08 [U-Boot] [PATCH] spi: omap3: fix claim/release bus within DM Hannes Schmelzer
2018-06-27 11:53 ` Jagan Teki
2018-06-27 19:57   ` Hannes Schmelzer
2018-06-28 14:26 ` Jagan Teki
2018-06-28 20:37   ` Hannes Schmelzer
2018-06-28 21:52     ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.