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
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>;
pl022,duplex = <0>;
};
};
-
#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"
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[] = {
{
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)
/* 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;
}
out:
- kfree(rx);
- kfree(tx);
+ kvfree(rx);
+ kvfree(tx);
return ret;
}
EXPORT_SYMBOL_GPL(spi_test_run_tests);
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;
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);
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);
#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
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));
}
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;
#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>
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:
};
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,