]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Merge remote-tracking branches 'spi/topic/loopback', 'spi/topic/omap2-mcspi', 'spi...
authorMark Brown <broonie@kernel.org>
Wed, 26 Apr 2017 14:58:10 +0000 (15:58 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 26 Apr 2017 14:58:10 +0000 (15:58 +0100)
Documentation/devicetree/bindings/spi/spi_pl022.txt
drivers/spi/spi-loopback-test.c
drivers/spi/spi-omap2-mcspi.c
drivers/spi/spi-orion.c
drivers/spi/spi-sc18is602.c

index 4d1673ca8cf802d4b9e13fb53538baa3d5372a48..7638b4968ddb4ad8adabbf36ab540751b6eec343 100644 (file)
@@ -30,7 +30,10 @@ contain the following properties.
        0: SPI
        1: Texas Instruments Synchronous Serial Frame Format
        2: Microwire (Half Duplex)
-- pl022,com-mode : polling, interrupt or dma
+- pl022,com-mode : specifies the transfer mode:
+       0: interrupt mode
+       1: polling mode (default mode if property not present)
+       2: DMA mode
 - pl022,rx-level-trig : Rx FIFO watermark level
 - pl022,tx-level-trig : Tx FIFO watermark level
 - pl022,ctrl-len : Microwire interface: Control length
@@ -56,9 +59,7 @@ Example:
                        spi-max-frequency = <12000000>;
                        spi-cpol;
                        spi-cpha;
-                       pl022,hierarchy = <0>;
                        pl022,interface = <0>;
-                       pl022,slave-tx-disable;
                        pl022,com-mode = <0x2>;
                        pl022,rx-level-trig = <0>;
                        pl022,tx-level-trig = <0>;
@@ -67,4 +68,3 @@ Example:
                        pl022,duplex = <0>;
                };
        };
-       
index 50e620f4e8fe2ae29c655358e38d771c464ec01d..4e7843ec8aac8af5f486199f18b0c0e7a18b3809 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/printk.h>
+#include <linux/vmalloc.h>
 #include <linux/spi/spi.h>
 
 #include "spi-test.h"
@@ -55,6 +56,18 @@ module_param(run_only_test, int, 0);
 MODULE_PARM_DESC(run_only_test,
                 "only run the test with this number (0-based !)");
 
