Skip to content

Commit b88f557

Browse files
committed
Merge tag 'spi-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi updates from Mark Brown: "A fairly quiet release for the SPI subsystem: - Move to using IDR for allocating bus numbers - Modernisation of the ep93xx driver, removing a lot of open coding and using the framework more - The tools have been moved to use the standard tools build system and an install target added (there will be a fairly trivial conflict with tip resulting from the changes in the main tools Makefile) - A refactoring of the Qualcomm QUP driver which enables new variants to be supported - Explicit support for the Freescale i.MX53 and i.MX6 SPI, Renesas R-Car H3 and Rockchip RV1108 controllers" * tag 'spi-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (71 commits) spi: spi-falcon: drop check of boot select spi: imx: fix use of native chip-selects with devicetree spi: pl022: constify amba_id spi: imx: fix little-endian build spi: omap: Allocate bus number from spi framework spi: Kernel coding style fixes spi: imx: dynamic burst length adjust for PIO mode spi: Pick spi bus number from Linux idr or spi alias spi: rockchip: configure CTRLR1 according to size and data frame spi: altera: Consolidate TX/RX data register access spi: altera: Switch to SPI core transfer queue management spi: rockchip: add compatible string for rv1108 spi spi: qup: fix 64-bit build warning spi: qup: hide warning for uninitialized variable spi: spi-ep93xx: use the default master transfer queueing mechanism spi: spi-ep93xx: remove private data 'current_msg' spi: spi-ep93xx: pass the spi_master pointer around spi: spi-ep93xx: absorb the interrupt enable/disable helpers spi: spi-ep93xx: add spi master prepare_transfer_hardware() spi: spi-ep93xx: use 32-bit read/write for all registers ...
2 parents 16a832a + ecb478b commit b88f557

34 files changed

+1126
-828
lines changed

Documentation/devicetree/bindings/spi/fsl-imx-cspi.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Required properties:
99
- "fsl,imx31-cspi" for SPI compatible with the one integrated on i.MX31
1010
- "fsl,imx35-cspi" for SPI compatible with the one integrated on i.MX35
1111
- "fsl,imx51-ecspi" for SPI compatible with the one integrated on i.MX51
12+
- "fsl,imx53-ecspi" for SPI compatible with the one integrated on i.MX53 and later Soc
1213
- reg : Offset and length of the register set for the device
1314
- interrupts : Should contain CSPI/eCSPI interrupt
1415
- cs-gpios : Specifies the gpio pins to be used for chipselects.

Documentation/devicetree/bindings/spi/sh-msiof.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Required properties:
66
"renesas,msiof-r8a7792" (R-Car V2H)
77
"renesas,msiof-r8a7793" (R-Car M2-N)
88
"renesas,msiof-r8a7794" (R-Car E2)
9+
"renesas,msiof-r8a7795" (R-Car H3)
910
"renesas,msiof-r8a7796" (R-Car M3-W)
1011
"renesas,msiof-sh73a0" (SH-Mobile AG5)
1112
"renesas,sh-mobile-msiof" (generic SH-Mobile compatibile device)

Documentation/devicetree/bindings/spi/spi-rockchip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and display controllers using the SPI communication interface.
66
Required Properties:
77

88
- compatible: should be one of the following.
9+
"rockchip,rv1108-spi" for rv1108 SoCs.
910
"rockchip,rk3036-spi" for rk3036 SoCS.
1011
"rockchip,rk3066-spi" for rk3066 SoCs.
1112
"rockchip,rk3188-spi" for rk3188 SoCs.

drivers/spi/Kconfig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ comment "SPI Master Controller Drivers"
5555

5656
config SPI_ALTERA
5757
tristate "Altera SPI Controller"
58-
select SPI_BITBANG
5958
help
6059
This is the driver for the Altera SPI Controller.
6160

@@ -518,8 +517,8 @@ config SPI_PPC4xx
518517

519518
config SPI_PXA2XX
520519
tristate "PXA2xx SSP SPI master"
521-
depends on (ARCH_PXA || PCI || ACPI)
522-
select PXA_SSP if ARCH_PXA
520+
depends on (ARCH_PXA || ARCH_MMP || PCI || ACPI)
521+
select PXA_SSP if ARCH_PXA || ARCH_MMP
523522
help
524523
This enables using a PXA2xx or Sodaville SSP port as a SPI master
525524
controller. The driver can be configured to use any SSP port and

