Skip to content

Commit

Permalink
Merge remote-tracking branches 'spi/topic/armada', 'spi/topic/ath79',…
Browse files Browse the repository at this point in the history
… 'spi/topic/bcm-qspi' and 'spi/topic/bcm53xx' into spi-next
  • Loading branch information
Mark Brown committed Feb 19, 2017
5 parents 3490462 + e92f005 + 91829a9 + 973f7dd + e360e72 commit 244a60c
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 94 deletions.
3 changes: 2 additions & 1 deletion drivers/spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ config SPI_BCM63XX_HSSPI

config SPI_BCM_QSPI
tristate "Broadcom BSPI and MSPI controller support"
depends on ARCH_BRCMSTB || ARCH_BCM || ARCH_BCM_IPROC || COMPILE_TEST
depends on ARCH_BRCMSTB || ARCH_BCM || ARCH_BCM_IPROC || \
BMIPS_GENERIC || COMPILE_TEST
default ARCH_BCM_IPROC
help
Enables support for the Broadcom SPI flash and MSPI controller.
Expand Down
14 changes: 6 additions & 8 deletions drivers/spi/spi-armada-3700.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ static int a3700_spi_pin_mode_set(struct a3700_spi *a3700_spi,
val &= ~(A3700_SPI_DATA_PIN0 | A3700_SPI_DATA_PIN1);

switch (pin_mode) {
case 1:
case SPI_NBITS_SINGLE:
break;
case 2:
case SPI_NBITS_DUAL:
val |= A3700_SPI_DATA_PIN0;
break;
case 4:
case SPI_NBITS_QUAD:
val |= A3700_SPI_DATA_PIN1;
break;
default:
Expand Down Expand Up @@ -340,8 +340,7 @@ static irqreturn_t a3700_spi_interrupt(int irq, void *dev_id)
spireg_write(a3700_spi, A3700_SPI_INT_STAT_REG, cause);

/* Wake up the transfer */
if (a3700_spi->wait_mask & cause)
complete(&a3700_spi->done);
complete(&a3700_spi->done);

return IRQ_HANDLED;
}
Expand Down Expand Up @@ -421,7 +420,7 @@ static void a3700_spi_fifo_thres_set(struct a3700_spi *a3700_spi,
}

static void a3700_spi_transfer_setup(struct spi_device *spi,
struct spi_transfer *xfer)
struct spi_transfer *xfer)
{
struct a3700_spi *a3700_spi;
unsigned int byte_len;
Expand Down Expand Up @@ -562,6 +561,7 @@ static int a3700_spi_fifo_read(struct a3700_spi *a3700_spi)
val = spireg_read(a3700_spi, A3700_SPI_DATA_IN_REG);
if (a3700_spi->buf_len >= 4) {
u32 data = le32_to_cpu(val);

memcpy(a3700_spi->rx_buf, &data, 4);

a3700_spi->buf_len -= 4;
Expand Down Expand Up @@ -901,15 +901,13 @@ static int a3700_spi_remove(struct platform_device *pdev)
struct a3700_spi *spi = spi_master_get_devdata(master);

clk_unprepare(spi->clk);
spi_master_put(master);

return 0;
}

static struct platform_driver a3700_spi_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(a3700_spi_dt_ids),
},
.probe = a3700_spi_probe,
Expand Down
23 changes: 12 additions & 11 deletions drivers/spi/spi-ath79.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
}

if (spi->chip_select) {
if (gpio_is_valid(spi->cs_gpio)) {
/* SPI is normally active-low */
gpio_set_value(spi->cs_gpio, cs_high);
gpio_set_value_cansleep(spi->cs_gpio, cs_high);
} else {
u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select);

if (cs_high)
sp->ioc_base |= AR71XX_SPI_IOC_CS0;
sp->ioc_base |= cs_bit;
else
sp->ioc_base &= ~AR71XX_SPI_IOC_CS0;
sp->ioc_base &= ~cs_bit;

ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
}
Expand Down Expand Up @@ -118,11 +120,8 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
struct ath79_spi *sp = ath79_spidev_to_sp(spi);
int status;

if (spi->chip_select && !gpio_is_valid(spi->cs_gpio))
return -EINVAL;

status = 0;
if (spi->chip_select) {
if (gpio_is_valid(spi->cs_gpio)) {
unsigned long flags;

flags = GPIOF_DIR_OUT;
Expand All @@ -134,10 +133,12 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
status = gpio_request_one(spi->cs_gpio, flags,
dev_name(&spi->dev));
} else {
u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select);

if (spi->mode & SPI_CS_HIGH)
sp->ioc_base &= ~AR71XX_SPI_IOC_CS0;
sp->ioc_base &= ~cs_bit;
else
sp->ioc_base |= AR71XX_SPI_IOC_CS0;
sp->ioc_base |= cs_bit;

ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
}
Expand All @@ -147,7 +148,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi)

static void ath79_spi_cleanup_cs(struct spi_device *spi)
{
if (spi->chip_select) {
if (gpio_is_valid(spi->cs_gpio)) {
gpio_free(spi->cs_gpio);
}
}
Expand Down
Loading

0 comments on commit 244a60c

Please sign in to comment.