Commit 2d2e7d19 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'spi-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "A respun version of the merges for the pull request previously sent
  with a few additional fixes.  The last two merges were fixed up by
  hand since the branches have moved on and currently have the prior
  merge in them.

  Quite a busy release for the SPI subsystem, mostly in cleanups big and
  small scattered through the stack rather than anything else:

   - New driver for the Broadcom BC63xx HSSPI controller
   - Fix duplicate device registration for ACPI
   - Conversion of s3c64xx to DMAEngine (this pulls in platform and DMA
     changes upon which the transiton depends)
   - Some small optimisations to reduce the amount of time we hold locks
     in the datapath, eliminate some redundant checks and the size of a
     spi_transfer
   - Lots of fixes, cleanups and general enhancements to drivers,
     especially the rspi and Atmel drivers"

* tag 'spi-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (112 commits)
  spi: core: Fix transfer failure when master->transfer_one returns positive value
  spi: Correct set_cs() documentation
  spi: Clarify transfer_one() w.r.t. spi_finalize_current_transfer()
  spi: Spelling s/finised/finished/
  spi: sc18is602: Convert to use bits_per_word_mask
  spi: Remove duplicate code to set default bits_per_word setting
  spi/pxa2xx: fix compilation warning when !CONFIG_PM_SLEEP
  spi: clps711x: Add MODULE_ALIAS to support module auto-loading
  spi: rspi: Add missing clk_disable() calls in error and cleanup paths
  spi: rspi: Spelling s/transmition/transmission/
  spi: rspi: Add support for specifying CPHA/CPOL
  spi/pxa2xx: initialize DMA channels to -1 to prevent inadvertent match
  spi: rspi: Add more QSPI register documentation
  spi: rspi: Add more RSPI register documentation
  spi: rspi: Remove dependency on DMAE for SHMOBILE
  spi/s3c64xx: Correct indentation
  spi: sh: Use spi_sh_clear_bit() instead of open-coded
  spi: bitbang: Grammar s/make to make/to make/
  spi: sh-hspi: Spelling s/recive/receive/
  spi: core: Improve tx/rx_nbits check comments
  ...
parents 15333539 8b8b773e
...@@ -67,7 +67,7 @@ only 1(SINGLE), 2(DUAL) and 4(QUAD). ...@@ -67,7 +67,7 @@ only 1(SINGLE), 2(DUAL) and 4(QUAD).
Dual/Quad mode is not allowed when 3-wire mode is used. Dual/Quad mode is not allowed when 3-wire mode is used.
If a gpio chipselect is used for the SPI slave the gpio number will be passed If a gpio chipselect is used for the SPI slave the gpio number will be passed
via the cs_gpio via the SPI master node cs-gpios property.
SPI example for an MPC5200 SPI bus: SPI example for an MPC5200 SPI bus:
spi@f00 { spi@f00 {
......
...@@ -3,6 +3,11 @@ TI QSPI controller. ...@@ -3,6 +3,11 @@ TI QSPI controller.
Required properties: Required properties:
- compatible : should be "ti,dra7xxx-qspi" or "ti,am4372-qspi". - compatible : should be "ti,dra7xxx-qspi" or "ti,am4372-qspi".
- reg: Should contain QSPI registers location and length. - reg: Should contain QSPI registers location and length.
- reg-names: Should contain the resource reg names.
- qspi_base: Qspi configuration register Address space
- qspi_mmap: Memory mapped Address space
- (optional) qspi_ctrlmod: Control module Address space
- interrupts: should contain the qspi interrupt number.
- #address-cells, #size-cells : Must be present if the device has sub-nodes - #address-cells, #size-cells : Must be present if the device has sub-nodes
- ti,hwmods: Name of the hwmod associated to the QSPI - ti,hwmods: Name of the hwmod associated to the QSPI
...@@ -14,7 +19,8 @@ Example: ...@@ -14,7 +19,8 @@ Example:
qspi: qspi@4b300000 { qspi: qspi@4b300000 {
compatible = "ti,dra7xxx-qspi"; compatible = "ti,dra7xxx-qspi";
reg = <0x4b300000 0x100>; reg = <0x47900000 0x100>, <0x30000000 0x3ffffff>;
reg-names = "qspi_base", "qspi_mmap";
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
spi-max-frequency = <25000000>; spi-max-frequency = <25000000>;
......
...@@ -34,7 +34,7 @@ SPI slave functions are usually not interoperable between vendors ...@@ -34,7 +34,7 @@ SPI slave functions are usually not interoperable between vendors
- It may also be used to stream data in either direction (half duplex), - It may also be used to stream data in either direction (half duplex),
or both of them at the same time (full duplex). or both of them at the same time (full duplex).
- Some devices may use eight bit words. Others may different word - Some devices may use eight bit words. Others may use different word
lengths, such as streams of 12-bit or 20-bit digital samples. lengths, such as streams of 12-bit or 20-bit digital samples.
- Words are usually sent with their most significant bit (MSB) first, - Words are usually sent with their most significant bit (MSB) first,
...@@ -121,7 +121,7 @@ active. So the master must set the clock to inactive before selecting ...@@ -121,7 +121,7 @@ active. So the master must set the clock to inactive before selecting
a slave, and the slave can tell the chosen polarity by sampling the a slave, and the slave can tell the chosen polarity by sampling the
clock level when its select line goes active. That's why many devices clock level when its select line goes active. That's why many devices
support for example both modes 0 and 3: they don't care about polarity, support for example both modes 0 and 3: they don't care about polarity,
and alway clock data in/out on rising clock edges. and always clock data in/out on rising clock edges.
How do these driver programming interfaces work? How do these driver programming interfaces work?
...@@ -139,7 +139,7 @@ a command and then reading its response. ...@@ -139,7 +139,7 @@ a command and then reading its response.
There are two types of SPI driver, here called: There are two types of SPI driver, here called:
Controller drivers ... controllers may be built in to System-On-Chip Controller drivers ... controllers may be built into System-On-Chip
processors, and often support both Master and Slave roles. processors, and often support both Master and Slave roles.
These drivers touch hardware registers and may use DMA. These drivers touch hardware registers and may use DMA.
Or they can be PIO bitbangers, needing just GPIO pins. Or they can be PIO bitbangers, needing just GPIO pins.
...@@ -548,7 +548,7 @@ SPI MASTER METHODS ...@@ -548,7 +548,7 @@ SPI MASTER METHODS
DEPRECATED METHODS DEPRECATED METHODS
master->transfer(struct spi_device *spi, struct spi_message *message) master->transfer(struct spi_device *spi, struct spi_message *message)
This must not sleep. Its responsibility is arrange that the This must not sleep. Its responsibility is to arrange that the
transfer happens and its complete() callback is issued. The two transfer happens and its complete() callback is issued. The two
will normally happen later, after other transfers complete, and will normally happen later, after other transfers complete, and
if the controller is idle it will need to be kickstarted. This if the controller is idle it will need to be kickstarted. This
......
/* linux/arch/arm/plat-samsung/include/plat/fiq.h
*
* Copyright (c) 2009 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* Header file for S3C24XX CPU FIQ support
*
* 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
* published by the Free Software Foundation.
*/
extern int s3c24xx_set_fiq(unsigned int irq, bool on);
...@@ -118,6 +118,13 @@ config SPI_BCM63XX ...@@ -118,6 +118,13 @@ config SPI_BCM63XX
help help
Enable support for the SPI controller on the Broadcom BCM63xx SoCs. Enable support for the SPI controller on the Broadcom BCM63xx SoCs.
config SPI_BCM63XX_HSSPI
tristate "Broadcom BCM63XX HS SPI controller driver"
depends on BCM63XX || COMPILE_TEST
help
This enables support for the High Speed SPI controller present on
newer Broadcom BCM63XX SoCs.
config SPI_BITBANG config SPI_BITBANG
tristate "Utilities for Bitbanging SPI masters" tristate "Utilities for Bitbanging SPI masters"
help help
...@@ -159,7 +166,6 @@ config SPI_DAVINCI ...@@ -159,7 +166,6 @@ config SPI_DAVINCI
tristate "Texas Instruments DaVinci/DA8x/OMAP-L/AM1x SoC SPI controller" tristate "Texas Instruments DaVinci/DA8x/OMAP-L/AM1x SoC SPI controller"
depends on ARCH_DAVINCI || ARCH_KEYSTONE depends on ARCH_DAVINCI || ARCH_KEYSTONE
select SPI_BITBANG select SPI_BITBANG
select TI_EDMA
help help
SPI master controller for DaVinci/DA8x/OMAP-L/AM1x SPI modules. SPI master controller for DaVinci/DA8x/OMAP-L/AM1x SPI modules.
...@@ -301,6 +307,7 @@ config SPI_OMAP_UWIRE ...@@ -301,6 +307,7 @@ config SPI_OMAP_UWIRE
config SPI_OMAP24XX config SPI_OMAP24XX
tristate "McSPI driver for OMAP" tristate "McSPI driver for OMAP"
depends on ARM || ARM64 || AVR32 || HEXAGON || MIPS || SH
depends on ARCH_OMAP2PLUS || COMPILE_TEST depends on ARCH_OMAP2PLUS || COMPILE_TEST
help help
SPI master controller for OMAP24XX and later Multichannel SPI SPI master controller for OMAP24XX and later Multichannel SPI
...@@ -370,7 +377,7 @@ config SPI_PXA2XX_PCI ...@@ -370,7 +377,7 @@ config SPI_PXA2XX_PCI
config SPI_RSPI config SPI_RSPI
tristate "Renesas RSPI controller" tristate "Renesas RSPI controller"
depends on (SUPERH || ARCH_SHMOBILE) && SH_DMAE_BASE depends on (SUPERH && SH_DMAE_BASE) || ARCH_SHMOBILE
help help
SPI driver for Renesas RSPI blocks. SPI driver for Renesas RSPI blocks.
...@@ -407,7 +414,8 @@ config SPI_SC18IS602 ...@@ -407,7 +414,8 @@ config SPI_SC18IS602
config SPI_SH_MSIOF config SPI_SH_MSIOF
tristate "SuperH MSIOF SPI controller" tristate "SuperH MSIOF SPI controller"
depends on (SUPERH || ARCH_SHMOBILE) && HAVE_CLK depends on HAVE_CLK
depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
select SPI_BITBANG select SPI_BITBANG
help help
SPI driver for SuperH and SH Mobile MSIOF blocks. SPI driver for SuperH and SH Mobile MSIOF blocks.
......
...@@ -16,6 +16,7 @@ obj-$(CONFIG_SPI_ATH79) += spi-ath79.o ...@@ -16,6 +16,7 @@ obj-$(CONFIG_SPI_ATH79) += spi-ath79.o
obj-$(CONFIG_SPI_AU1550) += spi-au1550.o obj-$(CONFIG_SPI_AU1550) += spi-au1550.o
obj-$(CONFIG_SPI_BCM2835) += spi-bcm2835.o 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_BFIN5XX) += spi-bfin5xx.o obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o
obj-$(CONFIG_SPI_BFIN_V3) += spi-bfin-v3.o obj-$(CONFIG_SPI_BFIN_V3) += spi-bfin-v3.o
obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o
......
...@@ -220,8 +220,6 @@ static int altera_spi_probe(struct platform_device *pdev) ...@@ -220,8 +220,6 @@ static int altera_spi_probe(struct platform_device *pdev)
/* setup the state for the bitbang driver */ /* setup the state for the bitbang driver */
hw->bitbang.master = master; hw->bitbang.master = master;
if (!hw->bitbang.master)
return err;
hw->bitbang.chipselect = altera_spi_chipsel; hw->bitbang.chipselect = altera_spi_chipsel;
hw->bitbang.txrx_bufs = altera_spi_txrx; hw->bitbang.txrx_bufs = altera_spi_txrx;
......
...@@ -243,21 +243,21 @@ static int ath79_spi_probe(struct platform_device *pdev) ...@@ -243,21 +243,21 @@ static int ath79_spi_probe(struct platform_device *pdev)
goto err_put_master; goto err_put_master;
} }
sp->base = ioremap(r->start, resource_size(r)); sp->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
if (!sp->base) { if (!sp->base) {
ret = -ENXIO; ret = -ENXIO;
goto err_put_master; goto err_put_master;
} }
sp->clk = clk_get(&pdev->dev, "ahb"); sp->clk = devm_clk_get(&pdev->dev, "ahb");
if (IS_ERR(sp->clk)) { if (IS_ERR(sp->clk)) {
ret = PTR_ERR(sp->clk); ret = PTR_ERR(sp->clk);
goto err_unmap; goto err_put_master;
} }
ret = clk_enable(sp->clk); ret = clk_enable(sp->clk);
if (ret) if (ret)
goto err_clk_put; goto err_put_master;
rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ); rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ);
if (!rate) { if (!rate) {
...@@ -280,10 +280,6 @@ static int ath79_spi_probe(struct platform_device *pdev) ...@@ -280,10 +280,6 @@ static int ath79_spi_probe(struct platform_device *pdev)
ath79_spi_disable(sp); ath79_spi_disable(sp);
err_clk_disable: err_clk_disable:
clk_disable(sp->clk); clk_disable(sp->clk);
err_clk_put:
clk_put(sp->clk);
err_unmap:
iounmap(sp->base);
err_put_master: err_put_master:
spi_master_put(sp->bitbang.master); spi_master_put(sp->bitbang.master);
...@@ -297,8 +293,6 @@ static int ath79_spi_remove(struct platform_device *pdev) ...@@ -297,8 +293,6 @@ static int ath79_spi_remove(struct platform_device *pdev)
spi_bitbang_stop(&sp->bitbang); spi_bitbang_stop(&sp->bitbang);
ath79_spi_disable(sp); ath79_spi_disable(sp);
clk_disable(sp->clk); clk_disable(sp->clk);
clk_put(sp->clk);
iounmap(sp->base);
spi_master_put(sp->bitbang.master); spi_master_put(sp->bitbang.master);
return 0; return 0;
......
This diff is collapsed.
...@@ -347,7 +347,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev) ...@@ -347,7 +347,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
clk_prepare_enable(bs->clk); clk_prepare_enable(bs->clk);
err = request_irq(bs->irq, bcm2835_spi_interrupt, 0, err = devm_request_irq(&pdev->dev, bs->irq, bcm2835_spi_interrupt, 0,
dev_name(&pdev->dev), master); dev_name(&pdev->dev), master);
if (err) { if (err) {
dev_err(&pdev->dev, "could not request IRQ: %d\n", err); dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
...@@ -361,13 +361,11 @@ static int bcm2835_spi_probe(struct platform_device *pdev) ...@@ -361,13 +361,11 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
err = devm_spi_register_master(&pdev->dev, master); err = devm_spi_register_master(&pdev->dev, master);
if (err) { if (err) {
dev_err(&pdev->dev, "could not register SPI master: %d\n", err); dev_err(&pdev->dev, "could not register SPI master: %d\n", err);
goto out_free_irq; goto out_clk_disable;
} }
return 0; return 0;
out_free_irq:
free_irq(bs->irq, master);
out_clk_disable: out_clk_disable:
clk_disable_unprepare(bs->clk); clk_disable_unprepare(bs->clk);
out_master_put: out_master_put:
...@@ -380,8 +378,6 @@ static int bcm2835_spi_remove(struct platform_device *pdev) ...@@ -380,8 +378,6 @@ static int bcm2835_spi_remove(struct platform_device *pdev)
struct spi_master *master = platform_get_drvdata(pdev); struct spi_master *master = platform_get_drvdata(pdev);
struct bcm2835_spi *bs = spi_master_get_devdata(master); struct bcm2835_spi *bs = spi_master_get_devdata(master);
free_irq(bs->irq, master);
/* Clear FIFOs, and disable the HW block */ /* Clear FIFOs, and disable the HW block */
bcm2835_wr(bs, BCM2835_SPI_CS, bcm2835_wr(bs, BCM2835_SPI_CS,
BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX); BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
......
This diff is collapsed.
...@@ -169,8 +169,6 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first, ...@@ -169,8 +169,6 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
transfer_list); transfer_list);
} }
len -= prepend_len;
init_completion(&bs->done); init_completion(&bs->done);
/* Fill in the Message control register */ /* Fill in the Message control register */
...@@ -205,13 +203,7 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first, ...@@ -205,13 +203,7 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
if (!timeout) if (!timeout)
return -ETIMEDOUT; return -ETIMEDOUT;
/* read out all data */ if (!do_rx)
rx_tail = bcm_spi_readb(bs, SPI_RX_TAIL);
if (do_rx && rx_tail != len)
return -EIO;
if (!rx_tail)
return 0; return 0;
len = 0; len = 0;
...@@ -345,22 +337,19 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -345,22 +337,19 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
dev_err(dev, "no irq\n"); dev_err(dev, "no irq\n");
ret = -ENXIO; return -ENXIO;
goto out;
} }
clk = clk_get(dev, "spi"); clk = devm_clk_get(dev, "spi");
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
dev_err(dev, "no clock for device\n"); dev_err(dev, "no clock for device\n");
ret = PTR_ERR(clk); return PTR_ERR(clk);
goto out;
} }
master = spi_alloc_master(dev, sizeof(*bs)); master = spi_alloc_master(dev, sizeof(*bs));
if (!master) { if (!master) {
dev_err(dev, "out of memory\n"); dev_err(dev, "out of memory\n");
ret = -ENOMEM; return -ENOMEM;
goto out_clk;
} }
bs = spi_master_get_devdata(master); bs = spi_master_get_devdata(master);
...@@ -408,7 +397,10 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -408,7 +397,10 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
} }
/* Initialize hardware */ /* Initialize hardware */
clk_prepare_enable(bs->clk); ret = clk_prepare_enable(bs->clk);
if (ret)
goto out_err;
bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS); bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
/* register and we are done */ /* register and we are done */
...@@ -427,9 +419,6 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -427,9 +419,6 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
clk_disable_unprepare(clk); clk_disable_unprepare(clk);
out_err: out_err:
spi_master_put(master); spi_master_put(master);
out_clk:
clk_put(clk);
out:
return ret; return ret;
} }
...@@ -443,12 +432,11 @@ static int bcm63xx_spi_remove(struct platform_device *pdev) ...@@ -443,12 +432,11 @@ static int bcm63xx_spi_remove(struct platform_device *pdev)
/* HW shutdown */ /* HW shutdown */
clk_disable_unprepare(bs->clk); clk_disable_unprepare(bs->clk);
clk_put(bs->clk);
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP
static int bcm63xx_spi_suspend(struct device *dev) static int bcm63xx_spi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_master *master = dev_get_drvdata(dev);
...@@ -465,29 +453,27 @@ static int bcm63xx_spi_resume(struct device *dev) ...@@ -465,29 +453,27 @@ static int bcm63xx_spi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_master *master = dev_get_drvdata(dev);
struct bcm63xx_spi *bs = spi_master_get_devdata(master); struct bcm63xx_spi *bs = spi_master_get_devdata(master);
int ret;
clk_prepare_enable(bs->clk); ret = clk_prepare_enable(bs->clk);
if (ret)
return ret;
spi_master_resume(master); spi_master_resume(master);
return 0; return 0;
} }
#endif
static const struct dev_pm_ops bcm63xx_spi_pm_ops = { static const struct dev_pm_ops bcm63xx_spi_pm_ops = {
.suspend = bcm63xx_spi_suspend, SET_SYSTEM_SLEEP_PM_OPS(bcm63xx_spi_suspend, bcm63xx_spi_resume)
.resume = bcm63xx_spi_resume,
}; };
#define BCM63XX_SPI_PM_OPS (&bcm63xx_spi_pm_ops)
#else
#define BCM63XX_SPI_PM_OPS NULL
#endif
static struct platform_driver bcm63xx_spi_driver = { static struct platform_driver bcm63xx_spi_driver = {
.driver = { .driver = {
.name = "bcm63xx-spi", .name = "bcm63xx-spi",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.pm = BCM63XX_SPI_PM_OPS, .pm = &bcm63xx_spi_pm_ops,
}, },
.probe = bcm63xx_spi_probe, .probe = bcm63xx_spi_probe,
.remove = bcm63xx_spi_remove, .remove = bcm63xx_spi_remove,
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* *
* Since this is software, the timings may not be exactly what your board's * Since this is software, the timings may not be exactly what your board's
* chips need ... there may be several reasons you'd need to tweak timings * chips need ... there may be several reasons you'd need to tweak timings
* in these routines, not just make to make it faster or slower to match a * in these routines, not just to make it faster or slower to match a
* particular CPU clock rate. * particular CPU clock rate.
*/ */
......
/* /*
* CLPS711X SPI bus driver * CLPS711X SPI bus driver
* *
* Copyright (C) 2012 Alexander Shiyan <shc_work@mail.ru> * Copyright (C) 2012-2014 Alexander Shiyan <shc_work@mail.ru>
* *
* 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 as published by * it under the terms of the GNU General Public License as published by
...@@ -198,7 +198,7 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -198,7 +198,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
ret = -EINVAL; ret = -EINVAL;
goto err_out; goto err_out;
} }
if (gpio_request(hw->chipselect[i], DRIVER_NAME)) { if (devm_gpio_request(&pdev->dev, hw->chipselect[i], NULL)) {
dev_err(&pdev->dev, "Can't get CS GPIO %i\n", i); dev_err(&pdev->dev, "Can't get CS GPIO %i\n", i);
ret = -EINVAL; ret = -EINVAL;
goto err_out; goto err_out;
...@@ -240,38 +240,21 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -240,38 +240,21 @@ static int spi_clps711x_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to register master\n"); dev_err(&pdev->dev, "Failed to register master\n");
err_out: err_out:
while (--i >= 0)
if (gpio_is_valid(hw->chipselect[i]))
gpio_free(hw->chipselect[i]);
spi_master_put(master); spi_master_put(master);
return ret; return ret;
} }
static int spi_clps711x_remove(struct platform_device *pdev)
{
int i;
struct spi_master *master = platform_get_drvdata(pdev);
struct spi_clps711x_data *hw = spi_master_get_devdata(master);
for (i = 0; i < master->num_chipselect; i++)
if (gpio_is_valid(hw->chipselect[i]))
gpio_free(hw->chipselect[i]);
return 0;
}
static struct platform_driver clps711x_spi_driver = { static struct platform_driver clps711x_spi_driver = {
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = spi_clps711x_probe, .probe = spi_clps711x_probe,
.remove = spi_clps711x_remove,
}; };
module_platform_driver(clps711x_spi_driver); module_platform_driver(clps711x_spi_driver);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>"); MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>");
MODULE_DESCRIPTION("CLPS711X SPI bus driver"); MODULE_DESCRIPTION("CLPS711X SPI bus driver");
MODULE_ALIAS("platform:" DRIVER_NAME);
...@@ -397,44 +397,31 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -397,44 +397,31 @@ static int mcfqspi_probe(struct platform_device *pdev)
mcfqspi = spi_master_get_devdata(master); mcfqspi = spi_master_get_devdata(master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { mcfqspi->iobase = devm_ioremap_resource(&pdev->dev, res);
dev_dbg(&pdev->dev, "platform_get_resource failed\n"); if (IS_ERR(mcfqspi->iobase)) {
status = -ENXIO; status = PTR_ERR(mcfqspi->iobase);
goto fail0; goto fail0;
} }
if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
dev_dbg(&pdev->dev, "request_mem_region failed\n");
status = -EBUSY;
goto fail0;
}
mcfqspi->iobase = ioremap(res->start, resource_size(res));
if (!mcfqspi->iobase) {
dev_dbg(&pdev->dev, "ioremap failed\n");
status = -ENOMEM;
goto fail1;
}
mcfqspi->irq = platform_get_irq(pdev, 0); mcfqspi->irq = platform_get_irq(pdev, 0);
if (mcfqspi->irq < 0) { if (mcfqspi->irq < 0) {
dev_dbg(&pdev->dev, "platform_get_irq failed\n"); dev_dbg(&pdev->dev, "platform_get_irq failed\n");
status = -ENXIO; status = -ENXIO;
goto fail2; goto fail0;
} }
status = request_irq(mcfqspi->irq, mcfqspi_irq_handler, 0, status = devm_request_irq(&pdev->dev, mcfqspi->irq, mcfqspi_irq_handler,
pdev->name, mcfqspi); 0, pdev->name, mcfqspi);
if (status) { if (status) {
dev_dbg(&pdev->dev, "request_irq failed\n"); dev_dbg(&pdev->dev, "request_irq failed\n");
goto fail2; goto fail0;
} }
mcfqspi->clk = clk_get(&pdev->dev, "qspi_clk"); mcfqspi->clk = devm_clk_get(&pdev->dev, "qspi_clk");
if (IS_ERR(mcfqspi->clk)) { if (IS_ERR(mcfqspi->clk)) {
dev_dbg(&pdev->dev, "clk_get failed\n"); dev_dbg(&pdev->dev, "clk_get failed\n");
status = PTR_ERR(mcfqspi->clk); status = PTR_ERR(mcfqspi->clk);
goto fail3; goto fail0;
} }
clk_enable(mcfqspi->clk); clk_enable(mcfqspi->clk);
...@@ -445,7 +432,7 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -445,7 +432,7 @@ static int mcfqspi_probe(struct platform_device *pdev)
status = mcfqspi_cs_setup(mcfqspi); status = mcfqspi_cs_setup(mcfqspi);
if (status) { if (status) {
dev_dbg(&pdev->dev, "error initializing cs_control\n"); dev_dbg(&pdev->dev, "error initializing cs_control\n");
goto fail4; goto fail1;
} }
init_waitqueue_head(&mcfqspi->waitq); init_waitqueue_head(&mcfqspi->waitq);
...@@ -459,10 +446,10 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -459,10 +446,10 @@ static int mcfqspi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
status = spi_register_master(master); status = devm_spi_register_master(&pdev->dev, master);
if (status) { if (status) {
dev_dbg(&pdev->dev, "spi_register_master failed\n"); dev_dbg(&pdev->dev, "spi_register_master failed\n");
goto fail5; goto fail2;
} }
pm_runtime_enable(mcfqspi->dev); pm_runtime_enable(mcfqspi->dev);
...@@ -470,17 +457,10 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -470,17 +457,10 @@ static int mcfqspi_probe(struct platform_device *pdev)
return 0; return 0;
fail5:
mcfqspi_cs_teardown(mcfqspi);
fail4:
clk_disable(mcfqspi->clk);
clk_put(mcfqspi->clk);
fail3:
free_irq(mcfqspi->irq, mcfqspi);
fail2: fail2:
iounmap(mcfqspi->iobase); mcfqspi_cs_teardown(mcfqspi);
fail1: fail1:
release_mem_region(res->start, resource_size(res)); clk_disable(mcfqspi->clk);
fail0: fail0:
spi_master_put(master); spi_master_put(master);
...@@ -501,11 +481,6 @@ static int mcfqspi_remove(struct platform_device *pdev) ...@@ -501,11 +481,6 @@ static int mcfqspi_remove(struct platform_device *pdev)
mcfqspi_cs_teardown(mcfqspi); mcfqspi_cs_teardown(mcfqspi);
clk_disable(mcfqspi->clk); clk_disable(mcfqspi->clk);
clk_put(mcfqspi->clk);
free_irq(mcfqspi->irq, mcfqspi);
iounmap(mcfqspi->iobase);
release_mem_region(res->start, resource_size(res));
spi_unregister_master(master);
return 0; return 0;
} }
......
...@@ -396,10 +396,6 @@ static int davinci_spi_setup(struct spi_device *spi) ...@@ -396,10 +396,6 @@ static int davinci_spi_setup(struct spi_device *spi)
dspi = spi_master_get_devdata(spi->master); dspi = spi_master_get_devdata(spi->master);
pdata = &dspi->pdata; pdata = &dspi->pdata;
/* if bits per word length is zero then set it default 8 */
if (!spi->bits_per_word)
spi->bits_per_word = 8;
if (!(spi->mode & SPI_NO_CS)) { if (!(spi->mode & SPI_NO_CS)) {
if ((pdata->chip_sel == NULL) || if ((pdata->chip_sel == NULL) ||
(pdata->chip_sel[spi->chip_select] == SPI_INTERN_CS)) (pdata->chip_sel[spi->chip_select] == SPI_INTERN_CS))
...@@ -853,7 +849,7 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -853,7 +849,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
struct spi_master *master; struct spi_master *master;
struct davinci_spi *dspi; struct davinci_spi *dspi;
struct davinci_spi_platform_data *pdata; struct davinci_spi_platform_data *pdata;
struct resource *r, *mem; struct resource *r;
resource_size_t dma_rx_chan = SPI_NO_RESOURCE; resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
resource_size_t dma_tx_chan = SPI_NO_RESOURCE; resource_size_t dma_tx_chan = SPI_NO_RESOURCE;
int i = 0, ret = 0; int i = 0, ret = 0;
...@@ -894,39 +890,33 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -894,39 +890,33 @@ static int davinci_spi_probe(struct platform_device *pdev)
dspi->pbase = r->start; dspi->pbase = r->start;
mem = request_mem_region(r->start, resource_size(r), pdev->name); dspi->base = devm_ioremap_resource(&pdev->dev, r);
if (mem == NULL) { if (IS_ERR(dspi->base)) {
ret = -EBUSY; ret = PTR_ERR(dspi->base);
goto free_master; goto free_master;
} }
dspi->base = ioremap(r->start, resource_size(r));
if (dspi->base == NULL) {
ret = -ENOMEM;
goto release_region;
}
dspi->irq = platform_get_irq(pdev, 0); dspi->irq = platform_get_irq(pdev, 0);
if (dspi->irq <= 0) { if (dspi->irq <= 0) {
ret = -EINVAL; ret = -EINVAL;
goto unmap_io; goto free_master;
} }
ret = request_threaded_irq(dspi->irq, davinci_spi_irq, dummy_thread_fn, ret = devm_request_threaded_irq(&pdev->dev, dspi->irq, davinci_spi_irq,
0, dev_name(&pdev->dev), dspi); dummy_thread_fn, 0, dev_name(&pdev->dev), dspi);
if (ret) if (ret)
goto unmap_io; goto free_master;
dspi->bitbang.master = master; dspi->bitbang.master = master;
if (dspi->bitbang.master == NULL) { if (dspi->bitbang.master == NULL) {
ret = -ENODEV; ret = -ENODEV;
goto irq_free; goto free_master;
} }
dspi->clk = clk_get(&pdev->dev, NULL); dspi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dspi->clk)) { if (IS_ERR(dspi->clk)) {
ret = -ENODEV; ret = -ENODEV;
goto irq_free; goto free_master;
} }
clk_prepare_enable(dspi->clk); clk_prepare_enable(dspi->clk);
...@@ -963,8 +953,8 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -963,8 +953,8 @@ static int davinci_spi_probe(struct platform_device *pdev)
goto free_clk; goto free_clk;
dev_info(&pdev->dev, "DMA: supported\n"); dev_info(&pdev->dev, "DMA: supported\n");
dev_info(&pdev->dev, "DMA: RX channel: %d, TX channel: %d, " dev_info(&pdev->dev, "DMA: RX channel: %pa, TX channel: %pa, "
"event queue: %d\n", dma_rx_chan, dma_tx_chan, "event queue: %d\n", &dma_rx_chan, &dma_tx_chan,
pdata->dma_event_q); pdata->dma_event_q);
} }
...@@ -1015,13 +1005,6 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -1015,13 +1005,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
dma_release_channel(dspi->dma_tx); dma_release_channel(dspi->dma_tx);
free_clk: free_clk:
clk_disable_unprepare(dspi->clk); clk_disable_unprepare(dspi->clk);
clk_put(dspi->clk);
irq_free:
free_irq(dspi->irq, dspi);
unmap_io:
iounmap(dspi->base);
release_region:
release_mem_region(dspi->pbase, resource_size(r));
free_master: free_master:
spi_master_put(master); spi_master_put(master);
err: err:
...@@ -1041,7 +1024,6 @@ static int davinci_spi_remove(struct platform_device *pdev) ...@@ -1041,7 +1024,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
{ {
struct davinci_spi *dspi; struct davinci_spi *dspi;
struct spi_master *master; struct spi_master *master;
struct resource *r;
master = platform_get_drvdata(pdev); master = platform_get_drvdata(pdev);
dspi = spi_master_get_devdata(master); dspi = spi_master_get_devdata(master);
...@@ -1049,11 +1031,6 @@ static int davinci_spi_remove(struct platform_device *pdev) ...@@ -1049,11 +1031,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
spi_bitbang_stop(&dspi->bitbang); spi_bitbang_stop(&dspi->bitbang);
clk_disable_unprepare(dspi->clk); clk_disable_unprepare(dspi->clk);
clk_put(dspi->clk);
free_irq(dspi->irq, dspi);
iounmap(dspi->base);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(dspi->pbase, resource_size(r));
spi_master_put(master); spi_master_put(master);
return 0; return 0;
......
...@@ -30,14 +30,13 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -30,14 +30,13 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
{ {
struct dw_spi_mmio *dwsmmio; struct dw_spi_mmio *dwsmmio;
struct dw_spi *dws; struct dw_spi *dws;
struct resource *mem, *ioarea; struct resource *mem;
int ret; int ret;
dwsmmio = kzalloc(sizeof(struct dw_spi_mmio), GFP_KERNEL); dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio),
if (!dwsmmio) { GFP_KERNEL);
ret = -ENOMEM; if (!dwsmmio)
goto err_end; return -ENOMEM;
}
dws = &dwsmmio->dws; dws = &dwsmmio->dws;
...@@ -45,80 +44,51 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -45,80 +44,51 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) { if (!mem) {
dev_err(&pdev->dev, "no mem resource?\n"); dev_err(&pdev->dev, "no mem resource?\n");
ret = -EINVAL; return -EINVAL;
goto err_kfree;
} }
ioarea = request_mem_region(mem->start, resource_size(mem), dws->regs = devm_ioremap_resource(&pdev->dev, mem);
pdev->name); if (IS_ERR(dws->regs)) {
if (!ioarea) { dev_err(&pdev->dev, "SPI region map failed\n");
dev_err(&pdev->dev, "SPI region already claimed\n"); return PTR_ERR(dws->regs);
ret = -EBUSY;
goto err_kfree;
}
dws->regs = ioremap_nocache(mem->start, resource_size(mem));
if (!dws->regs) {
dev_err(&pdev->dev, "SPI region already mapped\n");
ret = -ENOMEM;
goto err_release_reg;
} }
dws->irq = platform_get_irq(pdev, 0); dws->irq = platform_get_irq(pdev, 0);
if (dws->irq < 0) { if (dws->irq < 0) {
dev_err(&pdev->dev, "no irq resource?\n"); dev_err(&pdev->dev, "no irq resource?\n");
ret = dws->irq; /* -ENXIO */ return dws->irq; /* -ENXIO */
goto err_unmap;
} }
dwsmmio->clk = clk_get(&pdev->dev, NULL); dwsmmio->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dwsmmio->clk)) { if (IS_ERR(dwsmmio->clk))
ret = PTR_ERR(dwsmmio->clk); return PTR_ERR(dwsmmio->clk);
goto err_unmap; ret = clk_prepare_enable(dwsmmio->clk);
} if (ret)
clk_enable(dwsmmio->clk); return ret;
dws->parent_dev = &pdev->dev;
dws->bus_num = 0; dws->bus_num = 0;
dws->num_cs = 4; dws->num_cs = 4;
dws->max_freq = clk_get_rate(dwsmmio->clk); dws->max_freq = clk_get_rate(dwsmmio->clk);
ret = dw_spi_add_host(dws); ret = dw_spi_add_host(&pdev->dev, dws);
if (ret) if (ret)
goto err_clk; goto out;
platform_set_drvdata(pdev, dwsmmio); platform_set_drvdata(pdev, dwsmmio);
return 0; return 0;
err_clk: out:
clk_disable(dwsmmio->clk); clk_disable_unprepare(dwsmmio->clk);
clk_put(dwsmmio->clk);
dwsmmio->clk = NULL;
err_unmap:
iounmap(dws->regs);
err_release_reg:
release_mem_region(mem->start, resource_size(mem));
err_kfree:
kfree(dwsmmio);
err_end:
return ret; return ret;
} }
static int dw_spi_mmio_remove(struct platform_device *pdev) static int dw_spi_mmio_remove(struct platform_device *pdev)
{ {
struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev); struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
struct resource *mem;
clk_disable(dwsmmio->clk);
clk_put(dwsmmio->clk);
dwsmmio->clk = NULL;
clk_disable_unprepare(dwsmmio->clk);
dw_spi_remove_host(&dwsmmio->dws); dw_spi_remove_host(&dwsmmio->dws);
iounmap(dwsmmio->dws.regs);
kfree(dwsmmio);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(mem->start, resource_size(mem));
return 0; return 0;
} }
......
...@@ -43,35 +43,25 @@ static int spi_pci_probe(struct pci_dev *pdev, ...@@ -43,35 +43,25 @@ static int spi_pci_probe(struct pci_dev *pdev,
dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n", dev_info(&pdev->dev, "found PCI SPI controller(ID: %04x:%04x)\n",
pdev->vendor, pdev->device); pdev->vendor, pdev->device);
ret = pci_enable_device(pdev); ret = pcim_enable_device(pdev);
if (ret) if (ret)
return ret; return ret;
dwpci = kzalloc(sizeof(struct dw_spi_pci), GFP_KERNEL); dwpci = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_pci),
if (!dwpci) { GFP_KERNEL);
ret = -ENOMEM; if (!dwpci)
goto err_disable; return -ENOMEM;
}
dwpci->pdev = pdev; dwpci->pdev = pdev;
dws = &dwpci->dws; dws = &dwpci->dws;
/* Get basic io resource and map it */ /* Get basic io resource and map it */
dws->paddr = pci_resource_start(pdev, pci_bar); dws->paddr = pci_resource_start(pdev, pci_bar);
dws->iolen = pci_resource_len(pdev, pci_bar);
ret = pci_request_region(pdev, pci_bar, dev_name(&pdev->dev)); ret = pcim_iomap_regions(pdev, 1, dev_name(&pdev->dev));
if (ret) if (ret)
goto err_kfree; return ret;
dws->regs = ioremap_nocache((unsigned long)dws->paddr,
pci_resource_len(pdev, pci_bar));
if (!dws->regs) {
ret = -ENOMEM;
goto err_release_reg;
}
dws->parent_dev = &pdev->dev;
dws->bus_num = 0; dws->bus_num = 0;
dws->num_cs = 4; dws->num_cs = 4;
dws->irq = pdev->irq; dws->irq = pdev->irq;
...@@ -83,26 +73,17 @@ static int spi_pci_probe(struct pci_dev *pdev, ...@@ -83,26 +73,17 @@ static int spi_pci_probe(struct pci_dev *pdev,
if (pdev->device == 0x0800) { if (pdev->device == 0x0800) {
ret = dw_spi_mid_init(dws); ret = dw_spi_mid_init(dws);
if (ret) if (ret)
goto err_unmap; return ret;
} }
ret = dw_spi_add_host(dws); ret = dw_spi_add_host(&pdev->dev, dws);
if (ret) if (ret)
goto err_unmap; return ret;
/* PCI hook and SPI hook use the same drv data */ /* PCI hook and SPI hook use the same drv data */
pci_set_drvdata(pdev, dwpci); pci_set_drvdata(pdev, dwpci);
return 0;
err_unmap: return 0;
iounmap(dws->regs);
err_release_reg:
pci_release_region(pdev, pci_bar);
err_kfree:
kfree(dwpci);
err_disable:
pci_disable_device(pdev);
return ret;
} }
static void spi_pci_remove(struct pci_dev *pdev) static void spi_pci_remove(struct pci_dev *pdev)
...@@ -110,10 +91,6 @@ static void spi_pci_remove(struct pci_dev *pdev) ...@@ -110,10 +91,6 @@ static void spi_pci_remove(struct pci_dev *pdev)
struct dw_spi_pci *dwpci = pci_get_drvdata(pdev); struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
dw_spi_remove_host(&dwpci->dws); dw_spi_remove_host(&dwpci->dws);
iounmap(dwpci->dws.regs);
pci_release_region(pdev, 0);
kfree(dwpci);
pci_disable_device(pdev);
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -148,7 +125,7 @@ static int spi_resume(struct pci_dev *pdev) ...@@ -148,7 +125,7 @@ static int spi_resume(struct pci_dev *pdev)
#define spi_resume NULL #define spi_resume NULL
#endif #endif
static DEFINE_PCI_DEVICE_TABLE(pci_ids) = { static const struct pci_device_id pci_ids[] = {
/* Intel MID platform SPI controller 0 */ /* Intel MID platform SPI controller 0 */
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) },
{}, {},
......
...@@ -427,7 +427,6 @@ static void pump_transfers(unsigned long data) ...@@ -427,7 +427,6 @@ static void pump_transfers(unsigned long data)
dws->tx_end = dws->tx + transfer->len; dws->tx_end = dws->tx + transfer->len;
dws->rx = transfer->rx_buf; dws->rx = transfer->rx_buf;
dws->rx_end = dws->rx + transfer->len; dws->rx_end = dws->rx + transfer->len;
dws->cs_change = transfer->cs_change;
dws->len = dws->cur_transfer->len; dws->len = dws->cur_transfer->len;
if (chip != dws->prev_chip) if (chip != dws->prev_chip)
cs_change = 1; cs_change = 1;
...@@ -620,9 +619,11 @@ static int dw_spi_setup(struct spi_device *spi) ...@@ -620,9 +619,11 @@ static int dw_spi_setup(struct spi_device *spi)
/* Only alloc on first setup */ /* Only alloc on first setup */
chip = spi_get_ctldata(spi); chip = spi_get_ctldata(spi);
if (!chip) { if (!chip) {
chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL); chip = devm_kzalloc(&spi->dev, sizeof(struct chip_data),
GFP_KERNEL);
if (!chip) if (!chip)
return -ENOMEM; return -ENOMEM;
spi_set_ctldata(spi, chip);
} }
/* /*
...@@ -667,7 +668,6 @@ static int dw_spi_setup(struct spi_device *spi) ...@@ -667,7 +668,6 @@ 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);
spi_set_ctldata(spi, chip);
return 0; return 0;
} }
...@@ -776,18 +776,16 @@ static void spi_hw_init(struct dw_spi *dws) ...@@ -776,18 +776,16 @@ static void spi_hw_init(struct dw_spi *dws)
} }
} }
int dw_spi_add_host(struct dw_spi *dws) int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
{ {
struct spi_master *master; struct spi_master *master;
int ret; int ret;
BUG_ON(dws == NULL); BUG_ON(dws == NULL);
master = spi_alloc_master(dws->parent_dev, 0); master = spi_alloc_master(dev, 0);
if (!master) { if (!master)
ret = -ENOMEM; return -ENOMEM;
goto exit;
}
dws->master = master; dws->master = master;
dws->type = SSI_MOTO_SPI; dws->type = SSI_MOTO_SPI;
...@@ -797,7 +795,7 @@ int dw_spi_add_host(struct dw_spi *dws) ...@@ -797,7 +795,7 @@ int dw_spi_add_host(struct dw_spi *dws)
snprintf(dws->name, sizeof(dws->name), "dw_spi%d", snprintf(dws->name, sizeof(dws->name), "dw_spi%d",
dws->bus_num); dws->bus_num);
ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED,
dws->name, dws); dws->name, dws);
if (ret < 0) { if (ret < 0) {
dev_err(&master->dev, "can not get IRQ\n"); dev_err(&master->dev, "can not get IRQ\n");
...@@ -836,7 +834,7 @@ int dw_spi_add_host(struct dw_spi *dws) ...@@ -836,7 +834,7 @@ int dw_spi_add_host(struct dw_spi *dws)
} }
spi_master_set_devdata(master, dws); spi_master_set_devdata(master, dws);
ret = spi_register_master(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_queue_alloc;
...@@ -851,10 +849,8 @@ int dw_spi_add_host(struct dw_spi *dws) ...@@ -851,10 +849,8 @@ int dw_spi_add_host(struct dw_spi *dws)
dws->dma_ops->dma_exit(dws); dws->dma_ops->dma_exit(dws);
err_diable_hw: err_diable_hw:
spi_enable_chip(dws, 0); spi_enable_chip(dws, 0);
free_irq(dws->irq, dws);
err_free_master: err_free_master:
spi_master_put(master); spi_master_put(master);
exit:
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(dw_spi_add_host); EXPORT_SYMBOL_GPL(dw_spi_add_host);
...@@ -878,10 +874,6 @@ void dw_spi_remove_host(struct dw_spi *dws) ...@@ -878,10 +874,6 @@ void dw_spi_remove_host(struct dw_spi *dws)
spi_enable_chip(dws, 0); spi_enable_chip(dws, 0);
/* Disable clk */ /* Disable clk */
spi_set_clk(dws, 0); spi_set_clk(dws, 0);
free_irq(dws->irq, dws);
/* Disconnect from the SPI framework */
spi_unregister_master(dws->master);
} }
EXPORT_SYMBOL_GPL(dw_spi_remove_host); EXPORT_SYMBOL_GPL(dw_spi_remove_host);
......
...@@ -92,13 +92,11 @@ struct dw_spi_dma_ops { ...@@ -92,13 +92,11 @@ struct dw_spi_dma_ops {
struct dw_spi { struct dw_spi {
struct spi_master *master; struct spi_master *master;
struct spi_device *cur_dev; struct spi_device *cur_dev;
struct device *parent_dev;
enum dw_ssi_type type; enum dw_ssi_type type;
char name[16]; char name[16];
void __iomem *regs; void __iomem *regs;
unsigned long paddr; unsigned long paddr;
u32 iolen;
int irq; int irq;
u32 fifo_len; /* depth of the FIFO buffer */ u32 fifo_len; /* depth of the FIFO buffer */
u32 max_freq; /* max bus freq supported */ u32 max_freq; /* max bus freq supported */
...@@ -135,7 +133,6 @@ struct dw_spi { ...@@ -135,7 +133,6 @@ struct dw_spi {
u8 n_bytes; /* current is a 1/2 bytes op */ u8 n_bytes; /* current is a 1/2 bytes op */
u8 max_bits_per_word; /* maxim is 16b */ u8 max_bits_per_word; /* maxim is 16b */
u32 dma_width; u32 dma_width;
int cs_change;
irqreturn_t (*transfer_handler)(struct dw_spi *dws); irqreturn_t (*transfer_handler)(struct dw_spi *dws);
void (*cs_control)(u32 command); void (*cs_control)(u32 command);
...@@ -231,7 +228,7 @@ struct dw_spi_chip { ...@@ -231,7 +228,7 @@ struct dw_spi_chip {
void (*cs_control)(u32 command); void (*cs_control)(u32 command);
}; };
extern int dw_spi_add_host(struct dw_spi *dws); extern int dw_spi_add_host(struct device *dev, struct dw_spi *dws);
extern void dw_spi_remove_host(struct dw_spi *dws); extern void dw_spi_remove_host(struct dw_spi *dws);
extern int dw_spi_suspend_host(struct dw_spi *dws); extern int dw_spi_suspend_host(struct dw_spi *dws);
extern int dw_spi_resume_host(struct dw_spi *dws); extern int dw_spi_resume_host(struct dw_spi *dws);
......
...@@ -433,21 +433,12 @@ static int falcon_sflash_probe(struct platform_device *pdev) ...@@ -433,21 +433,12 @@ static int falcon_sflash_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
ret = spi_register_master(master); ret = devm_spi_register_master(&pdev->dev, master);
if (ret) if (ret)
spi_master_put(master); spi_master_put(master);
return ret; return ret;
} }
static int falcon_sflash_remove(struct platform_device *pdev)
{
struct falcon_sflash *priv = platform_get_drvdata(pdev);
spi_unregister_master(priv->master);
return 0;
}
static const struct of_device_id falcon_sflash_match[] = { static const struct of_device_id falcon_sflash_match[] = {
{ .compatible = "lantiq,sflash-falcon" }, { .compatible = "lantiq,sflash-falcon" },
{}, {},
...@@ -456,7 +447,6 @@ MODULE_DEVICE_TABLE(of, falcon_sflash_match); ...@@ -456,7 +447,6 @@ MODULE_DEVICE_TABLE(of, falcon_sflash_match);
static struct platform_driver falcon_sflash_driver = { static struct platform_driver falcon_sflash_driver = {
.probe = falcon_sflash_probe, .probe = falcon_sflash_probe,
.remove = falcon_sflash_remove,
.driver = { .driver = {
.name = DRV_NAME, .name = DRV_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
......
...@@ -320,8 +320,10 @@ static void dspi_chipselect(struct spi_device *spi, int value) ...@@ -320,8 +320,10 @@ static void dspi_chipselect(struct spi_device *spi, int value)
switch (value) { switch (value) {
case BITBANG_CS_ACTIVE: case BITBANG_CS_ACTIVE:
pushr |= SPI_PUSHR_CONT; pushr |= SPI_PUSHR_CONT;
break;
case BITBANG_CS_INACTIVE: case BITBANG_CS_INACTIVE:
pushr &= ~SPI_PUSHR_CONT; pushr &= ~SPI_PUSHR_CONT;
break;
} }
writel(pushr, dspi->base + SPI_PUSHR); writel(pushr, dspi->base + SPI_PUSHR);
...@@ -373,9 +375,6 @@ static int dspi_setup(struct spi_device *spi) ...@@ -373,9 +375,6 @@ static int dspi_setup(struct spi_device *spi)
if (!spi->max_speed_hz) if (!spi->max_speed_hz)
return -EINVAL; return -EINVAL;
if (!spi->bits_per_word)
spi->bits_per_word = 8;
return dspi_setup_transfer(spi, NULL); return dspi_setup_transfer(spi, NULL);
} }
......
...@@ -705,7 +705,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev) ...@@ -705,7 +705,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
goto err; goto err;
irq = irq_of_parse_and_map(np, 0); irq = irq_of_parse_and_map(np, 0);
if (!ret) { if (!irq) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
...@@ -727,6 +727,66 @@ static int of_fsl_espi_remove(struct platform_device *dev) ...@@ -727,6 +727,66 @@ static int of_fsl_espi_remove(struct platform_device *dev)
return mpc8xxx_spi_remove(&dev->dev); return mpc8xxx_spi_remove(&dev->dev);
} }
#ifdef CONFIG_PM_SLEEP
static int of_fsl_espi_suspend(struct device *dev)
{
struct spi_master *master = dev_get_drvdata(dev);
struct mpc8xxx_spi *mpc8xxx_spi;
struct fsl_espi_reg *reg_base;
u32 regval;
int ret;
mpc8xxx_spi = spi_master_get_devdata(master);
reg_base = mpc8xxx_spi->reg_base;
ret = spi_master_suspend(master);
if (ret) {
dev_warn(dev, "cannot suspend master\n");
return ret;
}
regval = mpc8xxx_spi_read_reg(&reg_base->mode);
regval &= ~SPMODE_ENABLE;
mpc8xxx_spi_write_reg(&reg_base->mode, regval);
return 0;
}
static int of_fsl_espi_resume(struct device *dev)
{
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
struct spi_master *master = dev_get_drvdata(dev);
struct mpc8xxx_spi *mpc8xxx_spi;
struct fsl_espi_reg *reg_base;
u32 regval;
int i;
mpc8xxx_spi = spi_master_get_devdata(master);
reg_base = mpc8xxx_spi->reg_base;
/* SPI controller initializations */
mpc8xxx_spi_write_reg(&reg_base->mode, 0);
mpc8xxx_spi_write_reg(&reg_base->mask, 0);
mpc8xxx_spi_write_reg(&reg_base->command, 0);
mpc8xxx_spi_write_reg(&reg_base->event, 0xffffffff);
/* Init eSPI CS mode register */
for (i = 0; i < pdata->max_chipselect; i++)
mpc8xxx_spi_write_reg(&reg_base->csmode[i], CSMODE_INIT_VAL);
/* Enable SPI interface */
regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
mpc8xxx_spi_write_reg(&reg_base->mode, regval);
return spi_master_resume(master);
}
#endif /* CONFIG_PM_SLEEP */
static const struct dev_pm_ops espi_pm = {
SET_SYSTEM_SLEEP_PM_OPS(of_fsl_espi_suspend, of_fsl_espi_resume)
};
static const struct of_device_id of_fsl_espi_match[] = { static const struct of_device_id of_fsl_espi_match[] = {
{ .compatible = "fsl,mpc8536-espi" }, { .compatible = "fsl,mpc8536-espi" },
{} {}
...@@ -738,6 +798,7 @@ static struct platform_driver fsl_espi_driver = { ...@@ -738,6 +798,7 @@ static struct platform_driver fsl_espi_driver = {
.name = "fsl_espi", .name = "fsl_espi",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = of_fsl_espi_match, .of_match_table = of_fsl_espi_match,
.pm = &espi_pm,
}, },
.probe = of_fsl_espi_probe, .probe = of_fsl_espi_probe,
.remove = of_fsl_espi_remove, .remove = of_fsl_espi_remove,
......
...@@ -115,17 +115,17 @@ spi_to_pdata(const struct spi_device *spi) ...@@ -115,17 +115,17 @@ spi_to_pdata(const struct spi_device *spi)
static inline void setsck(const struct spi_device *spi, int is_on) static inline void setsck(const struct spi_device *spi, int is_on)
{ {
gpio_set_value(SPI_SCK_GPIO, is_on); gpio_set_value_cansleep(SPI_SCK_GPIO, is_on);
} }
static inline void setmosi(const struct spi_device *spi, int is_on) static inline void setmosi(const struct spi_device *spi, int is_on)
{ {
gpio_set_value(SPI_MOSI_GPIO, is_on); gpio_set_value_cansleep(SPI_MOSI_GPIO, is_on);
} }
static inline int getmiso(const struct spi_device *spi) static inline int getmiso(const struct spi_device *spi)
{ {
return !!gpio_get_value(SPI_MISO_GPIO); return !!gpio_get_value_cansleep(SPI_MISO_GPIO);
} }
#undef pdata #undef pdata
...@@ -229,7 +229,7 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active) ...@@ -229,7 +229,7 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active)
if (cs != SPI_GPIO_NO_CHIPSELECT) { if (cs != SPI_GPIO_NO_CHIPSELECT) {
/* SPI is normally active-low */ /* SPI is normally active-low */
gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); gpio_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
} }
} }
......
...@@ -206,7 +206,8 @@ static unsigned int spi_imx_clkdiv_2(unsigned int fin, ...@@ -206,7 +206,8 @@ static unsigned int spi_imx_clkdiv_2(unsigned int fin,
#define MX51_ECSPI_STAT_RR (1 << 3) #define MX51_ECSPI_STAT_RR (1 << 3)
/* MX51 eCSPI */ /* MX51 eCSPI */
static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi) static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi,
unsigned int *fres)
{ {
/* /*
* there are two 4-bit dividers, the pre-divider divides by * there are two 4-bit dividers, the pre-divider divides by
...@@ -234,6 +235,10 @@ static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi) ...@@ -234,6 +235,10 @@ static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi)
pr_debug("%s: fin: %u, fspi: %u, post: %u, pre: %u\n", pr_debug("%s: fin: %u, fspi: %u, post: %u, pre: %u\n",
__func__, fin, fspi, post, pre); __func__, fin, fspi, post, pre);
/* Resulting frequency for the SCLK line. */
*fres = (fin / (pre + 1)) >> post;
return (pre << MX51_ECSPI_CTRL_PREDIV_OFFSET) | return (pre << MX51_ECSPI_CTRL_PREDIV_OFFSET) |
(post << MX51_ECSPI_CTRL_POSTDIV_OFFSET); (post << MX51_ECSPI_CTRL_POSTDIV_OFFSET);
} }
...@@ -264,6 +269,7 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, ...@@ -264,6 +269,7 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx,
struct spi_imx_config *config) struct spi_imx_config *config)
{ {
u32 ctrl = MX51_ECSPI_CTRL_ENABLE, cfg = 0; u32 ctrl = MX51_ECSPI_CTRL_ENABLE, cfg = 0;
u32 clk = config->speed_hz, delay;
/* /*
* The hardware seems to have a race condition when changing modes. The * The hardware seems to have a race condition when changing modes. The
...@@ -275,7 +281,7 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, ...@@ -275,7 +281,7 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx,
ctrl |= MX51_ECSPI_CTRL_MODE_MASK; ctrl |= MX51_ECSPI_CTRL_MODE_MASK;
/* set clock speed */ /* set clock speed */
ctrl |= mx51_ecspi_clkdiv(spi_imx->spi_clk, config->speed_hz); ctrl |= mx51_ecspi_clkdiv(spi_imx->spi_clk, config->speed_hz, &clk);
/* set chip select to use */ /* set chip select to use */
ctrl |= MX51_ECSPI_CTRL_CS(config->cs); ctrl |= MX51_ECSPI_CTRL_CS(config->cs);
...@@ -297,6 +303,23 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx, ...@@ -297,6 +303,23 @@ static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx,
writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL);
writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG);
/*
* Wait until the changes in the configuration register CONFIGREG
* propagate into the hardware. It takes exactly one tick of the
* SCLK clock, but we will wait two SCLK clock just to be sure. The
* effect of the delay it takes for the hardware to apply changes
* is noticable if the SCLK clock run very slow. In such a case, if
* the polarity of SCLK should be inverted, the GPIO ChipSelect might
* be asserted before the SCLK polarity changes, which would disrupt
* the SPI communication as the device on the other end would consider
* the change of SCLK polarity as a clock tick already.
*/
delay = (2 * 1000000) / clk;
if (likely(delay < 10)) /* SCLK is faster than 100 kHz */
udelay(delay);
else /* SCLK is _very_ slow */
usleep_range(delay, delay + 10);
return 0; return 0;
} }
......
...@@ -504,7 +504,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, ...@@ -504,7 +504,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
master->cleanup = mpc512x_psc_spi_cleanup; master->cleanup = mpc512x_psc_spi_cleanup;
master->dev.of_node = dev->of_node; master->dev.of_node = dev->of_node;
tempp = ioremap(regaddr, size); tempp = devm_ioremap(dev, regaddr, size);
if (!tempp) { if (!tempp) {
dev_err(dev, "could not ioremap I/O port range\n"); dev_err(dev, "could not ioremap I/O port range\n");
ret = -EFAULT; ret = -EFAULT;
...@@ -513,8 +513,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, ...@@ -513,8 +513,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
mps->psc = tempp; mps->psc = tempp;
mps->fifo = mps->fifo =
(struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc)); (struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
ret = request_irq(mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
"mpc512x-psc-spi", mps); "mpc512x-psc-spi", mps);
if (ret) if (ret)
goto free_master; goto free_master;
...@@ -525,11 +524,11 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, ...@@ -525,11 +524,11 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
clk = devm_clk_get(dev, clk_name); clk = devm_clk_get(dev, clk_name);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
ret = PTR_ERR(clk); ret = PTR_ERR(clk);
goto free_irq; goto free_master;
} }
ret = clk_prepare_enable(clk); ret = clk_prepare_enable(clk);
if (ret) if (ret)
goto free_irq; goto free_master;
mps->clk_mclk = clk; mps->clk_mclk = clk;
mps->mclk_rate = clk_get_rate(clk); mps->mclk_rate = clk_get_rate(clk);
...@@ -545,11 +544,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, ...@@ -545,11 +544,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
free_clock: free_clock:
clk_disable_unprepare(mps->clk_mclk); clk_disable_unprepare(mps->clk_mclk);
free_irq:
free_irq(mps->irq, mps);
free_master: free_master:
if (mps->psc)
iounmap(mps->psc);
spi_master_put(master); spi_master_put(master);
return ret; return ret;
...@@ -561,9 +556,6 @@ static int mpc512x_psc_spi_do_remove(struct device *dev) ...@@ -561,9 +556,6 @@ static int mpc512x_psc_spi_do_remove(struct device *dev)
struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
clk_disable_unprepare(mps->clk_mclk); clk_disable_unprepare(mps->clk_mclk);
free_irq(mps->irq, mps);
if (mps->psc)
iounmap(mps->psc);
return 0; return 0;
} }
......
...@@ -111,14 +111,6 @@ static int mxs_spi_setup_transfer(struct spi_device *dev, ...@@ -111,14 +111,6 @@ static int mxs_spi_setup_transfer(struct spi_device *dev,
return 0; return 0;
} }
static int mxs_spi_setup(struct spi_device *dev)
{
if (!dev->bits_per_word)
dev->bits_per_word = 8;
return 0;
}
static u32 mxs_spi_cs_to_reg(unsigned cs) static u32 mxs_spi_cs_to_reg(unsigned cs)
{ {
u32 select = 0; u32 select = 0;
...@@ -502,7 +494,6 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -502,7 +494,6 @@ static int mxs_spi_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
master->transfer_one_message = mxs_spi_transfer_one; master->transfer_one_message = mxs_spi_transfer_one;
master->setup = mxs_spi_setup;
master->bits_per_word_mask = SPI_BPW_MASK(8); master->bits_per_word_mask = SPI_BPW_MASK(8);
master->mode_bits = SPI_CPOL | SPI_CPHA; master->mode_bits = SPI_CPOL | SPI_CPHA;
master->num_chipselect = 3; master->num_chipselect = 3;
......
...@@ -57,7 +57,6 @@ struct nuc900_spi { ...@@ -57,7 +57,6 @@ struct nuc900_spi {
const unsigned char *tx; const unsigned char *tx;
unsigned char *rx; unsigned char *rx;
struct clk *clk; struct clk *clk;
struct resource *ioarea;
struct spi_master *master; struct spi_master *master;
struct spi_device *curdev; struct spi_device *curdev;
struct device *dev; struct device *dev;
...@@ -344,8 +343,7 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -344,8 +343,7 @@ static int nuc900_spi_probe(struct platform_device *pdev)
master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi));
if (master == NULL) { if (master == NULL) {
dev_err(&pdev->dev, "No memory for spi_master\n"); dev_err(&pdev->dev, "No memory for spi_master\n");
err = -ENOMEM; return -ENOMEM;
goto err_nomem;
} }
hw = spi_master_get_devdata(master); hw = spi_master_get_devdata(master);
...@@ -370,46 +368,31 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -370,46 +368,31 @@ static int nuc900_spi_probe(struct platform_device *pdev)
hw->bitbang.txrx_bufs = nuc900_spi_txrx; hw->bitbang.txrx_bufs = nuc900_spi_txrx;
hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (hw->res == NULL) { hw->regs = devm_ioremap_resource(&pdev->dev, hw->res);
dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); if (IS_ERR(hw->regs)) {
err = -ENOENT; err = PTR_ERR(hw->regs);
goto err_pdata;
}
hw->ioarea = request_mem_region(hw->res->start,
resource_size(hw->res), pdev->name);
if (hw->ioarea == NULL) {
dev_err(&pdev->dev, "Cannot reserve region\n");
err = -ENXIO;
goto err_pdata; goto err_pdata;
} }
hw->regs = ioremap(hw->res->start, resource_size(hw->res));
if (hw->regs == NULL) {
dev_err(&pdev->dev, "Cannot map IO\n");
err = -ENXIO;
goto err_iomap;
}
hw->irq = platform_get_irq(pdev, 0); hw->irq = platform_get_irq(pdev, 0);
if (hw->irq < 0) { if (hw->irq < 0) {
dev_err(&pdev->dev, "No IRQ specified\n"); dev_err(&pdev->dev, "No IRQ specified\n");
err = -ENOENT; err = -ENOENT;
goto err_irq; goto err_pdata;
} }
err = request_irq(hw->irq, nuc900_spi_irq, 0, pdev->name, hw); err = devm_request_irq(&pdev->dev, hw->irq, nuc900_spi_irq, 0,
pdev->name, hw);
if (err) { if (err) {
dev_err(&pdev->dev, "Cannot claim IRQ\n"); dev_err(&pdev->dev, "Cannot claim IRQ\n");
goto err_irq; goto err_pdata;
} }
hw->clk = clk_get(&pdev->dev, "spi"); hw->clk = devm_clk_get(&pdev->dev, "spi");
if (IS_ERR(hw->clk)) { if (IS_ERR(hw->clk)) {
dev_err(&pdev->dev, "No clock for device\n"); dev_err(&pdev->dev, "No clock for device\n");
err = PTR_ERR(hw->clk); err = PTR_ERR(hw->clk);
goto err_clk; goto err_pdata;
} }
mfp_set_groupg(&pdev->dev, NULL); mfp_set_groupg(&pdev->dev, NULL);
...@@ -425,17 +408,8 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -425,17 +408,8 @@ static int nuc900_spi_probe(struct platform_device *pdev)
err_register: err_register:
clk_disable(hw->clk); clk_disable(hw->clk);
clk_put(hw->clk);
err_clk:
free_irq(hw->irq, hw);
err_irq:
iounmap(hw->regs);
err_iomap:
release_mem_region(hw->res->start, resource_size(hw->res));
kfree(hw->ioarea);
err_pdata: err_pdata:
spi_master_put(hw->master); spi_master_put(hw->master);
err_nomem:
return err; return err;
} }
...@@ -443,18 +417,8 @@ static int nuc900_spi_remove(struct platform_device *dev) ...@@ -443,18 +417,8 @@ static int nuc900_spi_remove(struct platform_device *dev)
{ {
struct nuc900_spi *hw = platform_get_drvdata(dev); struct nuc900_spi *hw = platform_get_drvdata(dev);
free_irq(hw->irq, hw);
spi_bitbang_stop(&hw->bitbang); spi_bitbang_stop(&hw->bitbang);
clk_disable(hw->clk); clk_disable(hw->clk);
clk_put(hw->clk);
iounmap(hw->regs);
release_mem_region(hw->res->start, resource_size(hw->res));
kfree(hw->ioarea);
spi_master_put(hw->master); spi_master_put(hw->master);
return 0; return 0;
} }
......
...@@ -153,62 +153,22 @@ static int tiny_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -153,62 +153,22 @@ static int tiny_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
} }
wait_for_completion(&hw->done); wait_for_completion(&hw->done);
} else if (txp && rxp) { } else {
/* we need to tighten the transfer loop */ /* we need to tighten the transfer loop */
writeb(*txp++, hw->base + TINY_SPI_TXDATA); writeb(txp ? *txp++ : 0, hw->base + TINY_SPI_TXDATA);
if (t->len > 1) { for (i = 1; i < t->len; i++) {
writeb(*txp++, hw->base + TINY_SPI_TXDATA); writeb(txp ? *txp++ : 0, hw->base + TINY_SPI_TXDATA);
for (i = 2; i < t->len; i++) {
u8 rx, tx = *txp++; if (rxp || (i != t->len - 1))
tiny_spi_wait_txr(hw);
rx = readb(hw->base + TINY_SPI_TXDATA);
writeb(tx, hw->base + TINY_SPI_TXDATA);
*rxp++ = rx;
}
tiny_spi_wait_txr(hw);
*rxp++ = readb(hw->base + TINY_SPI_TXDATA);
}
tiny_spi_wait_txe(hw);
*rxp++ = readb(hw->base + TINY_SPI_RXDATA);
} else if (rxp) {
writeb(0, hw->base + TINY_SPI_TXDATA);
if (t->len > 1) {
writeb(0,
hw->base + TINY_SPI_TXDATA);
for (i = 2; i < t->len; i++) {
u8 rx;
tiny_spi_wait_txr(hw);
rx = readb(hw->base + TINY_SPI_TXDATA);
writeb(0, hw->base + TINY_SPI_TXDATA);
*rxp++ = rx;
}
tiny_spi_wait_txr(hw); tiny_spi_wait_txr(hw);
if (rxp)
*rxp++ = readb(hw->base + TINY_SPI_TXDATA); *rxp++ = readb(hw->base + TINY_SPI_TXDATA);
} }
tiny_spi_wait_txe(hw); tiny_spi_wait_txe(hw);
if (rxp)
*rxp++ = readb(hw->base + TINY_SPI_RXDATA); *rxp++ = readb(hw->base + TINY_SPI_RXDATA);
} else if (txp) {
writeb(*txp++, hw->base + TINY_SPI_TXDATA);
if (t->len > 1) {
writeb(*txp++, hw->base + TINY_SPI_TXDATA);
for (i = 2; i < t->len; i++) {
u8 tx = *txp++;
tiny_spi_wait_txr(hw);
writeb(tx, hw->base + TINY_SPI_TXDATA);
}
}
tiny_spi_wait_txe(hw);
} else {
writeb(0, hw->base + TINY_SPI_TXDATA);
if (t->len > 1) {
writeb(0, hw->base + TINY_SPI_TXDATA);
for (i = 2; i < t->len; i++) {
tiny_spi_wait_txr(hw);
writeb(0, hw->base + TINY_SPI_TXDATA);
}
}
tiny_spi_wait_txe(hw);
} }
return t->len; return t->len;
} }
......
...@@ -470,31 +470,12 @@ static int omap1_spi100k_probe(struct platform_device *pdev) ...@@ -470,31 +470,12 @@ static int omap1_spi100k_probe(struct platform_device *pdev)
return status; return status;
} }
static int omap1_spi100k_remove(struct platform_device *pdev)
{
struct spi_master *master;
struct omap1_spi100k *spi100k;
struct resource *r;
int status = 0;
master = platform_get_drvdata(pdev);
spi100k = spi_master_get_devdata(master);
if (status != 0)
return status;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
return 0;
}
static struct platform_driver omap1_spi100k_driver = { static struct platform_driver omap1_spi100k_driver = {
.driver = { .driver = {
.name = "omap1_spi100k", .name = "omap1_spi100k",
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = omap1_spi100k_probe, .probe = omap1_spi100k_probe,
.remove = omap1_spi100k_remove,
}; };
module_platform_driver(omap1_spi100k_driver); module_platform_driver(omap1_spi100k_driver);
...@@ -502,4 +483,3 @@ module_platform_driver(omap1_spi100k_driver); ...@@ -502,4 +483,3 @@ module_platform_driver(omap1_spi100k_driver);
MODULE_DESCRIPTION("OMAP7xx SPI 100k controller driver"); MODULE_DESCRIPTION("OMAP7xx SPI 100k controller driver");
MODULE_AUTHOR("Fabrice Crohas <fcrohas@gmail.com>"); MODULE_AUTHOR("Fabrice Crohas <fcrohas@gmail.com>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -157,14 +157,14 @@ static inline void mcspi_write_reg(struct spi_master *master, ...@@ -157,14 +157,14 @@ static inline void mcspi_write_reg(struct spi_master *master,
{ {
struct omap2_mcspi *mcspi = spi_master_get_devdata(master); struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
__raw_writel(val, mcspi->base + idx); writel_relaxed(val, mcspi->base + idx);
} }
static inline u32 mcspi_read_reg(struct spi_master *master, int idx) static inline u32 mcspi_read_reg(struct spi_master *master, int idx)
{ {
struct omap2_mcspi *mcspi = spi_master_get_devdata(master); struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
return __raw_readl(mcspi->base + idx); return readl_relaxed(mcspi->base + idx);
} }
static inline void mcspi_write_cs_reg(const struct spi_device *spi, static inline void mcspi_write_cs_reg(const struct spi_device *spi,
...@@ -172,14 +172,14 @@ static inline void mcspi_write_cs_reg(const struct spi_device *spi, ...@@ -172,14 +172,14 @@ static inline void mcspi_write_cs_reg(const struct spi_device *spi,
{ {
struct omap2_mcspi_cs *cs = spi->controller_state; struct omap2_mcspi_cs *cs = spi->controller_state;
__raw_writel(val, cs->base + idx); writel_relaxed(val, cs->base + idx);
} }
static inline u32 mcspi_read_cs_reg(const struct spi_device *spi, int idx) static inline u32 mcspi_read_cs_reg(const struct spi_device *spi, int idx)
{ {
struct omap2_mcspi_cs *cs = spi->controller_state; struct omap2_mcspi_cs *cs = spi->controller_state;
return __raw_readl(cs->base + idx); return readl_relaxed(cs->base + idx);
} }
static inline u32 mcspi_cached_chconf0(const struct spi_device *spi) static inline u32 mcspi_cached_chconf0(const struct spi_device *spi)
...@@ -338,7 +338,7 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi) ...@@ -338,7 +338,7 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable); mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE, ctx->wakeupenable);
list_for_each_entry(cs, &ctx->cs, node) list_for_each_entry(cs, &ctx->cs, node)
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); writel_relaxed(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
} }
static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit) static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
...@@ -346,9 +346,9 @@ static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit) ...@@ -346,9 +346,9 @@ static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
unsigned long timeout; unsigned long timeout;
timeout = jiffies + msecs_to_jiffies(1000); timeout = jiffies + msecs_to_jiffies(1000);
while (!(__raw_readl(reg) & bit)) { while (!(readl_relaxed(reg) & bit)) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
if (!(__raw_readl(reg) & bit)) if (!(readl_relaxed(reg) & bit))
return -ETIMEDOUT; return -ETIMEDOUT;
else else
return 0; return 0;
...@@ -675,7 +675,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -675,7 +675,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
} }
dev_vdbg(&spi->dev, "write-%d %02x\n", dev_vdbg(&spi->dev, "write-%d %02x\n",
word_len, *tx); word_len, *tx);
__raw_writel(*tx++, tx_reg); writel_relaxed(*tx++, tx_reg);
} }
if (rx != NULL) { if (rx != NULL) {
if (mcspi_wait_for_reg_bit(chstat_reg, if (mcspi_wait_for_reg_bit(chstat_reg,
...@@ -687,7 +687,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -687,7 +687,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
if (c == 1 && tx == NULL && if (c == 1 && tx == NULL &&
(l & OMAP2_MCSPI_CHCONF_TURBO)) { (l & OMAP2_MCSPI_CHCONF_TURBO)) {
omap2_mcspi_set_enable(spi, 0); omap2_mcspi_set_enable(spi, 0);
*rx++ = __raw_readl(rx_reg); *rx++ = readl_relaxed(rx_reg);
dev_vdbg(&spi->dev, "read-%d %02x\n", dev_vdbg(&spi->dev, "read-%d %02x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
if (mcspi_wait_for_reg_bit(chstat_reg, if (mcspi_wait_for_reg_bit(chstat_reg,
...@@ -701,7 +701,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -701,7 +701,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
omap2_mcspi_set_enable(spi, 0); omap2_mcspi_set_enable(spi, 0);
} }
*rx++ = __raw_readl(rx_reg); *rx++ = readl_relaxed(rx_reg);
dev_vdbg(&spi->dev, "read-%d %02x\n", dev_vdbg(&spi->dev, "read-%d %02x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
} }
...@@ -722,7 +722,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -722,7 +722,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
} }
dev_vdbg(&spi->dev, "write-%d %04x\n", dev_vdbg(&spi->dev, "write-%d %04x\n",
word_len, *tx); word_len, *tx);
__raw_writel(*tx++, tx_reg); writel_relaxed(*tx++, tx_reg);
} }
if (rx != NULL) { if (rx != NULL) {
if (mcspi_wait_for_reg_bit(chstat_reg, if (mcspi_wait_for_reg_bit(chstat_reg,
...@@ -734,7 +734,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -734,7 +734,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
if (c == 2 && tx == NULL && if (c == 2 && tx == NULL &&
(l & OMAP2_MCSPI_CHCONF_TURBO)) { (l & OMAP2_MCSPI_CHCONF_TURBO)) {
omap2_mcspi_set_enable(spi, 0); omap2_mcspi_set_enable(spi, 0);
*rx++ = __raw_readl(rx_reg); *rx++ = readl_relaxed(rx_reg);
dev_vdbg(&spi->dev, "read-%d %04x\n", dev_vdbg(&spi->dev, "read-%d %04x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
if (mcspi_wait_for_reg_bit(chstat_reg, if (mcspi_wait_for_reg_bit(chstat_reg,
...@@ -748,7 +748,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -748,7 +748,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
omap2_mcspi_set_enable(spi, 0); omap2_mcspi_set_enable(spi, 0);
} }
*rx++ = __raw_readl(rx_reg); *rx++ = readl_relaxed(rx_reg);
dev_vdbg(&spi->dev, "read-%d %04x\n", dev_vdbg(&spi->dev, "read-%d %04x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
} }
...@@ -769,7 +769,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -769,7 +769,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
} }
dev_vdbg(&spi->dev, "write-%d %08x\n", dev_vdbg(&spi->dev, "write-%d %08x\n",
word_len, *tx); word_len, *tx);
__raw_writel(*tx++, tx_reg); writel_relaxed(*tx++, tx_reg);
} }
if (rx != NULL) { if (rx != NULL) {
if (mcspi_wait_for_reg_bit(chstat_reg, if (mcspi_wait_for_reg_bit(chstat_reg,
...@@ -781,7 +781,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -781,7 +781,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
if (c == 4 && tx == NULL && if (c == 4 && tx == NULL &&
(l & OMAP2_MCSPI_CHCONF_TURBO)) { (l & OMAP2_MCSPI_CHCONF_TURBO)) {
omap2_mcspi_set_enable(spi, 0); omap2_mcspi_set_enable(spi, 0);
*rx++ = __raw_readl(rx_reg); *rx++ = readl_relaxed(rx_reg);
dev_vdbg(&spi->dev, "read-%d %08x\n", dev_vdbg(&spi->dev, "read-%d %08x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
if (mcspi_wait_for_reg_bit(chstat_reg, if (mcspi_wait_for_reg_bit(chstat_reg,
...@@ -795,7 +795,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -795,7 +795,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
omap2_mcspi_set_enable(spi, 0); omap2_mcspi_set_enable(spi, 0);
} }
*rx++ = __raw_readl(rx_reg); *rx++ = readl_relaxed(rx_reg);
dev_vdbg(&spi->dev, "read-%d %08x\n", dev_vdbg(&spi->dev, "read-%d %08x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
} }
...@@ -1107,7 +1107,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m) ...@@ -1107,7 +1107,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
/* RX_ONLY mode needs dummy data in TX reg */ /* RX_ONLY mode needs dummy data in TX reg */
if (t->tx_buf == NULL) if (t->tx_buf == NULL)
__raw_writel(0, cs->base writel_relaxed(0, cs->base
+ OMAP2_MCSPI_TX0); + OMAP2_MCSPI_TX0);
if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) && if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&
...@@ -1470,9 +1470,9 @@ static int omap2_mcspi_resume(struct device *dev) ...@@ -1470,9 +1470,9 @@ static int omap2_mcspi_resume(struct device *dev)
* change in account. * change in account.
*/ */
cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE; cs->chconf0 |= OMAP2_MCSPI_CHCONF_FORCE;
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); writel_relaxed(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE; cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
__raw_writel(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0); writel_relaxed(cs->chconf0, cs->base + OMAP2_MCSPI_CHCONF0);
} }
} }
pm_runtime_mark_last_busy(mcspi->dev); pm_runtime_mark_last_busy(mcspi->dev);
......
...@@ -434,7 +434,7 @@ static int orion_spi_probe(struct platform_device *pdev) ...@@ -434,7 +434,7 @@ static int orion_spi_probe(struct platform_device *pdev)
spi = spi_master_get_devdata(master); spi = spi_master_get_devdata(master);
spi->master = master; spi->master = master;
spi->clk = clk_get(&pdev->dev, NULL); spi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(spi->clk)) { if (IS_ERR(spi->clk)) {
status = PTR_ERR(spi->clk); status = PTR_ERR(spi->clk);
goto out; goto out;
...@@ -465,7 +465,6 @@ static int orion_spi_probe(struct platform_device *pdev) ...@@ -465,7 +465,6 @@ static int orion_spi_probe(struct platform_device *pdev)
out_rel_clk: out_rel_clk:
clk_disable_unprepare(spi->clk); clk_disable_unprepare(spi->clk);
clk_put(spi->clk);
out: out:
spi_master_put(master); spi_master_put(master);
return status; return status;
...@@ -481,7 +480,6 @@ static int orion_spi_remove(struct platform_device *pdev) ...@@ -481,7 +480,6 @@ static int orion_spi_remove(struct platform_device *pdev)
spi = spi_master_get_devdata(master); spi = spi_master_get_devdata(master);
clk_disable_unprepare(spi->clk); clk_disable_unprepare(spi->clk);
clk_put(spi->clk);
return 0; return 0;
} }
......
...@@ -62,7 +62,7 @@ static void ce4100_spi_remove(struct pci_dev *dev) ...@@ -62,7 +62,7 @@ static void ce4100_spi_remove(struct pci_dev *dev)
platform_device_unregister(pdev); platform_device_unregister(pdev);
} }
static DEFINE_PCI_DEVICE_TABLE(ce4100_spi_devices) = { static const struct pci_device_id ce4100_spi_devices[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e6a) },
{ }, { },
}; };
......
...@@ -1066,6 +1066,8 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) ...@@ -1066,6 +1066,8 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
pdata->num_chipselect = 1; pdata->num_chipselect = 1;
pdata->enable_dma = true; pdata->enable_dma = true;
pdata->tx_chan_id = -1;
pdata->rx_chan_id = -1;
return pdata; return pdata;
} }
...@@ -1266,7 +1268,7 @@ static void pxa2xx_spi_shutdown(struct platform_device *pdev) ...@@ -1266,7 +1268,7 @@ static void pxa2xx_spi_shutdown(struct platform_device *pdev)
dev_err(&pdev->dev, "shutdown failed with %d\n", status); dev_err(&pdev->dev, "shutdown failed with %d\n", status);
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP
static int pxa2xx_spi_suspend(struct device *dev) static int pxa2xx_spi_suspend(struct device *dev)
{ {
struct driver_data *drv_data = dev_get_drvdata(dev); struct driver_data *drv_data = dev_get_drvdata(dev);
......
This diff is collapsed.
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <plat/regs-spi.h> #include <plat/regs-spi.h>
#include <plat/fiq.h>
#include <asm/fiq.h> #include <asm/fiq.h>
#include "spi-s3c24xx-fiq.h" #include "spi-s3c24xx-fiq.h"
...@@ -78,14 +77,12 @@ struct s3c24xx_spi { ...@@ -78,14 +77,12 @@ struct s3c24xx_spi {
unsigned char *rx; unsigned char *rx;
struct clk *clk; struct clk *clk;
struct resource *ioarea;
struct spi_master *master; struct spi_master *master;
struct spi_device *curdev; struct spi_device *curdev;
struct device *dev; struct device *dev;
struct s3c2410_spi_info *pdata; struct s3c2410_spi_info *pdata;
}; };
#define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT) #define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT)
#define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP) #define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP)
...@@ -517,8 +514,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -517,8 +514,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
if (master == NULL) { if (master == NULL) {
dev_err(&pdev->dev, "No memory for spi_master\n"); dev_err(&pdev->dev, "No memory for spi_master\n");
err = -ENOMEM; return -ENOMEM;
goto err_nomem;
} }
hw = spi_master_get_devdata(master); hw = spi_master_get_devdata(master);
...@@ -562,48 +558,32 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -562,48 +558,32 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang); dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);
/* find and map our resources */ /* find and map our resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) { hw->regs = devm_ioremap_resource(&pdev->dev, res);
dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); if (IS_ERR(hw->regs)) {
err = -ENOENT; err = PTR_ERR(hw->regs);
goto err_no_iores; goto err_no_pdata;
}
hw->ioarea = request_mem_region(res->start, resource_size(res),
pdev->name);
if (hw->ioarea == NULL) {
dev_err(&pdev->dev, "Cannot reserve region\n");
err = -ENXIO;
goto err_no_iores;
}
hw->regs = ioremap(res->start, resource_size(res));
if (hw->regs == NULL) {
dev_err(&pdev->dev, "Cannot map IO\n");
err = -ENXIO;
goto err_no_iomap;
} }
hw->irq = platform_get_irq(pdev, 0); hw->irq = platform_get_irq(pdev, 0);
if (hw->irq < 0) { if (hw->irq < 0) {
dev_err(&pdev->dev, "No IRQ specified\n"); dev_err(&pdev->dev, "No IRQ specified\n");
err = -ENOENT; err = -ENOENT;
goto err_no_irq; goto err_no_pdata;
} }
err = request_irq(hw->irq, s3c24xx_spi_irq, 0, pdev->name, hw); err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0,
pdev->name, hw);
if (err) { if (err) {
dev_err(&pdev->dev, "Cannot claim IRQ\n"); dev_err(&pdev->dev, "Cannot claim IRQ\n");
goto err_no_irq; goto err_no_pdata;
} }
hw->clk = clk_get(&pdev->dev, "spi"); hw->clk = devm_clk_get(&pdev->dev, "spi");
if (IS_ERR(hw->clk)) { if (IS_ERR(hw->clk)) {
dev_err(&pdev->dev, "No clock for device\n"); dev_err(&pdev->dev, "No clock for device\n");
err = PTR_ERR(hw->clk); err = PTR_ERR(hw->clk);
goto err_no_clk; goto err_no_pdata;
} }
/* setup any gpio we can */ /* setup any gpio we can */
...@@ -615,7 +595,8 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -615,7 +595,8 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
goto err_register; goto err_register;
} }
err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev)); err = devm_gpio_request(&pdev->dev, pdata->pin_cs,
dev_name(&pdev->dev));
if (err) { if (err) {
dev_err(&pdev->dev, "Failed to get gpio for cs\n"); dev_err(&pdev->dev, "Failed to get gpio for cs\n");
goto err_register; goto err_register;
...@@ -639,27 +620,10 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -639,27 +620,10 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
return 0; return 0;
err_register: err_register:
if (hw->set_cs == s3c24xx_spi_gpiocs)
gpio_free(pdata->pin_cs);
clk_disable(hw->clk); clk_disable(hw->clk);
clk_put(hw->clk);
err_no_clk:
free_irq(hw->irq, hw);
err_no_irq:
iounmap(hw->regs);
err_no_iomap:
release_resource(hw->ioarea);
kfree(hw->ioarea);
err_no_iores:
err_no_pdata: err_no_pdata:
spi_master_put(hw->master); spi_master_put(hw->master);
err_nomem:
return err; return err;
} }
...@@ -668,19 +632,7 @@ static int s3c24xx_spi_remove(struct platform_device *dev) ...@@ -668,19 +632,7 @@ static int s3c24xx_spi_remove(struct platform_device *dev)
struct s3c24xx_spi *hw = platform_get_drvdata(dev); struct s3c24xx_spi *hw = platform_get_drvdata(dev);
spi_bitbang_stop(&hw->bitbang); spi_bitbang_stop(&hw->bitbang);
clk_disable(hw->clk); clk_disable(hw->clk);
clk_put(hw->clk);
free_irq(hw->irq, hw);
iounmap(hw->regs);
if (hw->set_cs == s3c24xx_spi_gpiocs)
gpio_free(hw->pdata->pin_cs);
release_resource(hw->ioarea);
kfree(hw->ioarea);
spi_master_put(hw->master); spi_master_put(hw->master);
return 0; return 0;
} }
......
...@@ -927,9 +927,6 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, ...@@ -927,9 +927,6 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master,
/* Start the signals */ /* Start the signals */
writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
/* Start the signals */
writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
spin_unlock_irqrestore(&sdd->lock, flags); spin_unlock_irqrestore(&sdd->lock, flags);
status = wait_for_xfer(sdd, xfer, use_dma); status = wait_for_xfer(sdd, xfer, use_dma);
......
...@@ -183,18 +183,11 @@ static int sc18is602_setup_transfer(struct sc18is602 *hw, u32 hz, u8 mode) ...@@ -183,18 +183,11 @@ static int sc18is602_setup_transfer(struct sc18is602 *hw, u32 hz, u8 mode)
static int sc18is602_check_transfer(struct spi_device *spi, static int sc18is602_check_transfer(struct spi_device *spi,
struct spi_transfer *t, int tlen) struct spi_transfer *t, int tlen)
{ {
int bpw;
uint32_t hz; uint32_t hz;
if (t && t->len + tlen > SC18IS602_BUFSIZ) if (t && t->len + tlen > SC18IS602_BUFSIZ)
return -EINVAL; return -EINVAL;
bpw = spi->bits_per_word;
if (t && t->bits_per_word)
bpw = t->bits_per_word;
if (bpw != 8)
return -EINVAL;
hz = spi->max_speed_hz; hz = spi->max_speed_hz;
if (t && t->speed_hz) if (t && t->speed_hz)
hz = t->speed_hz; hz = t->speed_hz;
...@@ -254,9 +247,6 @@ static int sc18is602_transfer_one(struct spi_master *master, ...@@ -254,9 +247,6 @@ static int sc18is602_transfer_one(struct spi_master *master,
static int sc18is602_setup(struct spi_device *spi) static int sc18is602_setup(struct spi_device *spi)
{ {
if (!spi->bits_per_word)
spi->bits_per_word = 8;
if (spi->mode & ~(SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST)) if (spi->mode & ~(SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST))
return -EINVAL; return -EINVAL;
...@@ -315,11 +305,12 @@ static int sc18is602_probe(struct i2c_client *client, ...@@ -315,11 +305,12 @@ static int sc18is602_probe(struct i2c_client *client,
} }
master->bus_num = client->adapter->nr; master->bus_num = client->adapter->nr;
master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST; master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST;
master->bits_per_word_mask = SPI_BPW_MASK(8);
master->setup = sc18is602_setup; master->setup = sc18is602_setup;
master->transfer_one_message = sc18is602_transfer_one; master->transfer_one_message = sc18is602_transfer_one;
master->dev.of_node = np; master->dev.of_node = np;
error = spi_register_master(master); error = devm_spi_register_master(dev, master);
if (error) if (error)
goto error_reg; goto error_reg;
...@@ -330,16 +321,6 @@ static int sc18is602_probe(struct i2c_client *client, ...@@ -330,16 +321,6 @@ static int sc18is602_probe(struct i2c_client *client,
return error; return error;
} }
static int sc18is602_remove(struct i2c_client *client)
{
struct sc18is602 *hw = i2c_get_clientdata(client);
struct spi_master *master = hw->master;
spi_unregister_master(master);
return 0;
}
static const struct i2c_device_id sc18is602_id[] = { static const struct i2c_device_id sc18is602_id[] = {
{ "sc18is602", sc18is602 }, { "sc18is602", sc18is602 },
{ "sc18is602b", sc18is602b }, { "sc18is602b", sc18is602b },
...@@ -353,7 +334,6 @@ static struct i2c_driver sc18is602_driver = { ...@@ -353,7 +334,6 @@ static struct i2c_driver sc18is602_driver = {
.name = "sc18is602", .name = "sc18is602",
}, },
.probe = sc18is602_probe, .probe = sc18is602_probe,
.remove = sc18is602_remove,
.id_table = sc18is602_id, .id_table = sc18is602_id,
}; };
......
...@@ -197,7 +197,7 @@ static int hspi_transfer_one_message(struct spi_master *master, ...@@ -197,7 +197,7 @@ static int hspi_transfer_one_message(struct spi_master *master,
hspi_write(hspi, SPTBR, tx); hspi_write(hspi, SPTBR, tx);
/* wait recive */ /* wait receive */
ret = hspi_status_check_timeout(hspi, 0x4, 0x4); ret = hspi_status_check_timeout(hspi, 0x4, 0x4);
if (ret < 0) if (ret < 0)
break; break;
...@@ -353,4 +353,4 @@ module_platform_driver(hspi_driver); ...@@ -353,4 +353,4 @@ module_platform_driver(hspi_driver);
MODULE_DESCRIPTION("SuperH HSPI bus driver"); MODULE_DESCRIPTION("SuperH HSPI bus driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
MODULE_ALIAS("platform:sh_spi"); MODULE_ALIAS("platform:sh-hspi");
...@@ -152,7 +152,7 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p, ...@@ -152,7 +152,7 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
size_t k; size_t k;
if (!WARN_ON(!spi_hz || !parent_rate)) if (!WARN_ON(!spi_hz || !parent_rate))
div = parent_rate / spi_hz; div = DIV_ROUND_UP(parent_rate, spi_hz);
/* TODO: make more fine grained */ /* TODO: make more fine grained */
...@@ -169,7 +169,7 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p, ...@@ -169,7 +169,7 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p, static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
u32 cpol, u32 cpha, u32 cpol, u32 cpha,
u32 tx_hi_z, u32 lsb_first) u32 tx_hi_z, u32 lsb_first, u32 cs_high)
{ {
u32 tmp; u32 tmp;
int edge; int edge;
...@@ -182,8 +182,12 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p, ...@@ -182,8 +182,12 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
* 1 1 11 11 1 1 * 1 1 11 11 1 1
*/ */
sh_msiof_write(p, FCTR, 0); sh_msiof_write(p, FCTR, 0);
sh_msiof_write(p, TMDR1, 0xe2000005 | (lsb_first << 24));
sh_msiof_write(p, RMDR1, 0x22000005 | (lsb_first << 24)); tmp = 0;
tmp |= !cs_high << 25;
tmp |= lsb_first << 24;
sh_msiof_write(p, TMDR1, 0xe0000005 | tmp);
sh_msiof_write(p, RMDR1, 0x20000005 | tmp);
tmp = 0xa0000000; tmp = 0xa0000000;
tmp |= cpol << 30; /* TSCKIZ */ tmp |= cpol << 30; /* TSCKIZ */
...@@ -417,11 +421,12 @@ static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on) ...@@ -417,11 +421,12 @@ static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on)
sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL), sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
!!(spi->mode & SPI_CPHA), !!(spi->mode & SPI_CPHA),
!!(spi->mode & SPI_3WIRE), !!(spi->mode & SPI_3WIRE),
!!(spi->mode & SPI_LSB_FIRST)); !!(spi->mode & SPI_LSB_FIRST),
!!(spi->mode & SPI_CS_HIGH));
} }
/* use spi->controller data for CS (same strategy as spi_gpio) */ /* use spi->controller data for CS (same strategy as spi_gpio) */
gpio_set_value((unsigned)spi->controller_data, value); gpio_set_value((uintptr_t)spi->controller_data, value);
if (is_on == BITBANG_CS_INACTIVE) { if (is_on == BITBANG_CS_INACTIVE) {
if (test_and_clear_bit(0, &p->flags)) { if (test_and_clear_bit(0, &p->flags)) {
...@@ -635,8 +640,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) ...@@ -635,8 +640,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv)); master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv));
if (master == NULL) { if (master == NULL) {
dev_err(&pdev->dev, "failed to allocate spi master\n"); dev_err(&pdev->dev, "failed to allocate spi master\n");
ret = -ENOMEM; return -ENOMEM;
goto err0;
} }
p = spi_master_get_devdata(master); p = spi_master_get_devdata(master);
...@@ -655,32 +659,38 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) ...@@ -655,32 +659,38 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
init_completion(&p->done); init_completion(&p->done);
p->clk = clk_get(&pdev->dev, NULL); p->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(p->clk)) { if (IS_ERR(p->clk)) {
dev_err(&pdev->dev, "cannot get clock\n"); dev_err(&pdev->dev, "cannot get clock\n");
ret = PTR_ERR(p->clk); ret = PTR_ERR(p->clk);
goto err1; goto err1;
} }
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
i = platform_get_irq(pdev, 0); i = platform_get_irq(pdev, 0);
if (!r || i < 0) { if (i < 0) {
dev_err(&pdev->dev, "cannot get platform resources\n"); dev_err(&pdev->dev, "cannot get platform IRQ\n");
ret = -ENOENT; ret = -ENOENT;
goto err2; goto err1;
} }
p->mapbase = ioremap_nocache(r->start, resource_size(r));
if (!p->mapbase) { r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
dev_err(&pdev->dev, "unable to ioremap\n"); p->mapbase = devm_ioremap_resource(&pdev->dev, r);
ret = -ENXIO; if (IS_ERR(p->mapbase)) {
goto err2; ret = PTR_ERR(p->mapbase);
goto err1;
} }
ret = request_irq(i, sh_msiof_spi_irq, 0, ret = devm_request_irq(&pdev->dev, i, sh_msiof_spi_irq, 0,
dev_name(&pdev->dev), p); dev_name(&pdev->dev), p);
if (ret) { if (ret) {
dev_err(&pdev->dev, "unable to request irq\n"); dev_err(&pdev->dev, "unable to request irq\n");
goto err3; goto err1;
}
ret = clk_prepare(p->clk);
if (ret < 0) {
dev_err(&pdev->dev, "unable to prepare clock\n");
goto err1;
} }
p->pdev = pdev; p->pdev = pdev;
...@@ -719,13 +729,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) ...@@ -719,13 +729,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
return 0; return 0;
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
err3: clk_unprepare(p->clk);
iounmap(p->mapbase);
err2:
clk_put(p->clk);
err1: err1:
spi_master_put(master); spi_master_put(master);
err0:
return ret; return ret;
} }
...@@ -737,9 +743,7 @@ static int sh_msiof_spi_remove(struct platform_device *pdev) ...@@ -737,9 +743,7 @@ static int sh_msiof_spi_remove(struct platform_device *pdev)
ret = spi_bitbang_stop(&p->bitbang); ret = spi_bitbang_stop(&p->bitbang);
if (!ret) { if (!ret) {
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
free_irq(platform_get_irq(pdev, 0), p); clk_unprepare(p->clk);
iounmap(p->mapbase);
clk_put(p->clk);
spi_master_put(p->bitbang.master); spi_master_put(p->bitbang.master);
} }
return ret; return ret;
......
...@@ -171,7 +171,6 @@ static int spi_sh_send(struct spi_sh_data *ss, struct spi_message *mesg, ...@@ -171,7 +171,6 @@ static int spi_sh_send(struct spi_sh_data *ss, struct spi_message *mesg,
int remain = t->len; int remain = t->len;
int cur_len; int cur_len;
unsigned char *data; unsigned char *data;
unsigned long tmp;
long ret; long ret;
if (t->len) if (t->len)
...@@ -213,9 +212,7 @@ static int spi_sh_send(struct spi_sh_data *ss, struct spi_message *mesg, ...@@ -213,9 +212,7 @@ static int spi_sh_send(struct spi_sh_data *ss, struct spi_message *mesg,
} }
if (list_is_last(&t->transfer_list, &mesg->transfers)) { if (list_is_last(&t->transfer_list, &mesg->transfers)) {
tmp = spi_sh_read(ss, SPI_SH_CR1); spi_sh_clear_bit(ss, SPI_SH_SSD | SPI_SH_SSDB, SPI_SH_CR1);
tmp = tmp & ~(SPI_SH_SSD | SPI_SH_SSDB);
spi_sh_write(ss, tmp, SPI_SH_CR1);
spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1);
ss->cr1 &= ~SPI_SH_TBE; ss->cr1 &= ~SPI_SH_TBE;
...@@ -239,7 +236,6 @@ static int spi_sh_receive(struct spi_sh_data *ss, struct spi_message *mesg, ...@@ -239,7 +236,6 @@ static int spi_sh_receive(struct spi_sh_data *ss, struct spi_message *mesg,
int remain = t->len; int remain = t->len;
int cur_len; int cur_len;
unsigned char *data; unsigned char *data;
unsigned long tmp;
long ret; long ret;
if (t->len > SPI_SH_MAX_BYTE) if (t->len > SPI_SH_MAX_BYTE)
...@@ -247,9 +243,7 @@ static int spi_sh_receive(struct spi_sh_data *ss, struct spi_message *mesg, ...@@ -247,9 +243,7 @@ static int spi_sh_receive(struct spi_sh_data *ss, struct spi_message *mesg,
else else
spi_sh_write(ss, t->len, SPI_SH_CR3); spi_sh_write(ss, t->len, SPI_SH_CR3);
tmp = spi_sh_read(ss, SPI_SH_CR1); spi_sh_clear_bit(ss, SPI_SH_SSD | SPI_SH_SSDB, SPI_SH_CR1);
tmp = tmp & ~(SPI_SH_SSD | SPI_SH_SSDB);
spi_sh_write(ss, tmp, SPI_SH_CR1);
spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1);
spi_sh_wait_write_buffer_empty(ss); spi_sh_wait_write_buffer_empty(ss);
...@@ -358,9 +352,6 @@ static int spi_sh_setup(struct spi_device *spi) ...@@ -358,9 +352,6 @@ static int spi_sh_setup(struct spi_device *spi)
{ {
struct spi_sh_data *ss = spi_master_get_devdata(spi->master); struct spi_sh_data *ss = spi_master_get_devdata(spi->master);
if (!spi->bits_per_word)
spi->bits_per_word = 8;
pr_debug("%s: enter\n", __func__); pr_debug("%s: enter\n", __func__);
spi_sh_write(ss, 0xfe, SPI_SH_CR1); /* SPI sycle stop */ spi_sh_write(ss, 0xfe, SPI_SH_CR1); /* SPI sycle stop */
......
...@@ -536,16 +536,9 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) ...@@ -536,16 +536,9 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
static int spi_sirfsoc_setup(struct spi_device *spi) static int spi_sirfsoc_setup(struct spi_device *spi)
{ {
struct sirfsoc_spi *sspi;
if (!spi->max_speed_hz) if (!spi->max_speed_hz)
return -EINVAL; return -EINVAL;
sspi = spi_master_get_devdata(spi->master);
if (!spi->bits_per_word)
spi->bits_per_word = 8;
return spi_sirfsoc_setup_transfer(spi, NULL); return spi_sirfsoc_setup_transfer(spi, NULL);
} }
......
This diff is collapsed.
...@@ -149,14 +149,14 @@ struct tegra_sflash_data { ...@@ -149,14 +149,14 @@ struct tegra_sflash_data {
static int tegra_sflash_runtime_suspend(struct device *dev); static int tegra_sflash_runtime_suspend(struct device *dev);
static int tegra_sflash_runtime_resume(struct device *dev); static int tegra_sflash_runtime_resume(struct device *dev);
static inline unsigned long tegra_sflash_readl(struct tegra_sflash_data *tsd, static inline u32 tegra_sflash_readl(struct tegra_sflash_data *tsd,
unsigned long reg) unsigned long reg)
{ {
return readl(tsd->base + reg); return readl(tsd->base + reg);
} }
static inline void tegra_sflash_writel(struct tegra_sflash_data *tsd, static inline void tegra_sflash_writel(struct tegra_sflash_data *tsd,
unsigned long val, unsigned long reg) u32 val, unsigned long reg)
{ {
writel(val, tsd->base + reg); writel(val, tsd->base + reg);
} }
...@@ -186,7 +186,7 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf( ...@@ -186,7 +186,7 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf(
struct tegra_sflash_data *tsd, struct spi_transfer *t) struct tegra_sflash_data *tsd, struct spi_transfer *t)
{ {
unsigned nbytes; unsigned nbytes;
unsigned long status; u32 status;
unsigned max_n_32bit = tsd->curr_xfer_words; unsigned max_n_32bit = tsd->curr_xfer_words;
u8 *tx_buf = (u8 *)t->tx_buf + tsd->cur_tx_pos; u8 *tx_buf = (u8 *)t->tx_buf + tsd->cur_tx_pos;
...@@ -197,11 +197,11 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf( ...@@ -197,11 +197,11 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf(
status = tegra_sflash_readl(tsd, SPI_STATUS); status = tegra_sflash_readl(tsd, SPI_STATUS);
while (!(status & SPI_TXF_FULL)) { while (!(status & SPI_TXF_FULL)) {
int i; int i;
unsigned int x = 0; u32 x = 0;
for (i = 0; nbytes && (i < tsd->bytes_per_word); for (i = 0; nbytes && (i < tsd->bytes_per_word);
i++, nbytes--) i++, nbytes--)
x |= ((*tx_buf++) << i*8); x |= (u32)(*tx_buf++) << (i * 8);
tegra_sflash_writel(tsd, x, SPI_TX_FIFO); tegra_sflash_writel(tsd, x, SPI_TX_FIFO);
if (!nbytes) if (!nbytes)
break; break;
...@@ -215,16 +215,14 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf( ...@@ -215,16 +215,14 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf(
static int tegra_sflash_read_rx_fifo_to_client_rxbuf( static int tegra_sflash_read_rx_fifo_to_client_rxbuf(
struct tegra_sflash_data *tsd, struct spi_transfer *t) struct tegra_sflash_data *tsd, struct spi_transfer *t)
{ {
unsigned long status; u32 status;
unsigned int read_words = 0; unsigned int read_words = 0;
u8 *rx_buf = (u8 *)t->rx_buf + tsd->cur_rx_pos; u8 *rx_buf = (u8 *)t->rx_buf + tsd->cur_rx_pos;
status = tegra_sflash_readl(tsd, SPI_STATUS); status = tegra_sflash_readl(tsd, SPI_STATUS);
while (!(status & SPI_RXF_EMPTY)) { while (!(status & SPI_RXF_EMPTY)) {
int i; int i;
unsigned long x; u32 x = tegra_sflash_readl(tsd, SPI_RX_FIFO);
x = tegra_sflash_readl(tsd, SPI_RX_FIFO);
for (i = 0; (i < tsd->bytes_per_word); i++) for (i = 0; (i < tsd->bytes_per_word); i++)
*rx_buf++ = (x >> (i*8)) & 0xFF; *rx_buf++ = (x >> (i*8)) & 0xFF;
read_words++; read_words++;
...@@ -237,7 +235,7 @@ static int tegra_sflash_read_rx_fifo_to_client_rxbuf( ...@@ -237,7 +235,7 @@ static int tegra_sflash_read_rx_fifo_to_client_rxbuf(
static int tegra_sflash_start_cpu_based_transfer( static int tegra_sflash_start_cpu_based_transfer(
struct tegra_sflash_data *tsd, struct spi_transfer *t) struct tegra_sflash_data *tsd, struct spi_transfer *t)
{ {
unsigned long val = 0; u32 val = 0;
unsigned cur_words; unsigned cur_words;
if (tsd->cur_direction & DATA_DIR_TX) if (tsd->cur_direction & DATA_DIR_TX)
...@@ -267,7 +265,7 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi, ...@@ -267,7 +265,7 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,
{ {
struct tegra_sflash_data *tsd = spi_master_get_devdata(spi->master); struct tegra_sflash_data *tsd = spi_master_get_devdata(spi->master);
u32 speed; u32 speed;
unsigned long command; u32 command;
speed = t->speed_hz; speed = t->speed_hz;
if (speed != tsd->cur_speed) { if (speed != tsd->cur_speed) {
......
...@@ -196,7 +196,7 @@ struct tegra_slink_data { ...@@ -196,7 +196,7 @@ struct tegra_slink_data {
u32 rx_status; u32 rx_status;
u32 status_reg; u32 status_reg;
bool is_packed; bool is_packed;
unsigned long packed_size; u32 packed_size;
u32 command_reg; u32 command_reg;
u32 command2_reg; u32 command2_reg;
...@@ -220,14 +220,14 @@ struct tegra_slink_data { ...@@ -220,14 +220,14 @@ struct tegra_slink_data {
static int tegra_slink_runtime_suspend(struct device *dev); static int tegra_slink_runtime_suspend(struct device *dev);
static int tegra_slink_runtime_resume(struct device *dev); static int tegra_slink_runtime_resume(struct device *dev);
static inline unsigned long tegra_slink_readl(struct tegra_slink_data *tspi, static inline u32 tegra_slink_readl(struct tegra_slink_data *tspi,
unsigned long reg) unsigned long reg)
{ {
return readl(tspi->base + reg); return readl(tspi->base + reg);
} }
static inline void tegra_slink_writel(struct tegra_slink_data *tspi, static inline void tegra_slink_writel(struct tegra_slink_data *tspi,
unsigned long val, unsigned long reg) u32 val, unsigned long reg)
{ {
writel(val, tspi->base + reg); writel(val, tspi->base + reg);
...@@ -238,38 +238,30 @@ static inline void tegra_slink_writel(struct tegra_slink_data *tspi, ...@@ -238,38 +238,30 @@ static inline void tegra_slink_writel(struct tegra_slink_data *tspi,
static void tegra_slink_clear_status(struct tegra_slink_data *tspi) static void tegra_slink_clear_status(struct tegra_slink_data *tspi)
{ {
unsigned long val; u32 val_write;
unsigned long val_write = 0;
val = tegra_slink_readl(tspi, SLINK_STATUS); tegra_slink_readl(tspi, SLINK_STATUS);
/* Write 1 to clear status register */ /* Write 1 to clear status register */
val_write = SLINK_RDY | SLINK_FIFO_ERROR; val_write = SLINK_RDY | SLINK_FIFO_ERROR;
tegra_slink_writel(tspi, val_write, SLINK_STATUS); tegra_slink_writel(tspi, val_write, SLINK_STATUS);
} }
static unsigned long tegra_slink_get_packed_size(struct tegra_slink_data *tspi, static u32 tegra_slink_get_packed_size(struct tegra_slink_data *tspi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
unsigned long val;
switch (tspi->bytes_per_word) { switch (tspi->bytes_per_word) {
case 0: case 0:
val = SLINK_PACK_SIZE_4; return SLINK_PACK_SIZE_4;
break;
case 1: case 1:
val = SLINK_PACK_SIZE_8; return SLINK_PACK_SIZE_8;
break;
case 2: case 2:
val = SLINK_PACK_SIZE_16; return SLINK_PACK_SIZE_16;
break;
case 4: case 4:
val = SLINK_PACK_SIZE_32; return SLINK_PACK_SIZE_32;
break;
default: default:
val = 0; return 0;
} }
return val;
} }
static unsigned tegra_slink_calculate_curr_xfer_param( static unsigned tegra_slink_calculate_curr_xfer_param(
...@@ -312,10 +304,9 @@ static unsigned tegra_slink_fill_tx_fifo_from_client_txbuf( ...@@ -312,10 +304,9 @@ static unsigned tegra_slink_fill_tx_fifo_from_client_txbuf(
{ {
unsigned nbytes; unsigned nbytes;
unsigned tx_empty_count; unsigned tx_empty_count;
unsigned long fifo_status; u32 fifo_status;
unsigned max_n_32bit; unsigned max_n_32bit;
unsigned i, count; unsigned i, count;
unsigned long x;
unsigned int written_words; unsigned int written_words;
unsigned fifo_words_left; unsigned fifo_words_left;
u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos;
...@@ -329,9 +320,9 @@ static unsigned tegra_slink_fill_tx_fifo_from_client_txbuf( ...@@ -329,9 +320,9 @@ static unsigned tegra_slink_fill_tx_fifo_from_client_txbuf(
nbytes = written_words * tspi->bytes_per_word; nbytes = written_words * tspi->bytes_per_word;
max_n_32bit = DIV_ROUND_UP(nbytes, 4); max_n_32bit = DIV_ROUND_UP(nbytes, 4);
for (count = 0; count < max_n_32bit; count++) { for (count = 0; count < max_n_32bit; count++) {
x = 0; u32 x = 0;
for (i = 0; (i < 4) && nbytes; i++, nbytes--) for (i = 0; (i < 4) && nbytes; i++, nbytes--)
x |= (*tx_buf++) << (i*8); x |= (u32)(*tx_buf++) << (i * 8);
tegra_slink_writel(tspi, x, SLINK_TX_FIFO); tegra_slink_writel(tspi, x, SLINK_TX_FIFO);
} }
} else { } else {
...@@ -339,10 +330,10 @@ static unsigned tegra_slink_fill_tx_fifo_from_client_txbuf( ...@@ -339,10 +330,10 @@ static unsigned tegra_slink_fill_tx_fifo_from_client_txbuf(
written_words = max_n_32bit; written_words = max_n_32bit;
nbytes = written_words * tspi->bytes_per_word; nbytes = written_words * tspi->bytes_per_word;
for (count = 0; count < max_n_32bit; count++) { for (count = 0; count < max_n_32bit; count++) {
x = 0; u32 x = 0;
for (i = 0; nbytes && (i < tspi->bytes_per_word); for (i = 0; nbytes && (i < tspi->bytes_per_word);
i++, nbytes--) i++, nbytes--)
x |= ((*tx_buf++) << i*8); x |= (u32)(*tx_buf++) << (i * 8);
tegra_slink_writel(tspi, x, SLINK_TX_FIFO); tegra_slink_writel(tspi, x, SLINK_TX_FIFO);
} }
} }
...@@ -354,9 +345,8 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf( ...@@ -354,9 +345,8 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf(
struct tegra_slink_data *tspi, struct spi_transfer *t) struct tegra_slink_data *tspi, struct spi_transfer *t)
{ {
unsigned rx_full_count; unsigned rx_full_count;
unsigned long fifo_status; u32 fifo_status;
unsigned i, count; unsigned i, count;
unsigned long x;
unsigned int read_words = 0; unsigned int read_words = 0;
unsigned len; unsigned len;
u8 *rx_buf = (u8 *)t->rx_buf + tspi->cur_rx_pos; u8 *rx_buf = (u8 *)t->rx_buf + tspi->cur_rx_pos;
...@@ -366,7 +356,7 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf( ...@@ -366,7 +356,7 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf(
if (tspi->is_packed) { if (tspi->is_packed) {
len = tspi->curr_dma_words * tspi->bytes_per_word; len = tspi->curr_dma_words * tspi->bytes_per_word;
for (count = 0; count < rx_full_count; count++) { for (count = 0; count < rx_full_count; count++) {
x = tegra_slink_readl(tspi, SLINK_RX_FIFO); u32 x = tegra_slink_readl(tspi, SLINK_RX_FIFO);
for (i = 0; len && (i < 4); i++, len--) for (i = 0; len && (i < 4); i++, len--)
*rx_buf++ = (x >> i*8) & 0xFF; *rx_buf++ = (x >> i*8) & 0xFF;
} }
...@@ -374,7 +364,7 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf( ...@@ -374,7 +364,7 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf(
read_words += tspi->curr_dma_words; read_words += tspi->curr_dma_words;
} else { } else {
for (count = 0; count < rx_full_count; count++) { for (count = 0; count < rx_full_count; count++) {
x = tegra_slink_readl(tspi, SLINK_RX_FIFO); u32 x = tegra_slink_readl(tspi, SLINK_RX_FIFO);
for (i = 0; (i < tspi->bytes_per_word); i++) for (i = 0; (i < tspi->bytes_per_word); i++)
*rx_buf++ = (x >> (i*8)) & 0xFF; *rx_buf++ = (x >> (i*8)) & 0xFF;
} }
...@@ -387,27 +377,24 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf( ...@@ -387,27 +377,24 @@ static unsigned int tegra_slink_read_rx_fifo_to_client_rxbuf(
static void tegra_slink_copy_client_txbuf_to_spi_txbuf( static void tegra_slink_copy_client_txbuf_to_spi_txbuf(
struct tegra_slink_data *tspi, struct spi_transfer *t) struct tegra_slink_data *tspi, struct spi_transfer *t)
{ {
unsigned len;
/* Make the dma buffer to read by cpu */ /* Make the dma buffer to read by cpu */
dma_sync_single_for_cpu(tspi->dev, tspi->tx_dma_phys, dma_sync_single_for_cpu(tspi->dev, tspi->tx_dma_phys,
tspi->dma_buf_size, DMA_TO_DEVICE); tspi->dma_buf_size, DMA_TO_DEVICE);
if (tspi->is_packed) { if (tspi->is_packed) {
len = tspi->curr_dma_words * tspi->bytes_per_word; unsigned len = tspi->curr_dma_words * tspi->bytes_per_word;
memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len); memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len);
} else { } else {
unsigned int i; unsigned int i;
unsigned int count; unsigned int count;
u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos;
unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word; unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word;
unsigned int x;
for (count = 0; count < tspi->curr_dma_words; count++) { for (count = 0; count < tspi->curr_dma_words; count++) {
x = 0; u32 x = 0;
for (i = 0; consume && (i < tspi->bytes_per_word); for (i = 0; consume && (i < tspi->bytes_per_word);
i++, consume--) i++, consume--)
x |= ((*tx_buf++) << i * 8); x |= (u32)(*tx_buf++) << (i * 8);
tspi->tx_dma_buf[count] = x; tspi->tx_dma_buf[count] = x;
} }
} }
...@@ -434,14 +421,10 @@ static void tegra_slink_copy_spi_rxbuf_to_client_rxbuf( ...@@ -434,14 +421,10 @@ static void tegra_slink_copy_spi_rxbuf_to_client_rxbuf(
unsigned int i; unsigned int i;
unsigned int count; unsigned int count;
unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos; unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos;
unsigned int x; u32 rx_mask = ((u32)1 << t->bits_per_word) - 1;
unsigned int rx_mask, bits_per_word;
bits_per_word = t->bits_per_word;
rx_mask = (1 << bits_per_word) - 1;
for (count = 0; count < tspi->curr_dma_words; count++) { for (count = 0; count < tspi->curr_dma_words; count++) {
x = tspi->rx_dma_buf[count]; u32 x = tspi->rx_dma_buf[count] & rx_mask;
x &= rx_mask;
for (i = 0; (i < tspi->bytes_per_word); i++) for (i = 0; (i < tspi->bytes_per_word); i++)
*rx_buf++ = (x >> (i*8)) & 0xFF; *rx_buf++ = (x >> (i*8)) & 0xFF;
} }
...@@ -501,17 +484,16 @@ static int tegra_slink_start_rx_dma(struct tegra_slink_data *tspi, int len) ...@@ -501,17 +484,16 @@ static int tegra_slink_start_rx_dma(struct tegra_slink_data *tspi, int len)
static int tegra_slink_start_dma_based_transfer( static int tegra_slink_start_dma_based_transfer(
struct tegra_slink_data *tspi, struct spi_transfer *t) struct tegra_slink_data *tspi, struct spi_transfer *t)
{ {
unsigned long val; u32 val;
unsigned long test_val;
unsigned int len; unsigned int len;
int ret = 0; int ret = 0;
unsigned long status; u32 status;
/* Make sure that Rx and Tx fifo are empty */ /* Make sure that Rx and Tx fifo are empty */
status = tegra_slink_readl(tspi, SLINK_STATUS); status = tegra_slink_readl(tspi, SLINK_STATUS);
if ((status & SLINK_FIFO_EMPTY) != SLINK_FIFO_EMPTY) { if ((status & SLINK_FIFO_EMPTY) != SLINK_FIFO_EMPTY) {
dev_err(tspi->dev, dev_err(tspi->dev, "Rx/Tx fifo are not empty status 0x%08x\n",
"Rx/Tx fifo are not empty status 0x%08lx\n", status); (unsigned)status);
return -EIO; return -EIO;
} }
...@@ -551,9 +533,9 @@ static int tegra_slink_start_dma_based_transfer( ...@@ -551,9 +533,9 @@ static int tegra_slink_start_dma_based_transfer(
} }
/* Wait for tx fifo to be fill before starting slink */ /* Wait for tx fifo to be fill before starting slink */
test_val = tegra_slink_readl(tspi, SLINK_STATUS); status = tegra_slink_readl(tspi, SLINK_STATUS);
while (!(test_val & SLINK_TX_FULL)) while (!(status & SLINK_TX_FULL))
test_val = tegra_slink_readl(tspi, SLINK_STATUS); status = tegra_slink_readl(tspi, SLINK_STATUS);
} }
if (tspi->cur_direction & DATA_DIR_RX) { if (tspi->cur_direction & DATA_DIR_RX) {
...@@ -587,7 +569,7 @@ static int tegra_slink_start_dma_based_transfer( ...@@ -587,7 +569,7 @@ static int tegra_slink_start_dma_based_transfer(
static int tegra_slink_start_cpu_based_transfer( static int tegra_slink_start_cpu_based_transfer(
struct tegra_slink_data *tspi, struct spi_transfer *t) struct tegra_slink_data *tspi, struct spi_transfer *t)
{ {
unsigned long val; u32 val;
unsigned cur_words; unsigned cur_words;
val = tspi->packed_size; val = tspi->packed_size;
...@@ -713,8 +695,8 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi, ...@@ -713,8 +695,8 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
u8 bits_per_word; u8 bits_per_word;
unsigned total_fifo_words; unsigned total_fifo_words;
int ret; int ret;
unsigned long command; u32 command;
unsigned long command2; u32 command2;
bits_per_word = t->bits_per_word; bits_per_word = t->bits_per_word;
speed = t->speed_hz; speed = t->speed_hz;
...@@ -761,17 +743,18 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi, ...@@ -761,17 +743,18 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
static int tegra_slink_setup(struct spi_device *spi) static int tegra_slink_setup(struct spi_device *spi)
{ {
struct tegra_slink_data *tspi = spi_master_get_devdata(spi->master); static const u32 cs_pol_bit[MAX_CHIP_SELECT] = {
unsigned long val;
unsigned long flags;
int ret;
unsigned int cs_pol_bit[MAX_CHIP_SELECT] = {
SLINK_CS_POLARITY, SLINK_CS_POLARITY,
SLINK_CS_POLARITY1, SLINK_CS_POLARITY1,
SLINK_CS_POLARITY2, SLINK_CS_POLARITY2,
SLINK_CS_POLARITY3, SLINK_CS_POLARITY3,
}; };
struct tegra_slink_data *tspi = spi_master_get_devdata(spi->master);
u32 val;
unsigned long flags;
int ret;
dev_dbg(&spi->dev, "setup %d bpw, %scpol, %scpha, %dHz\n", dev_dbg(&spi->dev, "setup %d bpw, %scpol, %scpha, %dHz\n",
spi->bits_per_word, spi->bits_per_word,
spi->mode & SPI_CPOL ? "" : "~", spi->mode & SPI_CPOL ? "" : "~",
......
This diff is collapsed.
...@@ -217,7 +217,7 @@ struct pch_pd_dev_save { ...@@ -217,7 +217,7 @@ struct pch_pd_dev_save {
struct pch_spi_board_data *board_dat; struct pch_spi_board_data *board_dat;
}; };
static DEFINE_PCI_DEVICE_TABLE(pch_spi_pcidev_id) = { static const struct pci_device_id pch_spi_pcidev_id[] = {
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_GE_SPI), 1, }, { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_GE_SPI), 1, },
{ PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_SPI), 2, }, { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_SPI), 2, },
{ PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_SPI), 1, }, { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_SPI), 1, },
...@@ -466,12 +466,6 @@ static void pch_spi_reset(struct spi_master *master) ...@@ -466,12 +466,6 @@ static void pch_spi_reset(struct spi_master *master)
static int pch_spi_setup(struct spi_device *pspi) static int pch_spi_setup(struct spi_device *pspi)
{ {
/* check bits per word */
if (pspi->bits_per_word == 0) {
pspi->bits_per_word = 8;
dev_dbg(&pspi->dev, "%s 8 bits per word\n", __func__);
}
/* Check baud rate setting */ /* Check baud rate setting */
/* if baud rate of chip is greater than /* if baud rate of chip is greater than
max we can support,return error */ max we can support,return error */
......
...@@ -348,7 +348,7 @@ static int txx9spi_probe(struct platform_device *dev) ...@@ -348,7 +348,7 @@ static int txx9spi_probe(struct platform_device *dev)
INIT_LIST_HEAD(&c->queue); INIT_LIST_HEAD(&c->queue);
init_waitqueue_head(&c->waitq); init_waitqueue_head(&c->waitq);
c->clk = clk_get(&dev->dev, "spi-baseclk"); c->clk = devm_clk_get(&dev->dev, "spi-baseclk");
if (IS_ERR(c->clk)) { if (IS_ERR(c->clk)) {
ret = PTR_ERR(c->clk); ret = PTR_ERR(c->clk);
c->clk = NULL; c->clk = NULL;
...@@ -356,7 +356,6 @@ static int txx9spi_probe(struct platform_device *dev) ...@@ -356,7 +356,6 @@ static int txx9spi_probe(struct platform_device *dev)
} }
ret = clk_enable(c->clk); ret = clk_enable(c->clk);
if (ret) { if (ret) {
clk_put(c->clk);
c->clk = NULL; c->clk = NULL;
goto exit; goto exit;
} }
...@@ -415,10 +414,8 @@ static int txx9spi_probe(struct platform_device *dev) ...@@ -415,10 +414,8 @@ static int txx9spi_probe(struct platform_device *dev)
exit: exit:
if (c->workqueue) if (c->workqueue)
destroy_workqueue(c->workqueue); destroy_workqueue(c->workqueue);
if (c->clk) { if (c->clk)
clk_disable(c->clk); clk_disable(c->clk);
clk_put(c->clk);
}
spi_master_put(master); spi_master_put(master);
return ret; return ret;
} }
...@@ -430,7 +427,6 @@ static int txx9spi_remove(struct platform_device *dev) ...@@ -430,7 +427,6 @@ static int txx9spi_remove(struct platform_device *dev)
destroy_workqueue(c->workqueue); destroy_workqueue(c->workqueue);
clk_disable(c->clk); clk_disable(c->clk);
clk_put(c->clk);
return 0; return 0;
} }
......
...@@ -231,22 +231,13 @@ static int spi_xcomm_probe(struct i2c_client *i2c, ...@@ -231,22 +231,13 @@ static int spi_xcomm_probe(struct i2c_client *i2c,
master->dev.of_node = i2c->dev.of_node; master->dev.of_node = i2c->dev.of_node;
i2c_set_clientdata(i2c, master); i2c_set_clientdata(i2c, master);
ret = spi_register_master(master); ret = devm_spi_register_master(&i2c->dev, master);
if (ret < 0) if (ret < 0)
spi_master_put(master); spi_master_put(master);
return ret; return ret;
} }
static int spi_xcomm_remove(struct i2c_client *i2c)
{
struct spi_master *master = i2c_get_clientdata(i2c);
spi_unregister_master(master);
return 0;
}
static const struct i2c_device_id spi_xcomm_ids[] = { static const struct i2c_device_id spi_xcomm_ids[] = {
{ "spi-xcomm" }, { "spi-xcomm" },
{ }, { },
...@@ -259,7 +250,6 @@ static struct i2c_driver spi_xcomm_driver = { ...@@ -259,7 +250,6 @@ static struct i2c_driver spi_xcomm_driver = {
}, },
.id_table = spi_xcomm_ids, .id_table = spi_xcomm_ids,
.probe = spi_xcomm_probe, .probe = spi_xcomm_probe,
.remove = spi_xcomm_remove,
}; };
module_i2c_driver(spi_xcomm_driver); module_i2c_driver(spi_xcomm_driver);
......
This diff is collapsed.
/* /*
* arch/arm/mach-w90x900/include/mach/nuc900_spi.h
*
* Copyright (c) 2009 Nuvoton technology corporation. * Copyright (c) 2009 Nuvoton technology corporation.
* *
* Wan ZongShun <mcuos.com@gmail.com> * Wan ZongShun <mcuos.com@gmail.com>
...@@ -11,8 +9,8 @@ ...@@ -11,8 +9,8 @@
* *
*/ */
#ifndef __ASM_ARCH_SPI_H #ifndef __SPI_NUC900_H
#define __ASM_ARCH_SPI_H #define __SPI_NUC900_H
extern void mfp_set_groupg(struct device *dev, const char *subname); extern void mfp_set_groupg(struct device *dev, const char *subname);
...@@ -32,4 +30,4 @@ struct nuc900_spi_chip { ...@@ -32,4 +30,4 @@ struct nuc900_spi_chip {
unsigned char bits_per_word; unsigned char bits_per_word;
}; };
#endif /* __ASM_ARCH_SPI_H */ #endif /* __SPI_NUC900_H */
...@@ -23,4 +23,6 @@ struct s3c2410_spi_info { ...@@ -23,4 +23,6 @@ struct s3c2410_spi_info {
void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol);
}; };
extern int s3c24xx_set_fiq(unsigned int irq, bool on);
#endif /* __LINUX_SPI_S3C24XX_H */ #endif /* __LINUX_SPI_S3C24XX_H */
...@@ -75,6 +75,7 @@ struct spi_device { ...@@ -75,6 +75,7 @@ struct spi_device {
struct spi_master *master; struct spi_master *master;
u32 max_speed_hz; u32 max_speed_hz;
u8 chip_select; u8 chip_select;
u8 bits_per_word;
u16 mode; u16 mode;
#define SPI_CPHA 0x01 /* clock phase */ #define SPI_CPHA 0x01 /* clock phase */
#define SPI_CPOL 0x02 /* clock polarity */ #define SPI_CPOL 0x02 /* clock polarity */
...@@ -92,7 +93,6 @@ struct spi_device { ...@@ -92,7 +93,6 @@ struct spi_device {
#define SPI_TX_QUAD 0x200 /* transmit with 4 wires */ #define SPI_TX_QUAD 0x200 /* transmit with 4 wires */
#define SPI_RX_DUAL 0x400 /* receive with 2 wires */ #define SPI_RX_DUAL 0x400 /* receive with 2 wires */
#define SPI_RX_QUAD 0x800 /* receive with 4 wires */ #define SPI_RX_QUAD 0x800 /* receive with 4 wires */
u8 bits_per_word;
int irq; int irq;
void *controller_state; void *controller_state;
void *controller_data; void *controller_data;
...@@ -277,15 +277,17 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) ...@@ -277,15 +277,17 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
* @unprepare_transfer_hardware: there are currently no more messages on the * @unprepare_transfer_hardware: there are currently no more messages on the
* queue so the subsystem notifies the driver that it may relax the * queue so the subsystem notifies the driver that it may relax the
* hardware by issuing this call * hardware by issuing this call
* @set_cs: assert or deassert chip select, true to assert. May be called * @set_cs: set the logic level of the chip select line. May be called
* from interrupt context. * from interrupt context.
* @prepare_message: set up the controller to transfer a single message, * @prepare_message: set up the controller to transfer a single message,
* for example doing DMA mapping. Called from threaded * for example doing DMA mapping. Called from threaded
* context. * context.
* @transfer_one: transfer a single spi_transfer. When the * @transfer_one: transfer a single spi_transfer.
* driver is finished with this transfer it must call * - return 0 if the transfer is finished,
* spi_finalize_current_transfer() so the subsystem can issue * - return 1 if the transfer is still in progress. When
* the next transfer * the driver is finished with this transfer it must
* call spi_finalize_current_transfer() so the subsystem
* can issue the next transfer
* @unprepare_message: undo any work done by prepare_message(). * @unprepare_message: undo any work done by prepare_message().
* @cs_gpios: Array of GPIOs to use as chip select lines; one per CS * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS
* number. Any individual value may be -ENOENT for CS lines that * number. Any individual value may be -ENOENT for CS lines that
...@@ -576,8 +578,8 @@ struct spi_transfer { ...@@ -576,8 +578,8 @@ struct spi_transfer {
dma_addr_t rx_dma; dma_addr_t rx_dma;
unsigned cs_change:1; unsigned cs_change:1;
u8 tx_nbits; unsigned tx_nbits:3;
u8 rx_nbits; unsigned rx_nbits:3;
#define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */ #define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */
#define SPI_NBITS_DUAL 0x02 /* 2bits transfer */ #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */
#define SPI_NBITS_QUAD 0x04 /* 4bits transfer */ #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */
...@@ -847,7 +849,7 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd) ...@@ -847,7 +849,7 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd)
ssize_t status; ssize_t status;
u16 result; u16 result;
status = spi_write_then_read(spi, &cmd, 1, (u8 *) &result, 2); status = spi_write_then_read(spi, &cmd, 1, &result, 2);
/* return negative errno or unsigned value */ /* return negative errno or unsigned value */
return (status < 0) ? status : result; return (status < 0) ? status : result;
......
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