Commit d7930c9e authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'next-spi' of git://git.secretlab.ca/git/linux-2.6

* 'next-spi' of git://git.secretlab.ca/git/linux-2.6: (31 commits)
  spi: Correct SPI clock frequency setting in spi_mpc8xxx
  spi/spi_s3c64xx.c: Fix continuation line formats
  spi/dw_spi: Fix dw_spi_mmio to depend on HAVE_CLK
  spi/dw_spi: Allow dw_spi.c to be a module
  spi/dw_spi: mmio code style fixups
  Memory-mapped dw_spi driver
  spi/dw_spi: fix missing export of dw_spi_remove_host
  spi/dw_spi: conditional transfer mode changes
  spi/dw_spi: remove conditional from 'poll_transfer'.
  spi/dw_spi: fixed a spelling typo in a warning message.
  spi/dw_spi: add return value to empty mrst_spi_debugfs_init()
  spi/dw_spi: enable platform specific chipselect.
  spi/dw_spi: add a FIFO depth detection
  spi/dw_spi: fix __init/__devinit section mismatch
  spi: xilinx_spi: Fix up I/O routine wrapping bogosity.
  spi/spi_imx: add device information by switching pr_debug() to dev_dbg()
  spi: update MSIOF includes
  spi/dw_spi: refine the IRQ mode working flow
  spi/dw_spi: add a missed dw_spi_remove_host() in exit sequence
  spi/dw_spi: bug fix in wait_till_not_busy()
  ...
