Skip to content

Commit 3aad3f0

Browse files
committed
Merge tag 'spi-for-linus' of git://git.secretlab.ca/git/linux
Pull SPI changes from Grant Likely: "Changes to both core spi code and spi device drivers. The driver changes are the usual set of bug fixes and platform enablement. Core code changes include: - More intelligent assignment of SPI bus numbers when using DT - Common mechanism for using gpios as CS lines - Pull checks for bits_per_word and transfer speed out of drivers and into core code - Ensure temporary DMA buffers are DMA safe" * tag 'spi-for-linus' of git://git.secretlab.ca/git/linux: (50 commits) spi: Document cs_gpios and cs_gpio in kernel-doc spi/of: Fix initialization of cs_gpios array spi/pxa2xx: add support for Lynxpoint SPI controllers spi/pxa2xx: add support for Intel Low Power Subsystem SPI spi/pxa2xx: add support for SPI_LOOP spi/pxa2xx: add support for runtime PM spi/pxa2xx: add support for DMA engine spi/pxa2xx: break out the private DMA API usage into a separate file spi/ath79: add shutdown handler spi/mips-lantiq: set SPI_MASTER_HALF_DUPLEX flag spi/mips-lantiq: make use of spi_finalize_current_message spi/bcm63xx: work around inability to keep CS up spi/davinci: use request_threaded_irq() to fix deadlock spi/orion: Use module_platform_driver() spi/bcm63xx: reject transfers unable to transfer spi: Ensure memory used for spi_write_then_read() is DMA safe spi/spi-mpc512x-psc: init mode bits supported by the driver spi/mpc512x-psc: don't use obsolet cell-index property spi: Remove erroneous __init, __exit and __exit_p() references in drivers spi/s3c64xx: fix checkpatch warnings and error ...
2 parents 10b6339 + 095c375 commit 3aad3f0

43 files changed

Lines changed: 2078 additions & 1237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Renesas MSIOF spi controller
2+
3+
Required properties:
4+
- compatible : "renesas,sh-msiof" for SuperH or
5+
"renesas,sh-mobile-msiof" for SH Mobile series
6+
- reg : Offset and length of the register set for the device
7+
- interrupts : interrupt line used by MSIOF
8+
9+
Optional properties:
10+
- num-cs : total number of chip-selects
11+
- renesas,tx-fifo-size : Overrides the default tx fifo size given in words
12+
- renesas,rx-fifo-size : Overrides the default rx fifo size given in words

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7168,6 +7168,7 @@ F: drivers/clk/spear/
71687168

71697169
SPI SUBSYSTEM
71707170
M: Grant Likely <grant.likely@secretlab.ca>
7171+
M: Mark Brown <broonie@opensource.wolfsonmicro.com>
71717172
L: spi-devel-general@lists.sourceforge.net
71727173
Q: http://patchwork.kernel.org/project/spi-devel-general/list/
71737174
T: git git://git.secretlab.ca/git/linux-2.6.git

drivers/spi/Kconfig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,28 @@ config SPI_PPC4xx
297297
help
298298
This selects a driver for the PPC4xx SPI Controller.
299299

300+
config SPI_PXA2XX_PXADMA
301+
bool "PXA2xx SSP legacy PXA DMA API support"
302+
depends on SPI_PXA2XX && ARCH_PXA
303+
help
304+
Enable PXA private legacy DMA API support. Note that this is
305+
deprecated in favor of generic DMA engine API.
306+
307+
config SPI_PXA2XX_DMA
308+
def_bool y
309+
depends on SPI_PXA2XX && !SPI_PXA2XX_PXADMA
310+
300311
config SPI_PXA2XX
301312
tristate "PXA2xx SSP SPI master"
302-
depends on (ARCH_PXA || (X86_32 && PCI)) && EXPERIMENTAL
313+
depends on ARCH_PXA || PCI || ACPI
303314
select PXA_SSP if ARCH_PXA
304315
help
305316
This enables using a PXA2xx or Sodaville SSP port as a SPI master
306317
controller. The driver can be configured to use any SSP port and
307318
additional documentation can be found a Documentation/spi/pxa2xx.
308319