drivers/spi/spi-altera.c

Lines changed: 59 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/module.h>
1919
#include <linux/platform_device.h>
2020
#include <linux/spi/spi.h>
21-
#include <linux/spi/spi_bitbang.h>
2221
#include <linux/io.h>
2322
#include <linux/of.h>
2423

@@ -45,10 +44,6 @@
4544
#define ALTERA_SPI_CONTROL_SSO_MSK 0x400
4645

4746
struct altera_spi {
48-
/* bitbang has to be first */
49-
struct spi_bitbang bitbang;
50-
struct completion done;
51-
5247
void __iomem *base;
5348
int irq;
5449
int len;
@@ -66,59 +61,64 @@ static inline struct altera_spi *altera_spi_to_hw(struct spi_device *sdev)
6661
return spi_master_get_devdata(sdev->master);
6762
}
6863

69-
static void altera_spi_chipsel(struct spi_device *spi, int value)
64+
static void altera_spi_set_cs(struct spi_device *spi, bool is_high)
7065
{
7166
struct altera_spi *hw = altera_spi_to_hw(spi);
7267

73-
if (spi->mode & SPI_CS_HIGH) {
74-
switch (value) {
75-
case BITBANG_CS_INACTIVE:
76-
writel(1 << spi->chip_select,
77-
hw->base + ALTERA_SPI_SLAVE_SEL);
78-
hw->imr |= ALTERA_SPI_CONTROL_SSO_MSK;
79-
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
80-
break;
81-
82-
case BITBANG_CS_ACTIVE:
83-
hw->imr &= ~ALTERA_SPI_CONTROL_SSO_MSK;
84-
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
85-
writel(0, hw->base + ALTERA_SPI_SLAVE_SEL);
86-
break;
87-
}
68+
if (is_high) {
69+
hw->imr &= ~ALTERA_SPI_CONTROL_SSO_MSK;
70+
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
71+
writel(0, hw->base + ALTERA_SPI_SLAVE_SEL);
8872
} else {
89-
switch (value) {
90-
case BITBANG_CS_INACTIVE:
91-
hw->imr &= ~ALTERA_SPI_CONTROL_SSO_MSK;
92-
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
93-
break;
73+
writel(BIT(spi->chip_select), hw->base + ALTERA_SPI_SLAVE_SEL);
74+
hw->imr |= ALTERA_SPI_CONTROL_SSO_MSK;
75+
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
76+
}
77+
}
78+
79+
static void altera_spi_tx_word(struct altera_spi *hw)
80+
{
81+
unsigned int txd = 0;
9482

95-
case BITBANG_CS_ACTIVE:
96-
writel(1 << spi->chip_select,
97-
hw->base + ALTERA_SPI_SLAVE_SEL);
98-
hw->imr |= ALTERA_SPI_CONTROL_SSO_MSK;
99-
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
83+
if (hw->tx) {
84+
switch (hw->bytes_per_word) {
85+
case 1:
86+
txd = hw->tx[hw->count];
87+
break;
88+
case 2:
89+
txd = (hw->tx[hw->count * 2]
90+
| (hw->tx[hw->count * 2 + 1] << 8));
10091
break;
10192
}
10293
}
94+
95+
writel(txd, hw->base + ALTERA_SPI_TXDATA);
10396
}
10497

105-
static inline unsigned int hw_txbyte(struct altera_spi *hw, int count)
98+
static void altera_spi_rx_word(struct altera_spi *hw)
10699
{
107-
if (hw->tx) {
100+
unsigned int rxd;
101+
102+
rxd = readl(hw->base + ALTERA_SPI_RXDATA);
103+
if (hw->rx) {
108104
switch (hw->bytes_per_word) {
109105
case 1:
110-
return hw->tx[count];
106+
hw->rx[hw->count] = rxd;
107+
break;
111108
case 2:
112-
return (hw->tx[count * 2]
113-
| (hw->tx[count * 2 + 1] << 8));
109+
hw->rx[hw->count * 2] = rxd;
110+
hw->rx[hw->count * 2 + 1] = rxd >> 8;
111+
break;
114112
}
115113
}
116-
return 0;
114+
115+
hw->count++;
117116
}
118117

119-
static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
118+
static int altera_spi_txrx(struct spi_master *master,
119+
struct spi_device *spi, struct spi_transfer *t)
120120
{
121-
struct altera_spi *hw = altera_spi_to_hw(spi);
121+
struct altera_spi *hw = spi_master_get_devdata(master);
122122

123123
hw->tx = t->tx_buf;
124124
hw->rx = t->rx_buf;
@@ -132,67 +132,39 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
132132
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
133133

134134
/* send the first byte */
135-
writel(hw_txbyte(hw, 0), hw->base + ALTERA_SPI_TXDATA);
136-
137-
wait_for_completion(&hw->done);
138-
/* disable receive interrupt */
139-
hw->imr &= ~ALTERA_SPI_CONTROL_IRRDY_MSK;
140-
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
135+
altera_spi_tx_word(hw);
141136
} else {
142137
while (hw->count < hw->len) {
143-
unsigned int rxd;
144-
145-
writel(hw_txbyte(hw, hw->count),
146-
hw->base + ALTERA_SPI_TXDATA);
138+
altera_spi_tx_word(hw);
147139

148140
while (!(readl(hw->base + ALTERA_SPI_STATUS) &
149141
ALTERA_SPI_STATUS_RRDY_MSK))
150142
cpu_relax();
151143

152-
rxd = readl(hw->base + ALTERA_SPI_RXDATA);
153-
if (hw->rx) {
154-
switch (hw->bytes_per_word) {
155-
case 1:
156-
hw->rx[hw->count] = rxd;
157-
break;
158-
case 2:
159-
hw->rx[hw->count * 2] = rxd;
160-
hw->rx[hw->count * 2 + 1] = rxd >> 8;
161-
break;
162-
}
163-
}
164-
165-
hw->count++;
144+
altera_spi_rx_word(hw);
166145
}
146+
spi_finalize_current_transfer(master);
167147
}
168148

169-
return hw->count * hw->bytes_per_word;
149+
return t->len;
170150
}
171151

172152
static irqreturn_t altera_spi_irq(int irq, void *dev)
173153
{
174-
struct altera_spi *hw = dev;
175-
unsigned int rxd;
154+
struct spi_master *master = dev;
155+
struct altera_spi *hw = spi_master_get_devdata(master);
176156

177-
rxd = readl(hw->base + ALTERA_SPI_RXDATA);
178-
if (hw->rx) {
179-
switch (hw->bytes_per_word) {
180-
case 1:
181-
hw->rx[hw->count] = rxd;
182-
break;
183-
case 2:
184-
hw->rx[hw->count * 2] = rxd;
185-
hw->rx[hw->count * 2 + 1] = rxd >> 8;
186-
break;
187-
}
188-
}
157+
altera_spi_rx_word(hw);
189158

190-
hw->count++;
159+
if (hw->count < hw->len) {
160+
altera_spi_tx_word(hw);
161+
} else {
162+
/* disable receive interrupt */
163+
hw->imr &= ~ALTERA_SPI_CONTROL_IRRDY_MSK;
164+
writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
191165

192-
if (hw->count < hw->len)
193-
writel(hw_txbyte(hw, hw->count), hw->base + ALTERA_SPI_TXDATA);
194-
else
195-
complete(&hw->done);
166+
spi_finalize_current_transfer(master);
167+
}
196168

197169
return IRQ_HANDLED;
198170
}
@@ -214,14 +186,10 @@ static int altera_spi_probe(struct platform_device *pdev)
214186
master->mode_bits = SPI_CS_HIGH;
215187
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 16);
216188
master->dev.of_node = pdev->dev.of_node;
189+
master->transfer_one = altera_spi_txrx;
190+
master->set_cs = altera_spi_set_cs;
217191

218192
hw = spi_master_get_devdata(master);
219-
platform_set_drvdata(pdev, hw);
220-
221-
/* setup the state for the bitbang driver */
222-
hw->bitbang.master = master;
223-
hw->bitbang.chipselect = altera_spi_chipsel;
224-
hw->bitbang.txrx_bufs = altera_spi_txrx;
225193

226194
/* find and map our resources */
227195
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -239,15 +207,13 @@ static int altera_spi_probe(struct platform_device *pdev)
239207
/* irq is optional */
240208
hw->irq = platform_get_irq(pdev, 0);
241209
if (hw->irq >= 0) {
242-
init_completion(&hw->done);
243210
err = devm_request_irq(&pdev->dev, hw->irq, altera_spi_irq, 0,
244-
pdev->name, hw);
211+
pdev->name, master);
245212
if (err)
246213
goto exit;
247214
}
248215

