diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-25 16:20:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-25 16:20:36 -0500 |
commit | 2d2e7d195b902c419bc0b69ced026aca444d69a8 (patch) | |
tree | a4caa21b9db159873897d64b553042a1ae920ab5 /drivers/spi/spi-tegra114.c | |
parent | 15333539a9b3022656f815f643a77f6b054b335f (diff) | |
parent | 8b8b773e6b611e6629ac01f85d401c949d153546 (diff) |
Merge tag 'spi-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi updates from Mark Brown:
"A respun version of the merges for the pull request previously sent
with a few additional fixes. The last two merges were fixed up by
hand since the branches have moved on and currently have the prior
merge in them.
Quite a busy release for the SPI subsystem, mostly in cleanups big and
small scattered through the stack rather than anything else:
- New driver for the Broadcom BC63xx HSSPI controller
- Fix duplicate device registration for ACPI
- Conversion of s3c64xx to DMAEngine (this pulls in platform and DMA
changes upon which the transiton depends)
- Some small optimisations to reduce the amount of time we hold locks
in the datapath, eliminate some redundant checks and the size of a
spi_transfer
- Lots of fixes, cleanups and general enhancements to drivers,
especially the rspi and Atmel drivers"
* tag 'spi-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (112 commits)
spi: core: Fix transfer failure when master->transfer_one returns positive value
spi: Correct set_cs() documentation
spi: Clarify transfer_one() w.r.t. spi_finalize_current_transfer()
spi: Spelling s/finised/finished/
spi: sc18is602: Convert to use bits_per_word_mask
spi: Remove duplicate code to set default bits_per_word setting
spi/pxa2xx: fix compilation warning when !CONFIG_PM_SLEEP
spi: clps711x: Add MODULE_ALIAS to support module auto-loading
spi: rspi: Add missing clk_disable() calls in error and cleanup paths
spi: rspi: Spelling s/transmition/transmission/
spi: rspi: Add support for specifying CPHA/CPOL
spi/pxa2xx: initialize DMA channels to -1 to prevent inadvertent match
spi: rspi: Add more QSPI register documentation
spi: rspi: Add more RSPI register documentation
spi: rspi: Remove dependency on DMAE for SHMOBILE
spi/s3c64xx: Correct indentation
spi: sh: Use spi_sh_clear_bit() instead of open-coded
spi: bitbang: Grammar s/make to make/to make/
spi: sh-hspi: Spelling s/recive/receive/
spi: core: Improve tx/rx_nbits check comments
...
Diffstat (limited to 'drivers/spi/spi-tegra114.c')
-rw-r--r-- | drivers/spi/spi-tegra114.c | 98 |
1 files changed, 34 insertions, 64 deletions
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c index c8604981a058..413c71843492 100644 --- a/drivers/spi/spi-tegra114.c +++ b/drivers/spi/spi-tegra114.c | |||
@@ -54,11 +54,8 @@ | |||
54 | #define SPI_CS_SS_VAL (1 << 20) | 54 | #define SPI_CS_SS_VAL (1 << 20) |
55 | #define SPI_CS_SW_HW (1 << 21) | 55 | #define SPI_CS_SW_HW (1 << 21) |
56 | /* SPI_CS_POL_INACTIVE bits are default high */ | 56 | /* SPI_CS_POL_INACTIVE bits are default high */ |
57 | #define SPI_CS_POL_INACTIVE 22 | 57 | /* n from 0 to 3 */ |
58 | #define SPI_CS_POL_INACTIVE_0 (1 << 22) | 58 | #define SPI_CS_POL_INACTIVE(n) (1 << (22 + (n))) |
59 | #define SPI_CS_POL_INACTIVE_1 (1 << 23) | ||
60 | #define SPI_CS_POL_INACTIVE_2 (1 << 24) | ||
61 | #define SPI_CS_POL_INACTIVE_3 (1 << 25) | ||
62 | #define SPI_CS_POL_INACTIVE_MASK (0xF << 22) | 59 | #define SPI_CS_POL_INACTIVE_MASK (0xF << 22) |
63 | 60 | ||
64 | #define SPI_CS_SEL_0 (0 << 26) | 61 | #define SPI_CS_SEL_0 (0 << 26) |
@@ -165,9 +162,6 @@ | |||
165 | #define MAX_HOLD_CYCLES 16 | 162 | #define MAX_HOLD_CYCLES 16 |
166 | #define SPI_DEFAULT_SPEED 25000000 | 163 | #define SPI_DEFAULT_SPEED 25000000 |
167 | 164 | ||
168 | #define MAX_CHIP_SELECT 4 | ||
169 | #define SPI_FIFO_DEPTH 64 | ||
170 | |||
171 | struct tegra_spi_data { | 165 | struct tegra_spi_data { |
172 | struct device *dev; | 166 | struct device *dev; |
173 | struct spi_master *master; | 167 | struct spi_master *master; |
@@ -184,7 +178,6 @@ struct tegra_spi_data { | |||
184 | struct spi_device *cur_spi; | 178 | struct spi_device *cur_spi; |
185 | struct spi_device *cs_control; | 179 | struct spi_device *cs_control; |
186 | unsigned cur_pos; | 180 | unsigned cur_pos; |
187 | unsigned cur_len; | ||
188 | unsigned words_per_32bit; | 181 | unsigned words_per_32bit; |
189 | unsigned bytes_per_word; | 182 | unsigned bytes_per_word; |
190 | unsigned curr_dma_words; | 183 | unsigned curr_dma_words; |
@@ -204,12 +197,10 @@ struct tegra_spi_data { | |||
204 | u32 rx_status; | 197 | u32 rx_status; |
205 | u32 status_reg; | 198 | u32 status_reg; |
206 | bool is_packed; | 199 | bool is_packed; |
207 | unsigned long packed_size; | ||
208 | 200 | ||
209 | u32 command1_reg; | 201 | u32 command1_reg; |
210 | u32 dma_control_reg; | 202 | u32 dma_control_reg; |
211 | u32 def_command1_reg; | 203 | u32 def_command1_reg; |
212 | u32 spi_cs_timing; | ||
213 | 204 | ||
214 | struct completion xfer_completion; | 205 | struct completion xfer_completion; |
215 | struct spi_transfer *curr_xfer; | 206 | struct spi_transfer *curr_xfer; |
@@ -227,14 +218,14 @@ struct tegra_spi_data { | |||
227 | static int tegra_spi_runtime_suspend(struct device *dev); | 218 | static int tegra_spi_runtime_suspend(struct device *dev); |
228 | static int tegra_spi_runtime_resume(struct device *dev); | 219 | static int tegra_spi_runtime_resume(struct device *dev); |
229 | 220 | ||
230 | static inline unsigned long tegra_spi_readl(struct tegra_spi_data *tspi, | 221 | static inline u32 tegra_spi_readl(struct tegra_spi_data *tspi, |
231 | unsigned long reg) | 222 | unsigned long reg) |
232 | { | 223 | { |
233 | return readl(tspi->base + reg); | 224 | return readl(tspi->base + reg); |
234 | } | 225 | } |
235 | 226 | ||
236 | static inline void tegra_spi_writel(struct tegra_spi_data *tspi, | 227 | static inline void tegra_spi_writel(struct tegra_spi_data *tspi, |
237 | unsigned long val, unsigned long reg) | 228 | u32 val, unsigned long reg) |
238 | { | 229 | { |
239 | writel(val, tspi->base + reg); | 230 | writel(val, tspi->base + reg); |
240 | 231 | ||
@@ -245,7 +236,7 @@ static inline void tegra_spi_writel(struct tegra_spi_data *tspi, | |||
245 | 236 | ||
246 | static void tegra_spi_clear_status(struct tegra_spi_data *tspi) | 237 | static void tegra_spi_clear_status(struct tegra_spi_data *tspi) |
247 | { | 238 | { |
248 | unsigned long val; | 239 | u32 val; |
249 | 240 | ||
250 | /* Write 1 to clear status register */ | 241 | /* Write 1 to clear status register */ |
251 | val = tegra_spi_readl(tspi, SPI_TRANS_STATUS); | 242 | val = tegra_spi_readl(tspi, SPI_TRANS_STATUS); |
@@ -296,10 +287,9 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf( | |||
296 | { | 287 | { |
297 | unsigned nbytes; | 288 | unsigned nbytes; |
298 | unsigned tx_empty_count; | 289 | unsigned tx_empty_count; |
299 | unsigned long fifo_status; | 290 | u32 fifo_status; |
300 | unsigned max_n_32bit; | 291 | unsigned max_n_32bit; |
301 | unsigned i, count; | 292 | unsigned i, count; |
302 | unsigned long x; | ||
303 | unsigned int written_words; | 293 | unsigned int written_words; |
304 | unsigned fifo_words_left; | 294 | unsigned fifo_words_left; |
305 | u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; | 295 | u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; |
@@ -313,9 +303,9 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf( | |||
313 | nbytes = written_words * tspi->bytes_per_word; | 303 | nbytes = written_words * tspi->bytes_per_word; |
314 | max_n_32bit = DIV_ROUND_UP(nbytes, 4); | 304 | max_n_32bit = DIV_ROUND_UP(nbytes, 4); |
315 | for (count = 0; count < max_n_32bit; count++) { | 305 | for (count = 0; count < max_n_32bit; count++) { |
316 | x = 0; | 306 | u32 x = 0; |
317 | for (i = 0; (i < 4) && nbytes; i++, nbytes--) | 307 | for (i = 0; (i < 4) && nbytes; i++, nbytes--) |
318 | x |= (*tx_buf++) << (i*8); | 308 | x |= (u32)(*tx_buf++) << (i * 8); |
319 | tegra_spi_writel(tspi, x, SPI_TX_FIFO); | 309 | tegra_spi_writel(tspi, x, SPI_TX_FIFO); |
320 | } | 310 | } |
321 | } else { | 311 | } else { |
@@ -323,10 +313,10 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf( | |||
323 | written_words = max_n_32bit; | 313 | written_words = max_n_32bit; |
324 | nbytes = written_words * tspi->bytes_per_word; | 314 | nbytes = written_words * tspi->bytes_per_word; |
325 | for (count = 0; count < max_n_32bit; count++) { | 315 | for (count = 0; count < max_n_32bit; count++) { |
326 | x = 0; | 316 | u32 x = 0; |
327 | for (i = 0; nbytes && (i < tspi->bytes_per_word); | 317 | for (i = 0; nbytes && (i < tspi->bytes_per_word); |
328 | i++, nbytes--) | 318 | i++, nbytes--) |
329 | x |= ((*tx_buf++) << i*8); | 319 | x |= (u32)(*tx_buf++) << (i * 8); |
330 | tegra_spi_writel(tspi, x, SPI_TX_FIFO); | 320 | tegra_spi_writel(tspi, x, SPI_TX_FIFO); |
331 | } | 321 | } |
332 | } | 322 | } |
@@ -338,9 +328,8 @@ static unsigned int tegra_spi_read_rx_fifo_to_client_rxbuf( | |||
338 | struct tegra_spi_data *tspi, struct spi_transfer *t) | 328 | struct tegra_spi_data *tspi, struct spi_transfer *t) |
339 | { | 329 | { |
340 | unsigned rx_full_count; | 330 | unsigned rx_full_count; |
341 | unsigned long fifo_status; | 331 | u32 fifo_status; |
342 | unsigned i, count; | 332 | unsigned i, count; |
343 | unsigned long x; | ||
344 | unsigned int read_words = 0; | 333 | unsigned int read_words = 0; |
345 | unsigned len; | 334 | unsigned len; |
346 | u8 *rx_buf = (u8 *)t->rx_buf + tspi->cur_rx_pos; | 335 | u8 *rx_buf = (u8 *)t->rx_buf + tspi->cur_rx_pos; |
@@ -350,20 +339,16 @@ static unsigned int tegra_spi_read_rx_fifo_to_client_rxbuf( | |||
350 | if (tspi->is_packed) { | 339 | if (tspi->is_packed) { |
351 | len = tspi->curr_dma_words * tspi->bytes_per_word; | 340 | len = tspi->curr_dma_words * tspi->bytes_per_word; |
352 | for (count = 0; count < rx_full_count; count++) { | 341 | for (count = 0; count < rx_full_count; count++) { |
353 | x = tegra_spi_readl(tspi, SPI_RX_FIFO); | 342 | u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO); |
354 | for (i = 0; len && (i < 4); i++, len--) | 343 | for (i = 0; len && (i < 4); i++, len--) |
355 | *rx_buf++ = (x >> i*8) & 0xFF; | 344 | *rx_buf++ = (x >> i*8) & 0xFF; |
356 | } | 345 | } |
357 | tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; | 346 | tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; |
358 | read_words += tspi->curr_dma_words; | 347 | read_words += tspi->curr_dma_words; |
359 | } else { | 348 | } else { |
360 | unsigned int rx_mask; | 349 | u32 rx_mask = ((u32)1 << t->bits_per_word) - 1; |
361 | unsigned int bits_per_word = t->bits_per_word; | ||
362 | |||
363 | rx_mask = (1 << bits_per_word) - 1; | ||
364 | for (count = 0; count < rx_full_count; count++) { | 350 | for (count = 0; count < rx_full_count; count++) { |
365 | x = tegra_spi_readl(tspi, SPI_RX_FIFO); | 351 | u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO) & rx_mask; |
366 | x &= rx_mask; | ||
367 | for (i = 0; (i < tspi->bytes_per_word); i++) | 352 | for (i = 0; (i < tspi->bytes_per_word); i++) |
368 | *rx_buf++ = (x >> (i*8)) & 0xFF; | 353 | *rx_buf++ = (x >> (i*8)) & 0xFF; |
369 | } | 354 | } |
@@ -376,27 +361,24 @@ static unsigned int tegra_spi_read_rx_fifo_to_client_rxbuf( | |||
376 | static void tegra_spi_copy_client_txbuf_to_spi_txbuf( | 361 | static void tegra_spi_copy_client_txbuf_to_spi_txbuf( |
377 | struct tegra_spi_data *tspi, struct spi_transfer *t) | 362 | struct tegra_spi_data *tspi, struct spi_transfer *t) |
378 | { | 363 | { |
379 | unsigned len; | ||
380 | |||
381 | /* Make the dma buffer to read by cpu */ | 364 | /* Make the dma buffer to read by cpu */ |
382 | dma_sync_single_for_cpu(tspi->dev, tspi->tx_dma_phys, | 365 | dma_sync_single_for_cpu(tspi->dev, tspi->tx_dma_phys, |
383 | tspi->dma_buf_size, DMA_TO_DEVICE); | 366 | tspi->dma_buf_size, DMA_TO_DEVICE); |
384 | 367 | ||
385 | if (tspi->is_packed) { | 368 | if (tspi->is_packed) { |
386 | len = tspi->curr_dma_words * tspi->bytes_per_word; | 369 | unsigned len = tspi->curr_dma_words * tspi->bytes_per_word; |
387 | memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len); | 370 | memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len); |
388 | } else { | 371 | } else { |
389 | unsigned int i; | 372 | unsigned int i; |
390 | unsigned int count; | 373 | unsigned int count; |
391 | u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; | 374 | u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; |
392 | unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word; | 375 | unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word; |
393 | unsigned int x; | ||
394 | 376 | ||
395 | for (count = 0; count < tspi->curr_dma_words; count++) { | 377 | for (count = 0; count < tspi->curr_dma_words; count++) { |
396 | x = 0; | 378 | u32 x = 0; |
397 | for (i = 0; consume && (i < tspi->bytes_per_word); | 379 | for (i = 0; consume && (i < tspi->bytes_per_word); |
398 | i++, consume--) | 380 | i++, consume--) |
399 | x |= ((*tx_buf++) << i * 8); | 381 | x |= (u32)(*tx_buf++) << (i * 8); |
400 | tspi->tx_dma_buf[count] = x; | 382 | tspi->tx_dma_buf[count] = x; |
401 | } | 383 | } |
402 | } | 384 | } |
@@ -410,27 +392,21 @@ static void tegra_spi_copy_client_txbuf_to_spi_txbuf( | |||
410 | static void tegra_spi_copy_spi_rxbuf_to_client_rxbuf( | 392 | static void tegra_spi_copy_spi_rxbuf_to_client_rxbuf( |
411 | struct tegra_spi_data *tspi, struct spi_transfer *t) | 393 | struct tegra_spi_data *tspi, struct spi_transfer *t) |
412 | { | 394 | { |
413 | unsigned len; | ||
414 | |||
415 | /* Make the dma buffer to read by cpu */ | 395 | /* Make the dma buffer to read by cpu */ |
416 | dma_sync_single_for_cpu(tspi->dev, tspi->rx_dma_phys, | 396 | dma_sync_single_for_cpu(tspi->dev, tspi->rx_dma_phys, |
417 | tspi->dma_buf_size, DMA_FROM_DEVICE); | 397 | tspi->dma_buf_size, DMA_FROM_DEVICE); |
418 | 398 | ||
419 | if (tspi->is_packed) { | 399 | if (tspi->is_packed) { |
420 | len = tspi->curr_dma_words * tspi->bytes_per_word; | 400 | unsigned len = tspi->curr_dma_words * tspi->bytes_per_word; |
421 | memcpy(t->rx_buf + tspi->cur_rx_pos, tspi->rx_dma_buf, len); | 401 | memcpy(t->rx_buf + tspi->cur_rx_pos, tspi->rx_dma_buf, len); |
422 | } else { | 402 | } else { |
423 | unsigned int i; | 403 | unsigned int i; |
424 | unsigned int count; | 404 | unsigned int count; |
425 | unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos; | 405 | unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos; |
426 | unsigned int x; | 406 | u32 rx_mask = ((u32)1 << t->bits_per_word) - 1; |
427 | unsigned int rx_mask; | ||
428 | unsigned int bits_per_word = t->bits_per_word; | ||
429 | 407 | ||
430 | rx_mask = (1 << bits_per_word) - 1; | ||
431 | for (count = 0; count < tspi->curr_dma_words; count++) { | 408 | for (count = 0; count < tspi->curr_dma_words; count++) { |
432 | x = tspi->rx_dma_buf[count]; | 409 | u32 x = tspi->rx_dma_buf[count] & rx_mask; |
433 | x &= rx_mask; | ||
434 | for (i = 0; (i < tspi->bytes_per_word); i++) | 410 | for (i = 0; (i < tspi->bytes_per_word); i++) |
435 | *rx_buf++ = (x >> (i*8)) & 0xFF; | 411 | *rx_buf++ = (x >> (i*8)) & 0xFF; |
436 | } | 412 | } |
@@ -490,16 +466,16 @@ static int tegra_spi_start_rx_dma(struct tegra_spi_data *tspi, int len) | |||
490 | static int tegra_spi_start_dma_based_transfer( | 466 | static int tegra_spi_start_dma_based_transfer( |
491 | struct tegra_spi_data *tspi, struct spi_transfer *t) | 467 | struct tegra_spi_data *tspi, struct spi_transfer *t) |
492 | { | 468 | { |
493 | unsigned long val; | 469 | u32 val; |
494 | unsigned int len; | 470 | unsigned int len; |
495 | int ret = 0; | 471 | int ret = 0; |
496 | unsigned long status; | 472 | u32 status; |
497 | 473 | ||
498 | /* Make sure that Rx and Tx fifo are empty */ | 474 | /* Make sure that Rx and Tx fifo are empty */ |
499 | status = tegra_spi_readl(tspi, SPI_FIFO_STATUS); | 475 | status = tegra_spi_readl(tspi, SPI_FIFO_STATUS); |
500 | if ((status & SPI_FIFO_EMPTY) != SPI_FIFO_EMPTY) { | 476 | if ((status & SPI_FIFO_EMPTY) != SPI_FIFO_EMPTY) { |
501 | dev_err(tspi->dev, | 477 | dev_err(tspi->dev, "Rx/Tx fifo are not empty status 0x%08x\n", |
502 | "Rx/Tx fifo are not empty status 0x%08lx\n", status); | 478 | (unsigned)status); |
503 | return -EIO; | 479 | return -EIO; |
504 | } | 480 | } |
505 | 481 | ||
@@ -564,7 +540,7 @@ static int tegra_spi_start_dma_based_transfer( | |||
564 | static int tegra_spi_start_cpu_based_transfer( | 540 | static int tegra_spi_start_cpu_based_transfer( |
565 | struct tegra_spi_data *tspi, struct spi_transfer *t) | 541 | struct tegra_spi_data *tspi, struct spi_transfer *t) |
566 | { | 542 | { |
567 | unsigned long val; | 543 | u32 val; |
568 | unsigned cur_words; | 544 | unsigned cur_words; |
569 | 545 | ||
570 | if (tspi->cur_direction & DATA_DIR_TX) | 546 | if (tspi->cur_direction & DATA_DIR_TX) |
@@ -676,13 +652,13 @@ static void tegra_spi_deinit_dma_param(struct tegra_spi_data *tspi, | |||
676 | dma_release_channel(dma_chan); | 652 | dma_release_channel(dma_chan); |
677 | } | 653 | } |
678 | 654 | ||
679 | static unsigned long tegra_spi_setup_transfer_one(struct spi_device *spi, | 655 | static u32 tegra_spi_setup_transfer_one(struct spi_device *spi, |
680 | struct spi_transfer *t, bool is_first_of_msg) | 656 | struct spi_transfer *t, bool is_first_of_msg) |
681 | { | 657 | { |
682 | struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); | 658 | struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); |
683 | u32 speed = t->speed_hz; | 659 | u32 speed = t->speed_hz; |
684 | u8 bits_per_word = t->bits_per_word; | 660 | u8 bits_per_word = t->bits_per_word; |
685 | unsigned long command1; | 661 | u32 command1; |
686 | int req_mode; | 662 | int req_mode; |
687 | 663 | ||
688 | if (speed != tspi->cur_speed) { | 664 | if (speed != tspi->cur_speed) { |
@@ -737,7 +713,7 @@ static unsigned long tegra_spi_setup_transfer_one(struct spi_device *spi, | |||
737 | } | 713 | } |
738 | 714 | ||
739 | static int tegra_spi_start_transfer_one(struct spi_device *spi, | 715 | static int tegra_spi_start_transfer_one(struct spi_device *spi, |
740 | struct spi_transfer *t, unsigned long command1) | 716 | struct spi_transfer *t, u32 command1) |
741 | { | 717 | { |
742 | struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); | 718 | struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); |
743 | unsigned total_fifo_words; | 719 | unsigned total_fifo_words; |
@@ -762,8 +738,8 @@ static int tegra_spi_start_transfer_one(struct spi_device *spi, | |||
762 | tegra_spi_writel(tspi, command1, SPI_COMMAND1); | 738 | tegra_spi_writel(tspi, command1, SPI_COMMAND1); |
763 | tspi->command1_reg = command1; | 739 | tspi->command1_reg = command1; |
764 | 740 | ||
765 | dev_dbg(tspi->dev, "The def 0x%x and written 0x%lx\n", | 741 | dev_dbg(tspi->dev, "The def 0x%x and written 0x%x\n", |
766 | tspi->def_command1_reg, command1); | 742 | tspi->def_command1_reg, (unsigned)command1); |
767 | 743 | ||
768 | if (total_fifo_words > SPI_FIFO_DEPTH) | 744 | if (total_fifo_words > SPI_FIFO_DEPTH) |
769 | ret = tegra_spi_start_dma_based_transfer(tspi, t); | 745 | ret = tegra_spi_start_dma_based_transfer(tspi, t); |
@@ -775,15 +751,9 @@ static int tegra_spi_start_transfer_one(struct spi_device *spi, | |||
775 | static int tegra_spi_setup(struct spi_device *spi) | 751 | static int tegra_spi_setup(struct spi_device *spi) |
776 | { | 752 | { |
777 | struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); | 753 | struct tegra_spi_data *tspi = spi_master_get_devdata(spi->master); |
778 | unsigned long val; | 754 | u32 val; |
779 | unsigned long flags; | 755 | unsigned long flags; |
780 | int ret; | 756 | int ret; |
781 | unsigned int cs_pol_bit[MAX_CHIP_SELECT] = { | ||
782 | SPI_CS_POL_INACTIVE_0, | ||
783 | SPI_CS_POL_INACTIVE_1, | ||
784 | SPI_CS_POL_INACTIVE_2, | ||
785 | SPI_CS_POL_INACTIVE_3, | ||
786 | }; | ||
787 | 757 | ||
788 | dev_dbg(&spi->dev, "setup %d bpw, %scpol, %scpha, %dHz\n", | 758 | dev_dbg(&spi->dev, "setup %d bpw, %scpol, %scpha, %dHz\n", |
789 | spi->bits_per_word, | 759 | spi->bits_per_word, |
@@ -805,9 +775,9 @@ static int tegra_spi_setup(struct spi_device *spi) | |||
805 | spin_lock_irqsave(&tspi->lock, flags); | 775 | spin_lock_irqsave(&tspi->lock, flags); |
806 | val = tspi->def_command1_reg; | 776 | val = tspi->def_command1_reg; |
807 | if (spi->mode & SPI_CS_HIGH) | 777 | if (spi->mode & SPI_CS_HIGH) |
808 | val &= ~cs_pol_bit[spi->chip_select]; | 778 | val &= ~SPI_CS_POL_INACTIVE(spi->chip_select); |
809 | else | 779 | else |
810 | val |= cs_pol_bit[spi->chip_select]; | 780 | val |= SPI_CS_POL_INACTIVE(spi->chip_select); |
811 | tspi->def_command1_reg = val; | 781 | tspi->def_command1_reg = val; |
812 | tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1); | 782 | tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1); |
813 | spin_unlock_irqrestore(&tspi->lock, flags); | 783 | spin_unlock_irqrestore(&tspi->lock, flags); |
@@ -841,7 +811,7 @@ static int tegra_spi_transfer_one_message(struct spi_master *master, | |||
841 | msg->actual_length = 0; | 811 | msg->actual_length = 0; |
842 | 812 | ||
843 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | 813 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { |
844 | unsigned long cmd1; | 814 | u32 cmd1; |
845 | 815 | ||
846 | reinit_completion(&tspi->xfer_completion); | 816 | reinit_completion(&tspi->xfer_completion); |
847 | 817 | ||