parents b6d97026 4f4517c4
...@@ -100,6 +100,23 @@ config SPI_BUTTERFLY ...@@ -100,6 +100,23 @@ config SPI_BUTTERFLY
inexpensive battery powered microcontroller evaluation board. inexpensive battery powered microcontroller evaluation board.
This same cable can be used to flash new firmware. This same cable can be used to flash new firmware.
config SPI_COLDFIRE_QSPI
tristate "Freescale Coldfire QSPI controller"
depends on (M520x || M523x || M5249 || M527x || M528x || M532x)
help
This enables support for the Coldfire QSPI controller in master
mode.
This driver can also be built as a module. If so, the module
will be called coldfire_qspi.
config SPI_DAVINCI
tristate "SPI controller driver for DaVinci/DA8xx SoC's"
depends on SPI_MASTER && ARCH_DAVINCI
select SPI_BITBANG
help
SPI master controller for DaVinci and DA8xx SPI modules.
config SPI_GPIO config SPI_GPIO
tristate "GPIO-based bitbanging SPI Master" tristate "GPIO-based bitbanging SPI Master"
depends on GENERIC_GPIO depends on GENERIC_GPIO
...@@ -308,7 +325,7 @@ config SPI_NUC900 ...@@ -308,7 +325,7 @@ config SPI_NUC900
# #
config SPI_DESIGNWARE config SPI_DESIGNWARE
bool "DesignWare SPI controller core support" tristate "DesignWare SPI controller core support"
depends on SPI_MASTER depends on SPI_MASTER
help help
general driver for SPI controller core from DesignWare general driver for SPI controller core from DesignWare
...@@ -317,6 +334,10 @@ config SPI_DW_PCI ...@@ -317,6 +334,10 @@ config SPI_DW_PCI
tristate "PCI interface driver for DW SPI core" tristate "PCI interface driver for DW SPI core"
depends on SPI_DESIGNWARE && PCI depends on SPI_DESIGNWARE && PCI
config SPI_DW_MMIO
tristate "Memory-mapped io interface driver for DW SPI core"
depends on SPI_DESIGNWARE && HAVE_CLK
# #
# There are lots of SPI device types, with sensors and memory # There are lots of SPI device types, with sensors and memory
# being probably the most widely used ones. # being probably the most widely used ones.
......
...@@ -16,8 +16,11 @@ obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.o ...@@ -16,8 +16,11 @@ obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.o
obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o
obj-$(CONFIG_SPI_AU1550) += au1550_spi.o obj-$(CONFIG_SPI_AU1550) += au1550_spi.o
obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o
obj-$(CONFIG_SPI_COLDFIRE_QSPI) += coldfire_qspi.o
obj-$(CONFIG_SPI_DAVINCI) += davinci_spi.o
obj-$(CONFIG_SPI_DESIGNWARE) += dw_spi.o obj-$(CONFIG_SPI_DESIGNWARE) += dw_spi.o
obj-$(CONFIG_SPI_DW_PCI) += dw_spi_pci.o obj-$(CONFIG_SPI_DW_PCI) += dw_spi_pci.o
obj-$(CONFIG_SPI_DW_MMIO) += dw_spi_mmio.o
obj-$(CONFIG_SPI_GPIO) += spi_gpio.o obj-$(CONFIG_SPI_GPIO) += spi_gpio.o
obj-$(CONFIG_SPI_IMX) += spi_imx.o obj-$(CONFIG_SPI_IMX) += spi_imx.o
obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o
......
This diff is collapsed.
This diff is collapsed.
...@@ -152,6 +152,7 @@ static void mrst_spi_debugfs_remove(struct dw_spi *dws) ...@@ -152,6 +152,7 @@ static void mrst_spi_debugfs_remove(struct dw_spi *dws)
#else #else
static inline int mrst_spi_debugfs_init(struct dw_spi *dws) static inline int mrst_spi_debugfs_init(struct dw_spi *dws)
{ {
return 0;
} }
static inline void mrst_spi_debugfs_remove(struct dw_spi *dws) static inline void mrst_spi_debugfs_remove(struct dw_spi *dws)
...@@ -161,14 +162,14 @@ static inline void mrst_spi_debugfs_remove(struct dw_spi *dws) ...@@ -161,14 +162,14 @@ static inline void mrst_spi_debugfs_remove(struct dw_spi *dws)
static void wait_till_not_busy(struct dw_spi *dws) static void wait_till_not_busy(struct dw_spi *dws)
{ {
unsigned long end = jiffies + usecs_to_jiffies(1000); unsigned long end = jiffies + 1 + usecs_to_jiffies(1000);
while (time_before(jiffies, end)) { while (time_before(jiffies, end)) {
if (!(dw_readw(dws, sr) & SR_BUSY)) if (!(dw_readw(dws, sr) & SR_BUSY))
return; return;
} }
dev_err(&dws->master->dev, dev_err(&dws->master->dev,
"DW SPI: Stutus keeps busy for 1000us after a read/write!\n"); "DW SPI: Status keeps busy for 1000us after a read/write!\n");
} }
static void flush(struct dw_spi *dws) static void flush(struct dw_spi *dws)
...@@ -358,6 +359,8 @@ static void transfer_complete(struct dw_spi *dws) ...@@ -358,6 +359,8 @@ static void transfer_complete(struct dw_spi *dws)
static irqreturn_t interrupt_transfer(struct dw_spi *dws) static irqreturn_t interrupt_transfer(struct dw_spi *dws)
{ {
u16 irq_status, irq_mask = 0x3f; u16 irq_status, irq_mask = 0x3f;
u32 int_level = dws->fifo_len / 2;
u32 left;
irq_status = dw_readw(dws, isr) & irq_mask; irq_status = dw_readw(dws, isr) & irq_mask;
/* Error handling */ /* Error handling */
...@@ -369,22 +372,23 @@ static irqreturn_t interrupt_transfer(struct dw_spi *dws) ...@@ -369,22 +372,23 @@ static irqreturn_t interrupt_transfer(struct dw_spi *dws)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/* INT comes from tx */ if (irq_status & SPI_INT_TXEI) {
if (dws->tx && (irq_status & SPI_INT_TXEI)) { spi_mask_intr(dws, SPI_INT_TXEI);
while (dws->tx < dws->tx_end)
left = (dws->tx_end - dws->tx) / dws->n_bytes;
left = (left > int_level) ? int_level : left;
while (left--)
dws->write(dws); dws->write(dws);
dws->read(dws);
if (dws->tx == dws->tx_end) { /* Re-enable the IRQ if there is still data left to tx */
spi_mask_intr(dws, SPI_INT_TXEI); if (dws->tx_end > dws->tx)
spi_umask_intr(dws, SPI_INT_TXEI);
else
transfer_complete(dws); transfer_complete(dws);
} }
}
/* INT comes from rx */
if (dws->rx && (irq_status & SPI_INT_RXFI)) {
if (dws->read(dws))
transfer_complete(dws);
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -404,12 +408,9 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id) ...@@ -404,12 +408,9 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id)
/* Must be called inside pump_transfers() */ /* Must be called inside pump_transfers() */
static void poll_transfer(struct dw_spi *dws) static void poll_transfer(struct dw_spi *dws)
{ {
if (dws->tx) {
while (dws->write(dws)) while (dws->write(dws))
dws->read(dws); dws->read(dws);
}
dws->read(dws);
transfer_complete(dws); transfer_complete(dws);
} }
...@@ -428,6 +429,7 @@ static void pump_transfers(unsigned long data) ...@@ -428,6 +429,7 @@ static void pump_transfers(unsigned long data)
u8 bits = 0; u8 bits = 0;
u8 imask = 0; u8 imask = 0;
u8 cs_change = 0; u8 cs_change = 0;
u16 txint_level = 0;
u16 clk_div = 0; u16 clk_div = 0;
u32 speed = 0; u32 speed = 0;
u32 cr0 = 0; u32 cr0 = 0;
...@@ -438,6 +440,9 @@ static void pump_transfers(unsigned long data) ...@@ -438,6 +440,9 @@ static void pump_transfers(unsigned long data)
chip = dws->cur_chip; chip = dws->cur_chip;
spi = message->spi; spi = message->spi;
if (unlikely(!chip->clk_div))
chip->clk_div = dws->max_freq / chip->speed_hz;
if (message->state == ERROR_STATE) { if (message->state == ERROR_STATE) {
message->status = -EIO; message->status = -EIO;
goto early_exit; goto early_exit;
...@@ -492,7 +497,7 @@ static void pump_transfers(unsigned long data) ...@@ -492,7 +497,7 @@ static void pump_transfers(unsigned long data)
/* clk_div doesn't support odd number */ /* clk_div doesn't support odd number */
clk_div = dws->max_freq / speed; clk_div = dws->max_freq / speed;
clk_div = (clk_div >> 1) << 1; clk_div = (clk_div + 1) & 0xfffe;
chip->speed_hz = speed; chip->speed_hz = speed;
chip->clk_div = clk_div; chip->clk_div = clk_div;
...@@ -532,13 +537,34 @@ static void pump_transfers(unsigned long data) ...@@ -532,13 +537,34 @@ static void pump_transfers(unsigned long data)
} }
message->state = RUNNING_STATE; message->state = RUNNING_STATE;
/*
* Adjust transfer mode if necessary. Requires platform dependent
* chipselect mechanism.
*/
if (dws->cs_control) {
if (dws->rx && dws->tx)
chip->tmode = 0x00;
else if (dws->rx)
chip->tmode = 0x02;
else
chip->tmode = 0x01;
cr0 &= ~(0x3 << SPI_MODE_OFFSET);
cr0 |= (chip->tmode << SPI_TMOD_OFFSET);
}
/* Check if current transfer is a DMA transaction */ /* Check if current transfer is a DMA transaction */
dws->dma_mapped = map_dma_buffers(dws); dws->dma_mapped = map_dma_buffers(dws);
/*
* Interrupt mode
* we only need set the TXEI IRQ, as TX/RX always happen syncronizely
*/
if (!dws->dma_mapped && !chip->poll_mode) { if (!dws->dma_mapped && !chip->poll_mode) {
if (dws->rx) int templen = dws->len / dws->n_bytes;
imask |= SPI_INT_RXFI; txint_level = dws->fifo_len / 2;
if (dws->tx) txint_level = (templen > txint_level) ? txint_level : templen;
imask |= SPI_INT_TXEI; imask |= SPI_INT_TXEI;
dws->transfer_handler = interrupt_transfer; dws->transfer_handler = interrupt_transfer;
} }
...@@ -549,21 +575,23 @@ static void pump_transfers(unsigned long data) ...@@ -549,21 +575,23 @@ static void pump_transfers(unsigned long data)
* 2. clk_div is changed * 2. clk_div is changed
* 3. control value changes * 3. control value changes
*/ */
if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div) { if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div || imask) {
spi_enable_chip(dws, 0); spi_enable_chip(dws, 0);
if (dw_readw(dws, ctrl0) != cr0) if (dw_readw(dws, ctrl0) != cr0)
dw_writew(dws, ctrl0, cr0); dw_writew(dws, ctrl0, cr0);
spi_set_clk(dws, clk_div ? clk_div : chip->clk_div);
spi_chip_sel(dws, spi->chip_select);
/* Set the interrupt mask, for poll mode just diable all int */ /* Set the interrupt mask, for poll mode just diable all int */
spi_mask_intr(dws, 0xff); spi_mask_intr(dws, 0xff);
if (!chip->poll_mode) if (imask)
spi_umask_intr(dws, imask); spi_umask_intr(dws, imask);
if (txint_level)
dw_writew(dws, txfltr, txint_level);
spi_set_clk(dws, clk_div ? clk_div : chip->clk_div);
spi_chip_sel(dws, spi->chip_select);
spi_enable_chip(dws, 1); spi_enable_chip(dws, 1);
if (cs_change) if (cs_change)
dws->prev_chip = chip; dws->prev_chip = chip;
} }
...@@ -712,11 +740,11 @@ static int dw_spi_setup(struct spi_device *spi) ...@@ -712,11 +740,11 @@ static int dw_spi_setup(struct spi_device *spi)
} }
chip->bits_per_word = spi->bits_per_word; chip->bits_per_word = spi->bits_per_word;
if (!spi->max_speed_hz) {
dev_err(&spi->dev, "No max speed HZ parameter\n");
return -EINVAL;
}
chip->speed_hz = spi->max_speed_hz; chip->speed_hz = spi->max_speed_hz;
if (chip->speed_hz)
chip->clk_div = 25000000 / chip->speed_hz;
else
chip->clk_div = 8; /* default value */
chip->tmode = 0; /* Tx & Rx */ chip->tmode = 0; /* Tx & Rx */
/* Default SPI mode is SCPOL = 0, SCPH = 0 */ /* Default SPI mode is SCPOL = 0, SCPH = 0 */
...@@ -735,7 +763,7 @@ static void dw_spi_cleanup(struct spi_device *spi) ...@@ -735,7 +763,7 @@ static void dw_spi_cleanup(struct spi_device *spi)
kfree(chip); kfree(chip);
} }
static int __init init_queue(struct dw_spi *dws) static int __devinit init_queue(struct dw_spi *dws)
{ {
INIT_LIST_HEAD(&dws->queue); INIT_LIST_HEAD(&dws->queue);
spin_lock_init(&dws->lock); spin_lock_init(&dws->lock);
...@@ -817,6 +845,22 @@ static void spi_hw_init(struct dw_spi *dws) ...@@ -817,6 +845,22 @@ static void spi_hw_init(struct dw_spi *dws)
spi_mask_intr(dws, 0xff); spi_mask_intr(dws, 0xff);
spi_enable_chip(dws, 1); spi_enable_chip(dws, 1);
flush(dws); flush(dws);
/*
* Try to detect the FIFO depth if not set by interface driver,
* the depth could be from 2 to 256 from HW spec
*/
if (!dws->fifo_len) {
u32 fifo;
for (fifo = 2; fifo <= 257; fifo++) {
dw_writew(dws, txfltr, fifo);
if (fifo != dw_readw(dws, txfltr))
break;
}
dws->fifo_len = (fifo == 257) ? 0 : fifo;
dw_writew(dws, txfltr, 0);
}
} }
int __devinit dw_spi_add_host(struct dw_spi *dws) int __devinit dw_spi_add_host(struct dw_spi *dws)
...@@ -913,6 +957,7 @@ void __devexit dw_spi_remove_host(struct dw_spi *dws) ...@@ -913,6 +957,7 @@ void __devexit dw_spi_remove_host(struct dw_spi *dws)
/* Disconnect from the SPI framework */ /* Disconnect from the SPI framework */
spi_unregister_master(dws->master); spi_unregister_master(dws->master);
} }
EXPORT_SYMBOL(dw_spi_remove_host);
int dw_spi_suspend_host(struct dw_spi *dws) int dw_spi_suspend_host(struct dw_spi *dws)
{ {
......
/*
* dw_spi_mmio.c - Memory-mapped interface driver for DW SPI Core
*
* Copyright (c) 2010, Octasic semiconductor.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*/
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/spi/dw_spi.h>
#include <linux/spi/spi.h>
#define DRIVER_NAME "dw_spi_mmio"
struct dw_spi_mmio {
struct dw_spi dws;
struct clk *clk;
};
static int __devinit dw_spi_mmio_probe(struct platform_device *pdev)
{
struct dw_spi_mmio *dwsmmio;
struct dw_spi *dws;
struct resource *mem, *ioarea;
int ret;
dwsmmio = kzalloc(sizeof(struct dw_spi_mmio), GFP_KERNEL);
if (!dwsmmio) {
ret = -ENOMEM;
goto err_end;
}
dws = &dwsmmio->dws;
/* Get basic io resource and map it */
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) {
dev_err(&pdev->dev, "no mem resource?\n");
ret = -EINVAL;
goto err_kfree;
}
ioarea = request_mem_region(mem->start, resource_size(mem),
pdev->name);
if (!ioarea) {
dev_err(&pdev->dev, "SPI region already claimed\n");
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);
if (dws->irq < 0) {
dev_err(&pdev->dev, "no irq resource?\n");
ret = dws->irq; /* -ENXIO */
goto err_unmap;
}
dwsmmio->clk = clk_get(&pdev->dev, NULL);
if (!dwsmmio->clk) {
ret = -ENODEV;
goto err_irq;
}
clk_enable(dwsmmio->clk);
dws->parent_dev = &pdev->dev;
dws->bus_num = 0;
dws->num_cs = 4;
dws->max_freq = clk_get_rate(dwsmmio->clk);
ret = dw_spi_add_host(dws);
if (ret)
goto err_clk;
platform_set_drvdata(pdev, dwsmmio);
return 0;
err_clk:
clk_disable(dwsmmio->clk);
clk_put(dwsmmio->clk);
dwsmmio->clk = NULL;
err_irq:
free_irq(dws->irq, dws);
err_unmap:
iounmap(dws->regs);
err_release_reg:
release_mem_region(mem->start, resource_size(mem));
err_kfree:
kfree(dwsmmio);
err_end:
return ret;
}
static int __devexit dw_spi_mmio_remove(struct platform_device *pdev)
{
struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev);
struct resource *mem;
platform_set_drvdata(pdev, NULL);
clk_disable(dwsmmio->clk);
clk_put(dwsmmio->clk);
dwsmmio->clk = NULL;
free_irq(dwsmmio->dws.irq, &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;
}
static struct platform_driver dw_spi_mmio_driver = {
.remove = __devexit_p(dw_spi_mmio_remove),
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
},
};
static int __init dw_spi_mmio_init(void)
{
return platform_driver_probe(&dw_spi_mmio_driver, dw_spi_mmio_probe);
}
module_init(dw_spi_mmio_init);
static void __exit dw_spi_mmio_exit(void)
{
platform_driver_unregister(&dw_spi_mmio_driver);
}
module_exit(dw_spi_mmio_exit);
MODULE_AUTHOR("Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>");
MODULE_DESCRIPTION("Memory-mapped I/O interface driver for DW SPI Core");
MODULE_LICENSE("GPL v2");
...@@ -73,6 +73,7 @@ static int __devinit spi_pci_probe(struct pci_dev *pdev, ...@@ -73,6 +73,7 @@ static int __devinit spi_pci_probe(struct pci_dev *pdev,
dws->num_cs = 4; dws->num_cs = 4;
dws->max_freq = 25000000; /* for Moorestwon */ dws->max_freq = 25000000; /* for Moorestwon */
dws->irq = pdev->irq; dws->irq = pdev->irq;
dws->fifo_len = 40; /* FIFO has 40 words buffer */
ret = dw_spi_add_host(dws); ret = dw_spi_add_host(dws);
if (ret) if (ret)
...@@ -98,6 +99,7 @@ static void __devexit spi_pci_remove(struct pci_dev *pdev) ...@@ -98,6 +99,7 @@ static void __devexit 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);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
dw_spi_remove_host(&dwpci->dws);
iounmap(dwpci->dws.regs); iounmap(dwpci->dws.regs);
pci_release_region(pdev, 0); pci_release_region(pdev, 0);
kfree(dwpci); kfree(dwpci);
......
...@@ -503,7 +503,7 @@ static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) ...@@ -503,7 +503,7 @@ static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op)
return mpc52xx_psc_spi_do_remove(&op->dev); return mpc52xx_psc_spi_do_remove(&op->dev);
} }
static struct of_device_id mpc52xx_psc_spi_of_match[] = { static const struct of_device_id mpc52xx_psc_spi_of_match[] = {
{ .compatible = "fsl,mpc5200-psc-spi", }, { .compatible = "fsl,mpc5200-psc-spi", },
{ .compatible = "mpc5200-psc-spi", }, /* old */ { .compatible = "mpc5200-psc-spi", }, /* old */
{} {}
......
...@@ -550,7 +550,7 @@ static int __devexit mpc52xx_spi_remove(struct of_device *op) ...@@ -550,7 +550,7 @@ static int __devexit mpc52xx_spi_remove(struct of_device *op)
return 0; return 0;
} }
static struct of_device_id mpc52xx_spi_match[] __devinitdata = { static const struct of_device_id mpc52xx_spi_match[] __devinitconst = {
{ .compatible = "fsl,mpc5200-spi", }, { .compatible = "fsl,mpc5200-spi", },
{} {}
}; };
......
...@@ -469,7 +469,7 @@ static int spi_imx_setup(struct spi_device *spi) ...@@ -469,7 +469,7 @@ static int spi_imx_setup(struct spi_device *spi)
struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master); struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
int gpio = spi_imx->chipselect[spi->chip_select]; int gpio = spi_imx->chipselect[spi->chip_select];
pr_debug("%s: mode %d, %u bpw, %d hz\n", __func__, dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
spi->mode, spi->bits_per_word, spi->max_speed_hz); spi->mode, spi->bits_per_word, spi->max_speed_hz);
if (gpio >= 0) if (gpio >= 0)
......
...@@ -365,7 +365,7 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) ...@@ -365,7 +365,7 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
if ((mpc8xxx_spi->spibrg / hz) > 64) { if ((mpc8xxx_spi->spibrg / hz) > 64) {
cs->hw_mode |= SPMODE_DIV16; cs->hw_mode |= SPMODE_DIV16;
pm = mpc8xxx_spi->spibrg / (hz * 64); pm = (mpc8xxx_spi->spibrg - 1) / (hz * 64) + 1;
WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. " WARN_ONCE(pm > 16, "%s: Requested speed is too low: %d Hz. "
"Will use %d Hz instead.\n", dev_name(&spi->dev), "Will use %d Hz instead.\n", dev_name(&spi->dev),
...@@ -373,7 +373,7 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) ...@@ -373,7 +373,7 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
if (pm > 16) if (pm > 16)
pm = 16; pm = 16;
} else } else
pm = mpc8xxx_spi->spibrg / (hz * 4); pm = (mpc8xxx_spi->spibrg - 1) / (hz * 4) + 1;
if (pm) if (pm)
pm--; pm--;
...@@ -1328,7 +1328,7 @@ static struct of_platform_driver of_mpc8xxx_spi_driver = { ...@@ -1328,7 +1328,7 @@ static struct of_platform_driver of_mpc8xxx_spi_driver = {
static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev) static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev)
{ {
struct resource *mem; struct resource *mem;
unsigned int irq; int irq;
struct spi_master *master; struct spi_master *master;
if (!pdev->dev.platform_data) if (!pdev->dev.platform_data)
...@@ -1339,7 +1339,7 @@ static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev) ...@@ -1339,7 +1339,7 @@ static int __devinit plat_mpc8xxx_spi_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (!irq) if (irq <= 0)
return -EINVAL; return -EINVAL;
master = mpc8xxx_spi_probe(&pdev->dev, mem, irq); master = mpc8xxx_spi_probe(&pdev->dev, mem, irq);
......
...@@ -578,7 +578,7 @@ static int __exit spi_ppc4xx_of_remove(struct of_device *op) ...@@ -578,7 +578,7 @@ static int __exit spi_ppc4xx_of_remove(struct of_device *op)
return 0; return 0;
} }
static struct of_device_id spi_ppc4xx_of_match[] = { static const struct of_device_id spi_ppc4xx_of_match[] = {
{ .compatible = "ibm,ppc4xx-spi", }, { .compatible = "ibm,ppc4xx-spi", },
{}, {},
}; };
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <mach/dma.h> #include <mach/dma.h>
#include <plat/spi.h> #include <plat/s3c64xx-spi.h>
/* Registers and bit-fields */ /* Registers and bit-fields */
...@@ -137,6 +137,7 @@ ...@@ -137,6 +137,7 @@
/** /**
* struct s3c64xx_spi_driver_data - Runtime info holder for SPI driver. * struct s3c64xx_spi_driver_data - Runtime info holder for SPI driver.
* @clk: Pointer to the spi clock. * @clk: Pointer to the spi clock.
* @src_clk: Pointer to the clock used to generate SPI signals.
* @master: Pointer to the SPI Protocol master. * @master: Pointer to the SPI Protocol master.
* @workqueue: Work queue for the SPI xfer requests. * @workqueue: Work queue for the SPI xfer requests.
* @cntrlr_info: Platform specific data for the controller this driver manages. * @cntrlr_info: Platform specific data for the controller this driver manages.
...@@ -157,10 +158,11 @@ ...@@ -157,10 +158,11 @@
struct s3c64xx_spi_driver_data { struct s3c64xx_spi_driver_data {
void __iomem *regs; void __iomem *regs;
struct clk *clk; struct clk *clk;
struct clk *src_clk;
struct platform_device *pdev; struct platform_device *pdev;
struct spi_master *master; struct spi_master *master;
struct workqueue_struct *workqueue; struct workqueue_struct *workqueue;
struct s3c64xx_spi_cntrlr_info *cntrlr_info; struct s3c64xx_spi_info *cntrlr_info;
struct spi_device *tgl_spi; struct spi_device *tgl_spi;
struct work_struct work; struct work_struct work;
struct list_head queue; struct list_head queue;
...@@ -180,7 +182,7 @@ static struct s3c2410_dma_client s3c64xx_spi_dma_client = { ...@@ -180,7 +182,7 @@ static struct s3c2410_dma_client s3c64xx_spi_dma_client = {
static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
{ {
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
void __iomem *regs = sdd->regs; void __iomem *regs = sdd->regs;
unsigned long loops; unsigned long loops;
u32 val; u32 val;
...@@ -225,7 +227,7 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, ...@@ -225,7 +227,7 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer, int dma_mode) struct spi_transfer *xfer, int dma_mode)
{ {
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
void __iomem *regs = sdd->regs; void __iomem *regs = sdd->regs;
u32 modecfg, chcfg; u32 modecfg, chcfg;
...@@ -298,19 +300,20 @@ static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd, ...@@ -298,19 +300,20 @@ static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd,
if (sdd->tgl_spi != spi) { /* if last mssg on diff device */ if (sdd->tgl_spi != spi) { /* if last mssg on diff device */
/* Deselect the last toggled device */ /* Deselect the last toggled device */
cs = sdd->tgl_spi->controller_data; cs = sdd->tgl_spi->controller_data;
cs->set_level(spi->mode & SPI_CS_HIGH ? 0 : 1); cs->set_level(cs->line,
spi->mode & SPI_CS_HIGH ? 0 : 1);
} }
sdd->tgl_spi = NULL; sdd->tgl_spi = NULL;
} }
cs = spi->controller_data; cs = spi->controller_data;
cs->set_level(spi->mode & SPI_CS_HIGH ? 1 : 0); cs->set_level(cs->line, spi->mode & SPI_CS_HIGH ? 1 : 0);
} }
static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd, static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
struct spi_transfer *xfer, int dma_mode) struct spi_transfer *xfer, int dma_mode)
{ {
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
void __iomem *regs = sdd->regs; void __iomem *regs = sdd->regs;
unsigned long val; unsigned long val;
int ms; int ms;
...@@ -384,12 +387,11 @@ static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd, ...@@ -384,12 +387,11 @@ static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd,
if (sdd->tgl_spi == spi) if (sdd->tgl_spi == spi)
sdd->tgl_spi = NULL; sdd->tgl_spi = NULL;
cs->set_level(spi->mode & SPI_CS_HIGH ? 0 : 1); cs->set_level(cs->line, spi->mode & SPI_CS_HIGH ? 0 : 1);
} }
static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
{ {
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
void __iomem *regs = sdd->regs; void __iomem *regs = sdd->regs;
u32 val; u32 val;
...@@ -435,7 +437,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) ...@@ -435,7 +437,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
/* Configure Clock */ /* Configure Clock */
val = readl(regs + S3C64XX_SPI_CLK_CFG); val = readl(regs + S3C64XX_SPI_CLK_CFG);
val &= ~S3C64XX_SPI_PSR_MASK; val &= ~S3C64XX_SPI_PSR_MASK;
val |= ((clk_get_rate(sci->src_clk) / sdd->cur_speed / 2 - 1) val |= ((clk_get_rate(sdd->src_clk) / sdd->cur_speed / 2 - 1)
& S3C64XX_SPI_PSR_MASK); & S3C64XX_SPI_PSR_MASK);
writel(val, regs + S3C64XX_SPI_CLK_CFG); writel(val, regs + S3C64XX_SPI_CLK_CFG);
...@@ -558,7 +560,7 @@ static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd, ...@@ -558,7 +560,7 @@ static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd,
static void handle_msg(struct s3c64xx_spi_driver_data *sdd, static void handle_msg(struct s3c64xx_spi_driver_data *sdd,
struct spi_message *msg) struct spi_message *msg)
{ {
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
struct spi_device *spi = msg->spi; struct spi_device *spi = msg->spi;
struct s3c64xx_spi_csinfo *cs = spi->controller_data; struct s3c64xx_spi_csinfo *cs = spi->controller_data;
struct spi_transfer *xfer; struct spi_transfer *xfer;
...@@ -632,8 +634,8 @@ static void handle_msg(struct s3c64xx_spi_driver_data *sdd, ...@@ -632,8 +634,8 @@ static void handle_msg(struct s3c64xx_spi_driver_data *sdd,
S3C64XX_SPI_DEACT(sdd); S3C64XX_SPI_DEACT(sdd);
if (status) { if (status) {
dev_err(&spi->dev, "I/O Error: \ dev_err(&spi->dev, "I/O Error: "
rx-%d tx-%d res:rx-%c tx-%c len-%d\n", "rx-%d tx-%d res:rx-%c tx-%c len-%d\n",
xfer->rx_buf ? 1 : 0, xfer->tx_buf ? 1 : 0, xfer->rx_buf ? 1 : 0, xfer->tx_buf ? 1 : 0,
(sdd->state & RXBUSY) ? 'f' : 'p', (sdd->state & RXBUSY) ? 'f' : 'p',
(sdd->state & TXBUSY) ? 'f' : 'p', (sdd->state & TXBUSY) ? 'f' : 'p',
...@@ -786,7 +788,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -786,7 +788,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
{ {
struct s3c64xx_spi_csinfo *cs = spi->controller_data; struct s3c64xx_spi_csinfo *cs = spi->controller_data;
struct s3c64xx_spi_driver_data *sdd; struct s3c64xx_spi_driver_data *sdd;
struct s3c64xx_spi_cntrlr_info *sci; struct s3c64xx_spi_info *sci;
struct spi_message *msg; struct spi_message *msg;
u32 psr, speed; u32 psr, speed;
unsigned long flags; unsigned long flags;
...@@ -831,17 +833,17 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -831,17 +833,17 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
} }
/* Check if we can provide the requested rate */ /* Check if we can provide the requested rate */
speed = clk_get_rate(sci->src_clk) / 2 / (0 + 1); /* Max possible */ speed = clk_get_rate(sdd->src_clk) / 2 / (0 + 1); /* Max possible */
if (spi->max_speed_hz > speed) if (spi->max_speed_hz > speed)
spi->max_speed_hz = speed; spi->max_speed_hz = speed;
psr = clk_get_rate(sci->src_clk) / 2 / spi->max_speed_hz - 1; psr = clk_get_rate(sdd->src_clk) / 2 / spi->max_speed_hz - 1;
psr &= S3C64XX_SPI_PSR_MASK; psr &= S3C64XX_SPI_PSR_MASK;
if (psr == S3C64XX_SPI_PSR_MASK) if (psr == S3C64XX_SPI_PSR_MASK)
psr--; psr--;
speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1); speed = clk_get_rate(sdd->src_clk) / 2 / (psr + 1);
if (spi->max_speed_hz < speed) { if (spi->max_speed_hz < speed) {
if (psr+1 < S3C64XX_SPI_PSR_MASK) { if (psr+1 < S3C64XX_SPI_PSR_MASK) {
psr++; psr++;
...@@ -851,7 +853,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -851,7 +853,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
} }
} }
speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1); speed = clk_get_rate(sdd->src_clk) / 2 / (psr + 1);
if (spi->max_speed_hz >= speed) if (spi->max_speed_hz >= speed)
spi->max_speed_hz = speed; spi->max_speed_hz = speed;
else else
...@@ -867,7 +869,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi) ...@@ -867,7 +869,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel) static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
{ {
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
void __iomem *regs = sdd->regs; void __iomem *regs = sdd->regs;
unsigned int val; unsigned int val;
...@@ -902,7 +904,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -902,7 +904,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
{ {
struct resource *mem_res, *dmatx_res, *dmarx_res; struct resource *mem_res, *dmatx_res, *dmarx_res;
struct s3c64xx_spi_driver_data *sdd; struct s3c64xx_spi_driver_data *sdd;
struct s3c64xx_spi_cntrlr_info *sci; struct s3c64xx_spi_info *sci;
struct spi_master *master; struct spi_master *master;
int ret; int ret;
...@@ -1000,18 +1002,15 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1000,18 +1002,15 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
goto err4; goto err4;
} }
if (sci->src_clk_nr == S3C64XX_SPI_SRCCLK_PCLK) sdd->src_clk = clk_get(&pdev->dev, sci->src_clk_name);
sci->src_clk = sdd->clk; if (IS_ERR(sdd->src_clk)) {
else
sci->src_clk = clk_get(&pdev->dev, sci->src_clk_name);
if (IS_ERR(sci->src_clk)) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Unable to acquire clock '%s'\n", sci->src_clk_name); "Unable to acquire clock '%s'\n", sci->src_clk_name);
ret = PTR_ERR(sci->src_clk); ret = PTR_ERR(sdd->src_clk);
goto err5; goto err5;
} }
if (sci->src_clk != sdd->clk && clk_enable(sci->src_clk)) { if (clk_enable(sdd->src_clk)) {
dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", dev_err(&pdev->dev, "Couldn't enable clock '%s'\n",
sci->src_clk_name); sci->src_clk_name);
ret = -EBUSY; ret = -EBUSY;
...@@ -1040,11 +1039,10 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1040,11 +1039,10 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
goto err8; goto err8;
} }
dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d \ dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d "
with %d Slaves attached\n", "with %d Slaves attached\n",
pdev->id, master->num_chipselect); pdev->id, master->num_chipselect);
dev_dbg(&pdev->dev, "\tIOmem=[0x%x-0x%x]\ dev_dbg(&pdev->dev, "\tIOmem=[0x%x-0x%x]\tDMA=[Rx-%d, Tx-%d]\n",
\tDMA=[Rx-%d, Tx-%d]\n",
mem_res->end, mem_res->start, mem_res->end, mem_res->start,
sdd->rx_dmach, sdd->tx_dmach); sdd->rx_dmach, sdd->tx_dmach);
...@@ -1053,11 +1051,9 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1053,11 +1051,9 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
err8: err8:
destroy_workqueue(sdd->workqueue); destroy_workqueue(sdd->workqueue);
err7: err7:
if (sci->src_clk != sdd->clk) clk_disable(sdd->src_clk);
clk_disable(sci->src_clk);
err6: err6:
if (sci->src_clk != sdd->clk) clk_put(sdd->src_clk);
clk_put(sci->src_clk);
err5: err5:
clk_disable(sdd->clk); clk_disable(sdd->clk);
err4: err4:
...@@ -1078,7 +1074,6 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) ...@@ -1078,7 +1074,6 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
struct resource *mem_res; struct resource *mem_res;
unsigned long flags; unsigned long flags;
...@@ -1093,11 +1088,8 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) ...@@ -1093,11 +1088,8 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
destroy_workqueue(sdd->workqueue); destroy_workqueue(sdd->workqueue);
if (sci->src_clk != sdd->clk) clk_disable(sdd->src_clk);
clk_disable(sci->src_clk); clk_put(sdd->src_clk);
if (sci->src_clk != sdd->clk)
clk_put(sci->src_clk);
clk_disable(sdd->clk); clk_disable(sdd->clk);
clk_put(sdd->clk); clk_put(sdd->clk);
...@@ -1105,6 +1097,7 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) ...@@ -1105,6 +1097,7 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
iounmap((void *) sdd->regs); iounmap((void *) sdd->regs);
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (mem_res != NULL)
release_mem_region(mem_res->start, resource_size(mem_res)); release_mem_region(mem_res->start, resource_size(mem_res));
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
...@@ -1118,8 +1111,6 @@ static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state) ...@@ -1118,8 +1111,6 @@ static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state)
{ {
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
struct s3c64xx_spi_csinfo *cs;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&sdd->lock, flags); spin_lock_irqsave(&sdd->lock, flags);
...@@ -1130,9 +1121,7 @@ static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state) ...@@ -1130,9 +1121,7 @@ static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state)
msleep(10); msleep(10);
/* Disable the clock */ /* Disable the clock */
if (sci->src_clk != sdd->clk) clk_disable(sdd->src_clk);
clk_disable(sci->src_clk);
clk_disable(sdd->clk); clk_disable(sdd->clk);
sdd->cur_speed = 0; /* Output Clock is stopped */ sdd->cur_speed = 0; /* Output Clock is stopped */
...@@ -1144,15 +1133,13 @@ static int s3c64xx_spi_resume(struct platform_device *pdev) ...@@ -1144,15 +1133,13 @@ static int s3c64xx_spi_resume(struct platform_device *pdev)
{ {
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info; struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
unsigned long flags; unsigned long flags;
sci->cfg_gpio(pdev); sci->cfg_gpio(pdev);
/* Enable the clock */ /* Enable the clock */
if (sci->src_clk != sdd->clk) clk_enable(sdd->src_clk);
clk_enable(sci->src_clk);
clk_enable(sdd->clk); clk_enable(sdd->clk);
s3c64xx_spi_hwinit(sdd, pdev->id); s3c64xx_spi_hwinit(sdd, pdev->id);
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/err.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h> #include <linux/spi/spi_bitbang.h>
#include <linux/spi/sh_msiof.h> #include <linux/spi/sh_msiof.h>
#include <asm/spi.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
struct sh_msiof_spi_priv { struct sh_msiof_spi_priv {
......
...@@ -76,7 +76,7 @@ struct stmp_spi { ...@@ -76,7 +76,7 @@ struct stmp_spi {
break; \ break; \
} \ } \
cpu_relax(); \ cpu_relax(); \
} while (time_before(end_jiffies, jiffies)); \ } while (time_before(jiffies, end_jiffies)); \
succeeded; \ succeeded; \
}) })
......
...@@ -93,6 +93,26 @@ struct xilinx_spi { ...@@ -93,6 +93,26 @@ struct xilinx_spi {
void (*rx_fn) (struct xilinx_spi *); void (*rx_fn) (struct xilinx_spi *);
}; };
static void xspi_write32(u32 val, void __iomem *addr)
{
iowrite32(val, addr);
}
static unsigned int xspi_read32(void __iomem *addr)
{
return ioread32(addr);
}
static void xspi_write32_be(u32 val, void __iomem *addr)
{
iowrite32be(val, addr);
}
static unsigned int xspi_read32_be(void __iomem *addr)
{
return ioread32be(addr);
}
static void xspi_tx8(struct xilinx_spi *xspi) static void xspi_tx8(struct xilinx_spi *xspi)
{ {
xspi->write_fn(*xspi->tx_ptr, xspi->regs + XSPI_TXD_OFFSET); xspi->write_fn(*xspi->tx_ptr, xspi->regs + XSPI_TXD_OFFSET);
...@@ -374,11 +394,11 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, ...@@ -374,11 +394,11 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
xspi->mem = *mem; xspi->mem = *mem;
xspi->irq = irq; xspi->irq = irq;
if (pdata->little_endian) { if (pdata->little_endian) {
xspi->read_fn = ioread32; xspi->read_fn = xspi_read32;
xspi->write_fn = iowrite32; xspi->write_fn = xspi_write32;
} else { } else {
xspi->read_fn = ioread32be; xspi->read_fn = xspi_read32_be;
xspi->write_fn = iowrite32be; xspi->write_fn = xspi_write32_be;
} }
xspi->bits_per_word = pdata->bits_per_word; xspi->bits_per_word = pdata->bits_per_word;
if (xspi->bits_per_word == 8) { if (xspi->bits_per_word == 8) {
......
...@@ -99,7 +99,7 @@ static int __exit xilinx_spi_of_remove(struct of_device *op) ...@@ -99,7 +99,7 @@ static int __exit xilinx_spi_of_remove(struct of_device *op)
return xilinx_spi_remove(op); return xilinx_spi_remove(op);
} }
static struct of_device_id xilinx_spi_of_match[] = { static const struct of_device_id xilinx_spi_of_match[] = {
{ .compatible = "xlnx,xps-spi-2.00.a", }, { .compatible = "xlnx,xps-spi-2.00.a", },
{ .compatible = "xlnx,xps-spi-2.00.b", }, { .compatible = "xlnx,xps-spi-2.00.b", },
{} {}
......
...@@ -90,6 +90,7 @@ struct dw_spi { ...@@ -90,6 +90,7 @@ struct dw_spi {
unsigned long paddr; unsigned long paddr;
u32 iolen; u32 iolen;
int irq; int irq;
u32 fifo_len; /* depth of the FIFO buffer */
u32 max_freq; /* max bus freq supported */ u32 max_freq; /* max bus freq supported */
u16 bus_num; u16 bus_num;
...@@ -171,6 +172,10 @@ static inline void spi_chip_sel(struct dw_spi *dws, u16 cs) ...@@ -171,6 +172,10 @@ static inline void spi_chip_sel(struct dw_spi *dws, u16 cs)
{ {
if (cs > dws->num_cs) if (cs > dws->num_cs)
return; return;
if (dws->cs_control)
dws->cs_control(1);
dw_writel(dws, ser, 1 << cs); dw_writel(dws, ser, 1 << cs);
} }
......
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