Commit e13cccfd authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'spi-v3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into next

Pull spi updates from Mark Brown:
 "For this release SPI has been exceptionally quiet, all the work has
  been on improving drivers (including taking advantage of some of the
  recent framework updates):

   - DMA support for the rspi driver providing a nice performance boost
   - performance improvement for the SIRF controller in PIO mode
   - new support for the Cadence SPI IP and for pxa2xx on BayTrail"

* tag 'spi-v3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (59 commits)
  spi: rspi: Extract rspi_common_transfer()
  spi: rspi: Add DMA support for RSPI on RZ/A1H
  spi: rspi: Add DMA support for QSPI on R-Car Gen2
  spi: rspi: Absorb rspi_rz_transfer_out_in() into rspi_rz_transfer_one()
  spi: rspi: Merge rspi_*_dma() into rspi_dma_transfer()
  spi: rspi: Pass sg_tables instead of spi_tranfer to rspi_*_dma()
  spi: rspi: Move RSPI-specific setup out of DMA routines
  spi: rspi: Use SPI core DMA mapping framework
  spi: rspi: SPI DMA core needs both RX and TX DMA to function
  spi: rspi: Remove unneeded resource test in DMA setup
  spi: rspi: Extract rspi_request_dma_chan()
  spi: rspi: Don't consider DMA configuration failures fatal
  spi: rspi: Extract rspi_pio_transfer()
  spi: rspi: Use core SPI_MASTER_MUST_[RT]X handling
  spi: rspi: Remove unused 16-bit DMA support
  spi: rspi: Do not call rspi_receive_init() for TX-only
  spi: rspi: Extract rspi_wait_for_{tx_empty,rx_full}()
  spi/pxa2xx: fix runtime PM enabling order
  spi/fsl-espi: fix rx_buf in fsl_espi_cmd_trans()/fsl_espi_rw_trans()
  spi: core: Ignore unsupported spi-[tr]x-bus-width property values
  ...
