* [RFC PATCH v2 01/12] spi: spi-ep93xx: use 32-bit read/write for all registers
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 02/12] spi: spi-ep93xx: add spi master prepare_transfer_hardware() Chris Packham
` (11 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
From: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
All the EP93xx SSP registers are 32-bit. Since most of the upper bits
are unused, this driver tries to be tricky and uses 8 or 16-bit I/O to
access the registers. This really just adds a bit of confusion.
Simplify the I/O by using 32-bit read/write's for all of the registers.
Signed-off-by: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 83 ++++++++++++++++++++++--------------------------
1 file changed, 38 insertions(+), 45 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 49c42a6c2be1..bc1db022d353 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -113,47 +113,47 @@ struct ep93xx_spi {
static int ep93xx_spi_enable(const struct ep93xx_spi *espi)
{
- u8 regval;
+ unsigned int val;
int err;
err = clk_enable(espi->clk);
if (err)
return err;
- regval = readb(espi->mmio + SSPCR1);
- regval |= SSPCR1_SSE;
- writeb(regval, espi->mmio + SSPCR1);
+ val = readl(espi->mmio + SSPCR1);
+ val |= SSPCR1_SSE;
+ writel(val, espi->mmio + SSPCR1);
return 0;
}
static void ep93xx_spi_disable(const struct ep93xx_spi *espi)
{
- u8 regval;
+ unsigned int val;
- regval = readb(espi->mmio + SSPCR1);
- regval &= ~SSPCR1_SSE;
- writeb(regval, espi->mmio + SSPCR1);
+ val = readl(espi->mmio + SSPCR1);
+ val &= ~SSPCR1_SSE;
+ writel(val, espi->mmio + SSPCR1);
clk_disable(espi->clk);
}
static void ep93xx_spi_enable_interrupts(const struct ep93xx_spi *espi)
{
- u8 regval;
+ unsigned int val;
- regval = readb(espi->mmio + SSPCR1);
- regval |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
- writeb(regval, espi->mmio + SSPCR1);
+ val = readl(espi->mmio + SSPCR1);
+ val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
+ writel(val, espi->mmio + SSPCR1);
}
static void ep93xx_spi_disable_interrupts(const struct ep93xx_spi *espi)
{
- u8 regval;
+ unsigned int val;
- regval = readb(espi->mmio + SSPCR1);
- regval &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
- writeb(regval, espi->mmio + SSPCR1);
+ val = readl(espi->mmio + SSPCR1);
+ val &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
+ writel(val, espi->mmio + SSPCR1);
}
/**
@@ -230,47 +230,41 @@ static int ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
spi->mode, div_cpsr, div_scr, dss);
dev_dbg(&espi->pdev->dev, "setup: cr0 %#x\n", cr0);
- writeb(div_cpsr, espi->mmio + SSPCPSR);
- writew(cr0, espi->mmio + SSPCR0);
+ writel(div_cpsr, espi->mmio + SSPCPSR);
+ writel(cr0, espi->mmio + SSPCR0);
return 0;
}
static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
{
- if (t->bits_per_word > 8) {
- u16 tx_val = 0;
+ unsigned int val = 0;
+ if (t->bits_per_word > 8) {
if (t->tx_buf)
- tx_val = ((u16 *)t->tx_buf)[espi->tx];
- writew(tx_val, espi->mmio + SSPDR);
- espi->tx += sizeof(tx_val);
+ val = ((u16 *)t->tx_buf)[espi->tx];
+ espi->tx += 2;
} else {
- u8 tx_val = 0;
-
if (t->tx_buf)
- tx_val = ((u8 *)t->tx_buf)[espi->tx];
- writeb(tx_val, espi->mmio + SSPDR);
- espi->tx += sizeof(tx_val);
+ val = ((u8 *)t->tx_buf)[espi->tx];
+ espi->tx += 1;
}
+ writel(val, espi->mmio + SSPDR);
}
static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
{
- if (t->bits_per_word > 8) {
- u16 rx_val;
+ unsigned int val;
- rx_val = readw(espi->mmio + SSPDR);
+ val = readl(espi->mmio + SSPDR);
+ if (t->bits_per_word > 8) {
if (t->rx_buf)
- ((u16 *)t->rx_buf)[espi->rx] = rx_val;
- espi->rx += sizeof(rx_val);
+ ((u16 *)t->rx_buf)[espi->rx] = val;
+ espi->rx += 2;
} else {
- u8 rx_val;
-
- rx_val = readb(espi->mmio + SSPDR);
if (t->rx_buf)
- ((u8 *)t->rx_buf)[espi->rx] = rx_val;
- espi->rx += sizeof(rx_val);
+ ((u8 *)t->rx_buf)[espi->rx] = val;
+ espi->rx += 1;
}
}
@@ -291,7 +285,7 @@ static int ep93xx_spi_read_write(struct ep93xx_spi *espi)
struct spi_transfer *t = msg->state;
/* read as long as RX FIFO has frames in it */
- while ((readb(espi->mmio + SSPSR) & SSPSR_RNE)) {
+ while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) {
ep93xx_do_read(espi, t);
espi->fifo_level--;
}
@@ -593,14 +587,14 @@ static void ep93xx_spi_process_message(struct ep93xx_spi *espi,
* Just to be sure: flush any data from RX FIFO.
*/
timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT);
- while (readw(espi->mmio + SSPSR) & SSPSR_RNE) {
+ while (readl(espi->mmio + SSPSR) & SSPSR_RNE) {
if (time_after(jiffies, timeout)) {
dev_warn(&espi->pdev->dev,
"timeout while flushing RX FIFO\n");
msg->status = -ETIMEDOUT;
return;
}
- readw(espi->mmio + SSPDR);
+ readl(espi->mmio + SSPDR);
}
/*
@@ -649,15 +643,14 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master,
static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
{
struct ep93xx_spi *espi = dev_id;
- u8 irq_status = readb(espi->mmio + SSPIIR);
/*
* If we got ROR (receive overrun) interrupt we know that something is
* wrong. Just abort the message.
*/
- if (unlikely(irq_status & SSPIIR_RORIS)) {
+ if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) {
/* clear the overrun interrupt */
- writeb(0, espi->mmio + SSPICR);
+ writel(0, espi->mmio + SSPICR);
dev_warn(&espi->pdev->dev,
"receive overrun, aborting the message\n");
espi->current_msg->status = -EIO;
@@ -857,7 +850,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
dev_warn(&pdev->dev, "DMA setup failed. Falling back to PIO\n");
/* make sure that the hardware is disabled */
- writeb(0, espi->mmio + SSPCR1);
+ writel(0, espi->mmio + SSPCR1);
error = devm_spi_register_master(&pdev->dev, master);
if (error) {
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 02/12] spi: spi-ep93xx: add spi master prepare_transfer_hardware()
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
2017-07-27 22:03 ` [RFC PATCH v2 01/12] spi: spi-ep93xx: use 32-bit read/write for all registers Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 03/12] spi: spi-ep93xx: absorb the interrupt enable/disable helpers Chris Packham
` (10 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
From: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
This driver currently enables the hardware at the start of every
message and disabled it when the message is complete. Make it a
bit smarter by adding the prepare_transfer_hardware() and
unprepare_transfer_hardware() callbacks so that the core can
enable/disable the hardware based on spi message queue.
Signed-off-by: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 72 ++++++++++++++++++++++--------------------------
1 file changed, 33 insertions(+), 39 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index bc1db022d353..dd179f3fbeeb 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -111,33 +111,6 @@ struct ep93xx_spi {
/* converts bits per word to CR0.DSS value */
#define bits_per_word_to_dss(bpw) ((bpw) - 1)
-static int ep93xx_spi_enable(const struct ep93xx_spi *espi)
-{
- unsigned int val;
- int err;
-
- err = clk_enable(espi->clk);
- if (err)
- return err;
-
- val = readl(espi->mmio + SSPCR1);
- val |= SSPCR1_SSE;
- writel(val, espi->mmio + SSPCR1);
-
- return 0;
-}
-
-static void ep93xx_spi_disable(const struct ep93xx_spi *espi)
-{
- unsigned int val;
-
- val = readl(espi->mmio + SSPCR1);
- val &= ~SSPCR1_SSE;
- writel(val, espi->mmio + SSPCR1);
-
- clk_disable(espi->clk);
-}
-
static void ep93xx_spi_enable_interrupts(const struct ep93xx_spi *espi)
{
unsigned int val;
@@ -571,17 +544,6 @@ static void ep93xx_spi_process_message(struct ep93xx_spi *espi,
{
unsigned long timeout;
struct spi_transfer *t;
- int err;
-
- /*
- * Enable the SPI controller and its clock.
- */
- err = ep93xx_spi_enable(espi);
- if (err) {
- dev_err(&espi->pdev->dev, "failed to enable SPI controller\n");
- msg->status = err;
- return;
- }
/*
* Just to be sure: flush any data from RX FIFO.
@@ -619,7 +581,6 @@ static void ep93xx_spi_process_message(struct ep93xx_spi *espi,
* deselect the device and disable the SPI controller.
*/
ep93xx_spi_cs_control(msg->spi, false);
- ep93xx_spi_disable(espi);
}
static int ep93xx_spi_transfer_one_message(struct spi_master *master,
@@ -679,6 +640,37 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static int ep93xx_spi_prepare_hardware(struct spi_master *master)
+{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
+ unsigned int val;
+ int ret;
+
+ ret = clk_enable(espi->clk);
+ if (ret)
+ return ret;
+
+ val = readl(espi->mmio + SSPCR1);
+ val |= SSPCR1_SSE;
+ writel(val, espi->mmio + SSPCR1);
+
+ return 0;
+}
+
+static int ep93xx_spi_unprepare_hardware(struct spi_master *master)
+{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
+ unsigned int val;
+
+ val = readl(espi->mmio + SSPCR1);
+ val &= ~SSPCR1_SSE;
+ writel(val, espi->mmio + SSPCR1);
+
+ clk_disable(espi->clk);
+
+ return 0;
+}
+
static bool ep93xx_spi_dma_filter(struct dma_chan *chan, void *filter_param)
{
if (ep93xx_dma_chan_is_m2p(chan))
@@ -780,6 +772,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
if (!master)
return -ENOMEM;
+ master->prepare_transfer_hardware = ep93xx_spi_prepare_hardware;
+ master->unprepare_transfer_hardware = ep93xx_spi_unprepare_hardware;
master->transfer_one_message = ep93xx_spi_transfer_one_message;
master->bus_num = pdev->id;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 03/12] spi: spi-ep93xx: absorb the interrupt enable/disable helpers
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
2017-07-27 22:03 ` [RFC PATCH v2 01/12] spi: spi-ep93xx: use 32-bit read/write for all registers Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 02/12] spi: spi-ep93xx: add spi master prepare_transfer_hardware() Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 04/12] spi: spi-ep93xx: pass the spi_master pointer around Chris Packham
` (9 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
From: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
These are each only called once. Just absorb them into the callers.
Signed-off-by: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index dd179f3fbeeb..e8f454b55b69 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -111,24 +111,6 @@ struct ep93xx_spi {
/* converts bits per word to CR0.DSS value */
#define bits_per_word_to_dss(bpw) ((bpw) - 1)
-static void ep93xx_spi_enable_interrupts(const struct ep93xx_spi *espi)
-{
- unsigned int val;
-
- val = readl(espi->mmio + SSPCR1);
- val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
- writel(val, espi->mmio + SSPCR1);
-}
-
-static void ep93xx_spi_disable_interrupts(const struct ep93xx_spi *espi)
-{
- unsigned int val;
-
- val = readl(espi->mmio + SSPCR1);
- val &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
- writel(val, espi->mmio + SSPCR1);
-}
-
/**
* ep93xx_spi_calc_divisors() - calculates SPI clock divisors
* @espi: ep93xx SPI controller struct
@@ -282,7 +264,12 @@ static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
* FIFO, enable interrupts, and wait for the transfer to complete.
*/
if (ep93xx_spi_read_write(espi)) {
- ep93xx_spi_enable_interrupts(espi);
+ unsigned int val;
+
+ val = readl(espi->mmio + SSPCR1);
+ val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
+ writel(val, espi->mmio + SSPCR1);
+
wait_for_completion(&espi->wait);
}
}
@@ -604,6 +591,7 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master,
static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
{
struct ep93xx_spi *espi = dev_id;
+ unsigned int val;
/*
* If we got ROR (receive overrun) interrupt we know that something is
@@ -635,8 +623,12 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
* any case we disable interrupts and notify the worker to handle
* any post-processing of the message.
*/
- ep93xx_spi_disable_interrupts(espi);
+ val = readl(espi->mmio + SSPCR1);
+ val &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
+ writel(val, espi->mmio + SSPCR1);
+
complete(&espi->wait);
+
return IRQ_HANDLED;
}
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 04/12] spi: spi-ep93xx: pass the spi_master pointer around
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (2 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 03/12] spi: spi-ep93xx: absorb the interrupt enable/disable helpers Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 05/12] spi: spi-ep93xx: remove private data 'current_msg' Chris Packham
` (8 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
From: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
Change the parameters for some of the functions so that the spi_master
pointer is passed around instead of the private data ep93xx_spi pointer.
This allows removing the 'pdev' member of the private data and will
help with some later cleanup.
Signed-off-by: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 90 ++++++++++++++++++++++++++----------------------
1 file changed, 49 insertions(+), 41 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index e8f454b55b69..f276ddee5a2e 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -70,7 +70,6 @@
/**
* struct ep93xx_spi - EP93xx SPI controller structure
- * @pdev: pointer to platform device
* @clk: clock for the controller
* @mmio: pointer to ioremap()'d registers
* @sspdr_phys: physical address of the SSPDR register
@@ -90,7 +89,6 @@
* the client
*/
struct ep93xx_spi {
- const struct platform_device *pdev;
struct clk *clk;
void __iomem *mmio;
unsigned long sspdr_phys;
@@ -113,15 +111,15 @@ struct ep93xx_spi {
/**
* ep93xx_spi_calc_divisors() - calculates SPI clock divisors
- * @espi: ep93xx SPI controller struct
+ * @master: SPI master
* @rate: desired SPI output clock rate
* @div_cpsr: pointer to return the cpsr (pre-scaler) divider
* @div_scr: pointer to return the scr divider
*/
-static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi,
+static int ep93xx_spi_calc_divisors(struct spi_master *master,
u32 rate, u8 *div_cpsr, u8 *div_scr)
{
- struct spi_master *master = platform_get_drvdata(espi->pdev);
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
unsigned long spi_clk_rate = clk_get_rate(espi->clk);
int cpsr, scr;
@@ -162,17 +160,18 @@ static void ep93xx_spi_cs_control(struct spi_device *spi, bool enable)
gpio_set_value(spi->cs_gpio, !enable);
}
-static int ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
+static int ep93xx_spi_chip_setup(struct spi_master *master,
struct spi_device *spi,
struct spi_transfer *xfer)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
u8 dss = bits_per_word_to_dss(xfer->bits_per_word);
u8 div_cpsr = 0;
u8 div_scr = 0;
u16 cr0;
int err;
- err = ep93xx_spi_calc_divisors(espi, xfer->speed_hz,
+ err = ep93xx_spi_calc_divisors(master, xfer->speed_hz,
&div_cpsr, &div_scr);
if (err)
return err;
@@ -181,9 +180,9 @@ static int ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
cr0 |= (spi->mode & (SPI_CPHA | SPI_CPOL)) << SSPCR0_MODE_SHIFT;
cr0 |= dss;
- dev_dbg(&espi->pdev->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
+ dev_dbg(&master->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
spi->mode, div_cpsr, div_scr, dss);
- dev_dbg(&espi->pdev->dev, "setup: cr0 %#x\n", cr0);
+ dev_dbg(&master->dev, "setup: cr0 %#x\n", cr0);
writel(div_cpsr, espi->mmio + SSPCPSR);
writel(cr0, espi->mmio + SSPCR0);
@@ -234,8 +233,9 @@ static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
* When this function is finished, RX FIFO should be empty and TX FIFO should be
* full.
*/
-static int ep93xx_spi_read_write(struct ep93xx_spi *espi)
+static int ep93xx_spi_read_write(struct spi_master *master)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
struct spi_message *msg = espi->current_msg;
struct spi_transfer *t = msg->state;
@@ -257,13 +257,15 @@ static int ep93xx_spi_read_write(struct ep93xx_spi *espi)
return -EINPROGRESS;
}
-static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
+static void ep93xx_spi_pio_transfer(struct spi_master *master)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
+
/*
* Now everything is set up for the current transfer. We prime the TX
* FIFO, enable interrupts, and wait for the transfer to complete.
*/
- if (ep93xx_spi_read_write(espi)) {
+ if (ep93xx_spi_read_write(master)) {
unsigned int val;
val = readl(espi->mmio + SSPCR1);
@@ -276,7 +278,7 @@ static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
/**
* ep93xx_spi_dma_prepare() - prepares a DMA transfer
- * @espi: ep93xx SPI controller struct
+ * @master: SPI master
* @dir: DMA transfer direction
*
* Function configures the DMA, maps the buffer and prepares the DMA
@@ -284,8 +286,10 @@ static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
* in case of failure.
*/
static struct dma_async_tx_descriptor *
-ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_transfer_direction dir)
+ep93xx_spi_dma_prepare(struct spi_master *master,
+ enum dma_transfer_direction dir)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
struct spi_transfer *t = espi->current_msg->state;
struct dma_async_tx_descriptor *txd;
enum dma_slave_buswidth buswidth;
@@ -361,7 +365,7 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_transfer_direction dir)
}
if (WARN_ON(len)) {
- dev_warn(&espi->pdev->dev, "len = %zu expected 0!\n", len);
+ dev_warn(&master->dev, "len = %zu expected 0!\n", len);
return ERR_PTR(-EINVAL);
}
@@ -379,15 +383,16 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_transfer_direction dir)
/**
* ep93xx_spi_dma_finish() - finishes with a DMA transfer
- * @espi: ep93xx SPI controller struct
+ * @master: SPI master
* @dir: DMA transfer direction
*
* Function finishes with the DMA transfer. After this, the DMA buffer is
* unmapped.
*/
-static void ep93xx_spi_dma_finish(struct ep93xx_spi *espi,
+static void ep93xx_spi_dma_finish(struct spi_master *master,
enum dma_transfer_direction dir)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
struct dma_chan *chan;
struct sg_table *sgt;
@@ -407,22 +412,23 @@ static void ep93xx_spi_dma_callback(void *callback_param)
complete(callback_param);
}
-static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
+static void ep93xx_spi_dma_transfer(struct spi_master *master)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
struct spi_message *msg = espi->current_msg;
struct dma_async_tx_descriptor *rxd, *txd;
- rxd = ep93xx_spi_dma_prepare(espi, DMA_DEV_TO_MEM);
+ rxd = ep93xx_spi_dma_prepare(master, DMA_DEV_TO_MEM);
if (IS_ERR(rxd)) {
- dev_err(&espi->pdev->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
+ dev_err(&master->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
msg->status = PTR_ERR(rxd);
return;
}
- txd = ep93xx_spi_dma_prepare(espi, DMA_MEM_TO_DEV);
+ txd = ep93xx_spi_dma_prepare(master, DMA_MEM_TO_DEV);
if (IS_ERR(txd)) {
- ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM);
- dev_err(&espi->pdev->dev, "DMA TX failed: %ld\n", PTR_ERR(txd));
+ ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
+ dev_err(&master->dev, "DMA TX failed: %ld\n", PTR_ERR(txd));
msg->status = PTR_ERR(txd);
return;
}
@@ -440,13 +446,13 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
wait_for_completion(&espi->wait);
- ep93xx_spi_dma_finish(espi, DMA_MEM_TO_DEV);
- ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM);
+ ep93xx_spi_dma_finish(master, DMA_MEM_TO_DEV);
+ ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
}
/**
* ep93xx_spi_process_transfer() - processes one SPI transfer
- * @espi: ep93xx SPI controller struct
+ * @master: SPI master
* @msg: current message
* @t: transfer to process
*
@@ -454,17 +460,18 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
* transfer is complete (may sleep) and updates @msg->status based on whether
* transfer was successfully processed or not.
*/
-static void ep93xx_spi_process_transfer(struct ep93xx_spi *espi,
+static void ep93xx_spi_process_transfer(struct spi_master *master,
struct spi_message *msg,
struct spi_transfer *t)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
int err;
msg->state = t;
- err = ep93xx_spi_chip_setup(espi, msg->spi, t);
+ err = ep93xx_spi_chip_setup(master, msg->spi, t);
if (err) {
- dev_err(&espi->pdev->dev,
+ dev_err(&master->dev,
"failed to setup chip for transfer\n");
msg->status = err;
return;
@@ -479,9 +486,9 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi *espi,
* So in these cases we will be using PIO and don't bother for DMA.
*/
if (espi->dma_rx && t->len > SPI_FIFO_SIZE)
- ep93xx_spi_dma_transfer(espi);
+ ep93xx_spi_dma_transfer(master);
else
- ep93xx_spi_pio_transfer(espi);
+ ep93xx_spi_pio_transfer(master);
/*
* In case of error during transmit, we bail out from processing
@@ -516,7 +523,7 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi *espi,
/*
* ep93xx_spi_process_message() - process one SPI message
- * @espi: ep93xx SPI controller struct
+ * @master: SPI master
* @msg: message to process
*
* This function processes a single SPI message. We go through all transfers in
@@ -526,9 +533,10 @@ static void ep93xx_spi_process_transfer(struct ep93xx_spi *espi,
* @msg->status contains %0 in case of success or negative error code in case of
* failure.
*/
-static void ep93xx_spi_process_message(struct ep93xx_spi *espi,
+static void ep93xx_spi_process_message(struct spi_master *master,
struct spi_message *msg)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
unsigned long timeout;
struct spi_transfer *t;
@@ -538,7 +546,7 @@ static void ep93xx_spi_process_message(struct ep93xx_spi *espi,
timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT);
while (readl(espi->mmio + SSPSR) & SSPSR_RNE) {
if (time_after(jiffies, timeout)) {
- dev_warn(&espi->pdev->dev,
+ dev_warn(&master->dev,
"timeout while flushing RX FIFO\n");
msg->status = -ETIMEDOUT;
return;
@@ -558,7 +566,7 @@ static void ep93xx_spi_process_message(struct ep93xx_spi *espi,
ep93xx_spi_cs_control(msg->spi, true);
list_for_each_entry(t, &msg->transfers, transfer_list) {
- ep93xx_spi_process_transfer(espi, msg, t);
+ ep93xx_spi_process_transfer(master, msg, t);
if (msg->status)
break;
}
@@ -580,7 +588,7 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master,
msg->actual_length = 0;
espi->current_msg = msg;
- ep93xx_spi_process_message(espi, msg);
+ ep93xx_spi_process_message(master, msg);
espi->current_msg = NULL;
spi_finalize_current_message(master);
@@ -590,7 +598,8 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master,
static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
{
- struct ep93xx_spi *espi = dev_id;
+ struct spi_master *master = dev_id;
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
unsigned int val;
/*
@@ -600,7 +609,7 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) {
/* clear the overrun interrupt */
writel(0, espi->mmio + SSPICR);
- dev_warn(&espi->pdev->dev,
+ dev_warn(&master->dev,
"receive overrun, aborting the message\n");
espi->current_msg->status = -EIO;
} else {
@@ -608,7 +617,7 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
* Interrupt is either RX (RIS) or TX (TIS). For both cases we
* simply execute next data transfer.
*/
- if (ep93xx_spi_read_write(espi)) {
+ if (ep93xx_spi_read_write(master)) {
/*
* In normal case, there still is some processing left
* for current transfer. Let's wait for the next
@@ -815,7 +824,6 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
*/
master->max_speed_hz = clk_get_rate(espi->clk) / 2;
master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256);
- espi->pdev = pdev;
espi->sspdr_phys = res->start + SSPDR;
@@ -826,7 +834,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
}
error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt,
- 0, "ep93xx-spi", espi);
+ 0, "ep93xx-spi", master);
if (error) {
dev_err(&pdev->dev, "failed to request irq\n");
goto fail_release_master;
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 05/12] spi: spi-ep93xx: remove private data 'current_msg'
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (3 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 04/12] spi: spi-ep93xx: pass the spi_master pointer around Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 06/12] spi: spi-ep93xx: use the default master transfer queueing mechanism Chris Packham
` (7 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
From: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
The currently in-flight message can be found from the spi master.
Use that instead and remove the private data pointer.
Signed-off-by: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index f276ddee5a2e..dd376266d77e 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -74,7 +74,6 @@
* @mmio: pointer to ioremap()'d registers
* @sspdr_phys: physical address of the SSPDR register
* @wait: wait here until given transfer is completed
- * @current_msg: message that is currently processed (or %NULL if none)
* @tx: current byte in transfer to transmit
* @rx: current byte in transfer to receive
* @fifo_level: how full is FIFO (%0..%SPI_FIFO_SIZE - %1). Receiving one
@@ -93,7 +92,6 @@ struct ep93xx_spi {
void __iomem *mmio;
unsigned long sspdr_phys;
struct completion wait;
- struct spi_message *current_msg;
size_t tx;
size_t rx;
size_t fifo_level;
@@ -236,8 +234,7 @@ static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
static int ep93xx_spi_read_write(struct spi_master *master)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
- struct spi_message *msg = espi->current_msg;
- struct spi_transfer *t = msg->state;
+ struct spi_transfer *t = master->cur_msg->state;
/* read as long as RX FIFO has frames in it */
while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) {
@@ -290,7 +287,7 @@ ep93xx_spi_dma_prepare(struct spi_master *master,
enum dma_transfer_direction dir)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
- struct spi_transfer *t = espi->current_msg->state;
+ struct spi_transfer *t = master->cur_msg->state;
struct dma_async_tx_descriptor *txd;
enum dma_slave_buswidth buswidth;
struct dma_slave_config conf;
@@ -415,13 +412,12 @@ static void ep93xx_spi_dma_callback(void *callback_param)
static void ep93xx_spi_dma_transfer(struct spi_master *master)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
- struct spi_message *msg = espi->current_msg;
struct dma_async_tx_descriptor *rxd, *txd;
rxd = ep93xx_spi_dma_prepare(master, DMA_DEV_TO_MEM);
if (IS_ERR(rxd)) {
dev_err(&master->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
- msg->status = PTR_ERR(rxd);
+ master->cur_msg->status = PTR_ERR(rxd);
return;
}
@@ -429,7 +425,7 @@ static void ep93xx_spi_dma_transfer(struct spi_master *master)
if (IS_ERR(txd)) {
ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
dev_err(&master->dev, "DMA TX failed: %ld\n", PTR_ERR(txd));
- msg->status = PTR_ERR(txd);
+ master->cur_msg->status = PTR_ERR(txd);
return;
}
@@ -587,9 +583,7 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master,
msg->status = 0;
msg->actual_length = 0;
- espi->current_msg = msg;
ep93xx_spi_process_message(master, msg);
- espi->current_msg = NULL;
spi_finalize_current_message(master);
@@ -611,7 +605,7 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
writel(0, espi->mmio + SSPICR);
dev_warn(&master->dev,
"receive overrun, aborting the message\n");
- espi->current_msg->status = -EIO;
+ master->cur_msg->status = -EIO;
} else {
/*
* Interrupt is either RX (RIS) or TX (TIS). For both cases we
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 06/12] spi: spi-ep93xx: use the default master transfer queueing mechanism
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (4 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 05/12] spi: spi-ep93xx: remove private data 'current_msg' Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 07/12] spi: use gpio_desc instead of numeric gpio Chris Packham
` (6 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
From: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
Update this driver to the default implementation of transfer_one_message().
Signed-off-by: H Hartley Sweeten <hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 322 ++++++++++++++++-------------------------------
1 file changed, 108 insertions(+), 214 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index dd376266d77e..d48d0508a886 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -73,7 +73,6 @@
* @clk: clock for the controller
* @mmio: pointer to ioremap()'d registers
* @sspdr_phys: physical address of the SSPDR register
- * @wait: wait here until given transfer is completed
* @tx: current byte in transfer to transmit
* @rx: current byte in transfer to receive
* @fifo_level: how full is FIFO (%0..%SPI_FIFO_SIZE - %1). Receiving one
@@ -91,7 +90,6 @@ struct ep93xx_spi {
struct clk *clk;
void __iomem *mmio;
unsigned long sspdr_phys;
- struct completion wait;
size_t tx;
size_t rx;
size_t fifo_level;
@@ -123,8 +121,7 @@ static int ep93xx_spi_calc_divisors(struct spi_master *master,
/*
* Make sure that max value is between values supported by the
- * controller. Note that minimum value is already checked in
- * ep93xx_spi_transfer_one_message().
+ * controller.
*/
rate = clamp(rate, master->min_speed_hz, master->max_speed_hz);
@@ -149,15 +146,6 @@ static int ep93xx_spi_calc_divisors(struct spi_master *master,
return -EINVAL;
}
-static void ep93xx_spi_cs_control(struct spi_device *spi, bool enable)
-{
- if (spi->mode & SPI_CS_HIGH)
- enable = !enable;
-
- if (gpio_is_valid(spi->cs_gpio))
- gpio_set_value(spi->cs_gpio, !enable);
-}
-
static int ep93xx_spi_chip_setup(struct spi_master *master,
struct spi_device *spi,
struct spi_transfer *xfer)
@@ -188,34 +176,38 @@ static int ep93xx_spi_chip_setup(struct spi_master *master,
return 0;
}
-static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
+static void ep93xx_do_write(struct spi_master *master)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
+ struct spi_transfer *xfer = master->cur_msg->state;
unsigned int val = 0;
- if (t->bits_per_word > 8) {
- if (t->tx_buf)
- val = ((u16 *)t->tx_buf)[espi->tx];
+ if (xfer->bits_per_word > 8) {
+ if (xfer->tx_buf)
+ val = ((u16 *)xfer->tx_buf)[espi->tx];
espi->tx += 2;
} else {
- if (t->tx_buf)
- val = ((u8 *)t->tx_buf)[espi->tx];
+ if (xfer->tx_buf)
+ val = ((u8 *)xfer->tx_buf)[espi->tx];
espi->tx += 1;
}
writel(val, espi->mmio + SSPDR);
}
-static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
+static void ep93xx_do_read(struct spi_master *master)
{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
+ struct spi_transfer *xfer = master->cur_msg->state;
unsigned int val;
val = readl(espi->mmio + SSPDR);
- if (t->bits_per_word > 8) {
- if (t->rx_buf)
- ((u16 *)t->rx_buf)[espi->rx] = val;
+ if (xfer->bits_per_word > 8) {
+ if (xfer->rx_buf)
+ ((u16 *)xfer->rx_buf)[espi->rx] = val;
espi->rx += 2;
} else {
- if (t->rx_buf)
- ((u8 *)t->rx_buf)[espi->rx] = val;
+ if (xfer->rx_buf)
+ ((u8 *)xfer->rx_buf)[espi->rx] = val;
espi->rx += 1;
}
}
@@ -234,45 +226,26 @@ static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
static int ep93xx_spi_read_write(struct spi_master *master)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
- struct spi_transfer *t = master->cur_msg->state;
+ struct spi_transfer *xfer = master->cur_msg->state;
/* read as long as RX FIFO has frames in it */
while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) {
- ep93xx_do_read(espi, t);
+ ep93xx_do_read(master);
espi->fifo_level--;
}
/* write as long as TX FIFO has room */
- while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < t->len) {
- ep93xx_do_write(espi, t);
+ while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < xfer->len) {
+ ep93xx_do_write(master);
espi->fifo_level++;
}
- if (espi->rx == t->len)
+ if (espi->rx == xfer->len)
return 0;
return -EINPROGRESS;
}
-static void ep93xx_spi_pio_transfer(struct spi_master *master)
-{
- struct ep93xx_spi *espi = spi_master_get_devdata(master);
-
- /*
- * Now everything is set up for the current transfer. We prime the TX
- * FIFO, enable interrupts, and wait for the transfer to complete.
- */
- if (ep93xx_spi_read_write(master)) {
- unsigned int val;
-
- val = readl(espi->mmio + SSPCR1);
- val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
- writel(val, espi->mmio + SSPCR1);
-
- wait_for_completion(&espi->wait);
- }
-}
-
/**
* ep93xx_spi_dma_prepare() - prepares a DMA transfer
* @master: SPI master
@@ -287,7 +260,7 @@ ep93xx_spi_dma_prepare(struct spi_master *master,
enum dma_transfer_direction dir)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
- struct spi_transfer *t = master->cur_msg->state;
+ struct spi_transfer *xfer = master->cur_msg->state;
struct dma_async_tx_descriptor *txd;
enum dma_slave_buswidth buswidth;
struct dma_slave_config conf;
@@ -295,10 +268,10 @@ ep93xx_spi_dma_prepare(struct spi_master *master,
struct sg_table *sgt;
struct dma_chan *chan;
const void *buf, *pbuf;
- size_t len = t->len;
+ size_t len = xfer->len;
int i, ret, nents;
- if (t->bits_per_word > 8)
+ if (xfer->bits_per_word > 8)
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
else
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
@@ -308,14 +281,14 @@ ep93xx_spi_dma_prepare(struct spi_master *master,
if (dir == DMA_DEV_TO_MEM) {
chan = espi->dma_rx;
- buf = t->rx_buf;
+ buf = xfer->rx_buf;
sgt = &espi->rx_sgt;
conf.src_addr = espi->sspdr_phys;
conf.src_addr_width = buswidth;
} else {
chan = espi->dma_tx;
- buf = t->tx_buf;
+ buf = xfer->tx_buf;
sgt = &espi->tx_sgt;
conf.dst_addr = espi->sspdr_phys;
@@ -406,10 +379,15 @@ static void ep93xx_spi_dma_finish(struct spi_master *master,
static void ep93xx_spi_dma_callback(void *callback_param)
{
- complete(callback_param);
+ struct spi_master *master = callback_param;
+
+ ep93xx_spi_dma_finish(master, DMA_MEM_TO_DEV);
+ ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
+
+ spi_finalize_current_transfer(master);
}
-static void ep93xx_spi_dma_transfer(struct spi_master *master)
+static int ep93xx_spi_dma_transfer(struct spi_master *master)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
struct dma_async_tx_descriptor *rxd, *txd;
@@ -417,177 +395,29 @@ static void ep93xx_spi_dma_transfer(struct spi_master *master)
rxd = ep93xx_spi_dma_prepare(master, DMA_DEV_TO_MEM);
if (IS_ERR(rxd)) {
dev_err(&master->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
- master->cur_msg->status = PTR_ERR(rxd);
- return;
+ return PTR_ERR(rxd);
}
txd = ep93xx_spi_dma_prepare(master, DMA_MEM_TO_DEV);
if (IS_ERR(txd)) {
ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
dev_err(&master->dev, "DMA TX failed: %ld\n", PTR_ERR(txd));
- master->cur_msg->status = PTR_ERR(txd);
- return;
+ return PTR_ERR(txd);
}
/* We are ready when RX is done */
rxd->callback = ep93xx_spi_dma_callback;
- rxd->callback_param = &espi->wait;
+ rxd->callback_param = master;
- /* Now submit both descriptors and wait while they finish */
+ /* Now submit both descriptors and start DMA */
dmaengine_submit(rxd);
dmaengine_submit(txd);
dma_async_issue_pending(espi->dma_rx);
dma_async_issue_pending(espi->dma_tx);
- wait_for_completion(&espi->wait);
-
- ep93xx_spi_dma_finish(master, DMA_MEM_TO_DEV);
- ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
-}
-
-/**
- * ep93xx_spi_process_transfer() - processes one SPI transfer
- * @master: SPI master
- * @msg: current message
- * @t: transfer to process
- *
- * This function processes one SPI transfer given in @t. Function waits until
- * transfer is complete (may sleep) and updates @msg->status based on whether
- * transfer was successfully processed or not.
- */
-static void ep93xx_spi_process_transfer(struct spi_master *master,
- struct spi_message *msg,
- struct spi_transfer *t)
-{
- struct ep93xx_spi *espi = spi_master_get_devdata(master);
- int err;
-
- msg->state = t;
-
- err = ep93xx_spi_chip_setup(master, msg->spi, t);
- if (err) {
- dev_err(&master->dev,
- "failed to setup chip for transfer\n");
- msg->status = err;
- return;
- }
-
- espi->rx = 0;
- espi->tx = 0;
-
- /*
- * There is no point of setting up DMA for the transfers which will
- * fit into the FIFO and can be transferred with a single interrupt.
- * So in these cases we will be using PIO and don't bother for DMA.
- */
- if (espi->dma_rx && t->len > SPI_FIFO_SIZE)
- ep93xx_spi_dma_transfer(master);
- else
- ep93xx_spi_pio_transfer(master);
-
- /*
- * In case of error during transmit, we bail out from processing
- * the message.
- */
- if (msg->status)
- return;
-
- msg->actual_length += t->len;
-
- /*
- * After this transfer is finished, perform any possible
- * post-transfer actions requested by the protocol driver.
- */
- if (t->delay_usecs) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(usecs_to_jiffies(t->delay_usecs));
- }
- if (t->cs_change) {
- if (!list_is_last(&t->transfer_list, &msg->transfers)) {
- /*
- * In case protocol driver is asking us to drop the
- * chipselect briefly, we let the scheduler to handle
- * any "delay" here.
- */
- ep93xx_spi_cs_control(msg->spi, false);
- cond_resched();
- ep93xx_spi_cs_control(msg->spi, true);
- }
- }
-}
-
-/*
- * ep93xx_spi_process_message() - process one SPI message
- * @master: SPI master
- * @msg: message to process
- *
- * This function processes a single SPI message. We go through all transfers in
- * the message and pass them to ep93xx_spi_process_transfer(). Chipselect is
- * asserted during the whole message (unless per transfer cs_change is set).
- *
- * @msg->status contains %0 in case of success or negative error code in case of
- * failure.
- */
-static void ep93xx_spi_process_message(struct spi_master *master,
- struct spi_message *msg)
-{
- struct ep93xx_spi *espi = spi_master_get_devdata(master);
- unsigned long timeout;
- struct spi_transfer *t;
-
- /*
- * Just to be sure: flush any data from RX FIFO.
- */
- timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT);
- while (readl(espi->mmio + SSPSR) & SSPSR_RNE) {
- if (time_after(jiffies, timeout)) {
- dev_warn(&master->dev,
- "timeout while flushing RX FIFO\n");
- msg->status = -ETIMEDOUT;
- return;
- }
- readl(espi->mmio + SSPDR);
- }
-
- /*
- * We explicitly handle FIFO level. This way we don't have to check TX
- * FIFO status using %SSPSR_TNF bit which may cause RX FIFO overruns.
- */
- espi->fifo_level = 0;
-
- /*
- * Assert the chipselect.
- */
- ep93xx_spi_cs_control(msg->spi, true);
-
- list_for_each_entry(t, &msg->transfers, transfer_list) {
- ep93xx_spi_process_transfer(master, msg, t);
- if (msg->status)
- break;
- }
-
- /*
- * Now the whole message is transferred (or failed for some reason). We
- * deselect the device and disable the SPI controller.
- */
- ep93xx_spi_cs_control(msg->spi, false);
-}
-
-static int ep93xx_spi_transfer_one_message(struct spi_master *master,
- struct spi_message *msg)
-{
- struct ep93xx_spi *espi = spi_master_get_devdata(master);
-
- msg->state = NULL;
- msg->status = 0;
- msg->actual_length = 0;
-
- ep93xx_spi_process_message(master, msg);
-
- spi_finalize_current_message(master);
-
- return 0;
+ /* signal that we need to wait for completion */
+ return 1;
}
static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
@@ -630,11 +460,76 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
val &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
writel(val, espi->mmio + SSPCR1);
- complete(&espi->wait);
+ spi_finalize_current_transfer(master);
return IRQ_HANDLED;
}
+static int ep93xx_spi_transfer_one(struct spi_master *master,
+ struct spi_device *spi,
+ struct spi_transfer *xfer)
+{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
+ unsigned int val;
+ int ret;
+
+ ret = ep93xx_spi_chip_setup(master, spi, xfer);
+ if (ret) {
+ dev_err(&master->dev, "failed to setup chip for transfer\n");
+ return ret;
+ }
+
+ master->cur_msg->state = xfer;
+ espi->rx = 0;
+ espi->tx = 0;
+
+ /*
+ * There is no point of setting up DMA for the transfers which will
+ * fit into the FIFO and can be transferred with a single interrupt.
+ * So in these cases we will be using PIO and don't bother for DMA.
+ */
+ if (espi->dma_rx && xfer->len > SPI_FIFO_SIZE)
+ return ep93xx_spi_dma_transfer(master);
+
+ /* Using PIO so prime the TX FIFO and enable interrupts */
+ ep93xx_spi_read_write(master);
+
+ val = readl(espi->mmio + SSPCR1);
+ val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
+ writel(val, espi->mmio + SSPCR1);
+
+ /* signal that we need to wait for completion */
+ return 1;
+}
+
+static int ep93xx_spi_prepare_message(struct spi_master *master,
+ struct spi_message *msg)
+{
+ struct ep93xx_spi *espi = spi_master_get_devdata(master);
+ unsigned long timeout;
+
+ /*
+ * Just to be sure: flush any data from RX FIFO.
+ */
+ timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT);
+ while (readl(espi->mmio + SSPSR) & SSPSR_RNE) {
+ if (time_after(jiffies, timeout)) {
+ dev_warn(&master->dev,
+ "timeout while flushing RX FIFO\n");
+ return -ETIMEDOUT;
+ }
+ readl(espi->mmio + SSPDR);
+ }
+
+ /*
+ * We explicitly handle FIFO level. This way we don't have to check TX
+ * FIFO status using %SSPSR_TNF bit which may cause RX FIFO overruns.
+ */
+ espi->fifo_level = 0;
+
+ return 0;
+}
+
static int ep93xx_spi_prepare_hardware(struct spi_master *master)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
@@ -769,7 +664,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
master->prepare_transfer_hardware = ep93xx_spi_prepare_hardware;
master->unprepare_transfer_hardware = ep93xx_spi_unprepare_hardware;
- master->transfer_one_message = ep93xx_spi_transfer_one_message;
+ master->prepare_message = ep93xx_spi_prepare_message;
+ master->transfer_one = ep93xx_spi_transfer_one;
master->bus_num = pdev->id;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
@@ -810,8 +706,6 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
goto fail_release_master;
}
- init_completion(&espi->wait);
-
/*
* Calculate maximum and minimum supported clock rates
* for the controller.
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 07/12] spi: use gpio_desc instead of numeric gpio
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (5 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 06/12] spi: spi-ep93xx: use the default master transfer queueing mechanism Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 08/12] ARM: ep93xx: add gpiod_lookup_table for spi chip-selects Chris Packham
` (5 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
By using a gpio_desc and gpiod_set_value() instead of a numeric gpio and
gpio_set_value() the gpio flags are taken into account. This is useful
when using a gpio chip-select to supplement a controllers native
chip-select.
Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
---
Notes:
(I've included this in this series for context, ultimately it should not be
needed once everything is using gpio_desc)
My specific use-case is I have a board that uses the spi-orion driver but
only has one CS pin available. In order to access two spi slave devices the
board has a 1-of-2 decoder/demultiplexer which is driven via a gpio.
The problem is that for one of the 2 slave devices the gpio level required
is opposite to the chip-select so I can't simply specify "spi-cs-high".
With this change I can flag the gpio as active low and the gpio subsystem
takes care of the additional inversion required.
drivers/spi/spi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0725c78b0de6..918a53c884dd 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -725,7 +725,10 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
enable = !enable;
if (gpio_is_valid(spi->cs_gpio)) {
- gpio_set_value(spi->cs_gpio, !enable);
+ struct gpio_desc *gpio = gpio_to_desc(spi->cs_gpio);
+
+ if (gpio)
+ gpiod_set_value(gpio, !enable);
/* Some SPI masters need both GPIO CS & slave_select */
if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
spi->controller->set_cs)
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 08/12] ARM: ep93xx: add gpiod_lookup_table for spi chip-selects
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (6 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 07/12] spi: use gpio_desc instead of numeric gpio Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 09/12] ARM: imx: " Chris Packham
` (4 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
This is a preparatory step which will allow the conversion of
spi-ep93xx.c to gpiod.
Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
---
arch/arm/mach-ep93xx/edb93xx.c | 12 ++++++++++++
arch/arm/mach-ep93xx/simone.c | 11 +++++++++++
arch/arm/mach-ep93xx/vision_ep9307.c | 15 +++++++++++++++
3 files changed, 38 insertions(+)
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c
index 0ac176386789..9042adfe03de 100644
--- a/arch/arm/mach-ep93xx/edb93xx.c
+++ b/arch/arm/mach-ep93xx/edb93xx.c
@@ -27,6 +27,8 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
#include <linux/i2c.h>
#include <linux/i2c-gpio.h>
#include <linux/spi/spi.h>
@@ -116,6 +118,15 @@ static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
},
};
+static struct gpiod_lookup_table edb93xx_gpios_table = {
+ .dev_id = "spi.0",
+ .table = {
+ GPIO_LOOKUP("gpio-ep93xx", EP93XX_GPIO_LINE_EGPIO6,
+ "spi-cs", GPIO_ACTIVE_HIGH),
+ {},
+ },
+};
+
static int edb93xx_spi_chipselects[] __initdata = {
EP93XX_GPIO_LINE_EGPIO6,
};
@@ -134,6 +145,7 @@ static void __init edb93xx_register_spi(void)
else if (machine_is_edb9315a())
edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO14;
+ gpiod_add_lookup_table(&edb93xx_gpios_table);
ep93xx_register_spi(&edb93xx_spi_info, edb93xx_spi_board_info,
ARRAY_SIZE(edb93xx_spi_board_info));
}
diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c
index c7a40f245892..f297a7a89ed9 100644
--- a/arch/arm/mach-ep93xx/simone.c
+++ b/arch/arm/mach-ep93xx/simone.c
@@ -26,6 +26,7 @@
#include <linux/platform_data/video-ep93xx.h>
#include <linux/platform_data/spi-ep93xx.h>
#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
#include <mach/hardware.h>
#include <mach/gpio-ep93xx.h>
@@ -119,6 +120,15 @@ static struct spi_board_info simone_spi_devices[] __initdata = {
* low between multi-message command blocks. From v1.4, it uses a GPIO instead.
* v1.3 parts will still work, since the signal on SFRMOUT is automatic.
*/
+static struct gpiod_lookup_table simone_gpios_table = {
+ .dev_id = "spi.0",
+ .table = {
+ GPIO_LOOKUP("gpio-ep93xx", EP93XX_GPIO_LINE_EGPIO1,
+ "spi-cs", GPIO_ACTIVE_HIGH),
+ {},
+ },
+};
+
static int simone_spi_chipselects[] __initdata = {
EP93XX_GPIO_LINE_EGPIO1,
};
@@ -163,6 +173,7 @@ static void __init simone_init_machine(void)
ep93xx_register_fb(&simone_fb_info);
ep93xx_register_i2c(&simone_i2c_gpio_data, simone_i2c_board_info,
ARRAY_SIZE(simone_i2c_board_info));
+ gpiod_add_lookup_table(&simone_gpios_table);
ep93xx_register_spi(&simone_spi_info, simone_spi_devices,
ARRAY_SIZE(simone_spi_devices));
simone_register_audio();
diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c
index 1daf9441058c..3d9c66bbf2af 100644
--- a/arch/arm/mach-ep93xx/vision_ep9307.c
+++ b/arch/arm/mach-ep93xx/vision_ep9307.c
@@ -18,6 +18,7 @@
#include <linux/platform_device.h>
#include <linux/irq.h>
#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
#include <linux/fb.h>
#include <linux/io.h>
#include <linux/mtd/partitions.h>
@@ -242,6 +243,19 @@ static struct spi_board_info vision_spi_board_info[] __initdata = {
},
};
+static struct gpiod_lookup_table vision_gpios_table = {
+ .dev_id = "spi.0",
+ .table = {
+ GPIO_LOOKUP_IDX("gpio-ep93xx", EP93XX_GPIO_LINE_EGPIO6,
+ "spi-cs", 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx", EP93XX_GPIO_LINE_EGPIO7,
+ "spi-cs", 1, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-ep93xx", EP93XX_GPIO_LINE_G(2),
+ "spi-cs", 2, GPIO_ACTIVE_HIGH),
+ {},
+ },
+};
+
static int vision_spi_chipselects[] __initdata = {
EP93XX_GPIO_LINE_EGPIO6,
EP93XX_GPIO_LINE_EGPIO7,
@@ -291,6 +305,7 @@ static void __init vision_init_machine(void)
ep93xx_register_i2c(&vision_i2c_gpio_data, vision_i2c_info,
ARRAY_SIZE(vision_i2c_info));
+ gpiod_add_lookup_table(&vision_gpios_table);
ep93xx_register_spi(&vision_spi_master, vision_spi_board_info,
ARRAY_SIZE(vision_spi_board_info));
vision_register_i2s();
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 09/12] ARM: imx: add gpiod_lookup_table for spi chip-selects
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (7 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 08/12] ARM: ep93xx: add gpiod_lookup_table for spi chip-selects Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 10/12] spi: core: convert spi_master to use gpio_desc Chris Packham
` (3 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
This is a preparatory step which will allow the conversion of
spi-imx.c to gpiod.
Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
---
arch/arm/mach-imx/mach-mx27_3ds.c | 21 +++++++++++++++++++++
arch/arm/mach-imx/mach-pca100.c | 13 +++++++++++++
2 files changed, 34 insertions(+)
diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index 45e16bd7e2f2..46d67be124f0 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -22,6 +22,7 @@
#include <linux/platform_device.h>
#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
#include <linux/irq.h>
#include <linux/usb/otg.h>
#include <linux/usb/ulpi.h>
@@ -313,6 +314,15 @@ static struct imx_ssi_platform_data mx27_3ds_ssi_pdata = {
};
/* SPI */
+static struct gpiod_lookup_table spi1_cs_gpio_table = {
+ .dev_id = "spi.0",
+ .table = {
+ GPIO_LOOKUP("gpio-mxc", SPI1_SS0,
+ "spi-cs", GPIO_ACTIVE_HIGH),
+ { },
+ },
+};
+
static int spi1_chipselect[] = {SPI1_SS0};
static const struct spi_imx_master spi1_pdata __initconst = {
@@ -320,6 +330,15 @@ static const struct spi_imx_master spi1_pdata __initconst = {
.num_chipselect = ARRAY_SIZE(spi1_chipselect),
};
+static struct gpiod_lookup_table spi2_cs_gpio_table = {
+ .dev_id = "spi.1",
+ .table = {
+ GPIO_LOOKUP("gpio-mxc", SPI2_SS0,
+ "spi-cs", GPIO_ACTIVE_HIGH),
+ { },
+ },
+};
+
static int spi2_chipselect[] = {SPI2_SS0};
static const struct spi_imx_master spi2_pdata __initconst = {
@@ -398,7 +417,9 @@ static void __init mx27pdk_init(void)
imx27_add_imx_keypad(&mx27_3ds_keymap_data);
imx27_add_imx2_wdt();
+ gpiod_add_lookup_table(&spi2_cs_gpio_table);
imx27_add_spi_imx1(&spi2_pdata);
+ gpiod_add_lookup_table(&spi1_cs_gpio_table);
imx27_add_spi_imx0(&spi1_pdata);
imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data);
diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c
index ed675863655b..8a2b5860f327 100644
--- a/arch/arm/mach-imx/mach-pca100.c
+++ b/arch/arm/mach-imx/mach-pca100.c
@@ -27,6 +27,7 @@
#include <linux/irq.h>
#include <linux/delay.h>
#include <linux/gpio.h>
+#include <linux/gpio/machine.h>
#include <linux/usb/otg.h>
#include <linux/usb/ulpi.h>
@@ -202,6 +203,17 @@ static struct spi_board_info pca100_spi_board_info[] __initdata = {
},
};
+static struct gpiod_lookup_table pca100_spi_cs_gpio_table = {
+ .dev_id = "spi.0",
+ .table = {
+ GPIO_LOOKUP_IDX("gpio-mxc", SPI1_SS0,
+ "spi-cs", 0, GPIO_ACTIVE_HIGH),
+ GPIO_LOOKUP_IDX("gpio-mxc", SPI1_SS1,
+ "spi-cs", 1, GPIO_ACTIVE_HIGH),
+ { },
+ },
+};
+
static int pca100_spi_cs[] = {SPI1_SS0, SPI1_SS1};
static const struct spi_imx_master pca100_spi0_data __initconst = {
@@ -376,6 +388,7 @@ static void __init pca100_init(void)
mxc_gpio_mode(GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN);
spi_register_board_info(pca100_spi_board_info,
ARRAY_SIZE(pca100_spi_board_info));
+ gpiod_add_lookup_table(&pca100_spi_cs_gpio_table);
imx27_add_spi_imx0(&pca100_spi0_data);
imx27_add_imx_fb(&pca100_fb_data);
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 10/12] spi: core: convert spi_master to use gpio_desc
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (8 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 09/12] ARM: imx: " Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
[not found] ` <20170727220322.26654-11-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
2017-07-27 22:03 ` [RFC PATCH v2 11/12] ARM: ep93xx: remove chipselect from ep93xx_spi_info Chris Packham
` (2 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
Instead of numeric gpios make struct spi_master hold an array of struct
gpio_desc. For now struct spi_device still maintains a numeric gpio
which will be updated in a subsequent change.
Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 18 ++++++++----------
drivers/spi/spi-imx.c | 25 +++++++++----------------
drivers/spi/spi-mt65xx.c | 13 -------------
drivers/spi/spi.c | 23 +++++++++++++++++------
include/linux/spi/spi.h | 2 +-
5 files changed, 35 insertions(+), 46 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index d48d0508a886..9d8328fee737 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -672,7 +672,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
master->num_chipselect = info->num_chipselect;
master->cs_gpios = devm_kzalloc(&master->dev,
- sizeof(int) * master->num_chipselect,
+ sizeof(*master->cs_gpios) * master->num_chipselect,
GFP_KERNEL);
if (!master->cs_gpios) {
error = -ENOMEM;
@@ -680,19 +680,17 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
}
for (i = 0; i < master->num_chipselect; i++) {
- master->cs_gpios[i] = info->chipselect[i];
+ struct gpio_desc *cs;
- if (!gpio_is_valid(master->cs_gpios[i]))
- continue;
-
- error = devm_gpio_request_one(&pdev->dev, master->cs_gpios[i],
- GPIOF_OUT_INIT_HIGH,
- "ep93xx-spi");
- if (error) {
+ cs = devm_gpiod_get_index(&pdev->dev, "spi-cs", i,
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(cs)) {
dev_err(&pdev->dev, "could not request cs gpio %d\n",
- master->cs_gpios[i]);
+ i);
+ error = PTR_ERR(cs);
goto fail_release_master;
}
+ master->cs_gpios[i] = cs;
}
platform_set_drvdata(pdev, master);
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 930e47597db3..d240aa4082c8 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1229,12 +1229,18 @@ static int spi_imx_probe(struct platform_device *pdev)
if (mxc_platform_info) {
master->num_chipselect = mxc_platform_info->num_chipselect;
master->cs_gpios = devm_kzalloc(&master->dev,
- sizeof(int) * master->num_chipselect, GFP_KERNEL);
+ sizeof(*master->cs_gpios) * master->num_chipselect, GFP_KERNEL);
if (!master->cs_gpios)
return -ENOMEM;
- for (i = 0; i < master->num_chipselect; i++)
- master->cs_gpios[i] = mxc_platform_info->chipselect[i];
+ for (i = 0; i < master->num_chipselect; i++) {
+ struct gpio_desc *cs;
+
+ cs = devm_gpiod_get_index(&pdev->dev, "spi-cs", i,
+ GPIOD_OUT_HIGH);
+ if (!IS_ERR(cs))
+ master->cs_gpios[i] = cs;
+ }
}
spi_imx->bitbang.chipselect = spi_imx_chipselect;
@@ -1327,19 +1333,6 @@ static int spi_imx_probe(struct platform_device *pdev)
goto out_clk_put;
}
- for (i = 0; i < master->num_chipselect; i++) {
- if (!gpio_is_valid(master->cs_gpios[i]))
- continue;
-
- ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i],
- DRIVER_NAME);
- if (ret) {
- dev_err(&pdev->dev, "Can't get CS GPIO %i\n",
- master->cs_gpios[i]);
- goto out_clk_put;
- }
- }
-
dev_info(&pdev->dev, "probed\n");
clk_disable(spi_imx->clk_ipg);
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 86bf45667a04..91a498e25cbb 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -732,19 +732,6 @@ static int mtk_spi_probe(struct platform_device *pdev)
ret = -EINVAL;
goto err_disable_runtime_pm;
}
-
- if (master->cs_gpios) {
- for (i = 0; i < master->num_chipselect; i++) {
- ret = devm_gpio_request(&pdev->dev,
- master->cs_gpios[i],
- dev_name(&pdev->dev));
- if (ret) {
- dev_err(&pdev->dev,
- "can't get CS GPIO %i\n", i);
- goto err_disable_runtime_pm;
- }
- }
- }
}
return 0;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 918a53c884dd..3860f0c84e1a 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -40,6 +40,7 @@
#include <linux/ioport.h>
#include <linux/acpi.h>
#include <linux/highmem.h>
+#include <linux/gpio/consumer.h>
#define CREATE_TRACE_POINTS
#include <trace/events/spi.h>
@@ -531,7 +532,9 @@ int spi_add_device(struct spi_device *spi)
}
if (ctlr->cs_gpios)
- spi->cs_gpio = ctlr->cs_gpios[spi->chip_select];
+ spi->cs_gpio = desc_to_gpio(ctlr->cs_gpios[spi->chip_select]);
+ else
+ spi->cs_gpio = -ENOENT;
/* Drivers may modify this initial i/o setup, but will
* normally rely on the device being setup. Devices
@@ -1988,7 +1991,8 @@ EXPORT_SYMBOL_GPL(__spi_alloc_controller);
#ifdef CONFIG_OF
static int of_spi_register_master(struct spi_controller *ctlr)
{
- int nb, i, *cs;
+ int nb, i;
+ struct gpio_desc **cs;
struct device_node *np = ctlr->dev.of_node;
if (!np)
@@ -2003,7 +2007,8 @@ static int of_spi_register_master(struct spi_controller *ctlr)
else if (nb < 0)
return nb;
- cs = devm_kzalloc(&ctlr->dev, sizeof(int) * ctlr->num_chipselect,
+ cs = devm_kzalloc(&ctlr->dev,
+ sizeof(*ctlr->cs_gpios) * ctlr->num_chipselect,
GFP_KERNEL);
ctlr->cs_gpios = cs;
@@ -2011,10 +2016,16 @@ static int of_spi_register_master(struct spi_controller *ctlr)
return -ENOMEM;
for (i = 0; i < ctlr->num_chipselect; i++)
- cs[i] = -ENOENT;
+ cs[i] = NULL;
+
+ for (i = 0; i < nb; i++) {
+ struct gpio_desc *gpio;
- for (i = 0; i < nb; i++)
- cs[i] = of_get_named_gpio(np, "cs-gpios", i);
+ gpio = devm_gpiod_get_index(&ctlr->dev, "cs", i,
+ GPIOD_OUT_HIGH);
+ if (!IS_ERR(gpio))
+ cs[i] = gpio;
+ }
return 0;
}
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 7b2170bfd6e7..7e170db7bc9d 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -565,7 +565,7 @@ struct spi_controller {
struct spi_message *message);
/* gpio chip select */
- int *cs_gpios;
+ struct gpio_desc **cs_gpios;
/* statistics */
struct spi_statistics statistics;
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 11/12] ARM: ep93xx: remove chipselect from ep93xx_spi_info
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (9 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 10/12] spi: core: convert spi_master to use gpio_desc Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
2017-07-27 22:03 ` [RFC PATCH v2 12/12] wip: convert struct spi_device to gpio_desc Chris Packham
2017-07-29 13:15 ` [RFC PATCH v2 00/12] spi: moving to struct gpio_desc Andy Shevchenko
12 siblings, 0 replies; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
Now that the driver has been updated to use gpiod there is no need to
have platform data to define the SPI chipselects. We still need to
define the number of chipselects used.
Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
---
arch/arm/mach-ep93xx/edb93xx.c | 7 +------
arch/arm/mach-ep93xx/simone.c | 7 +------
arch/arm/mach-ep93xx/vision_ep9307.c | 9 +--------
include/linux/platform_data/spi-ep93xx.h | 4 +---
4 files changed, 4 insertions(+), 23 deletions(-)
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c
index 9042adfe03de..b8d354fc27f5 100644
--- a/arch/arm/mach-ep93xx/edb93xx.c
+++ b/arch/arm/mach-ep93xx/edb93xx.c
@@ -127,13 +127,8 @@ static struct gpiod_lookup_table edb93xx_gpios_table = {
},
};
-static int edb93xx_spi_chipselects[] __initdata = {
- EP93XX_GPIO_LINE_EGPIO6,
-};
-
static struct ep93xx_spi_info edb93xx_spi_info __initdata = {
- .chipselect = edb93xx_spi_chipselects,
- .num_chipselect = ARRAY_SIZE(edb93xx_spi_chipselects),
+ .num_chipselect = 1,
};
static void __init edb93xx_register_spi(void)
diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c
index f297a7a89ed9..cb6bc2e1670a 100644
--- a/arch/arm/mach-ep93xx/simone.c
+++ b/arch/arm/mach-ep93xx/simone.c
@@ -129,13 +129,8 @@ static struct gpiod_lookup_table simone_gpios_table = {
},
};
-static int simone_spi_chipselects[] __initdata = {
- EP93XX_GPIO_LINE_EGPIO1,
-};
-
static struct ep93xx_spi_info simone_spi_info __initdata = {
- .chipselect = simone_spi_chipselects,
- .num_chipselect = ARRAY_SIZE(simone_spi_chipselects),
+ .num_chipselect = 1,
.use_dma = 1,
};
diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c
index 3d9c66bbf2af..494c55080472 100644
--- a/arch/arm/mach-ep93xx/vision_ep9307.c
+++ b/arch/arm/mach-ep93xx/vision_ep9307.c
@@ -256,15 +256,8 @@ static struct gpiod_lookup_table vision_gpios_table = {
},
};
-static int vision_spi_chipselects[] __initdata = {
- EP93XX_GPIO_LINE_EGPIO6,
- EP93XX_GPIO_LINE_EGPIO7,
- EP93XX_GPIO_LINE_G(2),
-};
-
static struct ep93xx_spi_info vision_spi_master __initdata = {
- .chipselect = vision_spi_chipselects,
- .num_chipselect = ARRAY_SIZE(vision_spi_chipselects),
+ .num_chipselect = 3,
.use_dma = 1,
};
diff --git a/include/linux/platform_data/spi-ep93xx.h b/include/linux/platform_data/spi-ep93xx.h
index 171a271c2cbd..efcf33eff851 100644
--- a/include/linux/platform_data/spi-ep93xx.h
+++ b/include/linux/platform_data/spi-ep93xx.h
@@ -5,12 +5,10 @@ struct spi_device;
/**
* struct ep93xx_spi_info - EP93xx specific SPI descriptor
- * @chipselect: array of gpio numbers to use as chip selects
- * @num_chipselect: ARRAY_SIZE(chipselect)
+ * @num_chipselect: number chip selects supported
* @use_dma: use DMA for the transfers
*/
struct ep93xx_spi_info {
- int *chipselect;
int num_chipselect;
bool use_dma;
};
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [RFC PATCH v2 12/12] wip: convert struct spi_device to gpio_desc
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (10 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 11/12] ARM: ep93xx: remove chipselect from ep93xx_spi_info Chris Packham
@ 2017-07-27 22:03 ` Chris Packham
[not found] ` <20170727220322.26654-13-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
2017-07-29 13:15 ` [RFC PATCH v2 00/12] spi: moving to struct gpio_desc Andy Shevchenko
12 siblings, 1 reply; 17+ messages in thread
From: Chris Packham @ 2017-07-27 22:03 UTC (permalink / raw)
To: andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA
---
drivers/spi/spi-ath79.c | 26 +++-----------------------
drivers/spi/spi-atmel.c | 4 ++--
drivers/spi/spi-bcm2835.c | 8 ++++----
drivers/spi/spi-cadence.c | 29 ++---------------------------
drivers/spi/spi-clps711x.c | 13 +------------
drivers/spi/spi-davinci.c | 10 ++++------
drivers/spi/spi-dw.c | 7 -------
drivers/spi/spi-fsl-spi.c | 29 +++++------------------------
drivers/spi/spi-img-spfi.c | 25 +------------------------
drivers/spi/spi-lantiq-ssc.c | 2 +-
drivers/spi/spi-mpc512x-psc.c | 20 +++-----------------
drivers/spi/spi-mt65xx.c | 3 ---
drivers/spi/spi-omap2-mcspi.c | 17 ++---------------
drivers/spi/spi-orion.c | 2 +-
drivers/spi/spi-pic32.c | 11 +----------
drivers/spi/spi-s3c64xx.c | 16 ++--------------
drivers/spi/spi-st-ssc4.c | 29 +----------------------------
drivers/spi/spi.c | 10 +++-------
include/linux/spi/spi.h | 2 +-
19 files changed, 37 insertions(+), 226 deletions(-)
diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c
index 0719bd484891..33a768206ab9 100644
--- a/drivers/spi/spi-ath79.c
+++ b/drivers/spi/spi-ath79.c
@@ -78,9 +78,9 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
}
- if (gpio_is_valid(spi->cs_gpio)) {
+ if (spi->cs_gpio) {
/* SPI is normally active-low */
- gpio_set_value_cansleep(spi->cs_gpio, cs_high);
+ gpiod_set_value_cansleep(spi->cs_gpio, cs_high);
} else {
u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select);
@@ -121,18 +121,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
int status;
status = 0;
- if (gpio_is_valid(spi->cs_gpio)) {
- unsigned long flags;
-
- flags = GPIOF_DIR_OUT;
- if (spi->mode & SPI_CS_HIGH)
- flags |= GPIOF_INIT_LOW;
- else
- flags |= GPIOF_INIT_HIGH;
-
- status = gpio_request_one(spi->cs_gpio, flags,
- dev_name(&spi->dev));
- } else {
+ if (!spi->cs_gpio) {
u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select);
if (spi->mode & SPI_CS_HIGH)
@@ -146,12 +135,6 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
return status;
}
-static void ath79_spi_cleanup_cs(struct spi_device *spi)
-{
- if (gpio_is_valid(spi->cs_gpio))
- gpio_free(spi->cs_gpio);
-}
-
static int ath79_spi_setup(struct spi_device *spi)
{
int status = 0;
@@ -163,15 +146,12 @@ static int ath79_spi_setup(struct spi_device *spi)
}
status = spi_bitbang_setup(spi);
- if (status && !spi->controller_state)
- ath79_spi_cleanup_cs(spi);
return status;
}
static void ath79_spi_cleanup(struct spi_device *spi)
{
- ath79_spi_cleanup_cs(spi);
spi_bitbang_cleanup(spi);
}
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index f95da364c283..15f2e02a02d4 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1179,8 +1179,8 @@ static int atmel_spi_setup(struct spi_device *spi)
if (!as->use_cs_gpios)
npcs_pin = spi->chip_select;
- else if (gpio_is_valid(spi->cs_gpio))
- npcs_pin = spi->cs_gpio;
+ else if (spi->cs_gpio)
+ npcs_pin = desc_to_gpio(spi->cs_gpio);
asd = spi->controller_state;
if (!asd) {
diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
index f35cc10772f6..f09dc8eb4fc0 100644
--- a/drivers/spi/spi-bcm2835.c
+++ b/drivers/spi/spi-bcm2835.c
@@ -179,7 +179,7 @@ static int bcm2835_spi_transfer_one_irq(struct spi_master *master,
* with gpio-cs this does not happen, so it is implemented
* only for this case
*/
- if (gpio_is_valid(spi->cs_gpio)) {
+ if (spi->cs_gpio) {
/* enable HW block, but without interrupts enabled
* this would triggern an immediate interrupt
*/
@@ -358,7 +358,7 @@ static bool bcm2835_spi_can_dma(struct spi_master *master,
struct spi_transfer *tfr)
{
/* only run for gpio_cs */
- if (!gpio_is_valid(spi->cs_gpio))
+ if (!spi->cs_gpio)
return false;
/* we start DMA efforts only on bigger transfers */
@@ -564,7 +564,7 @@ static int bcm2835_spi_transfer_one(struct spi_master *master,
* we can not run this in bcm2835_spi_set_cs, as it does
* not get called for cs_gpio cases, so we need to do it here
*/
- if (gpio_is_valid(spi->cs_gpio) || (spi->mode & SPI_NO_CS))
+ if (spi->cs_gpio || (spi->mode & SPI_NO_CS))
cs |= BCM2835_SPI_CS_CS_10 | BCM2835_SPI_CS_CS_01;
/* set transmit buffers and length */
@@ -693,7 +693,7 @@ static int bcm2835_spi_setup(struct spi_device *spi)
*/
if (spi->mode & SPI_NO_CS)
return 0;
- if (gpio_is_valid(spi->cs_gpio))
+ if (spi->cs_gpio)
return 0;
if (spi->chip_select > 1) {
/* error in the case of native CS requested with CS > 1
diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c
index f0b5c7b91f37..bac0ae3aad72 100644
--- a/drivers/spi/spi-cadence.c
+++ b/drivers/spi/spi-cadence.c
@@ -468,7 +468,7 @@ static int cdns_spi_setup(struct spi_device *spi)
struct cdns_spi_device_data *cdns_spi_data = spi_get_ctldata(spi);
/* this is a pin managed by the controller, leave it alone */
- if (spi->cs_gpio == -ENOENT)
+ if (!spi->cs_gpio)
return 0;
/* this seems to be the first time we're here */
@@ -476,33 +476,10 @@ static int cdns_spi_setup(struct spi_device *spi)
cdns_spi_data = kzalloc(sizeof(*cdns_spi_data), GFP_KERNEL);
if (!cdns_spi_data)
return -ENOMEM;
- cdns_spi_data->gpio_requested = false;
+ cdns_spi_data->gpio_requested = true;
spi_set_ctldata(spi, cdns_spi_data);
}
- /* if we haven't done so, grab the gpio */
- if (!cdns_spi_data->gpio_requested && gpio_is_valid(spi->cs_gpio)) {
- ret = gpio_request_one(spi->cs_gpio,
- (spi->mode & SPI_CS_HIGH) ?
- GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
- dev_name(&spi->dev));
- if (ret)
- dev_err(&spi->dev, "can't request chipselect gpio %d\n",
- spi->cs_gpio);
- else
- cdns_spi_data->gpio_requested = true;
- } else {
- if (gpio_is_valid(spi->cs_gpio)) {
- int mode = ((spi->mode & SPI_CS_HIGH) ?
- GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH);
-
- ret = gpio_direction_output(spi->cs_gpio, mode);
- if (ret)
- dev_err(&spi->dev, "chipselect gpio %d setup failed (%d)\n",
- spi->cs_gpio, ret);
- }
- }
-
return ret;
}
@@ -511,8 +488,6 @@ static void cdns_spi_cleanup(struct spi_device *spi)
struct cdns_spi_device_data *cdns_spi_data = spi_get_ctldata(spi);
if (cdns_spi_data) {
- if (cdns_spi_data->gpio_requested)
- gpio_free(spi->cs_gpio);
kfree(cdns_spi_data);
spi_set_ctldata(spi, NULL);
}
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c
index 18193df2eba8..6ed4f24c8d89 100644
--- a/drivers/spi/spi-clps711x.c
+++ b/drivers/spi/spi-clps711x.c
@@ -38,19 +38,8 @@ struct spi_clps711x_data {
static int spi_clps711x_setup(struct spi_device *spi)
{
- if (!spi->controller_state) {
- int ret;
-
- ret = devm_gpio_request(&spi->master->dev, spi->cs_gpio,
- dev_name(&spi->master->dev));
- if (ret)
- return ret;
-
+ if (!spi->controller_state)
spi->controller_state = spi;
- }
-
- /* We are expect that SPI-device is not selected */
- gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
return 0;
}
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 6ddb6ef1fda4..26c6037d00b2 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -224,11 +224,11 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
* Board specific chip select logic decides the polarity and cs
* line for the controller
*/
- if (spi->cs_gpio >= 0) {
+ if (spi->cs_gpio) {
if (value == BITBANG_CS_ACTIVE)
- gpio_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH);
+ gpiod_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH);
else
- gpio_set_value(spi->cs_gpio,
+ gpiod_set_value(spi->cs_gpio,
!(spi->mode & SPI_CS_HIGH));
} else {
if (value == BITBANG_CS_ACTIVE) {
@@ -430,9 +430,7 @@ static int davinci_spi_setup(struct spi_device *spi)
pdata = &dspi->pdata;
if (!(spi->mode & SPI_NO_CS)) {
- if (np && (master->cs_gpios != NULL) && (spi->cs_gpio >= 0)) {
- retval = gpio_direction_output(
- spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
+ if (np && (master->cs_gpios != NULL) && (spi->cs_gpio)) {
internal_cs = false;
} else if (pdata->chip_sel &&
spi->chip_select < pdata->num_chipselect &&
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index b217c22ff72f..2ddf8d4f8ca8 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -429,13 +429,6 @@ static int dw_spi_setup(struct spi_device *spi)
chip->tmode = SPI_TMOD_TR;
- if (gpio_is_valid(spi->cs_gpio)) {
- ret = gpio_direction_output(spi->cs_gpio,
- !(spi->mode & SPI_CS_HIGH));
- if (ret)
- return ret;
- }
-
return 0;
}
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 8f2e97857e8b..08fc26e9d30f 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -461,26 +461,10 @@ static int fsl_spi_setup(struct spi_device *spi)
}
if (mpc8xxx_spi->type == TYPE_GRLIB) {
- if (gpio_is_valid(spi->cs_gpio)) {
- int desel;
-
- retval = gpio_request(spi->cs_gpio,
- dev_name(&spi->dev));
- if (retval)
- return retval;
-
- desel = !(spi->mode & SPI_CS_HIGH);
- retval = gpio_direction_output(spi->cs_gpio, desel);
- if (retval) {
- gpio_free(spi->cs_gpio);
- return retval;
- }
- } else if (spi->cs_gpio != -ENOENT) {
- if (spi->cs_gpio < 0)
- return spi->cs_gpio;
+ if (!spi->cs_gpio)
return -EINVAL;
- }
- /* When spi->cs_gpio == -ENOENT, a hole in the phandle list
+
+ /* When spi->cs_gpio == NULL, a hole in the phandle list
* indicates to use native chipselect if present, or allow for
* an always selected chip
*/
@@ -497,9 +481,6 @@ static void fsl_spi_cleanup(struct spi_device *spi)
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
- if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio))
- gpio_free(spi->cs_gpio);
-
kfree(cs);
spi_set_ctldata(spi, NULL);
}
@@ -565,8 +546,8 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on)
u32 slvsel;
u16 cs = spi->chip_select;
- if (gpio_is_valid(spi->cs_gpio)) {
- gpio_set_value(spi->cs_gpio, on);
+ if (spi->cs_gpio) {
+ gpiod_set_value(spi->cs_gpio, on);
} else if (cs < mpc8xxx_spi->native_chipselects) {
slvsel = mpc8xxx_spi_read_reg(®_base->slvsel);
slvsel = on ? (slvsel | (1 << cs)) : (slvsel & ~(1 << cs));
diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
index 7a37090dabbe..4148993b3280 100644
--- a/drivers/spi/spi-img-spfi.c
+++ b/drivers/spi/spi-img-spfi.c
@@ -451,30 +451,9 @@ static int img_spfi_setup(struct spi_device *spi)
spfi_data = kzalloc(sizeof(*spfi_data), GFP_KERNEL);
if (!spfi_data)
return -ENOMEM;
- spfi_data->gpio_requested = false;
spi_set_ctldata(spi, spfi_data);
}
- if (!spfi_data->gpio_requested) {
- ret = gpio_request_one(spi->cs_gpio,
- (spi->mode & SPI_CS_HIGH) ?
- GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
- dev_name(&spi->dev));
- if (ret)
- dev_err(&spi->dev, "can't request chipselect gpio %d\n",
- spi->cs_gpio);
- else
- spfi_data->gpio_requested = true;
- } else {
- if (gpio_is_valid(spi->cs_gpio)) {
- int mode = ((spi->mode & SPI_CS_HIGH) ?
- GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH);
-
- ret = gpio_direction_output(spi->cs_gpio, mode);
- if (ret)
- dev_err(&spi->dev, "chipselect gpio %d setup failed (%d)\n",
- spi->cs_gpio, ret);
- }
- }
+
return ret;
}
@@ -483,8 +462,6 @@ static void img_spfi_cleanup(struct spi_device *spi)
struct img_spfi_device_data *spfi_data = spi_get_ctldata(spi);
if (spfi_data) {
- if (spfi_data->gpio_requested)
- gpio_free(spi->cs_gpio);
kfree(spfi_data);
spi_set_ctldata(spi, NULL);
}
diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c
index d5976615d924..06cf27a23127 100644
--- a/drivers/spi/spi-lantiq-ssc.c
+++ b/drivers/spi/spi-lantiq-ssc.c
@@ -394,7 +394,7 @@ static int lantiq_ssc_setup(struct spi_device *spidev)
u32 gpocon;
/* GPIOs are used for CS */
- if (gpio_is_valid(spidev->cs_gpio))
+ if (spidev->cs_gpio)
return 0;
dev_dbg(spi->dev, "using internal chipselect %u\n", cs);
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index c3ec46cd9f91..c114c5f54d42 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -132,7 +132,7 @@ static void mpc512x_psc_spi_activate_cs(struct spi_device *spi)
out_be32(psc_addr(mps, ccr), ccr);
mps->bits_per_word = cs->bits_per_word;
- if (mps->cs_control && gpio_is_valid(spi->cs_gpio))
+ if (mps->cs_control && spi->cs_gpio)
mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0);
}
@@ -140,7 +140,7 @@ static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi)
{
struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master);
- if (mps->cs_control && gpio_is_valid(spi->cs_gpio))
+ if (mps->cs_control && spi->cs_gpio)
mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1);
}
@@ -378,18 +378,6 @@ static int mpc512x_psc_spi_setup(struct spi_device *spi)
if (!cs)
return -ENOMEM;
- if (gpio_is_valid(spi->cs_gpio)) {
- ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
- if (ret) {
- dev_err(&spi->dev, "can't get CS gpio: %d\n",
- ret);
- kfree(cs);
- return ret;
- }
- gpio_direction_output(spi->cs_gpio,
- spi->mode & SPI_CS_HIGH ? 0 : 1);
- }
-
spi->controller_state = cs;
}
@@ -401,8 +389,6 @@ static int mpc512x_psc_spi_setup(struct spi_device *spi)
static void mpc512x_psc_spi_cleanup(struct spi_device *spi)
{
- if (gpio_is_valid(spi->cs_gpio))
- gpio_free(spi->cs_gpio);
kfree(spi->controller_state);
}
@@ -483,7 +469,7 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id)
static void mpc512x_spi_cs_control(struct spi_device *spi, bool onoff)
{
- gpio_set_value(spi->cs_gpio, onoff);
+ gpiod_set_value(spi->cs_gpio, onoff);
}
static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 91a498e25cbb..a0d34b5def2d 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -474,9 +474,6 @@ static int mtk_spi_setup(struct spi_device *spi)
if (!spi->controller_data)
spi->controller_data = (void *)&mtk_default_chip_info;
- if (mdata->dev_comp->need_pad_sel && gpio_is_valid(spi->cs_gpio))
- gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
-
return 0;
}
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index e048268d8ba2..f80b0d70209c 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1045,16 +1045,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
spi->controller_state = cs;
/* Link this to context save list */
list_add_tail(&cs->node, &ctx->cs);
-
- if (gpio_is_valid(spi->cs_gpio)) {
- ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
- if (ret) {
- dev_err(&spi->dev, "failed to request gpio\n");
- return ret;
- }
- gpio_direction_output(spi->cs_gpio,
- !(spi->mode & SPI_CS_HIGH));
- }
}
if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) {
@@ -1103,9 +1093,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
mcspi_dma->dma_tx = NULL;
}
}
-
- if (gpio_is_valid(spi->cs_gpio))
- gpio_free(spi->cs_gpio);
}
static int omap2_mcspi_transfer_one(struct spi_master *master,
@@ -1145,7 +1132,7 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
omap2_mcspi_set_enable(spi, 0);
- if (gpio_is_valid(spi->cs_gpio))
+ if (spi->cs_gpio)
omap2_mcspi_set_cs(spi, spi->mode & SPI_CS_HIGH);
if (par_override ||
@@ -1234,7 +1221,7 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
omap2_mcspi_set_enable(spi, 0);
- if (gpio_is_valid(spi->cs_gpio))
+ if (spi->cs_gpio)
omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH));
if (mcspi->fifo_depth > 0 && t)
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index 4b6dd73b80da..020d3ec21450 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -323,7 +323,7 @@ static void orion_spi_set_cs(struct spi_device *spi, bool enable)
struct orion_spi *orion_spi;
int cs;
- if (gpio_is_valid(spi->cs_gpio))
+ if (spi->cs_gpio)
cs = 0;
else
cs = spi->chip_select;
diff --git a/drivers/spi/spi-pic32.c b/drivers/spi/spi-pic32.c
index f8a45af1fa9f..01bb9e7920e4 100644
--- a/drivers/spi/spi-pic32.c
+++ b/drivers/spi/spi-pic32.c
@@ -600,20 +600,12 @@ static int pic32_spi_setup(struct spi_device *spi)
* unreliable/erroneous SPI transactions.
* To avoid that we will always handle /CS by toggling GPIO.
*/
- if (!gpio_is_valid(spi->cs_gpio))
+ if (!spi->cs_gpio)
return -EINVAL;
- gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
-
return 0;
}
-static void pic32_spi_cleanup(struct spi_device *spi)
-{
- /* de-activate cs-gpio */
- gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
-}
-
static void pic32_spi_dma_prep(struct pic32_spi *pic32s, struct device *dev)
{
struct spi_master *master = pic32s->master;
@@ -779,7 +771,6 @@ static int pic32_spi_probe(struct platform_device *pdev)
master->num_chipselect = 1; /* single chip-select */
master->max_speed_hz = clk_get_rate(pic32s->clk);
master->setup = pic32_spi_setup;
- master->cleanup = pic32_spi_cleanup;
master->flags = SPI_MASTER_MUST_TX | SPI_MASTER_MUST_RX;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16) |
SPI_BPW_MASK(32);
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index b392cca8fa4f..1bc48a1338fc 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -761,7 +761,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
spi->controller_data = cs;
} else if (cs) {
/* On non-DT platforms the SPI core will set spi->cs_gpio
- * to -ENOENT. The GPIO pin used to drive the chip select
+ * to NULL. The GPIO pin used to drive the chip select
* is defined by using platform data so spi->cs_gpio value
* has to be override to have the proper GPIO pin number.
*/
@@ -773,20 +773,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
return -ENODEV;
}
- if (!spi_get_ctldata(spi)) {
- if (gpio_is_valid(spi->cs_gpio)) {
- err = gpio_request_one(spi->cs_gpio, GPIOF_OUT_INIT_HIGH,
- dev_name(&spi->dev));
- if (err) {
- dev_err(&spi->dev,
- "Failed to get /CS gpio [%d]: %d\n",
- spi->cs_gpio, err);
- goto err_gpio_req;
- }
- }
-
+ if (!spi_get_ctldata(spi))
spi_set_ctldata(spi, cs);
- }
sci = sdd->cntrlr_info;
diff --git a/drivers/spi/spi-st-ssc4.c b/drivers/spi/spi-st-ssc4.c
index a4e43fc19ece..72d9b24ccf04 100644
--- a/drivers/spi/spi-st-ssc4.c
+++ b/drivers/spi/spi-st-ssc4.c
@@ -173,11 +173,6 @@ static int spi_st_transfer_one(struct spi_master *master,
return t->len;
}
-static void spi_st_cleanup(struct spi_device *spi)
-{
- gpio_free(spi->cs_gpio);
-}
-
/* the spi->mode bits understood by this driver: */
#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | SPI_LOOP | SPI_CS_HIGH)
static int spi_st_setup(struct spi_device *spi)
@@ -185,7 +180,6 @@ static int spi_st_setup(struct spi_device *spi)
struct spi_st *spi_st = spi_master_get_devdata(spi->master);
u32 spi_st_clk, sscbrg, var;
u32 hz = spi->max_speed_hz;
- int cs = spi->cs_gpio;
int ret;
if (!hz) {
@@ -193,21 +187,6 @@ static int spi_st_setup(struct spi_device *spi)
return -EINVAL;
}
- if (!gpio_is_valid(cs)) {
- dev_err(&spi->dev, "%d is not a valid gpio\n", cs);
- return -EINVAL;
- }
-
- ret = gpio_request(cs, dev_name(&spi->dev));
- if (ret) {
- dev_err(&spi->dev, "could not request gpio:%d\n", cs);
- return ret;
- }
-
- ret = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
- if (ret)
- goto out_free_gpio;
-
spi_st_clk = clk_get_rate(spi_st->clk);
/* Set SSC_BRF */
@@ -215,8 +194,7 @@ static int spi_st_setup(struct spi_device *spi)
if (sscbrg < 0x07 || sscbrg > BIT(16)) {
dev_err(&spi->dev,
"baudrate %d outside valid range %d\n", sscbrg, hz);
- ret = -EINVAL;
- goto out_free_gpio;
+ return -EINVAL;
}
spi_st->baud = spi_st_clk / (2 * sscbrg);
@@ -265,10 +243,6 @@ static int spi_st_setup(struct spi_device *spi)
readl_relaxed(spi_st->base + SSC_RBUF);
return 0;
-
-out_free_gpio:
- gpio_free(cs);
- return ret;
}
/* Interrupt fired when TX shift register becomes empty */
@@ -312,7 +286,6 @@ static int spi_st_probe(struct platform_device *pdev)
master->dev.of_node = np;
master->mode_bits = MODEBITS;
master->setup = spi_st_setup;
- master->cleanup = spi_st_cleanup;
master->transfer_one = spi_st_transfer_one;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->auto_runtime_pm = true;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 3860f0c84e1a..cfd1b251354e 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -459,7 +459,6 @@ struct spi_device *spi_alloc_device(struct spi_controller *ctlr)
spi->dev.parent = &ctlr->dev;
spi->dev.bus = &spi_bus_type;
spi->dev.release = spidev_release;
- spi->cs_gpio = -ENOENT;
spin_lock_init(&spi->statistics.lock);
@@ -532,7 +531,7 @@ int spi_add_device(struct spi_device *spi)
}
if (ctlr->cs_gpios)
- spi->cs_gpio = desc_to_gpio(ctlr->cs_gpios[spi->chip_select]);
+ spi->cs_gpio = ctlr->cs_gpios[spi->chip_select];
else
spi->cs_gpio = -ENOENT;
@@ -727,11 +726,8 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
if (spi->mode & SPI_CS_HIGH)
enable = !enable;
- if (gpio_is_valid(spi->cs_gpio)) {
- struct gpio_desc *gpio = gpio_to_desc(spi->cs_gpio);
-
- if (gpio)
- gpiod_set_value(gpio, !enable);
+ if (spi->cs_gpio) {
+ gpiod_set_value(spi->cs_gpio, !enable);
/* Some SPI masters need both GPIO CS & slave_select */
if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
spi->controller->set_cs)
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 7e170db7bc9d..e97a14637988 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -167,7 +167,7 @@ struct spi_device {
void *controller_state;
void *controller_data;
char modalias[SPI_NAME_SIZE];
- int cs_gpio; /* chip select gpio */
+ struct gpio_desc *cs_gpio; /* chip select gpio */
/* the statistics */
struct spi_statistics statistics;
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [RFC PATCH v2 00/12] spi: moving to struct gpio_desc
[not found] ` <20170727220322.26654-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>
` (11 preceding siblings ...)
2017-07-27 22:03 ` [RFC PATCH v2 12/12] wip: convert struct spi_device to gpio_desc Chris Packham
@ 2017-07-29 13:15 ` Andy Shevchenko
[not found] ` <CAHp75VeVijF13AO=SqkxtAaiYhss92gwrtCZ2WnxkkKtvjVS3A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
12 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2017-07-29 13:15 UTC (permalink / raw)
To: Chris Packham; +Cc: linux-spi
On Fri, Jul 28, 2017 at 1:03 AM, Chris Packham
<chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> wrote:
> Hi Andy,
>
> As requested here's my WIP series. I've included the ep93xx changes from H
> Hartley Sweeten. I had these locally to use as a base, I was kind of
> surprised they hadn't made it into linux-next.
>
> I tried to account for the master -> ctlr rename as I was rebasing but I
> wouldn't be surprised if I missed some occurrences. This is very much an
> untested WIP it will probably crash and burn in unexpected ways.
>
I briefly looked at the code, first 6 patches for my taste could be
submitted w/o RFC tag.
One comment to them though, better to use u32 instead of unsigned int
when operate with 32-bit registers.
> Chris Packham (6):
> spi: use gpio_desc instead of numeric gpio
> ARM: ep93xx: add gpiod_lookup_table for spi chip-selects
> ARM: imx: add gpiod_lookup_table for spi chip-selects
> spi: core: convert spi_master to use gpio_desc
> ARM: ep93xx: remove chipselect from ep93xx_spi_info
> wip: convert struct spi_device to gpio_desc
>
> H Hartley Sweeten (6):
> spi: spi-ep93xx: use 32-bit read/write for all registers
> spi: spi-ep93xx: add spi master prepare_transfer_hardware()
> spi: spi-ep93xx: absorb the interrupt enable/disable helpers
> spi: spi-ep93xx: pass the spi_master pointer around
> spi: spi-ep93xx: remove private data 'current_msg'
> spi: spi-ep93xx: use the default master transfer queueing mechanism
>
> arch/arm/mach-ep93xx/edb93xx.c | 15 +-
> arch/arm/mach-ep93xx/simone.c | 14 +-
> arch/arm/mach-ep93xx/vision_ep9307.c | 20 +-
> arch/arm/mach-imx/mach-mx27_3ds.c | 21 ++
> arch/arm/mach-imx/mach-pca100.c | 13 +
> drivers/spi/spi-ath79.c | 26 +-
> drivers/spi/spi-atmel.c | 4 +-
> drivers/spi/spi-bcm2835.c | 8 +-
> drivers/spi/spi-cadence.c | 29 +-
> drivers/spi/spi-clps711x.c | 13 +-
> drivers/spi/spi-davinci.c | 10 +-
> drivers/spi/spi-dw.c | 7 -
> drivers/spi/spi-ep93xx.c | 487 ++++++++++++-------------------
> drivers/spi/spi-fsl-spi.c | 29 +-
> drivers/spi/spi-img-spfi.c | 25 +-
> drivers/spi/spi-imx.c | 25 +-
> drivers/spi/spi-lantiq-ssc.c | 2 +-
> drivers/spi/spi-mpc512x-psc.c | 20 +-
> drivers/spi/spi-mt65xx.c | 16 -
> drivers/spi/spi-omap2-mcspi.c | 17 +-
> drivers/spi/spi-orion.c | 2 +-
> drivers/spi/spi-pic32.c | 11 +-
> drivers/spi/spi-s3c64xx.c | 16 +-
> drivers/spi/spi-st-ssc4.c | 29 +-
> drivers/spi/spi.c | 26 +-
> include/linux/platform_data/spi-ep93xx.h | 4 +-
> include/linux/spi/spi.h | 4 +-
> 27 files changed, 312 insertions(+), 581 deletions(-)
>
> --
> 2.13.0
>
--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread