fix mpc83xx spi prescale modulus calculate
PATCH 1/1 fix mpc83xx spi prescale modulus calculate
--- drivers/spi/spi_mpc83xx.c | 29 ++++++++++++++++------------- 1 files changed, 16 insertions(+), 13 deletions(-)
drivers/spi/spi_mpc83xx.c +16 -13
@@ -266,21 +266,24 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) cs->hw_mode |=SPMODE_LEN (bits_per_word); -if ((mpc83xx_spi->spibrg / hz) >=64 ) { - pm = mpc83xx_spi->spibrg / (hz *64 ) -1 ; -if (pm >0x0f ) { -dev_err (&spi->dev,"Requested speed is too " -"low: %d Hz. Will use %d Hz instead.\n" , - hz, mpc83xx_spi->spibrg /1024 ); - pm =0x0f ; +if ((mpc83xx_spi->spibrg / hz) >64 ) { + pm = mpc83xx_spi->spibrg / (hz *64 ); +if (pm >16 ) { + cs->hw_mode |=SPMODE_DIV16 ; + pm /=16 ; +if (pm >16 ) { +dev_err (&spi->dev,"Requested speed is too " +"low: %d Hz. Will use %d Hz instead.\n" , + hz, mpc83xx_spi->spibrg /1024 ); + pm =16 ; + } } - cs->hw_mode |=SPMODE_PM (pm) |SPMODE_DIV16 ; - }else { + }else pm = mpc83xx_spi->spibrg / (hz *4 ); -if (pm) - pm--; - cs->hw_mode |=SPMODE_PM (pm); - } +if (pm) + pm--; + + cs->hw_mode |=SPMODE_PM (pm); regval =mpc83xx_spi_read_reg (&mpc83xx_spi->base->mode);if (cs->hw_mode != regval) {unsigned long flags;
Signature · 1 line
1.5.4
Quoted 10 lines
-----Original Message-----
From: [email protected]=20 [mailto:[email protected]]=20 On Behalf Of Chen Gong
Sent: Friday, June 20, 2008 5:38 PM
To: [email protected]
Cc: Chen Gong
Subject: [PATCH] fix mpc83xx spi prescale modulus calculate =20Signed-off-by Chen Gong <[email protected]>
I think you should at least cc David Brownell and SPI mailling list.
- Leo
Quoted 1 line · Chen Gong
Signed-off-by Chen Gong <[email protected]>
The patch lacks any description. E.g. at which frequencies the current math breaks, and why?
Quoted 12 lines
--- drivers/spi/spi_mpc83xx.c | 29 ++++++++++++++++------------- 1 files changed, 16 insertions(+), 13 deletions(-)drivers/spi/spi_mpc83xx.c +0
-0@@ -266,21 +266,24 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) cs->hw_mode |=SPMODE_LEN (bits_per_word);
drivers/spi/spi_mpc83xx.c int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) · line 271
Quoted 10 lines
drivers/spi/spi_mpc83xx.c +3
-7-if ((mpc83xx_spi->spibrg / hz) >=64 ) { - pm = mpc83xx_spi->spibrg / (hz *64 ) -1 ; -if (pm >0x0f ) { -dev_err (&spi->dev,"Requested speed is too " -"low: %d Hz. Will use %d Hz instead.\n" , - hz, mpc83xx_spi->spibrg /1024 ); - pm =0x0f ; +if ((mpc83xx_spi->spibrg / hz) >64 ) { + pm = mpc83xx_spi->spibrg / (hz *64 ); +if (pm >16 ) {
Suppose this didn't happen. So we calculated:
pm = mpc83xx_spi->spibrg / (hz * 64);
And we didn't set any hw flag.
drivers/spi/spi_mpc83xx.c int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) · line 282
Quoted 13 lines
drivers/spi/spi_mpc83xx.c +9
-2+ cs->hw_mode |=SPMODE_DIV16 ; + pm /=16 ; +if (pm >16 ) { +dev_err (&spi->dev,"Requested speed is too " +"low: %d Hz. Will use %d Hz instead.\n" , + hz, mpc83xx_spi->spibrg /1024 ); + pm =16 ; + } } - cs->hw_mode |=SPMODE_PM (pm) |SPMODE_DIV16 ; - }else { + }else pm = mpc83xx_spi->spibrg / (hz *4 );
Now suppose this did happen. So we calculated:
pm = mpc83xx_spi->spibrg / (hz * 4);
And we didn't set any hw flag either.
So, we used two different formulas with the same hw flags.
Maybe I'm missing something, but this looks quite wrong.
Quoted 13 lines
drivers/spi/spi_mpc83xx.c +4
-4-if (pm) - pm--; - cs->hw_mode |=SPMODE_PM (pm); - } +if (pm) + pm--; + + cs->hw_mode |=SPMODE_PM (pm); regval =mpc83xx_spi_read_reg (&mpc83xx_spi->base->mode);if (cs->hw_mode != regval) {unsigned long flags;Signature · 1 line
1.5.4
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Quoted 5 lines · Chen Gong
Signed-off-by Chen Gong <[email protected]>---
drivers/spi/spi_mpc83xx.c| 29 ++++++++++++++++-------------1 files changed, 16 insertions(+), 13 deletions(-)
Please CC the SPI devel list.
- k