* [PATCH 1/4] spi: qup: Remove chip select function
2014-05-13 21:34 [PATCH 0/4] spi: qup: Fixes and new version support Andy Gross
@ 2014-05-13 21:34 ` Andy Gross
2014-05-19 8:07 ` Ivan T. Ivanov
2014-05-13 21:34 ` [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode Andy Gross
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Andy Gross @ 2014-05-13 21:34 UTC (permalink / raw)
To: linux-arm-kernel
This patch removes the chip select function. Chip select should instead be
supported using GPIOs, defining the DT entry "cs-gpios", and letting the SPI
core assert/deassert the chip select as it sees fit.
Signed-off-by: Andy Gross <agross@codeaurora.org>
---
.../devicetree/bindings/spi/qcom,spi-qup.txt | 6 +++++
drivers/spi/spi-qup.c | 28 ++------------------
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt b/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
index b82a268..bee6ff2 100644
--- a/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
+++ b/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
@@ -23,6 +23,12 @@ Optional properties:
- spi-max-frequency: Specifies maximum SPI clock frequency,
Units - Hz. Definition as per
Documentation/devicetree/bindings/spi/spi-bus.txt
+- num-cs: total number of chipselects
+- cs-gpios: should specify GPIOs used for chipselects.
+ The gpios will be referred to as reg = <index> in the SPI child
+ nodes. If unspecified, a single SPI device without a chip
+ select can be used.
+
SPI slave nodes must be children of the SPI master node and can contain
properties described in Documentation/devicetree/bindings/spi/spi-bus.txt
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index b032e88..ea7017b 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -18,7 +18,9 @@
#include <linux/io.h>
#include <linux/list.h>
#include <linux/module.h>
+#include <linux/gpio.h>
#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/spi/spi.h>
@@ -424,31 +426,6 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
return 0;
}
-static void spi_qup_set_cs(struct spi_device *spi, bool enable)
-{
- struct spi_qup *controller = spi_master_get_devdata(spi->master);
-
- u32 iocontol, mask;
-
- iocontol = readl_relaxed(controller->base + SPI_IO_CONTROL);
-
- /* Disable auto CS toggle and use manual */
- iocontol &= ~SPI_IO_C_MX_CS_MODE;
- iocontol |= SPI_IO_C_FORCE_CS;
-
- iocontol &= ~SPI_IO_C_CS_SELECT_MASK;
- iocontol |= SPI_IO_C_CS_SELECT(spi->chip_select);
-
- mask = SPI_IO_C_CS_N_POLARITY_0 << spi->chip_select;
-
- if (enable)
- iocontol |= mask;
- else
- iocontol &= ~mask;
-
- writel_relaxed(iocontol, controller->base + SPI_IO_CONTROL);
-}
-
static int spi_qup_transfer_one(struct spi_master *master,
struct spi_device *spi,
struct spi_transfer *xfer)
@@ -576,7 +553,6 @@ static int spi_qup_probe(struct platform_device *pdev)
master->num_chipselect = SPI_NUM_CHIPSELECTS;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
master->max_speed_hz = max_freq;
- master->set_cs = spi_qup_set_cs;
master->transfer_one = spi_qup_transfer_one;
master->dev.of_node = pdev->dev.of_node;
master->auto_runtime_pm = true;
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 1/4] spi: qup: Remove chip select function
2014-05-13 21:34 ` [PATCH 1/4] spi: qup: Remove chip select function Andy Gross
@ 2014-05-19 8:07 ` Ivan T. Ivanov
2014-06-12 4:02 ` Andy Gross
0 siblings, 1 reply; 13+ messages in thread
From: Ivan T. Ivanov @ 2014-05-19 8:07 UTC (permalink / raw)
To: linux-arm-kernel
Hi Andy,
On Tue, 2014-05-13 at 16:34 -0500, Andy Gross wrote:
> This patch removes the chip select function. Chip select should instead be
> supported using GPIOs, defining the DT entry "cs-gpios", and letting the SPI
> core assert/deassert the chip select as it sees fit.
>
> Signed-off-by: Andy Gross <agross@codeaurora.org>
<snip>
> +- num-cs: total number of chipselects
My understanding is that "num-cs" have to be parsed by
master driver, not by core SPI driver.
> -
> - /* Disable auto CS toggle and use manual */
> - iocontol &= ~SPI_IO_C_MX_CS_MODE;
Probably we should keep this?
Regards,
Ivan
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/4] spi: qup: Remove chip select function
2014-05-19 8:07 ` Ivan T. Ivanov
@ 2014-06-12 4:02 ` Andy Gross
0 siblings, 0 replies; 13+ messages in thread
From: Andy Gross @ 2014-06-12 4:02 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, May 19, 2014 at 11:07:38AM +0300, Ivan T. Ivanov wrote:
<snip>
> > +- num-cs: total number of chipselects
>
> My understanding is that "num-cs" have to be parsed by
> master driver, not by core SPI driver.
Right. I need to parse it and check vs the max cs and use that value to set the
master->num_chipselect
>
> > -
> > - /* Disable auto CS toggle and use manual */
> > - iocontol &= ~SPI_IO_C_MX_CS_MODE;
>
> Probably we should keep this?
Actually this is cleared in the probe during the initial settings of IO_CONTROL.
So this isn't necessary.
--
sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode
2014-05-13 21:34 [PATCH 0/4] spi: qup: Fixes and new version support Andy Gross
2014-05-13 21:34 ` [PATCH 1/4] spi: qup: Remove chip select function Andy Gross
@ 2014-05-13 21:34 ` Andy Gross
2014-05-14 15:17 ` Mark Brown
2014-05-19 7:31 ` Ivan T. Ivanov
2014-05-13 21:34 ` [PATCH 3/4] spi: qup: Fix order of spi_register_master Andy Gross
2014-05-13 21:34 ` [PATCH 4/4] spi: qup: Add support for v1.1.1 Andy Gross
3 siblings, 2 replies; 13+ messages in thread
From: Andy Gross @ 2014-05-13 21:34 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes the calculation for determining whether to use FIFO or BLOCK
mode.
Signed-off-by: Andy Gross <agross@codeaurora.org>
---
drivers/spi/spi-qup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index ea7017b..57b65e9 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -289,7 +289,7 @@ static irqreturn_t spi_qup_qup_irq(int irq, void *dev_id)
writel_relaxed(opflags, controller->base + QUP_OPERATIONAL);
if (!xfer) {
- dev_err_ratelimited(controller->dev, "unexpected irq %x08 %x08 %x08\n",
+ dev_err_ratelimited(controller->dev, "unexpected irq %08x %08x %08x\n",
qup_err, spi_err, opflags);
return IRQ_HANDLED;
}
@@ -368,7 +368,7 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
n_words = xfer->len / w_size;
controller->w_size = w_size;
- if (n_words <= controller->in_fifo_sz) {
+ if (n_words <= (controller->in_fifo_sz / sizeof(u32))) {
mode = QUP_IO_M_MODE_FIFO;
writel_relaxed(n_words, controller->base + QUP_MX_READ_CNT);
writel_relaxed(n_words, controller->base + QUP_MX_WRITE_CNT);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode
2014-05-13 21:34 ` [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode Andy Gross
@ 2014-05-14 15:17 ` Mark Brown
2014-05-19 7:31 ` Ivan T. Ivanov
1 sibling, 0 replies; 13+ messages in thread
From: Mark Brown @ 2014-05-14 15:17 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, May 13, 2014 at 04:34:42PM -0500, Andy Gross wrote:
> This patch fixes the calculation for determining whether to use FIFO or BLOCK
> mode.
Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140514/ea7dfec3/attachment.sig>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode
2014-05-13 21:34 ` [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode Andy Gross
2014-05-14 15:17 ` Mark Brown
@ 2014-05-19 7:31 ` Ivan T. Ivanov
1 sibling, 0 replies; 13+ messages in thread
From: Ivan T. Ivanov @ 2014-05-19 7:31 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, 2014-05-13 at 16:34 -0500, Andy Gross wrote:
> This patch fixes the calculation for determining whether to use FIFO or BLOCK
> mode.
<snip>
> @@ -368,7 +368,7 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
> n_words = xfer->len / w_size;
> controller->w_size = w_size;
>
> - if (n_words <= controller->in_fifo_sz) {
> + if (n_words <= (controller->in_fifo_sz / sizeof(u32))) {
Wouldn't be better to divide by w_size? Probably will not make
too much difference, but..
> mode = QUP_IO_M_MODE_FIFO;
Regards,
Ivan
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/4] spi: qup: Fix order of spi_register_master
2014-05-13 21:34 [PATCH 0/4] spi: qup: Fixes and new version support Andy Gross
2014-05-13 21:34 ` [PATCH 1/4] spi: qup: Remove chip select function Andy Gross
2014-05-13 21:34 ` [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode Andy Gross
@ 2014-05-13 21:34 ` Andy Gross
2014-05-19 8:51 ` Ivan T. Ivanov
2014-05-13 21:34 ` [PATCH 4/4] spi: qup: Add support for v1.1.1 Andy Gross
3 siblings, 1 reply; 13+ messages in thread
From: Andy Gross @ 2014-05-13 21:34 UTC (permalink / raw)
To: linux-arm-kernel
This patch moves the devm_spi_register_master below the initialization of the
runtime_pm. If done in the wrong order, the spi_register_master fails if any
probed slave devices issue SPI transactions.
Signed-off-by: Andy Gross <agross@codeaurora.org>
---
drivers/spi/spi-qup.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index 57b65e9..b518b51 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -616,16 +616,19 @@ static int spi_qup_probe(struct platform_device *pdev)
if (ret)
goto error;
- ret = devm_spi_register_master(dev, master);
- if (ret)
- goto error;
-
pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
pm_runtime_use_autosuspend(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
+
+ ret = devm_spi_register_master(dev, master);
+ if (ret)
+ goto disable_pm;
+
return 0;
+disable_pm:
+ pm_runtime_disable(&pdev->dev);
error:
clk_disable_unprepare(cclk);
clk_disable_unprepare(iclk);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/4] spi: qup: Add support for v1.1.1
2014-05-13 21:34 [PATCH 0/4] spi: qup: Fixes and new version support Andy Gross
` (2 preceding siblings ...)
2014-05-13 21:34 ` [PATCH 3/4] spi: qup: Fix order of spi_register_master Andy Gross
@ 2014-05-13 21:34 ` Andy Gross
2014-05-13 22:08 ` Stephen Boyd
2014-05-19 8:10 ` Ivan T. Ivanov
3 siblings, 2 replies; 13+ messages in thread
From: Andy Gross @ 2014-05-13 21:34 UTC (permalink / raw)
To: linux-arm-kernel
This patch adds support for v1.1.1 of the SPI QUP controller.
Signed-off-by: Andy Gross <agross@codeaurora.org>
---
drivers/spi/spi-qup.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index b518b51..abad630 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -144,6 +144,7 @@ struct spi_qup {
int w_size; /* bytes per SPI word */
int tx_bytes;
int rx_bytes;
+ int qup_v1;
};
@@ -422,7 +423,9 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
config |= QUP_CONFIG_SPI_MODE;
writel_relaxed(config, controller->base + QUP_CONFIG);
- writel_relaxed(0, controller->base + QUP_OPERATIONAL_MASK);
+ /* only write to OPERATIONAL_MASK when register is present */
+ if (!controller->qup_v1)
+ writel_relaxed(0, controller->base + QUP_OPERATIONAL_MASK);
return 0;
}
@@ -488,7 +491,7 @@ static int spi_qup_probe(struct platform_device *pdev)
struct resource *res;
struct device *dev;
void __iomem *base;
- u32 data, max_freq, iomode;
+ u32 data = 0, max_freq, iomode;
int ret, irq, size;
dev = &pdev->dev;
@@ -531,15 +534,6 @@ static int spi_qup_probe(struct platform_device *pdev)
return ret;
}
- data = readl_relaxed(base + QUP_HW_VERSION);
-
- if (data < QUP_HW_VERSION_2_1_1) {
- clk_disable_unprepare(cclk);
- clk_disable_unprepare(iclk);
- dev_err(dev, "v.%08x is not supported\n", data);
- return -ENXIO;
- }
-
master = spi_alloc_master(dev, sizeof(struct spi_qup));
if (!master) {
clk_disable_unprepare(cclk);
@@ -567,6 +561,10 @@ static int spi_qup_probe(struct platform_device *pdev)
controller->cclk = cclk;
controller->irq = irq;
+ /* set v1 flag if device is version 1 */
+ if (of_device_is_compatible(dev->of_node, "qcom,spi-qup-v1.1.1"))
+ controller->qup_v1 = 1;
+
spin_lock_init(&controller->lock);
init_completion(&controller->done);
@@ -604,10 +602,19 @@ static int spi_qup_probe(struct platform_device *pdev)
writel_relaxed(0, base + QUP_OPERATIONAL);
writel_relaxed(0, base + QUP_IO_M_MODES);
- writel_relaxed(0, base + QUP_OPERATIONAL_MASK);
+
+ if (!controller->qup_v1)
+ writel_relaxed(0, base + QUP_OPERATIONAL_MASK);
+
writel_relaxed(SPI_ERROR_CLK_UNDER_RUN | SPI_ERROR_CLK_OVER_RUN,
base + SPI_ERROR_FLAGS_EN);
+ /* if earlier version of the QUP, disable INPUT_OVERRUN */
+ if (controller->qup_v1)
+ writel_relaxed(QUP_ERROR_OUTPUT_OVER_RUN |
+ QUP_ERROR_INPUT_UNDER_RUN | QUP_ERROR_OUTPUT_UNDER_RUN,
+ base + QUP_ERROR_FLAGS_EN);
+
writel_relaxed(0, base + SPI_CONFIG);
writel_relaxed(SPI_IO_C_NO_TRI_STATE, base + SPI_IO_CONTROL);
@@ -729,6 +736,7 @@ static int spi_qup_remove(struct platform_device *pdev)
}
static struct of_device_id spi_qup_dt_match[] = {
+ { .compatible = "qcom,spi-qup-v1.1.1", },
{ .compatible = "qcom,spi-qup-v2.1.1", },
{ .compatible = "qcom,spi-qup-v2.2.1", },
{ }
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/4] spi: qup: Add support for v1.1.1
2014-05-13 21:34 ` [PATCH 4/4] spi: qup: Add support for v1.1.1 Andy Gross
@ 2014-05-13 22:08 ` Stephen Boyd
2014-05-13 22:20 ` Andy Gross
2014-05-19 8:10 ` Ivan T. Ivanov
1 sibling, 1 reply; 13+ messages in thread
From: Stephen Boyd @ 2014-05-13 22:08 UTC (permalink / raw)
To: linux-arm-kernel
On 05/13, Andy Gross wrote:
> @@ -488,7 +491,7 @@ static int spi_qup_probe(struct platform_device *pdev)
> struct resource *res;
> struct device *dev;
> void __iomem *base;
> - u32 data, max_freq, iomode;
> + u32 data = 0, max_freq, iomode;
It looks like data is unused? But actually it's used to print a
version out and now it will always print version 0. Perhaps that
printk needs an update?
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/4] spi: qup: Add support for v1.1.1
2014-05-13 22:08 ` Stephen Boyd
@ 2014-05-13 22:20 ` Andy Gross
0 siblings, 0 replies; 13+ messages in thread
From: Andy Gross @ 2014-05-13 22:20 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, May 13, 2014 at 03:08:45PM -0700, Stephen Boyd wrote:
> On 05/13, Andy Gross wrote:
> > @@ -488,7 +491,7 @@ static int spi_qup_probe(struct platform_device *pdev)
> > struct resource *res;
> > struct device *dev;
> > void __iomem *base;
> > - u32 data, max_freq, iomode;
> > + u32 data = 0, max_freq, iomode;
>
> It looks like data is unused? But actually it's used to print a
> version out and now it will always print version 0. Perhaps that
> printk needs an update?
ACK! I thought I killed that. I'll fix that.
--
sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/4] spi: qup: Add support for v1.1.1
2014-05-13 21:34 ` [PATCH 4/4] spi: qup: Add support for v1.1.1 Andy Gross
2014-05-13 22:08 ` Stephen Boyd
@ 2014-05-19 8:10 ` Ivan T. Ivanov
1 sibling, 0 replies; 13+ messages in thread
From: Ivan T. Ivanov @ 2014-05-19 8:10 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, 2014-05-13 at 16:34 -0500, Andy Gross wrote:
> This patch adds support for v1.1.1 of the SPI QUP controller.
>
> Signed-off-by: Andy Gross <agross@codeaurora.org>
Except Stephen comment this looks fine. Thank you.
Acked-by: Ivan T. Ivanov <iivanov@mm-sol.com>
^ permalink raw reply [flat|nested] 13+ messages in thread