Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[firefly-linux-kernel-4.4.55.git] / drivers / spi / atmel_spi.c
index 6fa260d1a9be06607be15658bcbc3b7a452b18e8..8b2601de36306e085d9a55481b0b777248db4946 100644 (file)
 #include <asm/io.h>
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
-
-#ifdef CONFIG_ARCH_AT91
 #include <asm/arch/cpu.h>
-#endif
 
 #include "atmel_spi.h"
 
@@ -116,16 +113,16 @@ static void atmel_spi_next_xfer(struct spi_master *master,
 
        len = as->remaining_bytes;
 
-       tx_dma = xfer->tx_dma;
-       rx_dma = xfer->rx_dma;
+       tx_dma = xfer->tx_dma + xfer->len - len;
+       rx_dma = xfer->rx_dma + xfer->len - len;
 
        /* use scratch buffer only when rx or tx data is unspecified */
-       if (rx_dma == INVALID_DMA_ADDRESS) {
+       if (!xfer->rx_buf) {
                rx_dma = as->buffer_dma;
                if (len > BUFFER_SIZE)
                        len = BUFFER_SIZE;
        }
-       if (tx_dma == INVALID_DMA_ADDRESS) {
+       if (!xfer->tx_buf) {
                tx_dma = as->buffer_dma;
                if (len > BUFFER_SIZE)
                        len = BUFFER_SIZE;
@@ -425,7 +422,7 @@ static int atmel_spi_setup(struct spi_device *spi)
                if (ret)
                        return ret;
                spi->controller_state = (void *)npcs_pin;
-               gpio_direction_output(npcs_pin);
+               gpio_direction_output(npcs_pin, !(spi->mode & SPI_CS_HIGH));
        }
 
        dev_dbg(&spi->dev,
@@ -552,10 +549,8 @@ static int __init atmel_spi_probe(struct platform_device *pdev)
                goto out_free_buffer;
        as->irq = irq;
        as->clk = clk;
-#ifdef CONFIG_ARCH_AT91
        if (!cpu_is_at91rm9200())
                as->new_1 = 1;
-#endif
 
        ret = request_irq(irq, atmel_spi_interrupt, 0,
                        pdev->dev.bus_id, master);