diff options
author | Marcus Weseloh <mweseloh42@gmail.com> | 2015-11-08 06:03:23 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-11-18 13:34:56 -0500 |
commit | 47284e3e0f3c427c93f8583549b6c938e8a18015 (patch) | |
tree | 887e031311e8c5f48cc785f9c1104a68cce6a496 /drivers/spi | |
parent | 8005c49d9aea74d382f474ce11afbbc7d7130bec (diff) |
spi: sun4i: allow transfers to set transmission speed
Allow transfers to set the transmission speed rather than using the
device max_speed_hz value. The SPI core makes sure that the speed_hz
value is always set on the transfer.
Signed-off-by: Marcus Weseloh <mweseloh42@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-sun4i.c | 8 | ||||
-rw-r--r-- | drivers/spi/spi-sun6i.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index fbb0a4d74e91..f60a6d634d61 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c | |||
@@ -229,8 +229,8 @@ static int sun4i_spi_transfer_one(struct spi_master *master, | |||
229 | 229 | ||
230 | /* Ensure that we have a parent clock fast enough */ | 230 | /* Ensure that we have a parent clock fast enough */ |
231 | mclk_rate = clk_get_rate(sspi->mclk); | 231 | mclk_rate = clk_get_rate(sspi->mclk); |
232 | if (mclk_rate < (2 * spi->max_speed_hz)) { | 232 | if (mclk_rate < (2 * tfr->speed_hz)) { |
233 | clk_set_rate(sspi->mclk, 2 * spi->max_speed_hz); | 233 | clk_set_rate(sspi->mclk, 2 * tfr->speed_hz); |
234 | mclk_rate = clk_get_rate(sspi->mclk); | 234 | mclk_rate = clk_get_rate(sspi->mclk); |
235 | } | 235 | } |
236 | 236 | ||
@@ -248,14 +248,14 @@ static int sun4i_spi_transfer_one(struct spi_master *master, | |||
248 | * First try CDR2, and if we can't reach the expected | 248 | * First try CDR2, and if we can't reach the expected |
249 | * frequency, fall back to CDR1. | 249 | * frequency, fall back to CDR1. |
250 | */ | 250 | */ |
251 | div = mclk_rate / (2 * spi->max_speed_hz); | 251 | div = mclk_rate / (2 * tfr->speed_hz); |
252 | if (div <= (SUN4I_CLK_CTL_CDR2_MASK + 1)) { | 252 | if (div <= (SUN4I_CLK_CTL_CDR2_MASK + 1)) { |
253 | if (div > 0) | 253 | if (div > 0) |
254 | div--; | 254 | div--; |
255 | 255 | ||
256 | reg = SUN4I_CLK_CTL_CDR2(div) | SUN4I_CLK_CTL_DRS; | 256 | reg = SUN4I_CLK_CTL_CDR2(div) | SUN4I_CLK_CTL_DRS; |
257 | } else { | 257 | } else { |
258 | div = ilog2(mclk_rate) - ilog2(spi->max_speed_hz); | 258 | div = ilog2(mclk_rate) - ilog2(tfr->speed_hz); |
259 | reg = SUN4I_CLK_CTL_CDR1(div); | 259 | reg = SUN4I_CLK_CTL_CDR1(div); |
260 | } | 260 | } |
261 | 261 | ||
diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index ac48f59705a8..42e2c4bd690a 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c | |||
@@ -217,8 +217,8 @@ static int sun6i_spi_transfer_one(struct spi_master *master, | |||
217 | 217 | ||
218 | /* Ensure that we have a parent clock fast enough */ | 218 | /* Ensure that we have a parent clock fast enough */ |
219 | mclk_rate = clk_get_rate(sspi->mclk); | 219 | mclk_rate = clk_get_rate(sspi->mclk); |
220 | if (mclk_rate < (2 * spi->max_speed_hz)) { | 220 | if (mclk_rate < (2 * tfr->speed_hz)) { |
221 | clk_set_rate(sspi->mclk, 2 * spi->max_speed_hz); | 221 | clk_set_rate(sspi->mclk, 2 * tfr->speed_hz); |
222 | mclk_rate = clk_get_rate(sspi->mclk); | 222 | mclk_rate = clk_get_rate(sspi->mclk); |
223 | } | 223 | } |
224 | 224 | ||
@@ -236,14 +236,14 @@ static int sun6i_spi_transfer_one(struct spi_master *master, | |||
236 | * First try CDR2, and if we can't reach the expected | 236 | * First try CDR2, and if we can't reach the expected |
237 | * frequency, fall back to CDR1. | 237 | * frequency, fall back to CDR1. |
238 | */ | 238 | */ |
239 | div = mclk_rate / (2 * spi->max_speed_hz); | 239 | div = mclk_rate / (2 * tfr->speed_hz); |
240 | if (div <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) { | 240 | if (div <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) { |
241 | if (div > 0) | 241 | if (div > 0) |
242 | div--; | 242 | div--; |
243 | 243 | ||
244 | reg = SUN6I_CLK_CTL_CDR2(div) | SUN6I_CLK_CTL_DRS; | 244 | reg = SUN6I_CLK_CTL_CDR2(div) | SUN6I_CLK_CTL_DRS; |
245 | } else { | 245 | } else { |
246 | div = ilog2(mclk_rate) - ilog2(spi->max_speed_hz); | 246 | div = ilog2(mclk_rate) - ilog2(tfr->speed_hz); |
247 | reg = SUN6I_CLK_CTL_CDR1(div); | 247 | reg = SUN6I_CLK_CTL_CDR1(div); |
248 | } | 248 | } |
249 | 249 | ||