249-
/* register our spi controller */
250-
err = spi_bitbang_start(&hw->bitbang);
216+
err = devm_spi_register_master(&pdev->dev, master);
251217
if (err)
252218
goto exit;
253219
dev_info(&pdev->dev, "base %p, irq %d\n", hw->base, hw->irq);
@@ -258,16 +224,6 @@ static int altera_spi_probe(struct platform_device *pdev)
258224
return err;
259225
}
260226

261-
static int altera_spi_remove(struct platform_device *dev)
262-
{
263-
struct altera_spi *hw = platform_get_drvdata(dev);
264-
struct spi_master *master = hw->bitbang.master;
265-
266-
spi_bitbang_stop(&hw->bitbang);
267-
spi_master_put(master);
268-
return 0;
269-
}
270-
271227
#ifdef CONFIG_OF
272228
static const struct of_device_id altera_spi_match[] = {
273229
{ .compatible = "ALTR,spi-1.0", },
@@ -279,7 +235,6 @@ MODULE_DEVICE_TABLE(of, altera_spi_match);
279235

280236
static struct platform_driver altera_spi_driver = {
281237
.probe = altera_spi_probe,
282-
.remove = altera_spi_remove,
283238
.driver = {
284239
.name = DRV_NAME,
285240
.pm = NULL,

drivers/spi/spi-ath79.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ struct ath79_spi {
3939
u32 reg_ctrl;
4040
void __iomem *base;
4141
struct clk *clk;
42-
unsigned rrw_delay;
42+
unsigned int rrw_delay;
4343
};
4444

45-
static inline u32 ath79_spi_rr(struct ath79_spi *sp, unsigned reg)
45+
static inline u32 ath79_spi_rr(struct ath79_spi *sp, unsigned int reg)
4646
{
4747
return ioread32(sp->base + reg);
4848
}
4949

50-
static inline void ath79_spi_wr(struct ath79_spi *sp, unsigned reg, u32 val)
50+
static inline void ath79_spi_wr(struct ath79_spi *sp, unsigned int reg, u32 val)
5151
{
5252
iowrite32(val, sp->base + reg);
5353
}
@@ -57,7 +57,7 @@ static inline struct ath79_spi *ath79_spidev_to_sp(struct spi_device *spi)
5757
return spi_master_get_devdata(spi->master);
5858
}
5959

60-
static inline void ath79_spi_delay(struct ath79_spi *sp, unsigned nsecs)
60+
static inline void ath79_spi_delay(struct ath79_spi *sp, unsigned int nsecs)
6161
{
6262
if (nsecs > sp->rrw_delay)
6363
ndelay(nsecs - sp->rrw_delay);
@@ -148,9 +148,8 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
148148

149149
static void ath79_spi_cleanup_cs(struct spi_device *spi)
150150
{
151-
if (gpio_is_valid(spi->cs_gpio)) {
151+
if (gpio_is_valid(spi->cs_gpio))
152152
gpio_free(spi->cs_gpio);
153-
}
154153
}
155154

156155
static int ath79_spi_setup(struct spi_device *spi)
@@ -176,7 +175,7 @@ static void ath79_spi_cleanup(struct spi_device *spi)
176175
spi_bitbang_cleanup(spi);
177176
}
178177

179-
static u32 ath79_spi_txrx_mode0(struct spi_device *spi, unsigned nsecs,
178+
static u32 ath79_spi_txrx_mode0(struct spi_device *spi, unsigned int nsecs,
180179
u32 word, u8 bits)
181180
{
182181
struct ath79_spi *sp = ath79_spidev_to_sp(spi);

0 commit comments

Comments
 (0)