+/* use vmalloc'ed buffers */
+int use_vmalloc;
+module_param(use_vmalloc, int, 0644);
+MODULE_PARM_DESC(use_vmalloc,
+                "use vmalloc'ed buffers instead of kmalloc'ed");
+
+/* check rx ranges */
+int check_ranges = 1;
+module_param(check_ranges, int, 0644);
+MODULE_PARM_DESC(check_ranges,
+                "checks rx_buffer pattern are valid");
+
 /* the actual tests to execute */
 static struct spi_test spi_tests[] = {
        {
@@ -492,9 +505,11 @@ static int spi_test_check_loopback_result(struct spi_device *spi,
        int ret;
 
        /* checks rx_buffer pattern are valid with loopback or without */
-       ret = spi_check_rx_ranges(spi, msg, rx);
-       if (ret)
-               return ret;
+       if (check_ranges) {
+               ret = spi_check_rx_ranges(spi, msg, rx);
+               if (ret)
+                       return ret;
+       }
 
        /* if we run without loopback, then return now */
        if (!loopback)
@@ -965,13 +980,19 @@ int spi_test_run_tests(struct spi_device *spi,
        /* allocate rx/tx buffers of 128kB size without devm
         * in the hope that is on a page boundary
         */
-       rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
+       if (use_vmalloc)
+               rx = vmalloc(SPI_TEST_MAX_SIZE_PLUS);
+       else
+               rx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
        if (!rx) {
                ret = -ENOMEM;
                goto out;
        }
 
-       tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
+       if (use_vmalloc)
+               tx = vmalloc(SPI_TEST_MAX_SIZE_PLUS);
+       else
+               tx = kzalloc(SPI_TEST_MAX_SIZE_PLUS, GFP_KERNEL);
        if (!tx) {
                ret = -ENOMEM;
                goto out;
@@ -999,8 +1020,8 @@ int spi_test_run_tests(struct spi_device *spi,
        }
 
 out:
-       kfree(rx);
-       kfree(tx);
+       kvfree(rx);
+       kvfree(tx);
        return ret;
 }
 EXPORT_SYMBOL_GPL(spi_test_run_tests);
index 79800e991ccd537180866aa4671ab165a4f896f8..7275223dbcd454d879bbb7a61e2ee50479212da8 100644 (file)
@@ -454,6 +454,8 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
        int                     elements = 0;
        int                     word_len, element_count;
        struct omap2_mcspi_cs   *cs = spi->controller_state;
+       void __iomem            *chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0;
+
        mcspi = spi_master_get_devdata(spi->master);
        mcspi_dma = &mcspi->dma_channels[spi->chip_select];
        count = xfer->len;
@@ -549,8 +551,8 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
        if (l & OMAP2_MCSPI_CHCONF_TURBO) {
                elements--;
 
-               if (likely(mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHSTAT0)
-                                  & OMAP2_MCSPI_CHSTAT_RXS)) {
+               if (!mcspi_wait_for_reg_bit(chstat_reg,
+                                           OMAP2_MCSPI_CHSTAT_RXS)) {
                        u32 w;
 
                        w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0);
@@ -568,8 +570,7 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
                        return count;
                }
        }
-       if (likely(mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHSTAT0)
-                               & OMAP2_MCSPI_CHSTAT_RXS)) {
+       if (!mcspi_wait_for_reg_bit(chstat_reg, OMAP2_MCSPI_CHSTAT_RXS)) {
                u32 w;
 
                w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0);
index 6b001c4a564086528e9db608f7250305656d5da7..be2e87ee8b31ac6c215c0ab41f17bd9ae3bdae3c 100644 (file)
@@ -39,6 +39,8 @@
 
 #define ORION_SPI_IF_CTRL_REG          0x00
 #define ORION_SPI_IF_CONFIG_REG                0x04
+#define ORION_SPI_IF_RXLSBF            BIT(14)
+#define ORION_SPI_IF_TXLSBF            BIT(13)
 #define ORION_SPI_DATA_OUT_REG         0x08
 #define ORION_SPI_DATA_IN_REG          0x0c
 #define ORION_SPI_INT_CAUSE_REG                0x10
@@ -234,6 +236,11 @@ orion_spi_mode_set(struct spi_device *spi)
                reg |= ORION_SPI_MODE_CPOL;
        if (spi->mode & SPI_CPHA)
                reg |= ORION_SPI_MODE_CPHA;
+       if (spi->mode & SPI_LSB_FIRST)
+               reg |= ORION_SPI_IF_RXLSBF | ORION_SPI_IF_TXLSBF;
+       else
+               reg &= ~(ORION_SPI_IF_RXLSBF | ORION_SPI_IF_TXLSBF);
+
        writel(reg, spi_reg(orion_spi, ORION_SPI_IF_CONFIG_REG));
 }
 
@@ -591,8 +598,8 @@ static int orion_spi_probe(struct platform_device *pdev)
                        master->bus_num = cell_index;
        }
 
-       /* we support only mode 0, and no options */
-       master->mode_bits = SPI_CPHA | SPI_CPOL;
+       /* we support all 4 SPI modes and LSB first option */
+       master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST;
        master->set_cs = orion_spi_set_cs;
        master->transfer_one = orion_spi_transfer_one;
        master->num_chipselect = ORION_NUM_CHIPSELECTS;
index f63714ffb62f46040b9bd6b9023fec781b7467ce..52cf0e9189c23660c2cb15c17b917202b4f2bc05 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
+#include <linux/of_device.h>
 #include <linux/of.h>
 #include <linux/platform_data/sc18is602.h>
 #include <linux/gpio/consumer.h>
@@ -271,7 +272,10 @@ static int sc18is602_probe(struct i2c_client *client,
        hw->dev = dev;
        hw->ctrl = 0xff;
 
-       hw->id = id->driver_data;
+       if (client->dev.of_node)
+               hw->id = (enum chips)of_device_get_match_data(&client->dev);
+       else
+               hw->id = id->driver_data;
 
        switch (hw->id) {
        case sc18is602:
@@ -323,9 +327,27 @@ static const struct i2c_device_id sc18is602_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, sc18is602_id);
 
+static const struct of_device_id sc18is602_of_match[] = {
+       {
+               .compatible = "nxp,sc18is602",
+               .data = (void *)sc18is602
+       },
+       {
+               .compatible = "nxp,sc18is602b",
+               .data = (void *)sc18is602b
+       },
+       {
+               .compatible = "nxp,sc18is603",
+               .data = (void *)sc18is603
+       },
+       { },
+};
+MODULE_DEVICE_TABLE(of, sc18is602_of_match);
+
 static struct i2c_driver sc18is602_driver = {
        .driver = {
                .name = "sc18is602",
+               .of_match_table = of_match_ptr(sc18is602_of_match),
        },
        .probe = sc18is602_probe,
        .id_table = sc18is602_id,