309320
config SPI_PXA2XX_PCI
310-
def_bool SPI_PXA2XX && X86_32 && PCI
321+
def_tristate SPI_PXA2XX && PCI
311322

312323
config SPI_RSPI
313324
tristate "Renesas RSPI controller"

drivers/spi/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ obj-$(CONFIG_SPI_OMAP24XX) += spi-omap2-mcspi.o
4747
obj-$(CONFIG_SPI_ORION) += spi-orion.o
4848
obj-$(CONFIG_SPI_PL022) += spi-pl022.o
4949
obj-$(CONFIG_SPI_PPC4xx) += spi-ppc4xx.o
50-
obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx.o
50+
spi-pxa2xx-platform-objs := spi-pxa2xx.o
51+
spi-pxa2xx-platform-$(CONFIG_SPI_PXA2XX_PXADMA) += spi-pxa2xx-pxadma.o
52+
spi-pxa2xx-platform-$(CONFIG_SPI_PXA2XX_DMA) += spi-pxa2xx-dma.o
53+
obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx-platform.o
5154
obj-$(CONFIG_SPI_PXA2XX_PCI) += spi-pxa2xx-pci.o
5255
obj-$(CONFIG_SPI_RSPI) += spi-rspi.o
5356
obj-$(CONFIG_SPI_S3C24XX) += spi-s3c24xx-hw.o

drivers/spi/spi-altera.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static int altera_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
134134
hw->tx = t->tx_buf;
135135
hw->rx = t->rx_buf;
136136
hw->count = 0;
137-
hw->bytes_per_word = (t->bits_per_word ? : spi->bits_per_word) / 8;
137+
hw->bytes_per_word = t->bits_per_word / 8;
138138
hw->len = t->len / hw->bytes_per_word;
139139

140140
if (hw->irq >= 0) {

drivers/spi/spi-ath79.c

Lines changed: 83 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,24 @@
2424
#include <linux/spi/spi_bitbang.h>
2525
#include <linux/bitops.h>
2626
#include <linux/gpio.h>
27+
#include <linux/clk.h>
28+
#include <linux/err.h>
2729

2830
#include <asm/mach-ath79/ar71xx_regs.h>
2931
#include <asm/mach-ath79/ath79_spi_platform.h>
3032

3133
#define DRV_NAME "ath79-spi"
3234

35+
#define ATH79_SPI_RRW_DELAY_FACTOR 12000
36+
#define MHZ (1000 * 1000)
37+
3338
struct ath79_spi {
3439
struct spi_bitbang bitbang;
3540
u32 ioc_base;
3641
u32 reg_ctrl;
3742
void __iomem *base;
43+
struct clk *clk;
44+
unsigned rrw_delay;
3845
};
3946

4047
static inline u32 ath79_spi_rr(struct ath79_spi *sp, unsigned reg)
@@ -52,6 +59,12 @@ static inline struct ath79_spi *ath79_spidev_to_sp(struct spi_device *spi)
5259
return spi_master_get_devdata(spi->master);
5360
}
5461

62+
static inline void ath79_spi_delay(struct ath79_spi *sp, unsigned nsecs)
63+
{
64+
if (nsecs > sp->rrw_delay)
65+
ndelay(nsecs - sp->rrw_delay);
66+
}
67+
5568
static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
5669
{
5770
struct ath79_spi *sp = ath79_spidev_to_sp(spi);
@@ -83,15 +96,8 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
8396

8497
}
8598

86-
static int ath79_spi_setup_cs(struct spi_device *spi)
99+
static void ath79_spi_enable(struct ath79_spi *sp)
87100
{
88-
struct ath79_spi *sp = ath79_spidev_to_sp(spi);
89-
struct ath79_spi_controller_data *cdata;
90-
91-
cdata = spi->controller_data;
92-
if (spi->chip_select && !cdata)
93-
return -EINVAL;
94-
95101
/* enable GPIO mode */
96102
ath79_spi_wr(sp, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
97103

@@ -101,44 +107,48 @@ static int ath79_spi_setup_cs(struct spi_device *spi)
101107

102108
/* TODO: setup speed? */
103109
ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, 0x43);
110+
}
104111

