1 From 8b9de04ef3aaa154f30baf1ac703a2d3b474ad4e Mon Sep 17 00:00:00 2001
2 From: Andy Gross <agross@codeaurora.org>
3 Date: Thu, 12 Jun 2014 14:34:12 -0500
4 Subject: [PATCH 135/182] spi: qup: Add support for v1.1.1
6 This patch adds support for v1.1.1 of the SPI QUP controller.
8 Signed-off-by: Andy Gross <agross@codeaurora.org>
10 .../devicetree/bindings/spi/qcom,spi-qup.txt | 6 +++-
11 drivers/spi/spi-qup.c | 36 ++++++++++++--------
12 2 files changed, 27 insertions(+), 15 deletions(-)
14 diff --git a/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt b/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
15 index bee6ff2..e2c88df 100644
16 --- a/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
17 +++ b/Documentation/devicetree/bindings/spi/qcom,spi-qup.txt
18 @@ -7,7 +7,11 @@ SPI in master mode supports up to 50MHz, up to four chip selects, programmable
19 data path from 4 bits to 32 bits and numerous protocol variants.
22 -- compatible: Should contain "qcom,spi-qup-v2.1.1" or "qcom,spi-qup-v2.2.1"
23 +- compatible: Should contain:
24 + "qcom,spi-qup-v1.1.1" for 8660, 8960 and 8064.
25 + "qcom,spi-qup-v2.1.1" for 8974 and later
26 + "qcom,spi-qup-v2.2.1" for 8974 v2 and later.
28 - reg: Should contain base register location and length
29 - interrupts: Interrupt number used by this controller
31 diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
32 index a404298..c137226 100644
33 --- a/drivers/spi/spi-qup.c
34 +++ b/drivers/spi/spi-qup.c
35 @@ -142,6 +142,7 @@ struct spi_qup {
36 int w_size; /* bytes per SPI word */
43 @@ -420,7 +421,9 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
44 config |= QUP_CONFIG_SPI_MODE;
45 writel_relaxed(config, controller->base + QUP_CONFIG);
47 - writel_relaxed(0, controller->base + QUP_OPERATIONAL_MASK);
48 + /* only write to OPERATIONAL_MASK when register is present */
49 + if (!controller->qup_v1)
50 + writel_relaxed(0, controller->base + QUP_OPERATIONAL_MASK);
54 @@ -486,7 +489,7 @@ static int spi_qup_probe(struct platform_device *pdev)
58 - u32 data, max_freq, iomode;
59 + u32 max_freq, iomode;
63 @@ -529,15 +532,6 @@ static int spi_qup_probe(struct platform_device *pdev)
67 - data = readl_relaxed(base + QUP_HW_VERSION);
69 - if (data < QUP_HW_VERSION_2_1_1) {
70 - clk_disable_unprepare(cclk);
71 - clk_disable_unprepare(iclk);
72 - dev_err(dev, "v.%08x is not supported\n", data);
76 master = spi_alloc_master(dev, sizeof(struct spi_qup));
78 clk_disable_unprepare(cclk);
79 @@ -570,6 +564,10 @@ static int spi_qup_probe(struct platform_device *pdev)
80 controller->cclk = cclk;
81 controller->irq = irq;
83 + /* set v1 flag if device is version 1 */
84 + if (of_device_is_compatible(dev->of_node, "qcom,spi-qup-v1.1.1"))
85 + controller->qup_v1 = 1;
87 spin_lock_init(&controller->lock);
88 init_completion(&controller->done);
90 @@ -593,8 +591,8 @@ static int spi_qup_probe(struct platform_device *pdev)
91 size = QUP_IO_M_INPUT_FIFO_SIZE(iomode);
92 controller->in_fifo_sz = controller->in_blk_sz * (2 << size);
94 - dev_info(dev, "v.%08x IN:block:%d, fifo:%d, OUT:block:%d, fifo:%d\n",
95 - data, controller->in_blk_sz, controller->in_fifo_sz,
96 + dev_info(dev, "IN:block:%d, fifo:%d, OUT:block:%d, fifo:%d\n",
97 + controller->in_blk_sz, controller->in_fifo_sz,
98 controller->out_blk_sz, controller->out_fifo_sz);
100 writel_relaxed(1, base + QUP_SW_RESET);
101 @@ -607,10 +605,19 @@ static int spi_qup_probe(struct platform_device *pdev)
103 writel_relaxed(0, base + QUP_OPERATIONAL);
104 writel_relaxed(0, base + QUP_IO_M_MODES);
105 - writel_relaxed(0, base + QUP_OPERATIONAL_MASK);
107 + if (!controller->qup_v1)
108 + writel_relaxed(0, base + QUP_OPERATIONAL_MASK);
110 writel_relaxed(SPI_ERROR_CLK_UNDER_RUN | SPI_ERROR_CLK_OVER_RUN,
111 base + SPI_ERROR_FLAGS_EN);
113 + /* if earlier version of the QUP, disable INPUT_OVERRUN */
114 + if (controller->qup_v1)
115 + writel_relaxed(QUP_ERROR_OUTPUT_OVER_RUN |
116 + QUP_ERROR_INPUT_UNDER_RUN | QUP_ERROR_OUTPUT_UNDER_RUN,
117 + base + QUP_ERROR_FLAGS_EN);
119 writel_relaxed(0, base + SPI_CONFIG);
120 writel_relaxed(SPI_IO_C_NO_TRI_STATE, base + SPI_IO_CONTROL);
122 @@ -732,6 +739,7 @@ static int spi_qup_remove(struct platform_device *pdev)
125 static struct of_device_id spi_qup_dt_match[] = {
126 + { .compatible = "qcom,spi-qup-v1.1.1", },
127 { .compatible = "qcom,spi-qup-v2.1.1", },
128 { .compatible = "qcom,spi-qup-v2.2.1", },