diff options
-rw-r--r-- | drivers/spi/spi_mpc83xx.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index fe69e94043e1..2adf856e44c2 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c | |||
@@ -148,6 +148,8 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value) | |||
148 | if (value == BITBANG_CS_ACTIVE) { | 148 | if (value == BITBANG_CS_ACTIVE) { |
149 | u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); | 149 | u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); |
150 | u32 len = spi->bits_per_word; | 150 | u32 len = spi->bits_per_word; |
151 | u8 pm; | ||
152 | |||
151 | if (len == 32) | 153 | if (len == 32) |
152 | len = 0; | 154 | len = 0; |
153 | else | 155 | else |
@@ -170,7 +172,7 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value) | |||
170 | regval |= SPMODE_LEN(len); | 172 | regval |= SPMODE_LEN(len); |
171 | 173 | ||
172 | if ((mpc83xx_spi->spibrg / spi->max_speed_hz) >= 64) { | 174 | if ((mpc83xx_spi->spibrg / spi->max_speed_hz) >= 64) { |
173 | u8 pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 64); | 175 | pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 64) - 1; |
174 | if (pm > 0x0f) { | 176 | if (pm > 0x0f) { |
175 | dev_err(&spi->dev, "Requested speed is too " | 177 | dev_err(&spi->dev, "Requested speed is too " |
176 | "low: %d Hz. Will use %d Hz instead.\n", | 178 | "low: %d Hz. Will use %d Hz instead.\n", |
@@ -180,7 +182,9 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value) | |||
180 | } | 182 | } |
181 | regval |= SPMODE_PM(pm) | SPMODE_DIV16; | 183 | regval |= SPMODE_PM(pm) | SPMODE_DIV16; |
182 | } else { | 184 | } else { |
183 | u8 pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 4); | 185 | pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 4); |
186 | if (pm) | ||
187 | pm--; | ||
184 | regval |= SPMODE_PM(pm); | 188 | regval |= SPMODE_PM(pm); |
185 | } | 189 | } |
186 | 190 | ||