105-
if (spi->chip_select) {
106-
int status = 0;
112+
static void ath79_spi_disable(struct ath79_spi *sp)
113+
{
114+
/* restore CTRL register */
115+
ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, sp->reg_ctrl);
116+
/* disable GPIO mode */
117+
ath79_spi_wr(sp, AR71XX_SPI_REG_FS, 0);
118+
}
107119

108-
status = gpio_request(cdata->gpio, dev_name(&spi->dev));
109-
if (status)
110-
return status;
120+
static int ath79_spi_setup_cs(struct spi_device *spi)
121+
{
122+
struct ath79_spi_controller_data *cdata;
123+
int status;
111124

112-
status = gpio_direction_output(cdata->gpio,
113-
spi->mode & SPI_CS_HIGH);
114-
if (status) {
115-
gpio_free(cdata->gpio);
116-
return status;
117-
}
118-
} else {
125+
cdata = spi->controller_data;
126+
if (spi->chip_select && !cdata)
127+
return -EINVAL;
128+
129+
status = 0;
130+
if (spi->chip_select) {
131+
unsigned long flags;
132+
133+
flags = GPIOF_DIR_OUT;
119134
if (spi->mode & SPI_CS_HIGH)
120-
sp->ioc_base |= AR71XX_SPI_IOC_CS0;
135+
flags |= GPIOF_INIT_HIGH;
121136
else
122-
sp->ioc_base &= ~AR71XX_SPI_IOC_CS0;
123-
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
137+
flags |= GPIOF_INIT_LOW;
138+
139+
status = gpio_request_one(cdata->gpio, flags,
140+
dev_name(&spi->dev));
124141
}
125142

126-
return 0;
143+
return status;
127144
}
128145

129146
static void ath79_spi_cleanup_cs(struct spi_device *spi)
130147
{
131-
struct ath79_spi *sp = ath79_spidev_to_sp(spi);
132-
133148
if (spi->chip_select) {
134149
struct ath79_spi_controller_data *cdata = spi->controller_data;
135150
gpio_free(cdata->gpio);
136151
}
137-
138-
/* restore CTRL register */
139-
ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, sp->reg_ctrl);
140-
/* disable GPIO mode */
141-
ath79_spi_wr(sp, AR71XX_SPI_REG_FS, 0);
142152
}
143153

144154
static int ath79_spi_setup(struct spi_device *spi)
@@ -184,7 +194,11 @@ static u32 ath79_spi_txrx_mode0(struct spi_device *spi, unsigned nsecs,
184194

185195
/* setup MSB (to slave) on trailing edge */
186196
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, out);
197+
ath79_spi_delay(sp, nsecs);
187198
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, out | AR71XX_SPI_IOC_CLK);
199+
ath79_spi_delay(sp, nsecs);
200+
if (bits == 1)
201+
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, out);
188202

189203
word <<= 1;
190204
}
@@ -198,6 +212,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
198212
struct ath79_spi *sp;
199213
struct ath79_spi_platform_data *pdata;
200214
struct resource *r;
215+
unsigned long rate;
201216
int ret;
202217

203218
master = spi_alloc_master(&pdev->dev, sizeof(*sp));
@@ -236,12 +251,39 @@ static int ath79_spi_probe(struct platform_device *pdev)
236251
goto err_put_master;
237252
}
238253