parents de6b25de 69e25c75
...@@ -42,6 +42,10 @@ Required properties: ...@@ -42,6 +42,10 @@ Required properties:
- interrupts : should contain eSPI interrupt, the device has one interrupt. - interrupts : should contain eSPI interrupt, the device has one interrupt.
- fsl,espi-num-chipselects : the number of the chipselect signals. - fsl,espi-num-chipselects : the number of the chipselect signals.
Optional properties:
- fsl,csbef: chip select assertion time in bits before frame starts
- fsl,csaft: chip select negation time in bits after frame ends
Example: Example:
spi@110000 { spi@110000 {
#address-cells = <1>; #address-cells = <1>;
...@@ -51,4 +55,6 @@ Example: ...@@ -51,4 +55,6 @@ Example:
interrupts = <53 0x2>; interrupts = <53 0x2>;
interrupt-parent = <&mpic>; interrupt-parent = <&mpic>;
fsl,espi-num-chipselects = <4>; fsl,espi-num-chipselects = <4>;
fsl,csbef = <1>;
fsl,csaft = <1>;
}; };
...@@ -55,6 +55,8 @@ contain the following properties. ...@@ -55,6 +55,8 @@ contain the following properties.
chip select active high chip select active high
- spi-3wire - (optional) Empty property indicating device requires - spi-3wire - (optional) Empty property indicating device requires
3-wire mode. 3-wire mode.
- spi-lsb-first - (optional) Empty property indicating device requires
LSB first mode.
- spi-tx-bus-width - (optional) The bus width(number of data wires) that - spi-tx-bus-width - (optional) The bus width(number of data wires) that
used for MOSI. Defaults to 1 if not present. used for MOSI. Defaults to 1 if not present.
- spi-rx-bus-width - (optional) The bus width(number of data wires) that - spi-rx-bus-width - (optional) The bus width(number of data wires) that
......
Cadence SPI controller Device Tree Bindings
-------------------------------------------
Required properties:
- compatible : Should be "cdns,spi-r1p6" or "xlnx,zynq-spi-r1p6".
- reg : Physical base address and size of SPI registers map.
- interrupts : Property with a value describing the interrupt
number.
- interrupt-parent : Must be core interrupt controller
- clock-names : List of input clock names - "ref_clk", "pclk"
(See clock bindings for details).
- clocks : Clock phandles (see clock bindings for details).
Optional properties:
- num-cs : Number of chip selects used.
If a decoder is used, this will be the number of
chip selects after the decoder.
- is-decoded-cs : Flag to indicate whether decoder is used or not.
Example:
spi@e0007000 {
compatible = "xlnx,zynq-spi-r1p6";
clock-names = "ref_clk", "pclk";
clocks = <&clkc 26>, <&clkc 35>;
interrupt-parent = <&intc>;
interrupts = <0 49 4>;
num-cs = <4>;
is-decoded-cs = <0>;
reg = <0xe0007000 0x1000>;
} ;
Synopsys DesignWare SPI master
Required properties:
- compatible: should be "snps,designware-spi"
- #address-cells: see spi-bus.txt
- #size-cells: see spi-bus.txt
- reg: address and length of the spi master registers
- interrupts: should contain one interrupt
- clocks: spi clock phandle
- num-cs: see spi-bus.txt
Optional properties:
- cs-gpios: see spi-bus.txt
Example:
spi: spi@4020a000 {
compatible = "snps,designware-spi";
interrupts = <11 1>;
reg = <0x4020a000 0x1000>;
clocks = <&pclk>;
num-cs = <2>;
cs-gpios = <&banka 0 0>;
};
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/pinctrl/machine.h> #include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinconf-generic.h> #include <linux/pinctrl/pinconf-generic.h>
#include <linux/platform_data/pinctrl-adi2.h> #include <linux/platform_data/pinctrl-adi2.h>
#include <asm/bfin_spi3.h> #include <linux/spi/adi_spi3.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/gpio.h> #include <asm/gpio.h>
#include <asm/nand.h> #include <asm/nand.h>
...@@ -767,13 +767,13 @@ static struct flash_platform_data bfin_spi_flash_data = { ...@@ -767,13 +767,13 @@ static struct flash_platform_data bfin_spi_flash_data = {
.type = "w25q32", .type = "w25q32",
}; };
static struct bfin_spi3_chip spi_flash_chip_info = { static struct adi_spi3_chip spi_flash_chip_info = {
.enable_dma = true, /* use dma transfer with this chip*/ .enable_dma = true, /* use dma transfer with this chip*/
}; };
#endif #endif
#if IS_ENABLED(CONFIG_SPI_SPIDEV) #if IS_ENABLED(CONFIG_SPI_SPIDEV)
static struct bfin_spi3_chip spidev_chip_info = { static struct adi_spi3_chip spidev_chip_info = {
.enable_dma = true, .enable_dma = true,
}; };
#endif #endif
...@@ -1736,7 +1736,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { ...@@ -1736,7 +1736,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
}, },
#endif #endif
}; };
#if IS_ENABLED(CONFIG_SPI_BFIN_V3) #if IS_ENABLED(CONFIG_SPI_ADI_V3)
/* SPI (0) */ /* SPI (0) */
static struct resource bfin_spi0_resource[] = { static struct resource bfin_spi0_resource[] = {
{ {
...@@ -1777,13 +1777,13 @@ static struct resource bfin_spi1_resource[] = { ...@@ -1777,13 +1777,13 @@ static struct resource bfin_spi1_resource[] = {
}; };
/* SPI controller data */ /* SPI controller data */
static struct bfin_spi3_master bf60x_spi_master_info0 = { static struct adi_spi3_master bf60x_spi_master_info0 = {
.num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
}; };
static struct platform_device bf60x_spi_master0 = { static struct platform_device bf60x_spi_master0 = {
.name = "bfin-spi3", .name = "adi-spi3",
.id = 0, /* Bus number */ .id = 0, /* Bus number */
.num_resources = ARRAY_SIZE(bfin_spi0_resource), .num_resources = ARRAY_SIZE(bfin_spi0_resource),
.resource = bfin_spi0_resource, .resource = bfin_spi0_resource,
...@@ -1792,13 +1792,13 @@ static struct platform_device bf60x_spi_master0 = { ...@@ -1792,13 +1792,13 @@ static struct platform_device bf60x_spi_master0 = {
}, },
}; };
static struct bfin_spi3_master bf60x_spi_master_info1 = { static struct adi_spi3_master bf60x_spi_master_info1 = {
.num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
.pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
}; };
static struct platform_device bf60x_spi_master1 = { static struct platform_device bf60x_spi_master1 = {
.name = "bfin-spi3", .name = "adi-spi3",
.id = 1, /* Bus number */ .id = 1, /* Bus number */
.num_resources = ARRAY_SIZE(bfin_spi1_resource), .num_resources = ARRAY_SIZE(bfin_spi1_resource),
.resource = bfin_spi1_resource, .resource = bfin_spi1_resource,
...@@ -1990,7 +1990,7 @@ static struct platform_device *ezkit_devices[] __initdata = { ...@@ -1990,7 +1990,7 @@ static struct platform_device *ezkit_devices[] __initdata = {
&bfin_sdh_device, &bfin_sdh_device,
#endif #endif
#if IS_ENABLED(CONFIG_SPI_BFIN_V3) #if IS_ENABLED(CONFIG_SPI_ADI_V3)
&bf60x_spi_master0, &bf60x_spi_master0,
&bf60x_spi_master1, &bf60x_spi_master1,
#endif #endif
...@@ -2051,8 +2051,8 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = { ...@@ -2051,8 +2051,8 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = {
PIN_MAP_MUX_GROUP_DEFAULT("bfin_sir.1", "pinctrl-adi2.0", NULL, "uart1"), PIN_MAP_MUX_GROUP_DEFAULT("bfin_sir.1", "pinctrl-adi2.0", NULL, "uart1"),
PIN_MAP_MUX_GROUP_DEFAULT("bfin-sdh.0", "pinctrl-adi2.0", NULL, "rsi0"), PIN_MAP_MUX_GROUP_DEFAULT("bfin-sdh.0", "pinctrl-adi2.0", NULL, "rsi0"),
PIN_MAP_MUX_GROUP_DEFAULT("stmmaceth.0", "pinctrl-adi2.0", NULL, "eth0"), PIN_MAP_MUX_GROUP_DEFAULT("stmmaceth.0", "pinctrl-adi2.0", NULL, "eth0"),
PIN_MAP_MUX_GROUP_DEFAULT("bfin-spi3.0", "pinctrl-adi2.0", NULL, "spi0"), PIN_MAP_MUX_GROUP_DEFAULT("adi-spi3.0", "pinctrl-adi2.0", NULL, "spi0"),
PIN_MAP_MUX_GROUP_DEFAULT("bfin-spi3.1", "pinctrl-adi2.0", NULL, "spi1"), PIN_MAP_MUX_GROUP_DEFAULT("adi-spi3.1", "pinctrl-adi2.0", NULL, "spi1"),
PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.0", "pinctrl-adi2.0", NULL, "twi0"), PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.0", "pinctrl-adi2.0", NULL, "twi0"),
PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.1", "pinctrl-adi2.0", NULL, "twi1"), PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.1", "pinctrl-adi2.0", NULL, "twi1"),
PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"),
......
...@@ -363,6 +363,12 @@ static struct clk ethclk = { ...@@ -363,6 +363,12 @@ static struct clk ethclk = {
.ops = &dummy_clk_ops, .ops = &dummy_clk_ops,
}; };
static struct clk spiclk = {
.name = "spi",
.parent = &sclk1,
.ops = &dummy_clk_ops,
};
static struct clk_lookup bf609_clks[] = { static struct clk_lookup bf609_clks[] = {
CLK(sys_clkin, NULL, "SYS_CLKIN"), CLK(sys_clkin, NULL, "SYS_CLKIN"),
CLK(pll_clk, NULL, "PLLCLK"), CLK(pll_clk, NULL, "PLLCLK"),
...@@ -375,6 +381,7 @@ static struct clk_lookup bf609_clks[] = { ...@@ -375,6 +381,7 @@ static struct clk_lookup bf609_clks[] = {
CLK(dclk, NULL, "DCLK"), CLK(dclk, NULL, "DCLK"),
CLK(oclk, NULL, "OCLK"), CLK(oclk, NULL, "OCLK"),
CLK(ethclk, NULL, "stmmaceth"), CLK(ethclk, NULL, "stmmaceth"),
CLK(spiclk, NULL, "spi"),
}; };
int __init clk_init(void) int __init clk_init(void)
......
...@@ -91,8 +91,8 @@ config SPI_BFIN5XX ...@@ -91,8 +91,8 @@ config SPI_BFIN5XX
help help
This is the SPI controller master driver for Blackfin 5xx processor. This is the SPI controller master driver for Blackfin 5xx processor.
config SPI_BFIN_V3 config SPI_ADI_V3
tristate "SPI controller v3 for Blackfin" tristate "SPI controller v3 for ADI"
depends on BF60x depends on BF60x
help help
This is the SPI controller v3 master driver This is the SPI controller v3 master driver
...@@ -148,6 +148,13 @@ config SPI_BUTTERFLY ...@@ -148,6 +148,13 @@ config SPI_BUTTERFLY
inexpensive battery powered microcontroller evaluation board. inexpensive battery powered microcontroller evaluation board.
This same cable can be used to flash new firmware. This same cable can be used to flash new firmware.
config SPI_CADENCE
tristate "Cadence SPI controller"
depends on ARM
help
This selects the Cadence SPI controller master driver
used by Xilinx Zynq.
config SPI_CLPS711X config SPI_CLPS711X
tristate "CLPS711X host SPI controller" tristate "CLPS711X host SPI controller"
depends on ARCH_CLPS711X || COMPILE_TEST depends on ARCH_CLPS711X || COMPILE_TEST
...@@ -505,7 +512,7 @@ config SPI_TEGRA20_SLINK ...@@ -505,7 +512,7 @@ config SPI_TEGRA20_SLINK
config SPI_TOPCLIFF_PCH config SPI_TOPCLIFF_PCH
tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) SPI" tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) SPI"
depends on PCI depends on PCI && (X86_32 || COMPILE_TEST)
help help
SPI driver for the Topcliff PCH (Platform Controller Hub) SPI bus SPI driver for the Topcliff PCH (Platform Controller Hub) SPI bus
used in some x86 embedded processors. used in some x86 embedded processors.
......
...@@ -18,10 +18,11 @@ obj-$(CONFIG_SPI_BCM2835) += spi-bcm2835.o ...@@ -18,10 +18,11 @@ obj-$(CONFIG_SPI_BCM2835) += spi-bcm2835.o
obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o
obj-$(CONFIG_SPI_BCM63XX_HSSPI) += spi-bcm63xx-hsspi.o obj-$(CONFIG_SPI_BCM63XX_HSSPI) += spi-bcm63xx-hsspi.o
obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o
obj-$(CONFIG_SPI_BFIN_V3) += spi-bfin-v3.o obj-$(CONFIG_SPI_ADI_V3) += spi-adi-v3.o
obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o
obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o
obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o
obj-$(CONFIG_SPI_CADENCE) += spi-cadence.o
obj-$(CONFIG_SPI_CLPS711X) += spi-clps711x.o obj-$(CONFIG_SPI_CLPS711X) += spi-clps711x.o
obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi-coldfire-qspi.o obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi-coldfire-qspi.o
obj-$(CONFIG_SPI_DAVINCI) += spi-davinci.o obj-$(CONFIG_SPI_DAVINCI) += spi-davinci.o
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
......
...@@ -224,7 +224,7 @@ struct atmel_spi { ...@@ -224,7 +224,7 @@ struct atmel_spi {
struct platform_device *pdev; struct platform_device *pdev;
struct spi_transfer *current_transfer; struct spi_transfer *current_transfer;
unsigned long current_remaining_bytes; int current_remaining_bytes;
int done_status; int done_status;
struct completion xfer_completion; struct completion xfer_completion;
...@@ -874,8 +874,9 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer) ...@@ -874,8 +874,9 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer)
spi_readl(as, RDR); spi_readl(as, RDR);
} }
if (xfer->bits_per_word > 8) { if (xfer->bits_per_word > 8) {
as->current_remaining_bytes -= 2; if (as->current_remaining_bytes > 2)
if (as->current_remaining_bytes < 0) as->current_remaining_bytes -= 2;
else
as->current_remaining_bytes = 0; as->current_remaining_bytes = 0;
} else { } else {
as->current_remaining_bytes--; as->current_remaining_bytes--;
...@@ -1110,6 +1111,8 @@ static int atmel_spi_one_transfer(struct spi_master *master, ...@@ -1110,6 +1111,8 @@ static int atmel_spi_one_transfer(struct spi_master *master,
atmel_spi_next_xfer_pio(master, xfer); atmel_spi_next_xfer_pio(master, xfer);
} else { } else {
as->current_remaining_bytes -= len; as->current_remaining_bytes -= len;
if (as->current_remaining_bytes < 0)
as->current_remaining_bytes = 0;
} }
} else { } else {
atmel_spi_next_xfer_pio(master, xfer); atmel_spi_next_xfer_pio(master, xfer);
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/workqueue.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#define HSSPI_GLOBAL_CTRL_REG 0x0 #define HSSPI_GLOBAL_CTRL_REG 0x0
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/workqueue.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <bcm63xx_dev_spi.h> #include <bcm63xx_dev_spi.h>
......
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_gpio.h>
#include "spi-dw.h" #include "spi-dw.h"
...@@ -70,6 +71,27 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -70,6 +71,27 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
dws->num_cs = 4; dws->num_cs = 4;
dws->max_freq = clk_get_rate(dwsmmio->clk); dws->max_freq = clk_get_rate(dwsmmio->clk);
if (pdev->dev.of_node) {
int i;
for (i = 0; i < dws->num_cs; i++) {
int cs_gpio = of_get_named_gpio(pdev->dev.of_node,
"cs-gpios", i);
if (cs_gpio == -EPROBE_DEFER) {
ret = cs_gpio;
goto out;
}
if (gpio_is_valid(cs_gpio)) {
ret = devm_gpio_request(&pdev->dev, cs_gpio,
dev_name(&pdev->dev));
if (ret)
goto out;
}
}
}
ret = dw_spi_add_host(&pdev->dev, dws); ret = dw_spi_add_host(&pdev->dev, dws);
if (ret) if (ret)
goto out; goto out;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/gpio.h>
#include "spi-dw.h" #include "spi-dw.h"
...@@ -36,12 +37,6 @@ ...@@ -36,12 +37,6 @@
#define DONE_STATE ((void *)2) #define DONE_STATE ((void *)2)
#define ERROR_STATE ((void *)-1) #define ERROR_STATE ((void *)-1)
#define QUEUE_RUNNING 0
#define QUEUE_STOPPED 1
#define MRST_SPI_DEASSERT 0
#define MRST_SPI_ASSERT 1
/* Slave spi_dev related */ /* Slave spi_dev related */
struct chip_data { struct chip_data {
u16 cr0; u16 cr0;
...@@ -263,28 +258,22 @@ static int map_dma_buffers(struct dw_spi *dws) ...@@ -263,28 +258,22 @@ static int map_dma_buffers(struct dw_spi *dws)
static void giveback(struct dw_spi *dws) static void giveback(struct dw_spi *dws)
{ {
struct spi_transfer *last_transfer; struct spi_transfer *last_transfer;
unsigned long flags;
struct spi_message *msg; struct spi_message *msg;
spin_lock_irqsave(&dws->lock, flags);
msg = dws->cur_msg; msg = dws->cur_msg;
dws->cur_msg = NULL; dws->cur_msg = NULL;
dws->cur_transfer = NULL; dws->cur_transfer = NULL;
dws->prev_chip = dws->cur_chip; dws->prev_chip = dws->cur_chip;
dws->cur_chip = NULL; dws->cur_chip = NULL;
dws->dma_mapped = 0; dws->dma_mapped = 0;
queue_work(dws->workqueue, &dws->pump_messages);
spin_unlock_irqrestore(&dws->lock, flags);
last_transfer = list_last_entry(&msg->transfers, struct spi_transfer, last_transfer = list_last_entry(&msg->transfers, struct spi_transfer,
transfer_list); transfer_list);
if (!last_transfer->cs_change && dws->cs_control) if (!last_transfer->cs_change)
dws->cs_control(MRST_SPI_DEASSERT); spi_chip_sel(dws, dws->cur_msg->spi, 0);
msg->state = NULL; spi_finalize_current_message(dws->master);
if (msg->complete)
msg->complete(msg->context);
} }
static void int_error_stop(struct dw_spi *dws, const char *msg) static void int_error_stop(struct dw_spi *dws, const char *msg)
...@@ -502,7 +491,7 @@ static void pump_transfers(unsigned long data) ...@@ -502,7 +491,7 @@ static void pump_transfers(unsigned long data)
dw_writew(dws, DW_SPI_CTRL0, cr0); dw_writew(dws, DW_SPI_CTRL0, cr0);
spi_set_clk(dws, clk_div ? clk_div : chip->clk_div); spi_set_clk(dws, clk_div ? clk_div : chip->clk_div);
spi_chip_sel(dws, spi->chip_select); spi_chip_sel(dws, spi, 1);
/* Set the interrupt mask, for poll mode just disable all int */ /* Set the interrupt mask, for poll mode just disable all int */
spi_mask_intr(dws, 0xff); spi_mask_intr(dws, 0xff);
...@@ -529,30 +518,12 @@ static void pump_transfers(unsigned long data) ...@@ -529,30 +518,12 @@ static void pump_transfers(unsigned long data)
return; return;
} }
static void pump_messages(struct work_struct *work) static int dw_spi_transfer_one_message(struct spi_master *master,
struct spi_message *msg)
{ {
struct dw_spi *dws = struct dw_spi *dws = spi_master_get_devdata(master);
container_of(work, struct dw_spi, pump_messages);
unsigned long flags;
/* Lock queue and check for queue work */
spin_lock_irqsave(&dws->lock, flags);
if (list_empty(&dws->queue) || dws->run == QUEUE_STOPPED) {
dws->busy = 0;
spin_unlock_irqrestore(&dws->lock, flags);
return;
}
/* Make sure we are not already running a message */
if (dws->cur_msg) {
spin_unlock_irqrestore(&dws->lock, flags);
return;
}
/* Extract head of queue */
dws->cur_msg = list_entry(dws->queue.next, struct spi_message, queue);
list_del_init(&dws->cur_msg->queue);
dws->cur_msg = msg;
/* Initial message state*/ /* Initial message state*/
dws->cur_msg->state = START_STATE; dws->cur_msg->state = START_STATE;
dws->cur_transfer = list_entry(dws->cur_msg->transfers.next, dws->cur_transfer = list_entry(dws->cur_msg->transfers.next,
...@@ -560,46 +531,9 @@ static void pump_messages(struct work_struct *work) ...@@ -560,46 +531,9 @@ static void pump_messages(struct work_struct *work)
transfer_list); transfer_list);
dws->cur_chip = spi_get_ctldata(dws->cur_msg->spi); dws->cur_chip = spi_get_ctldata(dws->cur_msg->spi);
/* Mark as busy and launch transfers */ /* Launch transfers */
tasklet_schedule(&dws->pump_transfers); tasklet_schedule(&dws->pump_transfers);
dws->busy = 1;
spin_unlock_irqrestore(&dws->lock, flags);
}
/* spi_device use this to queue in their spi_msg */
static int dw_spi_transfer(struct spi_device *spi, struct spi_message *msg)
{
struct dw_spi *dws = spi_master_get_devdata(spi->master);
unsigned long flags;
spin_lock_irqsave(&dws->lock, flags);
if (dws->run == QUEUE_STOPPED) {
spin_unlock_irqrestore(&dws->lock, flags);
return -ESHUTDOWN;
}
msg->actual_length = 0;
msg->status = -EINPROGRESS;
msg->state = START_STATE;
list_add_tail(&msg->queue, &dws->queue);
if (dws->run == QUEUE_RUNNING && !dws->busy) {
if (dws->cur_transfer || dws->cur_msg)
queue_work(dws->workqueue,
&dws->pump_messages);
else {
/* If no other data transaction in air, just go */
spin_unlock_irqrestore(&dws->lock, flags);
pump_messages(&dws->pump_messages);
return 0;
}
}
spin_unlock_irqrestore(&dws->lock, flags);
return 0; return 0;
} }
...@@ -608,6 +542,7 @@ static int dw_spi_setup(struct spi_device *spi) ...@@ -608,6 +542,7 @@ static int dw_spi_setup(struct spi_device *spi)
{ {
struct dw_spi_chip *chip_info = NULL; struct dw_spi_chip *chip_info = NULL;
struct chip_data *chip; struct chip_data *chip;
int ret;
/* Only alloc on first setup */ /* Only alloc on first setup */
chip = spi_get_ctldata(spi); chip = spi_get_ctldata(spi);
...@@ -661,81 +596,13 @@ static int dw_spi_setup(struct spi_device *spi) ...@@ -661,81 +596,13 @@ static int dw_spi_setup(struct spi_device *spi)
| (spi->mode << SPI_MODE_OFFSET) | (spi->mode << SPI_MODE_OFFSET)
| (chip->tmode << SPI_TMOD_OFFSET); | (chip->tmode << SPI_TMOD_OFFSET);
return 0; if (gpio_is_valid(spi->cs_gpio)) {
} ret = gpio_direction_output(spi->cs_gpio,
!(spi->mode & SPI_CS_HIGH));
static int init_queue(struct dw_spi *dws) if (ret)
{ return ret;
INIT_LIST_HEAD(&dws->queue);
spin_lock_init(&dws->lock);
dws->run = QUEUE_STOPPED;
dws->busy = 0;
tasklet_init(&dws->pump_transfers,
pump_transfers, (unsigned long)dws);
INIT_WORK(&dws->pump_messages, pump_messages);
dws->workqueue = create_singlethread_workqueue(
dev_name(dws->master->dev.parent));
if (dws->workqueue == NULL)
return -EBUSY;
return 0;
}
static int start_queue(struct dw_spi *dws)
{
unsigned long flags;
spin_lock_irqsave(&dws->lock, flags);
if (dws->run == QUEUE_RUNNING || dws->busy) {
spin_unlock_irqrestore(&dws->lock, flags);
return -EBUSY;
} }
dws->run = QUEUE_RUNNING;
dws->cur_msg = NULL;
dws->cur_transfer = NULL;
dws->cur_chip = NULL;
dws->prev_chip = NULL;
spin_unlock_irqrestore(&dws->lock, flags);
queue_work(dws->workqueue, &dws->pump_messages);
return 0;
}
static int stop_queue(struct dw_spi *dws)
{
unsigned long flags;
unsigned limit = 50;
int status = 0;
spin_lock_irqsave(&dws->lock, flags);
dws->run = QUEUE_STOPPED;
while ((!list_empty(&dws->queue) || dws->busy) && limit--) {
spin_unlock_irqrestore(&dws->lock, flags);
msleep(10);
spin_lock_irqsave(&dws->lock, flags);
}
if (!list_empty(&dws->queue) || dws->busy)
status = -EBUSY;
spin_unlock_irqrestore(&dws->lock, flags);
return status;
}
static int destroy_queue(struct dw_spi *dws)
{
int status;
status = stop_queue(dws);
if (status != 0)
return status;
destroy_workqueue(dws->workqueue);
return 0; return 0;
} }
...@@ -794,7 +661,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) ...@@ -794,7 +661,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
master->bus_num = dws->bus_num; master->bus_num = dws->bus_num;
master->num_chipselect = dws->num_cs; master->num_chipselect = dws->num_cs;
master->setup = dw_spi_setup; master->setup = dw_spi_setup;
master->transfer = dw_spi_transfer; master->transfer_one_message = dw_spi_transfer_one_message;
master->max_speed_hz = dws->max_freq; master->max_speed_hz = dws->max_freq;
/* Basic HW init */ /* Basic HW init */
...@@ -808,33 +675,21 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) ...@@ -808,33 +675,21 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
} }
} }
/* Initial and start queue */ tasklet_init(&dws->pump_transfers, pump_transfers, (unsigned long)dws);
ret = init_queue(dws);
if (ret) {
dev_err(&master->dev, "problem initializing queue\n");
goto err_diable_hw;
}
ret = start_queue(dws);
if (ret) {
dev_err(&master->dev, "problem starting queue\n");
goto err_diable_hw;
}
spi_master_set_devdata(master, dws); spi_master_set_devdata(master, dws);
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_master(dev, master);
if (ret) { if (ret) {
dev_err(&master->dev, "problem registering spi master\n"); dev_err(&master->dev, "problem registering spi master\n");
goto err_queue_alloc; goto err_dma_exit;
} }
mrst_spi_debugfs_init(dws); mrst_spi_debugfs_init(dws);
return 0; return 0;
err_queue_alloc: err_dma_exit:
destroy_queue(dws);
if (dws->dma_ops && dws->dma_ops->dma_exit) if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws); dws->dma_ops->dma_exit(dws);
err_diable_hw:
spi_enable_chip(dws, 0); spi_enable_chip(dws, 0);
err_free_master: err_free_master:
spi_master_put(master); spi_master_put(master);
...@@ -844,18 +699,10 @@ EXPORT_SYMBOL_GPL(dw_spi_add_host); ...@@ -844,18 +699,10 @@ EXPORT_SYMBOL_GPL(dw_spi_add_host);
void dw_spi_remove_host(struct dw_spi *dws) void dw_spi_remove_host(struct dw_spi *dws)
{ {
int status = 0;
if (!dws) if (!dws)
return; return;
mrst_spi_debugfs_remove(dws); mrst_spi_debugfs_remove(dws);
/* Remove the queue */
status = destroy_queue(dws);
if (status != 0)
dev_err(&dws->master->dev,
"dw_spi_remove: workqueue will not complete, message memory not freed\n");
if (dws->dma_ops && dws->dma_ops->dma_exit) if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws); dws->dma_ops->dma_exit(dws);
spi_enable_chip(dws, 0); spi_enable_chip(dws, 0);
...@@ -868,7 +715,7 @@ int dw_spi_suspend_host(struct dw_spi *dws) ...@@ -868,7 +715,7 @@ int dw_spi_suspend_host(struct dw_spi *dws)
{ {
int ret = 0; int ret = 0;
ret = stop_queue(dws); ret = spi_master_suspend(dws->master);
if (ret) if (ret)
return ret; return ret;
spi_enable_chip(dws, 0); spi_enable_chip(dws, 0);
...@@ -882,7 +729,7 @@ int dw_spi_resume_host(struct dw_spi *dws) ...@@ -882,7 +729,7 @@ int dw_spi_resume_host(struct dw_spi *dws)
int ret; int ret;
spi_hw_init(dws); spi_hw_init(dws);
ret = start_queue(dws); ret = spi_master_resume(dws->master);
if (ret) if (ret)
dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret); dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret);
return ret; return ret;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/gpio.h>
/* Register offsets */ /* Register offsets */
#define DW_SPI_CTRL0 0x00 #define DW_SPI_CTRL0 0x00
...@@ -104,14 +105,6 @@ struct dw_spi { ...@@ -104,14 +105,6 @@ struct dw_spi {
u16 bus_num; u16 bus_num;
u16 num_cs; /* supported slave numbers */ u16 num_cs; /* supported slave numbers */
/* Driver message queue */
struct workqueue_struct *workqueue;
struct work_struct pump_messages;
spinlock_t lock;
struct list_head queue;
int busy;
int run;
/* Message Transfer pump */ /* Message Transfer pump */
struct tasklet_struct pump_transfers; struct tasklet_struct pump_transfers;
...@@ -186,15 +179,20 @@ static inline void spi_set_clk(struct dw_spi *dws, u16 div) ...@@ -186,15 +179,20 @@ static inline void spi_set_clk(struct dw_spi *dws, u16 div)
dw_writel(dws, DW_SPI_BAUDR, div); dw_writel(dws, DW_SPI_BAUDR, div);
} }
static inline void spi_chip_sel(struct dw_spi *dws, u16 cs) static inline void spi_chip_sel(struct dw_spi *dws, struct spi_device *spi,
int active)
{ {
if (cs > dws->num_cs) u16 cs = spi->chip_select;
return; int gpio_val = active ? (spi->mode & SPI_CS_HIGH) :
!(spi->mode & SPI_CS_HIGH);
if (dws->cs_control) if (dws->cs_control)
dws->cs_control(1); dws->cs_control(active);
if (gpio_is_valid(spi->cs_gpio))
gpio_set_value(spi->cs_gpio, gpio_val);
dw_writel(dws, DW_SPI_SER, 1 << cs); if (active)
dw_writel(dws, DW_SPI_SER, 1 << cs);
} }
/* Disable IRQ bits */ /* Disable IRQ bits */
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
......
...@@ -406,7 +406,7 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id) ...@@ -406,7 +406,7 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static struct of_device_id fsl_dspi_dt_ids[] = { static const struct of_device_id fsl_dspi_dt_ids[] = {
{ .compatible = "fsl,vf610-dspi", .data = NULL, }, { .compatible = "fsl,vf610-dspi", .data = NULL, },
{ /* sentinel */ } { /* sentinel */ }
}; };
......
...@@ -348,7 +348,7 @@ static void fsl_espi_cmd_trans(struct spi_message *m, ...@@ -348,7 +348,7 @@ static void fsl_espi_cmd_trans(struct spi_message *m,
} }
espi_trans->tx_buf = local_buf; espi_trans->tx_buf = local_buf;
espi_trans->rx_buf = local_buf + espi_trans->n_tx; espi_trans->rx_buf = local_buf;
fsl_espi_do_trans(m, espi_trans); fsl_espi_do_trans(m, espi_trans);
espi_trans->actual_length = espi_trans->len; espi_trans->actual_length = espi_trans->len;
...@@ -397,7 +397,7 @@ static void fsl_espi_rw_trans(struct spi_message *m, ...@@ -397,7 +397,7 @@ static void fsl_espi_rw_trans(struct spi_message *m,
espi_trans->n_rx = trans_len; espi_trans->n_rx = trans_len;
espi_trans->len = trans_len + n_tx; espi_trans->len = trans_len + n_tx;
espi_trans->tx_buf = local_buf; espi_trans->tx_buf = local_buf;
espi_trans->rx_buf = local_buf + n_tx; espi_trans->rx_buf = local_buf;
fsl_espi_do_trans(m, espi_trans); fsl_espi_do_trans(m, espi_trans);
memcpy(rx_buf + pos, espi_trans->rx_buf + n_tx, trans_len); memcpy(rx_buf + pos, espi_trans->rx_buf + n_tx, trans_len);
...@@ -458,7 +458,7 @@ static int fsl_espi_setup(struct spi_device *spi) ...@@ -458,7 +458,7 @@ static int fsl_espi_setup(struct spi_device *spi)
return -EINVAL; return -EINVAL;
if (!cs) { if (!cs) {
cs = kzalloc(sizeof *cs, GFP_KERNEL); cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL);
if (!cs) if (!cs)
return -ENOMEM; return -ENOMEM;
spi->controller_state = cs; spi->controller_state = cs;
...@@ -586,8 +586,10 @@ static struct spi_master * fsl_espi_probe(struct device *dev, ...@@ -586,8 +586,10 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
struct spi_master *master; struct spi_master *master;
struct mpc8xxx_spi *mpc8xxx_spi; struct mpc8xxx_spi *mpc8xxx_spi;
struct fsl_espi_reg *reg_base; struct fsl_espi_reg *reg_base;
u32 regval; struct device_node *nc;
int i, ret = 0; const __be32 *prop;
u32 regval, csmode;
int i, len, ret = 0;
master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi)); master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
if (!master) { if (!master) {
...@@ -634,8 +636,32 @@ static struct spi_master * fsl_espi_probe(struct device *dev, ...@@ -634,8 +636,32 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
mpc8xxx_spi_write_reg(&reg_base->event, 0xffffffff); mpc8xxx_spi_write_reg(&reg_base->event, 0xffffffff);
/* Init eSPI CS mode register */ /* Init eSPI CS mode register */
for (i = 0; i < pdata->max_chipselect; i++) for_each_available_child_of_node(master->dev.of_node, nc) {
mpc8xxx_spi_write_reg(&reg_base->csmode[i], CSMODE_INIT_VAL); /* get chip select */
prop = of_get_property(nc, "reg", &len);
if (!prop || len < sizeof(*prop))
continue;
i = be32_to_cpup(prop);
if (i < 0 || i >= pdata->max_chipselect)
continue;
csmode = CSMODE_INIT_VAL;
/* check if CSBEF is set in device tree */
prop = of_get_property(nc, "fsl,csbef", &len);
if (prop && len >= sizeof(*prop)) {
csmode &= ~(CSMODE_BEF(0xf));
csmode |= CSMODE_BEF(be32_to_cpup(prop));
}
/* check if CSAFT is set in device tree */
prop = of_get_property(nc, "fsl,csaft", &len);
if (prop && len >= sizeof(*prop)) {
csmode &= ~(CSMODE_AFT(0xf));
csmode |= CSMODE_AFT(be32_to_cpup(prop));
}
mpc8xxx_spi_write_reg(&reg_base->csmode[i], csmode);
dev_info(dev, "cs=%d, init_csmode=0x%x\n", i, csmode);
}
/* Enable SPI interface */ /* Enable SPI interface */
regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
......
...@@ -99,11 +99,6 @@ int mpc8xxx_spi_transfer(struct spi_device *spi, ...@@ -99,11 +99,6 @@ int mpc8xxx_spi_transfer(struct spi_device *spi,
return 0; return 0;
} }
void mpc8xxx_spi_cleanup(struct spi_device *spi)
{
kfree(spi->controller_state);
}
const char *mpc8xxx_spi_strmode(unsigned int flags) const char *mpc8xxx_spi_strmode(unsigned int flags)
{ {
if (flags & SPI_QE_CPU_MODE) { if (flags & SPI_QE_CPU_MODE) {
...@@ -134,7 +129,6 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, ...@@ -134,7 +129,6 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
| SPI_LSB_FIRST | SPI_LOOP; | SPI_LSB_FIRST | SPI_LOOP;
master->transfer = mpc8xxx_spi_transfer; master->transfer = mpc8xxx_spi_transfer;
master->cleanup = mpc8xxx_spi_cleanup;
master->dev.of_node = dev->of_node; master->dev.of_node = dev->of_node;
mpc8xxx_spi = spi_master_get_devdata(master); mpc8xxx_spi = spi_master_get_devdata(master);
......
...@@ -124,7 +124,6 @@ extern struct mpc8xxx_spi_probe_info *to_of_pinfo( ...@@ -124,7 +124,6 @@ extern struct mpc8xxx_spi_probe_info *to_of_pinfo(
extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi, extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi,
struct spi_transfer *t, unsigned int len); struct spi_transfer *t, unsigned int len);
extern int mpc8xxx_spi_transfer(struct spi_device *spi, struct spi_message *m); extern int mpc8xxx_spi_transfer(struct spi_device *spi, struct spi_message *m);
extern void mpc8xxx_spi_cleanup(struct spi_device *spi);
extern const char *mpc8xxx_spi_strmode(unsigned int flags); extern const char *mpc8xxx_spi_strmode(unsigned int flags);
extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
unsigned int irq); unsigned int irq);
......
...@@ -431,7 +431,7 @@ static int fsl_spi_setup(struct spi_device *spi) ...@@ -431,7 +431,7 @@ static int fsl_spi_setup(struct spi_device *spi)
return -EINVAL; return -EINVAL;
if (!cs) { if (!cs) {
cs = kzalloc(sizeof *cs, GFP_KERNEL); cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL);
if (!cs) if (!cs)
return -ENOMEM; return -ENOMEM;
spi->controller_state = cs; spi->controller_state = cs;
......
...@@ -340,7 +340,7 @@ static int spi_gpio_request(struct spi_gpio_platform_data *pdata, ...@@ -340,7 +340,7 @@ static int spi_gpio_request(struct spi_gpio_platform_data *pdata,
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
static struct of_device_id spi_gpio_dt_ids[] = { static const struct of_device_id spi_gpio_dt_ids[] = {
{ .compatible = "spi-gpio" }, { .compatible = "spi-gpio" },
{} {}
}; };
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/errno.h> #include <linux/errno.h>
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/clk.h> #include <linux/clk.h>
......
...@@ -1111,10 +1111,8 @@ static int pl022_dma_probe(struct pl022 *pl022) ...@@ -1111,10 +1111,8 @@ static int pl022_dma_probe(struct pl022 *pl022)
} }
pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL); pl022->dummypage = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!pl022->dummypage) { if (!pl022->dummypage)
dev_dbg(&pl022->adev->dev, "no DMA dummypage!\n");
goto err_no_dummypage; goto err_no_dummypage;
}
dev_info(&pl022->adev->dev, "setup for DMA on RX %s, TX %s\n", dev_info(&pl022->adev->dev, "setup for DMA on RX %s, TX %s\n",
dma_chan_name(pl022->dma_rx_channel), dma_chan_name(pl022->dma_rx_channel),
...@@ -1809,11 +1807,8 @@ static int pl022_setup(struct spi_device *spi) ...@@ -1809,11 +1807,8 @@ static int pl022_setup(struct spi_device *spi)
if (chip == NULL) { if (chip == NULL) {
chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL); chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
if (!chip) { if (!chip)
dev_err(&spi->dev,
"cannot allocate controller state\n");
return -ENOMEM; return -ENOMEM;
}
dev_dbg(&spi->dev, dev_dbg(&spi->dev,
"allocated memory for controller's runtime state\n"); "allocated memory for controller's runtime state\n");
} }
...@@ -2050,10 +2045,8 @@ pl022_platform_data_dt_get(struct device *dev) ...@@ -2050,10 +2045,8 @@ pl022_platform_data_dt_get(struct device *dev)
} }
pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL); pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL);
if (!pd) { if (!pd)
dev_err(dev, "cannot allocate platform data memory\n");
return NULL; return NULL;
}
pd->bus_id = -1; pd->bus_id = -1;
pd->enable_dma = 1; pd->enable_dma = 1;
......
...@@ -8,7 +8,43 @@ ...@@ -8,7 +8,43 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/spi/pxa2xx_spi.h> #include <linux/spi/pxa2xx_spi.h>
static int ce4100_spi_probe(struct pci_dev *dev, enum {
PORT_CE4100,
PORT_BYT,
};
struct pxa_spi_info {
enum pxa_ssp_type type;
int port_id;
int num_chipselect;
int tx_slave_id;
int tx_chan_id;
int rx_slave_id;
int rx_chan_id;
};
static struct pxa_spi_info spi_info_configs[] = {
[PORT_CE4100] = {
.type = PXA25x_SSP,
.port_id = -1,
.num_chipselect = -1,
.tx_slave_id = -1,
.tx_chan_id = -1,
.rx_slave_id = -1,
.rx_chan_id = -1,
},
[PORT_BYT] = {
.type = LPSS_SSP,
.port_id = 0,
.num_chipselect = 1,
.tx_slave_id = 0,
.tx_chan_id = 0,
.rx_slave_id = 1,
.rx_chan_id = 1,
},
};
static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
struct platform_device_info pi; struct platform_device_info pi;
...@@ -16,6 +52,7 @@ static int ce4100_spi_probe(struct pci_dev *dev, ...@@ -16,6 +52,7 @@ static int ce4100_spi_probe(struct pci_dev *dev,
struct platform_device *pdev; struct platform_device *pdev;
struct pxa2xx_spi_master spi_pdata; struct pxa2xx_spi_master spi_pdata;
struct ssp_device *ssp; struct ssp_device *ssp;
struct pxa_spi_info *c;
ret = pcim_enable_device(dev); ret = pcim_enable_device(dev);
if (ret) if (ret)
...@@ -25,8 +62,16 @@ static int ce4100_spi_probe(struct pci_dev *dev, ...@@ -25,8 +62,16 @@ static int ce4100_spi_probe(struct pci_dev *dev,
if (ret) if (ret)
return ret; return ret;
c = &spi_info_configs[ent->driver_data];
memset(&spi_pdata, 0, sizeof(spi_pdata)); memset(&spi_pdata, 0, sizeof(spi_pdata));
spi_pdata.num_chipselect = dev->devfn; spi_pdata.num_chipselect = (c->num_chipselect > 0) ?
c->num_chipselect : dev->devfn;
spi_pdata.tx_slave_id = c->tx_slave_id;
spi_pdata.tx_chan_id = c->tx_chan_id;
spi_pdata.rx_slave_id = c->rx_slave_id;
spi_pdata.rx_chan_id = c->rx_chan_id;
spi_pdata.enable_dma = c->rx_slave_id >= 0 && c->tx_slave_id >= 0;
ssp = &spi_pdata.ssp; ssp = &spi_pdata.ssp;
ssp->phys_base = pci_resource_start(dev, 0); ssp->phys_base = pci_resource_start(dev, 0);
...@@ -36,8 +81,8 @@ static int ce4100_spi_probe(struct pci_dev *dev, ...@@ -36,8 +81,8 @@ static int ce4100_spi_probe(struct pci_dev *dev,
return -EIO; return -EIO;
} }
ssp->irq = dev->irq; ssp->irq = dev->irq;
ssp->port_id = dev->devfn; ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn;
ssp->type = PXA25x_SSP; ssp->type = c->type;
memset(&pi, 0, sizeof(pi)); memset(&pi, 0, sizeof(pi));
pi.parent = &dev->dev; pi.parent = &dev->dev;
...@@ -55,28 +100,29 @@ static int ce4100_spi_probe(struct pci_dev *dev, ...@@ -55,28 +100,29 @@ static int ce4100_spi_probe(struct pci_dev *dev,
return 0; return 0;
} }
static void ce4100_spi_remove(struct pci_dev *dev) static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
{ {
struct platform_device *pdev = pci_get_drvdata(dev); struct platform_device *pdev = pci_get_drvdata(dev);
platform_device_unregister(pdev); platform_device_unregister(pdev);
} }
static const struct pci_device_id ce4100_spi_devices[] = { static const struct pci_device_id pxa2xx_spi_pci_devices[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) }, { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 },
{ PCI_VDEVICE(INTEL, 0x0f0e), PORT_BYT },
{ }, { },
}; };
MODULE_DEVICE_TABLE(pci, ce4100_spi_devices); MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices);
static struct pci_driver ce4100_spi_driver = { static struct pci_driver pxa2xx_spi_pci_driver = {
.name = "ce4100_spi", .name = "pxa2xx_spi_pci",
.id_table = ce4100_spi_devices, .id_table = pxa2xx_spi_pci_devices,
.probe = ce4100_spi_probe, .probe = pxa2xx_spi_pci_probe,
.remove = ce4100_spi_remove, .remove = pxa2xx_spi_pci_remove,
}; };
module_pci_driver(ce4100_spi_driver); module_pci_driver(pxa2xx_spi_pci_driver);
MODULE_DESCRIPTION("CE4100 PCI-SPI glue code for PXA's driver"); MODULE_DESCRIPTION("CE4100/LPSS PCI-SPI glue code for PXA's driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>"); MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spi/pxa2xx_spi.h> #include <linux/spi/pxa2xx_spi.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/workqueue.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -886,11 +885,8 @@ static int setup(struct spi_device *spi) ...@@ -886,11 +885,8 @@ static int setup(struct spi_device *spi)
chip = spi_get_ctldata(spi); chip = spi_get_ctldata(spi);
if (!chip) { if (!chip) {
chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL); chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
if (!chip) { if (!chip)
dev_err(&spi->dev,
"failed setup: can't allocate chip data\n");
return -ENOMEM; return -ENOMEM;
}
if (drv_data->ssp_type == CE4100_SSP) { if (drv_data->ssp_type == CE4100_SSP) {
if (spi->chip_select > 4) { if (spi->chip_select > 4) {
...@@ -1037,11 +1033,8 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) ...@@ -1037,11 +1033,8 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
return NULL; return NULL;
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) { if (!pdata)
dev_err(&pdev->dev,
"failed to allocate memory for platform data\n");
return NULL; return NULL;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) if (!res)
...@@ -1202,6 +1195,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) ...@@ -1202,6 +1195,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
tasklet_init(&drv_data->pump_transfers, pump_transfers, tasklet_init(&drv_data->pump_transfers, pump_transfers,
(unsigned long)drv_data); (unsigned long)drv_data);
pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
/* Register with the SPI framework */ /* Register with the SPI framework */
platform_set_drvdata(pdev, drv_data); platform_set_drvdata(pdev, drv_data);
status = devm_spi_register_master(&pdev->dev, master); status = devm_spi_register_master(&pdev->dev, master);
...@@ -1210,11 +1208,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) ...@@ -1210,11 +1208,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
goto out_error_clock_enabled; goto out_error_clock_enabled;
} }
pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
return status; return status;
out_error_clock_enabled: out_error_clock_enabled:
......
...@@ -287,7 +287,7 @@ static irqreturn_t spi_qup_qup_irq(int irq, void *dev_id) ...@@ -287,7 +287,7 @@ static irqreturn_t spi_qup_qup_irq(int irq, void *dev_id)
writel_relaxed(opflags, controller->base + QUP_OPERATIONAL); writel_relaxed(opflags, controller->base + QUP_OPERATIONAL);
if (!xfer) { 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); qup_err, spi_err, opflags);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -366,7 +366,7 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -366,7 +366,7 @@ static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
n_words = xfer->len / w_size; n_words = xfer->len / w_size;
controller->w_size = 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; mode = QUP_IO_M_MODE_FIFO;
writel_relaxed(n_words, controller->base + QUP_MX_READ_CNT); writel_relaxed(n_words, controller->base + QUP_MX_READ_CNT);
writel_relaxed(n_words, controller->base + QUP_MX_WRITE_CNT); writel_relaxed(n_words, controller->base + QUP_MX_WRITE_CNT);
...@@ -749,7 +749,7 @@ static int spi_qup_remove(struct platform_device *pdev) ...@@ -749,7 +749,7 @@ static int spi_qup_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct of_device_id spi_qup_dt_match[] = { static const struct of_device_id spi_qup_dt_match[] = {
{ .compatible = "qcom,spi-qup-v2.1.1", }, { .compatible = "qcom,spi-qup-v2.1.1", },
{ .compatible = "qcom,spi-qup-v2.2.1", }, { .compatible = "qcom,spi-qup-v2.2.1", },
{ } { }
......
This diff is collapsed.
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
*/ */
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -183,11 +182,11 @@ static int s3c24xx_spi_setup(struct spi_device *spi) ...@@ -183,11 +182,11 @@ static int s3c24xx_spi_setup(struct spi_device *spi)
/* allocate settings on the first call */ /* allocate settings on the first call */
if (!cs) { if (!cs) {
cs = kzalloc(sizeof(struct s3c24xx_spi_devstate), GFP_KERNEL); cs = devm_kzalloc(&spi->dev,
if (!cs) { sizeof(struct s3c24xx_spi_devstate),
dev_err(&spi->dev, "no memory for controller state\n"); GFP_KERNEL);
if (!cs)
return -ENOMEM; return -ENOMEM;
}
cs->spcon = SPCON_DEFAULT; cs->spcon = SPCON_DEFAULT;
cs->hz = -1; cs->hz = -1;
...@@ -209,11 +208,6 @@ static int s3c24xx_spi_setup(struct spi_device *spi) ...@@ -209,11 +208,6 @@ static int s3c24xx_spi_setup(struct spi_device *spi)
return 0; return 0;
} }
static void s3c24xx_spi_cleanup(struct spi_device *spi)
{
kfree(spi->controller_state);
}
static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count) static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count)
{ {
return hw->tx ? hw->tx[count] : 0; return hw->tx ? hw->tx[count] : 0;
...@@ -543,7 +537,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -543,7 +537,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
hw->bitbang.txrx_bufs = s3c24xx_spi_txrx; hw->bitbang.txrx_bufs = s3c24xx_spi_txrx;
hw->master->setup = s3c24xx_spi_setup; hw->master->setup = s3c24xx_spi_setup;
hw->master->cleanup = s3c24xx_spi_cleanup;
dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang); dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/clk.h> #include <linux/clk.h>
...@@ -773,7 +772,6 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( ...@@ -773,7 +772,6 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
cs = kzalloc(sizeof(*cs), GFP_KERNEL); cs = kzalloc(sizeof(*cs), GFP_KERNEL);
if (!cs) { if (!cs) {
dev_err(&spi->dev, "could not allocate memory for controller data\n");
of_node_put(data_np); of_node_put(data_np);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
...@@ -987,10 +985,8 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) ...@@ -987,10 +985,8 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev)
u32 temp; u32 temp;
sci = devm_kzalloc(dev, sizeof(*sci), GFP_KERNEL); sci = devm_kzalloc(dev, sizeof(*sci), GFP_KERNEL);
if (!sci) { if (!sci)
dev_err(dev, "memory allocation for spi_info failed\n");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
}
if (of_property_read_u32(dev->of_node, "samsung,spi-src-clk", &temp)) { if (of_property_read_u32(dev->of_node, "samsung,spi-src-clk", &temp)) {
dev_warn(dev, "spi bus clock parent not specified, using clock at index 0 as parent\n"); dev_warn(dev, "spi bus clock parent not specified, using clock at index 0 as parent\n");
......
...@@ -642,10 +642,8 @@ static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev) ...@@ -642,10 +642,8 @@ static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev)
u32 num_cs = 1; u32 num_cs = 1;
info = devm_kzalloc(dev, sizeof(struct sh_msiof_spi_info), GFP_KERNEL); info = devm_kzalloc(dev, sizeof(struct sh_msiof_spi_info), GFP_KERNEL);
if (!info) { if (!info)
dev_err(dev, "failed to allocate setup data\n");
return NULL; return NULL;
}
/* Parse the MSIOF properties */ /* Parse the MSIOF properties */
of_property_read_u32(np, "num-cs", &num_cs); of_property_read_u32(np, "num-cs", &num_cs);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
......
This diff is collapsed.
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/workqueue.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/workqueue.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
......
...@@ -1012,7 +1012,7 @@ static irqreturn_t tegra_spi_isr(int irq, void *context_data) ...@@ -1012,7 +1012,7 @@ static irqreturn_t tegra_spi_isr(int irq, void *context_data)
return IRQ_WAKE_THREAD; return IRQ_WAKE_THREAD;
} }
static struct of_device_id tegra_spi_of_match[] = { static const struct of_device_id tegra_spi_of_match[] = {
{ .compatible = "nvidia,tegra114-spi", }, { .compatible = "nvidia,tegra114-spi", },
{} {}
}; };
......
...@@ -419,7 +419,7 @@ static irqreturn_t tegra_sflash_isr(int irq, void *context_data) ...@@ -419,7 +419,7 @@ static irqreturn_t tegra_sflash_isr(int irq, void *context_data)
return handle_cpu_based_xfer(tsd); return handle_cpu_based_xfer(tsd);
} }
static struct of_device_id tegra_sflash_of_match[] = { static const struct of_device_id tegra_sflash_of_match[] = {
{ .compatible = "nvidia,tegra20-sflash", }, { .compatible = "nvidia,tegra20-sflash", },
{} {}
}; };
......
...@@ -1001,7 +1001,7 @@ static const struct tegra_slink_chip_data tegra20_spi_cdata = { ...@@ -1001,7 +1001,7 @@ static const struct tegra_slink_chip_data tegra20_spi_cdata = {
.cs_hold_time = false, .cs_hold_time = false,
}; };
static struct of_device_id tegra_slink_of_match[] = { static const struct of_device_id tegra_slink_of_match[] = {
{ .compatible = "nvidia,tegra30-slink", .data = &tegra30_spi_cdata, }, { .compatible = "nvidia,tegra30-slink", .data = &tegra30_spi_cdata, },
{ .compatible = "nvidia,tegra20-slink", .data = &tegra20_spi_cdata, }, { .compatible = "nvidia,tegra20-slink", .data = &tegra20_spi_cdata, },
{} {}
......
...@@ -253,10 +253,8 @@ static int tle62x0_probe(struct spi_device *spi) ...@@ -253,10 +253,8 @@ static int tle62x0_probe(struct spi_device *spi)
} }
st = kzalloc(sizeof(struct tle62x0_state), GFP_KERNEL); st = kzalloc(sizeof(struct tle62x0_state), GFP_KERNEL);
if (st == NULL) { if (st == NULL)
dev_err(&spi->dev, "no memory for device state\n");
return -ENOMEM; return -ENOMEM;
}
st->us = spi; st->us = spi;
st->nr_gpio = pdata->gpio_count; st->nr_gpio = pdata->gpio_count;
......
...@@ -1578,14 +1578,11 @@ static int pch_spi_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1578,14 +1578,11 @@ static int pch_spi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
struct pch_pd_dev_save *pd_dev_save; struct pch_pd_dev_save *pd_dev_save;
pd_dev_save = kzalloc(sizeof(struct pch_pd_dev_save), GFP_KERNEL); pd_dev_save = kzalloc(sizeof(struct pch_pd_dev_save), GFP_KERNEL);
if (!pd_dev_save) { if (!pd_dev_save)
dev_err(&pdev->dev, "%s Can't allocate pd_dev_sav\n", __func__);
return -ENOMEM; return -ENOMEM;
}
board_dat = kzalloc(sizeof(struct pch_spi_board_data), GFP_KERNEL); board_dat = kzalloc(sizeof(struct pch_spi_board_data), GFP_KERNEL);
if (!board_dat) { if (!board_dat) {
dev_err(&pdev->dev, "%s Can't allocate board_dat\n", __func__);
retval = -ENOMEM; retval = -ENOMEM;
goto err_no_mem; goto err_no_mem;
} }
......
...@@ -796,7 +796,7 @@ static int spi_transfer_one_message(struct spi_master *master, ...@@ -796,7 +796,7 @@ static int spi_transfer_one_message(struct spi_master *master,
if (ret > 0) { if (ret > 0) {
ret = 0; ret = 0;
ms = xfer->len * 8 * 1000 / xfer->speed_hz; ms = xfer->len * 8 * 1000 / xfer->speed_hz;
ms += 10; /* some tolerance */ ms += ms + 100; /* some tolerance */
ms = wait_for_completion_timeout(&master->xfer_completion, ms = wait_for_completion_timeout(&master->xfer_completion,
msecs_to_jiffies(ms)); msecs_to_jiffies(ms));
...@@ -1255,6 +1255,8 @@ static void of_register_spi_devices(struct spi_master *master) ...@@ -1255,6 +1255,8 @@ static void of_register_spi_devices(struct spi_master *master)
spi->mode |= SPI_CS_HIGH; spi->mode |= SPI_CS_HIGH;
if (of_find_property(nc, "spi-3wire", NULL)) if (of_find_property(nc, "spi-3wire", NULL))
spi->mode |= SPI_3WIRE; spi->mode |= SPI_3WIRE;
if (of_find_property(nc, "spi-lsb-first", NULL))
spi->mode |= SPI_LSB_FIRST;
/* Device DUAL/QUAD mode */ /* Device DUAL/QUAD mode */
if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) { if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
...@@ -1268,11 +1270,10 @@ static void of_register_spi_devices(struct spi_master *master) ...@@ -1268,11 +1270,10 @@ static void of_register_spi_devices(struct spi_master *master)
spi->mode |= SPI_TX_QUAD; spi->mode |= SPI_TX_QUAD;
break; break;
default: default:
dev_err(&master->dev, dev_warn(&master->dev,
"spi-tx-bus-width %d not supported\n", "spi-tx-bus-width %d not supported\n",
value); value);
spi_dev_put(spi); break;
continue;
} }
} }
...@@ -1287,11 +1288,10 @@ static void of_register_spi_devices(struct spi_master *master) ...@@ -1287,11 +1288,10 @@ static void of_register_spi_devices(struct spi_master *master)
spi->mode |= SPI_RX_QUAD; spi->mode |= SPI_RX_QUAD;
break; break;
default: default:
dev_err(&master->dev, dev_warn(&master->dev,
"spi-rx-bus-width %d not supported\n", "spi-rx-bus-width %d not supported\n",
value); value);
spi_dev_put(spi); break;
continue;
} }
} }
......
/* /*
* Analog Devices SPI3 controller driver * Analog Devices SPI3 controller driver
* *
* Copyright (c) 2011 Analog Devices Inc. * Copyright (c) 2014 Analog Devices Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -11,14 +11,10 @@ ...@@ -11,14 +11,10 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef _SPI_CHANNEL_H_ #ifndef _ADI_SPI3_H_
#define _SPI_CHANNEL_H_ #define _ADI_SPI3_H_
#include <linux/types.h> #include <linux/types.h>
...@@ -209,9 +205,9 @@ ...@@ -209,9 +205,9 @@
#define SPI_ILAT_CLR_TFI 0x00000800 /* Transmit Finish Indication */ #define SPI_ILAT_CLR_TFI 0x00000800 /* Transmit Finish Indication */
/* /*
* bfin spi3 registers layout * adi spi3 registers layout
*/ */
struct bfin_spi_regs { struct adi_spi_regs {
u32 revid; u32 revid;
u32 control; u32 control;
u32 rx_control; u32 rx_control;
...@@ -240,7 +236,7 @@ struct bfin_spi_regs { ...@@ -240,7 +236,7 @@ struct bfin_spi_regs {
#define MAX_CTRL_CS 8 /* cs in spi controller */ #define MAX_CTRL_CS 8 /* cs in spi controller */
/* device.platform_data for SSP controller devices */ /* device.platform_data for SSP controller devices */
struct bfin_spi3_master { struct adi_spi3_master {
u16 num_chipselect; u16 num_chipselect;
u16 pin_req[7]; u16 pin_req[7];
}; };
...@@ -248,11 +244,11 @@ struct bfin_spi3_master { ...@@ -248,11 +244,11 @@ struct bfin_spi3_master {
/* spi_board_info.controller_data for SPI slave devices, /* spi_board_info.controller_data for SPI slave devices,
* copied to spi_device.platform_data ... mostly for dma tuning * copied to spi_device.platform_data ... mostly for dma tuning
*/ */
struct bfin_spi3_chip { struct adi_spi3_chip {
u32 control; u32 control;
u16 cs_chg_udelay; /* Some devices require 16-bit delays */ u16 cs_chg_udelay; /* Some devices require 16-bit delays */
u32 tx_dummy_val; /* tx value for rx only transfer */ u32 tx_dummy_val; /* tx value for rx only transfer */
bool enable_dma; bool enable_dma;
}; };
#endif /* _SPI_CHANNEL_H_ */ #endif /* _ADI_SPI3_H_ */
...@@ -25,8 +25,6 @@ struct rspi_plat_data { ...@@ -25,8 +25,6 @@ struct rspi_plat_data {
unsigned int dma_tx_id; unsigned int dma_tx_id;
unsigned int dma_rx_id; unsigned int dma_rx_id;
unsigned dma_width_16bit:1; /* DMAC read/write width = 16-bit */
u16 num_chipselect; u16 num_chipselect;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment