Commit aa62325d authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'spi-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "The big theme for this release has been performance, we've had a
  series of unrelated overhauls of a few drivers all with a big
  peformance component.

  Otherwise it's been relatively quiet, highlights include:

   - A big overhaul of the spi-fsl-dspi driver improving the code
     quality, performance and stability from Vladimir Oltean.

   - A big performance enhancement for the bc2835 (Raspberry Pi) driver
     for unidirectional transfers from Lukas Wunner.

   - Improved performance on small transfers for the uniphier driver
     from Keiji Hayashibara.

   - Lots of coccinelle generated cleanups from Yue Haibing.

   - New device support for Freescale ls2080a and Nuvoton NPCM FIU"

* tag 'spi-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (102 commits)
  spi: mediatek: support large PA
  spi: mediatek: add spi support for mt6765 IC
  dt-bindings: spi: update bindings for MT6765 SoC
  spi: bcm2835: Speed up RX-only DMA transfers by zero-filling TX FIFO
  spi: bcm2835: Speed up TX-only DMA transfers by clearing RX FIFO
  dmaengine: bcm2835: Avoid accessing memory when copying zeroes
  spi: bcm2835: Cache CS register value for ->prepare_message()
  dmaengine: bcm2835: Document struct bcm2835_dmadev
  spi: Guarantee cacheline alignment of driver-private data
  dmaengine: bcm2835: Allow reusable descriptors
  dmaengine: bcm2835: Allow cyclic transactions without interrupt
  spi: bcm2835: Drop dma_pending flag
  spi: bcm2835: Work around DONE bit erratum
  spi-gpio: Use PTR_ERR_OR_ZERO() in spi_gpio_request()
  spi: Use an abbreviated pointer to ctlr->cur_msg in __spi_pump_messages
  spi: npcm-fiu: remove set but not used variable 'retlen'
  spi: fsl-spi: use devm_platform_ioremap_resource() to simplify code
  spi: zynq-qspi: use devm_platform_ioremap_resource() to simplify code
  spi: zynqmp: use devm_platform_ioremap_resource() to simplify code
  spi: xlp: use devm_platform_ioremap_resource() to simplify code
  ...
parents c4d11ccb b769c5ba
This diff is collapsed.
...@@ -491,7 +491,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -491,7 +491,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct bcm2835aux_spi *bs; struct bcm2835aux_spi *bs;
struct resource *res;
unsigned long clk_hz; unsigned long clk_hz;
int err; int err;
...@@ -524,8 +523,7 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -524,8 +523,7 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
bs = spi_master_get_devdata(master); bs = spi_master_get_devdata(master);
/* the main area */ /* the main area */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); bs->regs = devm_platform_ioremap_resource(pdev, 0);
bs->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(bs->regs)) { if (IS_ERR(bs->regs)) {
err = PTR_ERR(bs->regs); err = PTR_ERR(bs->regs);
goto out_master_put; goto out_master_put;
...@@ -540,7 +538,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -540,7 +538,6 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
bs->irq = platform_get_irq(pdev, 0); bs->irq = platform_get_irq(pdev, 0);
if (bs->irq <= 0) { if (bs->irq <= 0) {
dev_err(&pdev->dev, "could not get IRQ: %d\n", bs->irq);
err = bs->irq ? bs->irq : -ENODEV; err = bs->irq ? bs->irq : -ENODEV;
goto out_master_put; goto out_master_put;
} }
......
...@@ -330,7 +330,6 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -330,7 +330,6 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct bcm63xx_hsspi *bs; struct bcm63xx_hsspi *bs;
struct resource *res_mem;
void __iomem *regs; void __iomem *regs;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct clk *clk, *pll_clk = NULL; struct clk *clk, *pll_clk = NULL;
...@@ -338,13 +337,10 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -338,13 +337,10 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS; u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0)
dev_err(dev, "no irq: %d\n", irq);
return irq; return irq;
}
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = devm_platform_ioremap_resource(pdev, 0);
regs = devm_ioremap_resource(dev, res_mem);
if (IS_ERR(regs)) if (IS_ERR(regs))
return PTR_ERR(regs); return PTR_ERR(regs);
......
...@@ -520,10 +520,8 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -520,10 +520,8 @@ 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: %d\n", irq);
return irq; return irq;
}
clk = devm_clk_get(dev, "spi"); clk = devm_clk_get(dev, "spi");
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
......
...@@ -474,7 +474,6 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -474,7 +474,6 @@ static int cdns_spi_probe(struct platform_device *pdev)
int ret = 0, irq; int ret = 0, irq;
struct spi_master *master; struct spi_master *master;
struct cdns_spi *xspi; struct cdns_spi *xspi;
struct resource *res;
u32 num_cs; u32 num_cs;
master = spi_alloc_master(&pdev->dev, sizeof(*xspi)); master = spi_alloc_master(&pdev->dev, sizeof(*xspi));
...@@ -485,8 +484,7 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -485,8 +484,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
master->dev.of_node = pdev->dev.of_node; master->dev.of_node = pdev->dev.of_node;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); xspi->regs = devm_platform_ioremap_resource(pdev, 0);
xspi->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(xspi->regs)) { if (IS_ERR(xspi->regs)) {
ret = PTR_ERR(xspi->regs); ret = PTR_ERR(xspi->regs);
goto remove_master; goto remove_master;
...@@ -540,7 +538,6 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -540,7 +538,6 @@ static int cdns_spi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq <= 0) { if (irq <= 0) {
ret = -ENXIO; ret = -ENXIO;
dev_err(&pdev->dev, "irq number is invalid\n");
goto clk_dis_all; goto clk_dis_all;
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
static int octeon_spi_probe(struct platform_device *pdev) static int octeon_spi_probe(struct platform_device *pdev)
{ {
struct resource *res_mem;
void __iomem *reg_base; void __iomem *reg_base;
struct spi_master *master; struct spi_master *master;
struct octeon_spi *p; struct octeon_spi *p;
...@@ -30,8 +29,7 @@ static int octeon_spi_probe(struct platform_device *pdev) ...@@ -30,8 +29,7 @@ static int octeon_spi_probe(struct platform_device *pdev)
p = spi_master_get_devdata(master); p = spi_master_get_devdata(master);
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); reg_base = devm_platform_ioremap_resource(pdev, 0);
reg_base = devm_ioremap_resource(&pdev->dev, res_mem);
if (IS_ERR(reg_base)) { if (IS_ERR(reg_base)) {
err = PTR_ERR(reg_base); err = PTR_ERR(reg_base);
goto fail; goto fail;
......
...@@ -91,7 +91,6 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -91,7 +91,6 @@ static int spi_clps711x_probe(struct platform_device *pdev)
{ {
struct spi_clps711x_data *hw; struct spi_clps711x_data *hw;
struct spi_master *master; struct spi_master *master;
struct resource *res;
int irq, ret; int irq, ret;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
...@@ -125,8 +124,7 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -125,8 +124,7 @@ static int spi_clps711x_probe(struct platform_device *pdev)
goto err_out; goto err_out;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hw->syncio = devm_platform_ioremap_resource(pdev, 0);
hw->syncio = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->syncio)) { if (IS_ERR(hw->syncio)) {
ret = PTR_ERR(hw->syncio); ret = PTR_ERR(hw->syncio);
goto err_out; goto err_out;
......
...@@ -339,7 +339,6 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -339,7 +339,6 @@ static int mcfqspi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_master *master;
struct mcfqspi *mcfqspi; struct mcfqspi *mcfqspi;
struct resource *res;
struct mcfqspi_platform_data *pdata; struct mcfqspi_platform_data *pdata;
int status; int status;
...@@ -362,8 +361,7 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -362,8 +361,7 @@ 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); mcfqspi->iobase = devm_platform_ioremap_resource(pdev, 0);
mcfqspi->iobase = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(mcfqspi->iobase)) { if (IS_ERR(mcfqspi->iobase)) {
status = PTR_ERR(mcfqspi->iobase); status = PTR_ERR(mcfqspi->iobase);
goto fail0; goto fail0;
......
...@@ -79,14 +79,12 @@ static int dw_spi_mscc_init(struct platform_device *pdev, ...@@ -79,14 +79,12 @@ static int dw_spi_mscc_init(struct platform_device *pdev,
const char *cpu_syscon, u32 if_si_owner_offset) const char *cpu_syscon, u32 if_si_owner_offset)
{ {
struct dw_spi_mscc *dwsmscc; struct dw_spi_mscc *dwsmscc;
struct resource *res;
dwsmscc = devm_kzalloc(&pdev->dev, sizeof(*dwsmscc), GFP_KERNEL); dwsmscc = devm_kzalloc(&pdev->dev, sizeof(*dwsmscc), GFP_KERNEL);
if (!dwsmscc) if (!dwsmscc)
return -ENOMEM; return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); dwsmscc->spi_mst = devm_platform_ioremap_resource(pdev, 1);
dwsmscc->spi_mst = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dwsmscc->spi_mst)) { if (IS_ERR(dwsmscc->spi_mst)) {
dev_err(&pdev->dev, "SPI_MST region map failed\n"); dev_err(&pdev->dev, "SPI_MST region map failed\n");
return PTR_ERR(dwsmscc->spi_mst); return PTR_ERR(dwsmscc->spi_mst);
...@@ -138,7 +136,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -138,7 +136,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
struct dw_spi_mmio *dwsmmio); struct dw_spi_mmio *dwsmmio);
struct dw_spi_mmio *dwsmmio; struct dw_spi_mmio *dwsmmio;
struct dw_spi *dws; struct dw_spi *dws;
struct resource *mem;
int ret; int ret;
int num_cs; int num_cs;
...@@ -150,18 +147,15 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -150,18 +147,15 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
dws = &dwsmmio->dws; dws = &dwsmmio->dws;
/* Get basic io resource and map it */ /* Get basic io resource and map it */
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); dws->regs = devm_platform_ioremap_resource(pdev, 0);
dws->regs = devm_ioremap_resource(&pdev->dev, mem);
if (IS_ERR(dws->regs)) { if (IS_ERR(dws->regs)) {
dev_err(&pdev->dev, "SPI region map failed\n"); dev_err(&pdev->dev, "SPI region map failed\n");
return PTR_ERR(dws->regs); return PTR_ERR(dws->regs);
} }
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");
return dws->irq; /* -ENXIO */ return dws->irq; /* -ENXIO */
}
dwsmmio->clk = devm_clk_get(&pdev->dev, NULL); dwsmmio->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dwsmmio->clk)) if (IS_ERR(dwsmmio->clk))
...@@ -172,8 +166,10 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) ...@@ -172,8 +166,10 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
/* Optional clock needed to access the registers */ /* Optional clock needed to access the registers */
dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
if (IS_ERR(dwsmmio->pclk)) if (IS_ERR(dwsmmio->pclk)) {
return PTR_ERR(dwsmmio->pclk); ret = PTR_ERR(dwsmmio->pclk);
goto out_clk;
}
ret = clk_prepare_enable(dwsmmio->pclk); ret = clk_prepare_enable(dwsmmio->pclk);
if (ret) if (ret)
goto out_clk; goto out_clk;
......
...@@ -19,6 +19,7 @@ struct spi_pci_desc { ...@@ -19,6 +19,7 @@ struct spi_pci_desc {
int (*setup)(struct dw_spi *); int (*setup)(struct dw_spi *);
u16 num_cs; u16 num_cs;
u16 bus_num; u16 bus_num;
u32 max_freq;
}; };
static struct spi_pci_desc spi_pci_mid_desc_1 = { static struct spi_pci_desc spi_pci_mid_desc_1 = {
...@@ -33,6 +34,12 @@ static struct spi_pci_desc spi_pci_mid_desc_2 = { ...@@ -33,6 +34,12 @@ static struct spi_pci_desc spi_pci_mid_desc_2 = {
.bus_num = 1, .bus_num = 1,
}; };
static struct spi_pci_desc spi_pci_ehl_desc = {
.num_cs = 1,
.bus_num = -1,
.max_freq = 100000000,
};
static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
struct dw_spi *dws; struct dw_spi *dws;
...@@ -65,6 +72,7 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -65,6 +72,7 @@ static int spi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (desc) { if (desc) {
dws->num_cs = desc->num_cs; dws->num_cs = desc->num_cs;
dws->bus_num = desc->bus_num; dws->bus_num = desc->bus_num;
dws->max_freq = desc->max_freq;
if (desc->setup) { if (desc->setup) {
ret = desc->setup(dws); ret = desc->setup(dws);
...@@ -98,16 +106,14 @@ static void spi_pci_remove(struct pci_dev *pdev) ...@@ -98,16 +106,14 @@ static void spi_pci_remove(struct pci_dev *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int spi_suspend(struct device *dev) static int spi_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct dw_spi *dws = dev_get_drvdata(dev);
struct dw_spi *dws = pci_get_drvdata(pdev);
return dw_spi_suspend_host(dws); return dw_spi_suspend_host(dws);
} }
static int spi_resume(struct device *dev) static int spi_resume(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct dw_spi *dws = dev_get_drvdata(dev);
struct dw_spi *dws = pci_get_drvdata(pdev);
return dw_spi_resume_host(dws); return dw_spi_resume_host(dws);
} }
...@@ -125,8 +131,14 @@ static const struct pci_device_id pci_ids[] = { ...@@ -125,8 +131,14 @@ static const struct pci_device_id pci_ids[] = {
{ PCI_VDEVICE(INTEL, 0x0800), (kernel_ulong_t)&spi_pci_mid_desc_1}, { PCI_VDEVICE(INTEL, 0x0800), (kernel_ulong_t)&spi_pci_mid_desc_1},
/* Intel MID platform SPI controller 2 */ /* Intel MID platform SPI controller 2 */
{ PCI_VDEVICE(INTEL, 0x0812), (kernel_ulong_t)&spi_pci_mid_desc_2}, { PCI_VDEVICE(INTEL, 0x0812), (kernel_ulong_t)&spi_pci_mid_desc_2},
/* Intel Elkhart Lake PSE SPI controllers */
{ PCI_VDEVICE(INTEL, 0x4b84), (kernel_ulong_t)&spi_pci_ehl_desc},
{ PCI_VDEVICE(INTEL, 0x4b85), (kernel_ulong_t)&spi_pci_ehl_desc},
{ PCI_VDEVICE(INTEL, 0x4b86), (kernel_ulong_t)&spi_pci_ehl_desc},
{ PCI_VDEVICE(INTEL, 0x4b87), (kernel_ulong_t)&spi_pci_ehl_desc},
{}, {},
}; };
MODULE_DEVICE_TABLE(pci, pci_ids);
static struct pci_driver dw_spi_driver = { static struct pci_driver dw_spi_driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
......
...@@ -400,10 +400,8 @@ static int efm32_spi_probe(struct platform_device *pdev) ...@@ -400,10 +400,8 @@ static int efm32_spi_probe(struct platform_device *pdev)
} }
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret <= 0) { if (ret <= 0)
dev_err(&pdev->dev, "failed to get rx irq (%d)\n", ret);
goto err; goto err;
}
ddata->rxirq = ret; ddata->rxirq = ret;
......
...@@ -656,10 +656,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) ...@@ -656,10 +656,8 @@ static int ep93xx_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(&pdev->dev, "failed to get irq resources\n");
return -EBUSY; return -EBUSY;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
......
...@@ -305,12 +305,10 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi) ...@@ -305,12 +305,10 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi)
} }
if (mspi->flags & SPI_CPM1) { if (mspi->flags & SPI_CPM1) {
struct resource *res;
void *pram; void *pram;
res = platform_get_resource(to_platform_device(dev), pram = devm_platform_ioremap_resource(to_platform_device(dev),
IORESOURCE_MEM, 1); 1);
pram = devm_ioremap_resource(dev, res);
if (IS_ERR(pram)) if (IS_ERR(pram))
mspi->pram = NULL; mspi->pram = NULL;
else else
......
This diff is collapsed.
...@@ -91,9 +91,6 @@ static inline u32 mpc8xxx_spi_read_reg(__be32 __iomem *reg) ...@@ -91,9 +91,6 @@ static inline u32 mpc8xxx_spi_read_reg(__be32 __iomem *reg)
struct mpc8xxx_spi_probe_info { struct mpc8xxx_spi_probe_info {
struct fsl_spi_platform_data pdata; struct fsl_spi_platform_data pdata;
int ngpios;
int *gpios;
bool *alow_flags;
__be32 __iomem *immr_spi_cs; __be32 __iomem *immr_spi_cs;
}; };
......
...@@ -860,10 +860,8 @@ static int fsl_qspi_probe(struct platform_device *pdev) ...@@ -860,10 +860,8 @@ static int fsl_qspi_probe(struct platform_device *pdev)
/* find the irq */ /* find the irq */
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) { if (ret < 0)
dev_err(dev, "failed to get the irq: %d\n", ret);
goto err_disable_clk; goto err_disable_clk;
}
ret = devm_request_irq(dev, ret, ret = devm_request_irq(dev, ret,
fsl_qspi_irq_handler, 0, pdev->name, q); fsl_qspi_irq_handler, 0, pdev->name, q);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/fsl_devices.h> #include <linux/fsl_devices.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_gpio.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -481,32 +480,6 @@ static int fsl_spi_setup(struct spi_device *spi) ...@@ -481,32 +480,6 @@ static int fsl_spi_setup(struct spi_device *spi)
return retval; return retval;
} }
if (mpc8xxx_spi->type == TYPE_GRLIB) {
if (gpio_is_valid(spi->cs_gpio)) {
int desel;
retval = gpio_request(spi->cs_gpio,
dev_name(&spi->dev));
if (retval)
return retval;
desel = !(spi->mode & SPI_CS_HIGH);
retval = gpio_direction_output(spi->cs_gpio, desel);
if (retval) {
gpio_free(spi->cs_gpio);
return retval;
}
} else if (spi->cs_gpio != -ENOENT) {
if (spi->cs_gpio < 0)
return spi->cs_gpio;
return -EINVAL;
}
/* When spi->cs_gpio == -ENOENT, a hole in the phandle list
* indicates to use native chipselect if present, or allow for
* an always selected chip
*/
}
/* Initialize chipselect - might be active for SPI_CS_HIGH mode */ /* Initialize chipselect - might be active for SPI_CS_HIGH mode */
fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE); fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
...@@ -515,12 +488,8 @@ static int fsl_spi_setup(struct spi_device *spi) ...@@ -515,12 +488,8 @@ static int fsl_spi_setup(struct spi_device *spi)
static void fsl_spi_cleanup(struct spi_device *spi) static void fsl_spi_cleanup(struct spi_device *spi)
{ {
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
if (mpc8xxx_spi->type == TYPE_GRLIB && gpio_is_valid(spi->cs_gpio))
gpio_free(spi->cs_gpio);
kfree(cs); kfree(cs);
spi_set_ctldata(spi, NULL); spi_set_ctldata(spi, NULL);
} }
...@@ -586,8 +555,8 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on) ...@@ -586,8 +555,8 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on)
u32 slvsel; u32 slvsel;
u16 cs = spi->chip_select; u16 cs = spi->chip_select;
if (gpio_is_valid(spi->cs_gpio)) { if (spi->cs_gpiod) {
gpio_set_value(spi->cs_gpio, on); gpiod_set_value(spi->cs_gpiod, on);
} else if (cs < mpc8xxx_spi->native_chipselects) { } else if (cs < mpc8xxx_spi->native_chipselects) {
slvsel = mpc8xxx_spi_read_reg(&reg_base->slvsel); slvsel = mpc8xxx_spi_read_reg(&reg_base->slvsel);
slvsel = on ? (slvsel | (1 << cs)) : (slvsel & ~(1 << cs)); slvsel = on ? (slvsel | (1 << cs)) : (slvsel & ~(1 << cs));
...@@ -718,139 +687,19 @@ err: ...@@ -718,139 +687,19 @@ err:
static void fsl_spi_cs_control(struct spi_device *spi, bool on) static void fsl_spi_cs_control(struct spi_device *spi, bool on)
{ {
struct device *dev = spi->dev.parent->parent; if (spi->cs_gpiod) {
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); gpiod_set_value(spi->cs_gpiod, on);
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
u16 cs = spi->chip_select;
if (cs < pinfo->ngpios) {
int gpio = pinfo->gpios[cs];
bool alow = pinfo->alow_flags[cs];