254+
sp->clk = clk_get(&pdev->dev, "ahb");
255+
if (IS_ERR(sp->clk)) {
256+
ret = PTR_ERR(sp->clk);
257+
goto err_unmap;
258+
}
259+
260+
ret = clk_enable(sp->clk);
261+
if (ret)
262+
goto err_clk_put;
263+
264+
rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ);
265+
if (!rate) {
266+
ret = -EINVAL;
267+
goto err_clk_disable;
268+
}
269+
270+
sp->rrw_delay = ATH79_SPI_RRW_DELAY_FACTOR / rate;
271+
dev_dbg(&pdev->dev, "register read/write delay is %u nsecs\n",
272+
sp->rrw_delay);
273+
274+
ath79_spi_enable(sp);
239275
ret = spi_bitbang_start(&sp->bitbang);
240276
if (ret)
241-
goto err_unmap;
277+
goto err_disable;
242278

243279
return 0;
244280

281+
err_disable:
282+
ath79_spi_disable(sp);
283+
err_clk_disable:
284+
clk_disable(sp->clk);
285+
err_clk_put:
286+
clk_put(sp->clk);
245287
err_unmap:
246288
iounmap(sp->base);
247289
err_put_master:
@@ -256,16 +298,25 @@ static int ath79_spi_remove(struct platform_device *pdev)
256298
struct ath79_spi *sp = platform_get_drvdata(pdev);
257299

258300
spi_bitbang_stop(&sp->bitbang);
301+
ath79_spi_disable(sp);
302+
clk_disable(sp->clk);
303+
clk_put(sp->clk);
259304
iounmap(sp->base);
260305
platform_set_drvdata(pdev, NULL);
261306
spi_master_put(sp->bitbang.master);
262307

263308
return 0;
264309
}
265310

311+
static void ath79_spi_shutdown(struct platform_device *pdev)
312+
{
313+
ath79_spi_remove(pdev);
314+
}
315+
266316
static struct platform_driver ath79_spi_driver = {
267317
.probe = ath79_spi_probe,
268318
.remove = ath79_spi_remove,
319+
.shutdown = ath79_spi_shutdown,
269320
.driver = {
270321
.name = DRV_NAME,
271322
.owner = THIS_MODULE,

drivers/spi/spi-atmel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ static struct platform_driver atmel_spi_driver = {
10881088
.suspend = atmel_spi_suspend,
10891089
.resume = atmel_spi_resume,
10901090
.probe = atmel_spi_probe,
1091-
.remove = __exit_p(atmel_spi_remove),
1091+
.remove = atmel_spi_remove,
10921092
};
10931093
module_platform_driver(atmel_spi_driver);
10941094

drivers/spi/spi-au1550.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ static void au1550_spi_bits_handlers_set(struct au1550_spi *hw, int bpw)
717717
}
718718
}
719719

720-
static void __init au1550_spi_setup_psc_as_spi(struct au1550_spi *hw)
720+
static void au1550_spi_setup_psc_as_spi(struct au1550_spi *hw)
721721
{
722722
u32 stat, cfg;
723723

@@ -766,7 +766,7 @@ static void __init au1550_spi_setup_psc_as_spi(struct au1550_spi *hw)
766766
}
767767

768768

769-
static int __init au1550_spi_probe(struct platform_device *pdev)
769+
static int au1550_spi_probe(struct platform_device *pdev)
770770
{
771771
struct au1550_spi *hw;
772772
struct spi_master *master;
@@ -968,7 +968,7 @@ static int __init au1550_spi_probe(struct platform_device *pdev)
968968
return err;
969969
}
970970

971-
static int __exit au1550_spi_remove(struct platform_device *pdev)
971+
static int au1550_spi_remove(struct platform_device *pdev)
972972
{
973973
struct au1550_spi *hw = platform_get_drvdata(pdev);
974974

@@ -997,7 +997,7 @@ static int __exit au1550_spi_remove(struct platform_device *pdev)
997997
MODULE_ALIAS("platform:au1550-spi");
998998

999999
static struct platform_driver au1550_spi_drv = {
1000-
.remove = __exit_p(au1550_spi_remove),
1000+
.remove = au1550_spi_remove,
10011001
.driver = {
10021002
.name = "au1550-spi",
10031003
.owner = THIS_MODULE,

0 commit comments

Comments
 (0)