You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'spi/next' of git://git.secretlab.ca/git/linux-2.6
* 'spi/next' of git://git.secretlab.ca/git/linux-2.6: (34 commits)
spi/dw_spi: move dw_spi.h into drivers/spi
spi/dw_spi: Fix missing header
gpio/langwell: Clear edge bit before handling
gpio/langwell: Simplify demux loop
gpio/langwell: Convert irq name space
gpio/langwell: Fix broken irq_eoi change.
gpio; Make Intel chipset gpio drivers depend on x86
gpio/cs5535-gpio: Fix section mismatch
spi/rtc-{ds1390,ds3234,m41t94}: Use spi_get_drvdata() for SPI devices
spi/davinci: Support DMA transfers larger than 65535 words
spi/davinci: Use correct length parameter to dma_map_single calls
gpio: Use __devexit at necessary places
gpio: add MODULE_DEVICE_TABLE to pch_gpio and ml_ioh_gpio
gpio/mcp23s08: support mcp23s17 variant
of_mmc_spi: add card detect irq support
spi/omap_mcspi: catch xfers of non-multiple SPI word size
spi/omap_mcspi: Off-by-one error in finding the right divisor
gpio/pca953x: Fix wrong pointer type
spi/pl022: rid dangling labels
spi: add support for SuperH SPI
...
This commit is contained in:
@@ -7,8 +7,13 @@ Required properties:
|
||||
- voltage-ranges : two cells are required, first cell specifies minimum
|
||||
slot voltage (mV), second cell specifies maximum slot voltage (mV).
|
||||
Several ranges could be specified.
|
||||
- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO,
|
||||
|
||||
Optional properties:
|
||||
- gpios : may specify GPIOs in this order: Card-Detect GPIO,
|
||||
Write-Protect GPIO.
|
||||
- interrupts : the interrupt of a card detect interrupt.
|
||||
- interrupt-parent : the phandle for the interrupt controller that
|
||||
services interrupts for this device.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -20,4 +25,6 @@ Example:
|
||||
&qe_pio_d 15 0>;
|
||||
voltage-ranges = <3300 3300>;
|
||||
spi-max-frequency = <50000000>;
|
||||
interrupts = <42>;
|
||||
interrupt-parent = <&PIC>;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Altera SPI
|
||||
|
||||
Required properties:
|
||||
- compatible : should be "ALTR,spi-1.0".
|
||||
@@ -0,0 +1,12 @@
|
||||
OpenCores tiny SPI
|
||||
|
||||
Required properties:
|
||||
- compatible : should be "opencores,tiny-spi-rtlsvn2".
|
||||
- gpios : should specify GPIOs used for chipselect.
|
||||
Optional properties:
|
||||
- clock-frequency : input clock frequency to the core.
|
||||
- baud-width: width, in bits, of the programmable divider used to scale
|
||||
the input clock to SCLK.
|
||||
|
||||
The clock-frequency and baud-width properties are needed only if the divider
|
||||
is programmable. They are not needed if the divider is fixed.
|
||||
@@ -133,7 +133,7 @@ exit_destroy:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gen_74x164_remove(struct spi_device *spi)
|
||||
static int __devexit gen_74x164_remove(struct spi_device *spi)
|
||||
{
|
||||
struct gen_74x164_chip *chip;
|
||||
int ret;
|
||||
|
||||
@@ -101,7 +101,7 @@ config GPIO_VR41XX
|
||||
|
||||
config GPIO_SCH
|
||||
tristate "Intel SCH GPIO"
|
||||
depends on GPIOLIB && PCI
|
||||
depends on GPIOLIB && PCI && X86
|
||||
select MFD_CORE
|
||||
select LPC_SCH
|
||||
help
|
||||
@@ -321,13 +321,13 @@ config GPIO_BT8XX
|
||||
|
||||
config GPIO_LANGWELL
|
||||
bool "Intel Langwell/Penwell GPIO support"
|
||||
depends on PCI
|
||||
depends on PCI && X86
|
||||
help
|
||||
Say Y here to support Intel Langwell/Penwell GPIO.
|
||||
|
||||
config GPIO_PCH
|
||||
tristate "PCH GPIO of Intel Topcliff"
|
||||
depends on PCI
|
||||
depends on PCI && X86
|
||||
help
|
||||
This driver is for PCH(Platform controller Hub) GPIO of Intel Topcliff
|
||||
which is an IOH(Input/Output Hub) for x86 embedded processor.
|
||||
@@ -368,11 +368,11 @@ config GPIO_MAX7301
|
||||
GPIO driver for Maxim MAX7301 SPI-based GPIO expander.
|
||||
|
||||
config GPIO_MCP23S08
|
||||
tristate "Microchip MCP23S08 I/O expander"
|
||||
tristate "Microchip MCP23Sxx I/O expander"
|
||||
depends on SPI_MASTER
|
||||
help
|
||||
SPI driver for Microchip MCP23S08 I/O expander. This provides
|
||||
a GPIO interface supporting inputs and outputs.
|
||||
SPI driver for Microchip MCP23S08/MPC23S17 I/O expanders.
|
||||
This provides a GPIO interface supporting inputs and outputs.
|
||||
|
||||
config GPIO_MC33880
|
||||
tristate "Freescale MC33880 high-side/low-side switch"
|
||||
|
||||
@@ -373,7 +373,7 @@ static int __devexit cs5535_gpio_remove(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver cs5535_gpio_drv = {
|
||||
static struct platform_driver cs5535_gpio_driver = {
|
||||
.driver = {
|
||||
.name = DRV_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
@@ -384,12 +384,12 @@ static struct platform_driver cs5535_gpio_drv = {
|
||||
|
||||
static int __init cs5535_gpio_init(void)
|
||||
{
|
||||
return platform_driver_register(&cs5535_gpio_drv);
|
||||
return platform_driver_register(&cs5535_gpio_driver);
|
||||
}
|
||||
|
||||
static void __exit cs5535_gpio_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&cs5535_gpio_drv);
|
||||
platform_driver_unregister(&cs5535_gpio_driver);
|
||||
}
|
||||
|
||||
module_init(cs5535_gpio_init);
|
||||
|
||||
@@ -187,31 +187,28 @@ MODULE_DEVICE_TABLE(pci, lnw_gpio_ids);
|
||||
|
||||
static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
|
||||
{
|
||||
struct lnw_gpio *lnw = get_irq_data(irq);
|
||||
u32 base, gpio;
|
||||
struct irq_data *data = irq_desc_get_irq_data(desc);
|
||||
struct lnw_gpio *lnw = irq_data_get_irq_handler_data(data);
|
||||
struct irq_chip *chip = irq_data_get_irq_chip(data);
|
||||
u32 base, gpio, mask;
|
||||
unsigned long pending;
|
||||
void __iomem *gedr;
|
||||
u32 gedr_v;
|
||||
|
||||
/* check GPIO controller to check which pin triggered the interrupt */
|
||||
for (base = 0; base < lnw->chip.ngpio; base += 32) {
|
||||
gedr = gpio_reg(&lnw->chip, base, GEDR);
|
||||
gedr_v = readl(gedr);
|
||||
if (!gedr_v)
|
||||
continue;
|
||||
for (gpio = base; gpio < base + 32; gpio++)
|
||||
if (gedr_v & BIT(gpio % 32)) {
|
||||
pr_debug("pin %d triggered\n", gpio);
|
||||
generic_handle_irq(lnw->irq_base + gpio);
|
||||
pending = readl(gedr);
|
||||
while (pending) {
|
||||
gpio = __ffs(pending) - 1;
|
||||
mask = BIT(gpio);
|
||||
pending &= ~mask;
|
||||
/* Clear before handling so we can't lose an edge */
|
||||
writel(mask, gedr);
|
||||
generic_handle_irq(lnw->irq_base + base + gpio);
|
||||
}
|
||||
/* clear the edge detect status bit */
|
||||
writel(gedr_v, gedr);
|
||||
}
|
||||
|
||||
if (desc->chip->irq_eoi)
|
||||
desc->chip->irq_eoi(irq_get_irq_data(irq));
|
||||
else
|
||||
dev_warn(lnw->chip.dev, "missing EOI handler for irq %d\n", irq);
|
||||
|
||||
chip->irq_eoi(data);
|
||||
}
|
||||
|
||||
static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
|
||||
@@ -279,12 +276,12 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
|
||||
dev_err(&pdev->dev, "langwell gpiochip_add error %d\n", retval);
|
||||
goto err5;
|
||||
}
|
||||
set_irq_data(pdev->irq, lnw);
|
||||
set_irq_chained_handler(pdev->irq, lnw_irq_handler);
|
||||
irq_set_handler_data(pdev->irq, lnw);
|
||||
irq_set_chained_handler(pdev->irq, lnw_irq_handler);
|
||||
for (i = 0; i < lnw->chip.ngpio; i++) {
|
||||
set_irq_chip_and_handler_name(i + lnw->irq_base, &lnw_irqchip,
|
||||
irq_set_chip_and_handler_name(i + lnw->irq_base, &lnw_irqchip,
|
||||
handle_simple_irq, "demux");
|
||||
set_irq_chip_data(i + lnw->irq_base, lnw);
|
||||
irq_set_chip_data(i + lnw->irq_base, lnw);
|
||||
}
|
||||
|
||||
spin_lock_init(&lnw->lock);
|
||||
|
||||
@@ -146,7 +146,7 @@ exit_destroy:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mc33880_remove(struct spi_device *spi)
|
||||
static int __devexit mc33880_remove(struct spi_device *spi)
|
||||
{
|
||||
struct mc33880 *mc;
|
||||
int ret;
|
||||
|
||||
+142
-47
@@ -10,7 +10,13 @@
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/spi/mcp23s08.h>
|
||||
#include <linux/slab.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
/**
|
||||
* MCP types supported by driver
|
||||
*/
|
||||
#define MCP_TYPE_S08 0
|
||||
#define MCP_TYPE_S17 1
|
||||
|
||||
/* Registers are all 8 bits wide.
|
||||
*
|
||||
@@ -35,27 +41,38 @@
|
||||
#define MCP_GPIO 0x09
|
||||
#define MCP_OLAT 0x0a
|
||||
|
||||
struct mcp23s08;
|
||||
|
||||
struct mcp23s08_ops {
|
||||
int (*read)(struct mcp23s08 *mcp, unsigned reg);
|
||||
int (*write)(struct mcp23s08 *mcp, unsigned reg, unsigned val);
|
||||
int (*read_regs)(struct mcp23s08 *mcp, unsigned reg,
|
||||
u16 *vals, unsigned n);
|
||||
};
|
||||
|
||||
struct mcp23s08 {
|
||||
struct spi_device *spi;
|
||||
u8 addr;
|
||||
|
||||
u8 cache[11];
|
||||
u16 cache[11];
|
||||
/* lock protects the cached values */
|
||||
struct mutex lock;
|
||||
|
||||
struct gpio_chip chip;
|
||||
|
||||
struct work_struct work;
|
||||
|
||||
const struct mcp23s08_ops *ops;
|
||||
};
|
||||
|
||||
/* A given spi_device can represent up to four mcp23s08 chips
|
||||
/* A given spi_device can represent up to eight mcp23sxx chips
|
||||
* sharing the same chipselect but using different addresses
|
||||
* (e.g. chips #0 and #3 might be populated, but not #1 or $2).
|
||||
* Driver data holds all the per-chip data.
|
||||
*/
|
||||
struct mcp23s08_driver_data {
|
||||
unsigned ngpio;
|
||||
struct mcp23s08 *mcp[4];
|
||||
struct mcp23s08 *mcp[8];
|
||||
struct mcp23s08 chip[];
|
||||
};
|
||||
|
||||
@@ -70,7 +87,7 @@ static int mcp23s08_read(struct mcp23s08 *mcp, unsigned reg)
|
||||
return (status < 0) ? status : rx[0];
|
||||
}
|
||||
|
||||
static int mcp23s08_write(struct mcp23s08 *mcp, unsigned reg, u8 val)
|
||||
static int mcp23s08_write(struct mcp23s08 *mcp, unsigned reg, unsigned val)
|
||||
{
|
||||
u8 tx[3];
|
||||
|
||||
@@ -81,16 +98,80 @@ static int mcp23s08_write(struct mcp23s08 *mcp, unsigned reg, u8 val)
|
||||
}
|
||||
|
||||
static int
|
||||
mcp23s08_read_regs(struct mcp23s08 *mcp, unsigned reg, u8 *vals, unsigned n)
|
||||
mcp23s08_read_regs(struct mcp23s08 *mcp, unsigned reg, u16 *vals, unsigned n)
|
||||
{
|
||||
u8 tx[2];
|
||||
u8 tx[2], *tmp;
|
||||
int status;
|
||||
|
||||
if ((n + reg) > sizeof mcp->cache)
|
||||
return -EINVAL;
|
||||
tx[0] = mcp->addr | 0x01;
|
||||
tx[1] = reg;
|
||||
return spi_write_then_read(mcp->spi, tx, sizeof tx, vals, n);
|
||||
|
||||
tmp = (u8 *)vals;
|
||||
status = spi_write_then_read(mcp->spi, tx, sizeof tx, tmp, n);
|
||||
if (status >= 0) {
|
||||
while (n--)
|
||||
vals[n] = tmp[n]; /* expand to 16bit */
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static int mcp23s17_read(struct mcp23s08 *mcp, unsigned reg)
|
||||
{
|
||||
u8 tx[2], rx[2];
|
||||
int status;
|
||||
|
||||
tx[0] = mcp->addr | 0x01;
|
||||
tx[1] = reg << 1;
|
||||
status = spi_write_then_read(mcp->spi, tx, sizeof tx, rx, sizeof rx);
|
||||
return (status < 0) ? status : (rx[0] | (rx[1] << 8));
|
||||
}
|
||||
|
||||
static int mcp23s17_write(struct mcp23s08 *mcp, unsigned reg, unsigned val)
|
||||
{
|
||||
u8 tx[4];
|
||||
|
||||
tx[0] = mcp->addr;
|
||||
tx[1] = reg << 1;
|
||||
tx[2] = val;
|
||||
tx[3] = val >> 8;
|
||||
return spi_write_then_read(mcp->spi, tx, sizeof tx, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
mcp23s17_read_regs(struct mcp23s08 *mcp, unsigned reg, u16 *vals, unsigned n)
|
||||
{
|
||||
u8 tx[2];
|
||||
int status;
|
||||
|
||||
if ((n + reg) > sizeof mcp->cache)
|
||||
return -EINVAL;
|
||||
tx[0] = mcp->addr | 0x01;
|
||||
tx[1] = reg << 1;
|
||||
|
||||
status = spi_write_then_read(mcp->spi, tx, sizeof tx,
|
||||
(u8 *)vals, n * 2);
|
||||
if (status >= 0) {
|
||||
while (n--)
|
||||
vals[n] = __le16_to_cpu((__le16)vals[n]);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static const struct mcp23s08_ops mcp23s08_ops = {
|
||||
.read = mcp23s08_read,
|
||||
.write = mcp23s08_write,
|
||||
.read_regs = mcp23s08_read_regs,
|
||||
};
|
||||
|
||||
static const struct mcp23s08_ops mcp23s17_ops = {
|
||||
.read = mcp23s17_read,
|
||||
.write = mcp23s17_write,
|
||||
.read_regs = mcp23s17_read_regs,
|
||||
};
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -101,7 +182,7 @@ static int mcp23s08_direction_input(struct gpio_chip *chip, unsigned offset)
|
||||
|
||||
mutex_lock(&mcp->lock);
|
||||
mcp->cache[MCP_IODIR] |= (1 << offset);
|
||||
status = mcp23s08_write(mcp, MCP_IODIR, mcp->cache[MCP_IODIR]);
|
||||
status = mcp->ops->write(mcp, MCP_IODIR, mcp->cache[MCP_IODIR]);
|
||||
mutex_unlock(&mcp->lock);
|
||||
return status;
|
||||
}
|
||||
@@ -114,7 +195,7 @@ static int mcp23s08_get(struct gpio_chip *chip, unsigned offset)
|
||||
mutex_lock(&mcp->lock);
|
||||
|
||||
/* REVISIT reading this clears any IRQ ... */
|
||||
status = mcp23s08_read(mcp, MCP_GPIO);
|
||||
status = mcp->ops->read(mcp, MCP_GPIO);
|
||||
if (status < 0)
|
||||
status = 0;
|
||||
else {
|
||||
@@ -127,20 +208,20 @@ static int mcp23s08_get(struct gpio_chip *chip, unsigned offset)
|
||||
|
||||
static int __mcp23s08_set(struct mcp23s08 *mcp, unsigned mask, int value)
|
||||
{
|
||||
u8 olat = mcp->cache[MCP_OLAT];
|
||||
unsigned olat = mcp->cache[MCP_OLAT];
|
||||
|
||||
if (value)
|
||||
olat |= mask;
|
||||
else
|
||||
olat &= ~mask;
|
||||
mcp->cache[MCP_OLAT] = olat;
|
||||
return mcp23s08_write(mcp, MCP_OLAT, olat);
|
||||
return mcp->ops->write(mcp, MCP_OLAT, olat);
|
||||
}
|
||||
|
||||
static void mcp23s08_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
{
|
||||
struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip);
|
||||
u8 mask = 1 << offset;
|
||||
unsigned mask = 1 << offset;
|
||||
|
||||
mutex_lock(&mcp->lock);
|
||||
__mcp23s08_set(mcp, mask, value);
|
||||
@@ -151,14 +232,14 @@ static int
|
||||
mcp23s08_direction_output(struct gpio_chip *chip, unsigned offset, int value)
|
||||
{
|
||||
struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip);
|
||||
u8 mask = 1 << offset;
|
||||
unsigned mask = 1 << offset;
|
||||
int status;
|
||||
|
||||
mutex_lock(&mcp->lock);
|
||||
status = __mcp23s08_set(mcp, mask, value);
|
||||
if (status == 0) {
|
||||
mcp->cache[MCP_IODIR] &= ~mask;
|
||||
status = mcp23s08_write(mcp, MCP_IODIR, mcp->cache[MCP_IODIR]);
|
||||
status = mcp->ops->write(mcp, MCP_IODIR, mcp->cache[MCP_IODIR]);
|
||||
}
|
||||
mutex_unlock(&mcp->lock);
|
||||
return status;
|
||||
@@ -184,16 +265,16 @@ static void mcp23s08_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
||||
mcp = container_of(chip, struct mcp23s08, chip);
|
||||
|
||||
/* NOTE: we only handle one bank for now ... */
|
||||
bank = '0' + ((mcp->addr >> 1) & 0x3);
|
||||
bank = '0' + ((mcp->addr >> 1) & 0x7);
|
||||
|
||||
mutex_lock(&mcp->lock);
|
||||
t = mcp23s08_read_regs(mcp, 0, mcp->cache, sizeof mcp->cache);
|
||||
t = mcp->ops->read_regs(mcp, 0, mcp->cache, ARRAY_SIZE(mcp->cache));
|
||||
if (t < 0) {
|
||||
seq_printf(s, " I/O ERROR %d\n", t);
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (t = 0, mask = 1; t < 8; t++, mask <<= 1) {
|
||||
for (t = 0, mask = 1; t < chip->ngpio; t++, mask <<= 1) {
|
||||
const char *label;
|
||||
|
||||
label = gpiochip_is_requested(chip, t);
|
||||
@@ -219,28 +300,33 @@ done:
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static int mcp23s08_probe_one(struct spi_device *spi, unsigned addr,
|
||||
unsigned base, unsigned pullups)
|
||||
unsigned type, unsigned base, unsigned pullups)
|
||||
{
|
||||
struct mcp23s08_driver_data *data = spi_get_drvdata(spi);
|
||||
struct mcp23s08 *mcp = data->mcp[addr];
|
||||
int status;
|
||||
int do_update = 0;
|
||||
|
||||
mutex_init(&mcp->lock);
|
||||
|
||||
mcp->spi = spi;
|
||||
mcp->addr = 0x40 | (addr << 1);
|
||||
|
||||
mcp->chip.label = "mcp23s08",
|
||||
|
||||
mcp->chip.direction_input = mcp23s08_direction_input;
|
||||
mcp->chip.get = mcp23s08_get;
|
||||
mcp->chip.direction_output = mcp23s08_direction_output;
|
||||
mcp->chip.set = mcp23s08_set;
|
||||
mcp->chip.dbg_show = mcp23s08_dbg_show;
|
||||
|
||||
mcp->chip.base = base;
|
||||
if (type == MCP_TYPE_S17) {
|
||||
mcp->ops = &mcp23s17_ops;
|
||||
mcp->chip.ngpio = 16;
|
||||
mcp->chip.label = "mcp23s17";
|
||||
} else {
|
||||
mcp->ops = &mcp23s08_ops;
|
||||
mcp->chip.ngpio = 8;
|
||||
mcp->chip.label = "mcp23s08";
|
||||
}
|
||||
mcp->chip.base = base;
|
||||
mcp->chip.can_sleep = 1;
|
||||
mcp->chip.dev = &spi->dev;
|
||||
mcp->chip.owner = THIS_MODULE;
|
||||
@@ -248,45 +334,39 @@ static int mcp23s08_probe_one(struct spi_device *spi, unsigned addr,
|
||||
/* verify MCP_IOCON.SEQOP = 0, so sequential reads work,
|
||||
* and MCP_IOCON.HAEN = 1, so we work with all chips.
|
||||
*/
|
||||
status = mcp23s08_read(mcp, MCP_IOCON);
|
||||
status = mcp->ops->read(mcp, MCP_IOCON);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN)) {
|
||||
status &= ~IOCON_SEQOP;
|
||||
status |= IOCON_HAEN;
|
||||
status = mcp23s08_write(mcp, MCP_IOCON, (u8) status);
|
||||
/* mcp23s17 has IOCON twice, make sure they are in sync */
|
||||
status &= ~(IOCON_SEQOP | (IOCON_SEQOP << 8));
|
||||
status |= IOCON_HAEN | (IOCON_HAEN << 8);
|
||||
status = mcp->ops->write(mcp, MCP_IOCON, status);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* configure ~100K pullups */
|
||||
status = mcp23s08_write(mcp, MCP_GPPU, pullups);
|
||||
status = mcp->ops->write(mcp, MCP_GPPU, pullups);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
|
||||
status = mcp23s08_read_regs(mcp, 0, mcp->cache, sizeof mcp->cache);
|
||||
status = mcp->ops->read_regs(mcp, 0, mcp->cache, ARRAY_SIZE(mcp->cache));
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
|
||||
/* disable inverter on input */
|
||||
if (mcp->cache[MCP_IPOL] != 0) {
|
||||
mcp->cache[MCP_IPOL] = 0;
|
||||
do_update = 1;
|
||||
status = mcp->ops->write(mcp, MCP_IPOL, 0);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* disable irqs */
|
||||
if (mcp->cache[MCP_GPINTEN] != 0) {
|
||||
mcp->cache[MCP_GPINTEN] = 0;
|
||||
do_update = 1;
|
||||
}
|
||||
|
||||
if (do_update) {
|
||||
u8 tx[4];
|
||||
|
||||
tx[0] = mcp->addr;
|
||||
tx[1] = MCP_IPOL;
|
||||
memcpy(&tx[2], &mcp->cache[MCP_IPOL], sizeof(tx) - 2);
|
||||
status = spi_write_then_read(mcp->spi, tx, sizeof tx, NULL, 0);
|
||||
status = mcp->ops->write(mcp, MCP_GPINTEN, 0);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
}
|
||||
@@ -305,19 +385,26 @@ static int mcp23s08_probe(struct spi_device *spi)
|
||||
unsigned addr;
|
||||
unsigned chips = 0;
|
||||
struct mcp23s08_driver_data *data;
|
||||
int status;
|
||||
int status, type;
|
||||
unsigned base;
|
||||
|
||||
type = spi_get_device_id(spi)->driver_data;
|
||||
|
||||
pdata = spi->dev.platform_data;
|
||||
if (!pdata || !gpio_is_valid(pdata->base)) {
|
||||
dev_dbg(&spi->dev, "invalid or missing platform data\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (addr = 0; addr < 4; addr++) {
|
||||
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
|
||||
if (!pdata->chip[addr].is_present)
|
||||
continue;
|
||||
chips++;
|
||||
if ((type == MCP_TYPE_S08) && (addr > 3)) {
|
||||
dev_err(&spi->dev,
|
||||
"mcp23s08 only supports address 0..3\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (!chips)
|
||||
return -ENODEV;
|
||||
@@ -329,16 +416,17 @@ static int mcp23s08_probe(struct spi_device *spi)
|
||||
spi_set_drvdata(spi, data);
|
||||
|
||||
base = pdata->base;
|
||||
for (addr = 0; addr < 4; addr++) {
|
||||
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
|
||||
if (!pdata->chip[addr].is_present)
|
||||
continue;
|
||||
chips--;
|
||||
data->mcp[addr] = &data->chip[chips];
|
||||
status = mcp23s08_probe_one(spi, addr, base,
|
||||
status = mcp23s08_probe_one(spi, addr, type, base,
|
||||
pdata->chip[addr].pullups);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
base += 8;
|
||||
|
||||
base += (type == MCP_TYPE_S17) ? 16 : 8;
|
||||
}
|
||||
data->ngpio = base - pdata->base;
|
||||
|
||||
@@ -358,7 +446,7 @@ static int mcp23s08_probe(struct spi_device *spi)
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
for (addr = 0; addr < 4; addr++) {
|
||||
for (addr = 0; addr < ARRAY_SIZE(data->mcp); addr++) {
|
||||
int tmp;
|
||||
|
||||
if (!data->mcp[addr])
|
||||
@@ -388,7 +476,7 @@ static int mcp23s08_remove(struct spi_device *spi)
|
||||
}
|
||||
}
|
||||
|
||||
for (addr = 0; addr < 4; addr++) {
|
||||
for (addr = 0; addr < ARRAY_SIZE(data->mcp); addr++) {
|
||||
int tmp;
|
||||
|
||||
if (!data->mcp[addr])
|
||||
@@ -405,9 +493,17 @@ static int mcp23s08_remove(struct spi_device *spi)
|
||||
return status;
|
||||
}
|
||||
|
||||
static const struct spi_device_id mcp23s08_ids[] = {
|
||||
{ "mcp23s08", MCP_TYPE_S08 },
|
||||
{ "mcp23s17", MCP_TYPE_S17 },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, mcp23s08_ids);
|
||||
|
||||
static struct spi_driver mcp23s08_driver = {
|
||||
.probe = mcp23s08_probe,
|
||||
.remove = mcp23s08_remove,
|
||||
.id_table = mcp23s08_ids,
|
||||
.driver = {
|
||||
.name = "mcp23s08",
|
||||
.owner = THIS_MODULE,
|
||||
@@ -432,4 +528,3 @@ static void __exit mcp23s08_exit(void)
|
||||
module_exit(mcp23s08_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("spi:mcp23s08");
|
||||
|
||||
@@ -462,7 +462,8 @@ pca953x_get_alt_pdata(struct i2c_client *client)
|
||||
{
|
||||
struct pca953x_platform_data *pdata;
|
||||
struct device_node *node;
|
||||
const uint16_t *val;
|
||||
const __be32 *val;
|
||||
int size;
|
||||
|
||||
node = client->dev.of_node;
|
||||
if (node == NULL)
|
||||
@@ -475,13 +476,13 @@ pca953x_get_alt_pdata(struct i2c_client *client)
|
||||
}
|
||||
|
||||
pdata->gpio_base = -1;
|
||||
val = of_get_property(node, "linux,gpio-base", NULL);
|
||||
val = of_get_property(node, "linux,gpio-base", &size);
|
||||
if (val) {
|
||||
if (*val < 0)
|
||||
dev_warn(&client->dev,
|
||||
"invalid gpio-base in device tree\n");
|
||||
if (size != sizeof(*val))
|
||||
dev_warn(&client->dev, "%s: wrong linux,gpio-base\n",
|
||||
node->full_name);
|
||||
else
|
||||
pdata->gpio_base = *val;
|
||||
pdata->gpio_base = be32_to_cpup(val);
|
||||
}
|
||||
|
||||
val = of_get_property(node, "polarity", NULL);
|
||||
|
||||
+36
-16
@@ -25,6 +25,8 @@
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/i2c/sx150x.h>
|
||||
|
||||
#define NO_UPDATE_PENDING -1
|
||||
|
||||
struct sx150x_device_data {
|
||||
u8 reg_pullup;
|
||||
u8 reg_pulldn;
|
||||
@@ -47,8 +49,11 @@ struct sx150x_chip {
|
||||
const struct sx150x_device_data *dev_cfg;
|
||||
int irq_summary;
|
||||
int irq_base;
|
||||
int irq_update;
|
||||
u32 irq_sense;
|
||||
unsigned long irq_set_type_pending;
|
||||
u32 irq_masked;
|
||||
u32 dev_sense;
|
||||
u32 dev_masked;
|
||||
struct irq_chip irq_chip;
|
||||
struct mutex lock;
|
||||
};
|
||||
@@ -312,9 +317,8 @@ static void sx150x_irq_mask(struct irq_data *d)
|
||||
|
||||
chip = container_of(ic, struct sx150x_chip, irq_chip);
|
||||
n = d->irq - chip->irq_base;
|
||||
|
||||
sx150x_write_cfg(chip, n, 1, chip->dev_cfg->reg_irq_mask, 1);
|
||||
sx150x_write_cfg(chip, n, 2, chip->dev_cfg->reg_sense, 0);
|
||||
chip->irq_masked |= (1 << n);
|
||||
chip->irq_update = n;
|
||||
}
|
||||
|
||||
static void sx150x_irq_unmask(struct irq_data *d)
|
||||
@@ -326,9 +330,8 @@ static void sx150x_irq_unmask(struct irq_data *d)
|
||||
chip = container_of(ic, struct sx150x_chip, irq_chip);
|
||||
n = d->irq - chip->irq_base;
|
||||
|
||||
sx150x_write_cfg(chip, n, 1, chip->dev_cfg->reg_irq_mask, 0);
|
||||
sx150x_write_cfg(chip, n, 2, chip->dev_cfg->reg_sense,
|
||||
chip->irq_sense >> (n * 2));
|
||||
chip->irq_masked &= ~(1 << n);
|
||||
chip->irq_update = n;
|
||||
}
|
||||
|
||||
static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type)
|
||||
@@ -350,7 +353,7 @@ static int sx150x_irq_set_type(struct irq_data *d, unsigned int flow_type)
|
||||
|
||||
chip->irq_sense &= ~(3UL << (n * 2));
|
||||
chip->irq_sense |= val << (n * 2);
|
||||
chip->irq_set_type_pending |= BIT(n);
|
||||
chip->irq_update = n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -404,15 +407,29 @@ static void sx150x_irq_bus_sync_unlock(struct irq_data *d)
|
||||
|
||||
chip = container_of(ic, struct sx150x_chip, irq_chip);
|
||||
|
||||
while (chip->irq_set_type_pending) {
|
||||
n = __ffs(chip->irq_set_type_pending);
|
||||
chip->irq_set_type_pending &= ~BIT(n);
|
||||
if (!(irq_to_desc(n + chip->irq_base)->status & IRQ_MASKED))
|
||||
sx150x_write_cfg(chip, n, 2,
|
||||
chip->dev_cfg->reg_sense,
|
||||
if (chip->irq_update == NO_UPDATE_PENDING)
|
||||
goto out;
|
||||
|
||||
n = chip->irq_update;
|
||||
chip->irq_update = NO_UPDATE_PENDING;
|
||||
|
||||
/* Avoid updates if nothing changed */
|
||||
if (chip->dev_sense == chip->irq_sense &&
|
||||
chip->dev_sense == chip->irq_masked)
|
||||
goto out;
|
||||
|
||||
chip->dev_sense = chip->irq_sense;
|
||||
chip->dev_masked = chip->irq_masked;
|
||||
|
||||
if (chip->irq_masked & (1 << n)) {
|
||||
sx150x_write_cfg(chip, n, 1, chip->dev_cfg->reg_irq_mask, 1);
|
||||
sx150x_write_cfg(chip, n, 2, chip->dev_cfg->reg_sense, 0);
|
||||
} else {
|
||||
sx150x_write_cfg(chip, n, 1, chip->dev_cfg->reg_irq_mask, 0);
|
||||
sx150x_write_cfg(chip, n, 2, chip->dev_cfg->reg_sense,
|
||||
chip->irq_sense >> (n * 2));
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_unlock(&chip->lock);
|
||||
}
|
||||
|
||||
@@ -445,8 +462,11 @@ static void sx150x_init_chip(struct sx150x_chip *chip,
|
||||
chip->irq_chip.irq_bus_sync_unlock = sx150x_irq_bus_sync_unlock;
|
||||
chip->irq_summary = -1;
|
||||
chip->irq_base = -1;
|
||||
chip->irq_masked = ~0;
|
||||
chip->irq_sense = 0;
|
||||
chip->irq_set_type_pending = 0;
|
||||
chip->dev_masked = ~0;
|
||||
chip->dev_sense = 0;
|
||||
chip->irq_update = NO_UPDATE_PENDING;
|
||||
}
|
||||
|
||||
static int sx150x_init_io(struct sx150x_chip *chip, u8 base, u16 cfg)
|
||||
|
||||
@@ -34,6 +34,7 @@ enum {
|
||||
struct of_mmc_spi {
|
||||
int gpios[NUM_GPIOS];
|
||||
bool alow_gpios[NUM_GPIOS];
|
||||
int detect_irq;
|
||||
struct mmc_spi_platform_data pdata;
|
||||
};
|
||||
|
||||
@@ -61,6 +62,22 @@ static int of_mmc_spi_get_ro(struct device *dev)
|
||||
return of_mmc_spi_read_gpio(dev, WP_GPIO);
|
||||
}
|
||||
|
||||
static int of_mmc_spi_init(struct device *dev,
|
||||
irqreturn_t (*irqhandler)(int, void *), void *mmc)
|
||||
{
|
||||
struct of_mmc_spi *oms = to_of_mmc_spi(dev);
|
||||
|
||||
return request_threaded_irq(oms->detect_irq, NULL, irqhandler, 0,
|
||||
dev_name(dev), mmc);
|
||||
}
|
||||
|
||||
static void of_mmc_spi_exit(struct device *dev, void *mmc)
|
||||
{
|
||||
struct of_mmc_spi *oms = to_of_mmc_spi(dev);
|
||||
|
||||
free_irq(oms->detect_irq, mmc);
|
||||
}
|
||||
|
||||
struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
@@ -121,8 +138,13 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
|
||||
if (gpio_is_valid(oms->gpios[WP_GPIO]))
|
||||
oms->pdata.get_ro = of_mmc_spi_get_ro;
|
||||
|
||||
/* We don't support interrupts yet, let's poll. */
|
||||
oms->detect_irq = irq_of_parse_and_map(np, 0);
|
||||
if (oms->detect_irq != NO_IRQ) {
|
||||
oms->pdata.init = of_mmc_spi_init;
|
||||
oms->pdata.exit = of_mmc_spi_exit;
|
||||
} else {
|
||||
oms->pdata.caps |= MMC_CAP_NEEDS_POLL;
|
||||
}
|
||||
|
||||
dev->platform_data = &oms->pdata;
|
||||
return dev->platform_data;
|
||||
|
||||
@@ -158,7 +158,7 @@ static int __devinit ds1390_probe(struct spi_device *spi)
|
||||
|
||||
static int __devexit ds1390_remove(struct spi_device *spi)
|
||||
{
|
||||
struct ds1390 *chip = platform_get_drvdata(spi);
|
||||
struct ds1390 *chip = spi_get_drvdata(spi);
|
||||
|
||||
rtc_device_unregister(chip->rtc);
|
||||
kfree(chip);
|
||||
|
||||
@@ -158,7 +158,7 @@ static int __devinit ds3234_probe(struct spi_device *spi)
|
||||
|
||||
static int __devexit ds3234_remove(struct spi_device *spi)
|
||||
{
|
||||
struct rtc_device *rtc = platform_get_drvdata(spi);
|
||||
struct rtc_device *rtc = spi_get_drvdata(spi);
|
||||
|
||||
rtc_device_unregister(rtc);
|
||||
return 0;
|
||||
|
||||
@@ -136,7 +136,7 @@ static int __devinit m41t94_probe(struct spi_device *spi)
|
||||
|
||||
static int __devexit m41t94_remove(struct spi_device *spi)
|
||||
{
|
||||
struct rtc_device *rtc = platform_get_drvdata(spi);
|
||||
struct rtc_device *rtc = spi_get_drvdata(spi);
|
||||
|
||||
if (rtc)
|
||||
rtc_device_unregister(rtc);
|
||||
|
||||
@@ -53,6 +53,12 @@ if SPI_MASTER
|
||||
|
||||
comment "SPI Master Controller Drivers"
|
||||
|
||||
config SPI_ALTERA
|
||||
tristate "Altera SPI Controller"
|
||||
select SPI_BITBANG
|
||||
help
|
||||
This is the driver for the Altera SPI Controller.
|
||||
|
||||
config SPI_ATH79
|
||||
tristate "Atheros AR71XX/AR724X/AR913X SPI controller driver"
|
||||
depends on ATH79 && GENERIC_GPIO
|
||||
@@ -231,6 +237,13 @@ config SPI_FSL_ESPI
|
||||
From MPC8536, 85xx platform uses the controller, and all P10xx,
|
||||
P20xx, P30xx,P40xx, P50xx uses this controller.
|
||||
|
||||
config SPI_OC_TINY
|
||||
tristate "OpenCores tiny SPI"
|
||||
depends on GENERIC_GPIO
|
||||
select SPI_BITBANG
|
||||
help
|
||||
This is the driver for OpenCores tiny SPI master controller.
|
||||
|
||||
config SPI_OMAP_UWIRE
|
||||
tristate "OMAP1 MicroWire"
|
||||
depends on ARCH_OMAP1
|
||||
@@ -330,6 +343,12 @@ config SPI_SH_MSIOF
|
||||
help
|
||||
SPI driver for SuperH MSIOF blocks.
|
||||
|
||||
config SPI_SH
|
||||
tristate "SuperH SPI controller"
|
||||
depends on SUPERH
|
||||
help
|
||||
SPI driver for SuperH SPI blocks.
|
||||
|
||||
config SPI_SH_SCI
|
||||
tristate "SuperH SCI SPI controller"
|
||||
depends on SUPERH
|
||||
|
||||
@@ -9,6 +9,7 @@ ccflags-$(CONFIG_SPI_DEBUG) := -DDEBUG
|
||||
obj-$(CONFIG_SPI_MASTER) += spi.o
|
||||
|
||||
# SPI master controller drivers (bus)
|
||||
obj-$(CONFIG_SPI_ALTERA) += spi_altera.o
|
||||
obj-$(CONFIG_SPI_ATMEL) += atmel_spi.o
|
||||
obj-$(CONFIG_SPI_ATH79) += ath79_spi.o
|
||||
obj-$(CONFIG_SPI_BFIN) += spi_bfin5xx.o
|
||||
@@ -27,6 +28,7 @@ obj-$(CONFIG_SPI_IMX) += spi_imx.o
|
||||
obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o
|
||||
obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o
|
||||
obj-$(CONFIG_SPI_PXA2XX_PCI) += pxa2xx_spi_pci.o
|
||||
obj-$(CONFIG_SPI_OC_TINY) += spi_oc_tiny.o
|
||||
obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o
|
||||
obj-$(CONFIG_SPI_OMAP24XX) += omap2_mcspi.o
|
||||
obj-$(CONFIG_SPI_OMAP_100K) += omap_spi_100k.o
|
||||
@@ -47,6 +49,7 @@ obj-$(CONFIG_SPI_TI_SSP) += ti-ssp-spi.o
|
||||
obj-$(CONFIG_SPI_TOPCLIFF_PCH) += spi_topcliff_pch.o
|
||||
obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
|
||||
obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o
|
||||
obj-$(CONFIG_SPI_SH) += spi_sh.o
|
||||
obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o
|
||||
obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o
|
||||
obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o
|
||||
|
||||
+39
-34
@@ -329,15 +329,16 @@ struct vendor_data {
|
||||
/**
|
||||
* struct pl022 - This is the private SSP driver data structure
|
||||
* @adev: AMBA device model hookup
|
||||
* @vendor: Vendor data for the IP block
|
||||
* @phybase: The physical memory where the SSP device resides
|
||||
* @virtbase: The virtual memory where the SSP is mapped
|
||||
* @vendor: vendor data for the IP block
|
||||
* @phybase: the physical memory where the SSP device resides
|
||||
* @virtbase: the virtual memory where the SSP is mapped
|
||||
* @clk: outgoing clock "SPICLK" for the SPI bus
|
||||
* @master: SPI framework hookup
|
||||
* @master_info: controller-specific data from machine setup
|
||||
* @regs: SSP controller register's virtual address
|
||||
* @pump_messages: Work struct for scheduling work to the workqueue
|
||||
* @lock: spinlock to syncronise access to driver data
|
||||
* @workqueue: a workqueue on which any spi_message request is queued
|
||||
* @pump_messages: work struct for scheduling work to the workqueue
|
||||
* @queue_lock: spinlock to syncronise access to message queue
|
||||
* @queue: message queue
|
||||
* @busy: workqueue is busy
|
||||
* @running: workqueue is running
|
||||
* @pump_transfers: Tasklet used in Interrupt Transfer mode
|
||||
@@ -348,8 +349,14 @@ struct vendor_data {
|
||||
* @tx_end: end position in TX buffer to be read
|
||||
* @rx: current position in RX buffer to be written
|
||||
* @rx_end: end position in RX buffer to be written
|
||||
* @readingtype: the type of read currently going on
|
||||
* @writingtype: the type or write currently going on
|
||||
* @read: the type of read currently going on
|
||||
* @write: the type of write currently going on
|
||||
* @exp_fifo_level: expected FIFO level
|
||||
* @dma_rx_channel: optional channel for RX DMA
|
||||
* @dma_tx_channel: optional channel for TX DMA
|
||||
* @sgt_rx: scattertable for the RX transfer
|
||||
* @sgt_tx: scattertable for the TX transfer
|
||||
* @dummypage: a dummy page used for driving data on the bus with DMA
|
||||
*/
|
||||
struct pl022 {
|
||||
struct amba_device *adev;
|
||||
@@ -397,8 +404,8 @@ struct pl022 {
|
||||
* @cpsr: Value of Clock prescale register
|
||||
* @n_bytes: how many bytes(power of 2) reqd for a given data width of client
|
||||
* @enable_dma: Whether to enable DMA or not
|
||||
* @write: function ptr to be used to write when doing xfer for this chip
|
||||
* @read: function ptr to be used to read when doing xfer for this chip
|
||||
* @write: function ptr to be used to write when doing xfer for this chip
|
||||
* @cs_control: chip select callback provided by chip
|
||||
* @xfer_type: polling/interrupt/DMA
|
||||
*
|
||||
@@ -508,9 +515,10 @@ static void giveback(struct pl022 *pl022)
|
||||
msg->state = NULL;
|
||||
if (msg->complete)
|
||||
msg->complete(msg->context);
|
||||
/* This message is completed, so let's turn off the clocks! */
|
||||
/* This message is completed, so let's turn off the clocks & power */
|
||||
clk_disable(pl022->clk);
|
||||
amba_pclk_disable(pl022->adev);
|
||||
amba_vcore_disable(pl022->adev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -917,7 +925,6 @@ static int configure_dma(struct pl022 *pl022)
|
||||
struct dma_chan *txchan = pl022->dma_tx_channel;
|
||||
struct dma_async_tx_descriptor *rxdesc;
|
||||
struct dma_async_tx_descriptor *txdesc;
|
||||
dma_cookie_t cookie;
|
||||
|
||||
/* Check that the channels are available */
|
||||
if (!rxchan || !txchan)
|
||||
@@ -962,10 +969,8 @@ static int configure_dma(struct pl022 *pl022)
|
||||
tx_conf.dst_addr_width = rx_conf.src_addr_width;
|
||||
BUG_ON(rx_conf.src_addr_width != tx_conf.dst_addr_width);
|
||||
|
||||
rxchan->device->device_control(rxchan, DMA_SLAVE_CONFIG,
|
||||
(unsigned long) &rx_conf);
|
||||
txchan->device->device_control(txchan, DMA_SLAVE_CONFIG,
|
||||
(unsigned long) &tx_conf);
|
||||
dmaengine_slave_config(rxchan, &rx_conf);
|
||||
dmaengine_slave_config(txchan, &tx_conf);
|
||||
|
||||
/* Create sglists for the transfers */
|
||||
pages = (pl022->cur_transfer->len >> PAGE_SHIFT) + 1;
|
||||
@@ -1018,23 +1023,17 @@ static int configure_dma(struct pl022 *pl022)
|
||||
rxdesc->callback_param = pl022;
|
||||
|
||||
/* Submit and fire RX and TX with TX last so we're ready to read! */
|
||||
cookie = rxdesc->tx_submit(rxdesc);
|
||||
if (dma_submit_error(cookie))
|
||||
goto err_submit_rx;
|
||||
cookie = txdesc->tx_submit(txdesc);
|
||||
if (dma_submit_error(cookie))
|
||||
goto err_submit_tx;
|
||||
rxchan->device->device_issue_pending(rxchan);
|
||||
txchan->device->device_issue_pending(txchan);
|
||||
dmaengine_submit(rxdesc);
|
||||
dmaengine_submit(txdesc);
|
||||
dma_async_issue_pending(rxchan);
|
||||
dma_async_issue_pending(txchan);
|
||||
|
||||
return 0;
|
||||
|
||||
err_submit_tx:
|
||||
err_submit_rx:
|
||||
err_txdesc:
|
||||
txchan->device->device_control(txchan, DMA_TERMINATE_ALL, 0);
|
||||
dmaengine_terminate_all(txchan);
|
||||
err_rxdesc:
|
||||
rxchan->device->device_control(rxchan, DMA_TERMINATE_ALL, 0);
|
||||
dmaengine_terminate_all(rxchan);
|
||||
dma_unmap_sg(txchan->device->dev, pl022->sgt_tx.sgl,
|
||||
pl022->sgt_tx.nents, DMA_TO_DEVICE);
|
||||
err_tx_sgmap:
|
||||
@@ -1101,8 +1100,8 @@ static void terminate_dma(struct pl022 *pl022)
|
||||
struct dma_chan *rxchan = pl022->dma_rx_channel;
|
||||
struct dma_chan *txchan = pl022->dma_tx_channel;
|
||||
|
||||
rxchan->device->device_control(rxchan, DMA_TERMINATE_ALL, 0);
|
||||
txchan->device->device_control(txchan, DMA_TERMINATE_ALL, 0);
|
||||
dmaengine_terminate_all(rxchan);
|
||||
dmaengine_terminate_all(txchan);
|
||||
unmap_free_dma_scatter(pl022);
|
||||
}
|
||||
|
||||
@@ -1482,9 +1481,11 @@ static void pump_messages(struct work_struct *work)
|
||||
/* Setup the SPI using the per chip configuration */
|
||||
pl022->cur_chip = spi_get_ctldata(pl022->cur_msg->spi);
|
||||
/*
|
||||
* We enable the clocks here, then the clocks will be disabled when
|
||||
* giveback() is called in each method (poll/interrupt/DMA)
|
||||
* We enable the core voltage and clocks here, then the clocks
|
||||
* and core will be disabled when giveback() is called in each method
|
||||
* (poll/interrupt/DMA)
|
||||
*/
|
||||
amba_vcore_enable(pl022->adev);
|
||||
amba_pclk_enable(pl022->adev);
|
||||
clk_enable(pl022->clk);
|
||||
restore_state(pl022);
|
||||
@@ -1910,8 +1911,6 @@ static int pl022_setup(struct spi_device *spi)
|
||||
&& ((pl022->master_info)->enable_dma)) {
|
||||
chip->enable_dma = true;
|
||||
dev_dbg(&spi->dev, "DMA mode set in controller state\n");
|
||||
if (status < 0)
|
||||
goto err_config_params;
|
||||
SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
|
||||
SSP_DMACR_MASK_RXDMAE, 0);
|
||||
SSP_WRITE_BITS(chip->dmacr, SSP_DMA_ENABLED,
|
||||
@@ -2130,8 +2129,12 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
|
||||
goto err_spi_register;
|
||||
}
|
||||
dev_dbg(dev, "probe succeded\n");
|
||||
/* Disable the silicon block pclk and clock it when needed */
|
||||
/*
|
||||
* Disable the silicon block pclk and any voltage domain and just
|
||||
* power it up and clock it when it's needed
|
||||
*/
|
||||
amba_pclk_disable(adev);
|
||||
amba_vcore_disable(adev);
|
||||
return 0;
|
||||
|
||||
err_spi_register:
|
||||
@@ -2196,9 +2199,11 @@ static int pl022_suspend(struct amba_device *adev, pm_message_t state)
|
||||
return status;
|
||||
}
|
||||
|
||||
amba_vcore_enable(adev);
|
||||
amba_pclk_enable(adev);
|
||||
load_ssp_default_config(pl022);
|
||||
amba_pclk_disable(adev);
|
||||
amba_vcore_disable(adev);
|
||||
dev_dbg(&adev->dev, "suspended\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+30
-13
@@ -571,6 +571,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
|
||||
unsigned long tx_reg, rx_reg;
|
||||
struct edmacc_param param;
|
||||
void *rx_buf;
|
||||
int b, c;
|
||||
|
||||
dma = &dspi->dma;
|
||||
|
||||
@@ -591,22 +592,38 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
|
||||
|
||||
if (t->tx_buf) {
|
||||
t->tx_dma = dma_map_single(&spi->dev, (void *)t->tx_buf,
|
||||
dspi->wcount, DMA_TO_DEVICE);
|
||||
t->len, DMA_TO_DEVICE);
|
||||
if (dma_mapping_error(&spi->dev, t->tx_dma)) {
|
||||
dev_dbg(sdev, "Unable to DMA map %d bytes"
|
||||
"TX buffer\n", dspi->wcount);
|
||||
"TX buffer\n", t->len);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If number of words is greater than 65535, then we need
|
||||
* to configure a 3 dimension transfer. Use the BCNTRLD
|
||||
* feature to allow for transfers that aren't even multiples
|
||||
* of 65535 (or any other possible b size) by first transferring
|
||||
* the remainder amount then grabbing the next N blocks of
|
||||
* 65535 words.
|
||||
*/
|
||||
|
||||
c = dspi->wcount / (SZ_64K - 1); /* N 65535 Blocks */
|
||||
b = dspi->wcount - c * (SZ_64K - 1); /* Remainder */
|
||||
if (b)
|
||||
c++;
|
||||
else
|
||||
b = SZ_64K - 1;
|
||||
|
||||
param.opt = TCINTEN | EDMA_TCC(dma->tx_channel);
|
||||
param.src = t->tx_buf ? t->tx_dma : tx_reg;
|
||||
param.a_b_cnt = dspi->wcount << 16 | data_type;
|
||||
param.a_b_cnt = b << 16 | data_type;
|
||||
param.dst = tx_reg;
|
||||
param.src_dst_bidx = t->tx_buf ? data_type : 0;
|
||||
param.link_bcntrld = 0xffff;
|
||||
param.src_dst_cidx = 0;
|
||||
param.ccnt = 1;
|
||||
param.link_bcntrld = 0xffffffff;
|
||||
param.src_dst_cidx = t->tx_buf ? data_type : 0;
|
||||
param.ccnt = c;
|
||||
edma_write_slot(dma->tx_channel, ¶m);
|
||||
edma_link(dma->tx_channel, dma->dummy_param_slot);
|
||||
|
||||
@@ -624,7 +641,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
|
||||
|
||||
if (t->rx_buf) {
|
||||
rx_buf = t->rx_buf;
|
||||
rx_buf_count = dspi->rcount;
|
||||
rx_buf_count = t->len;
|
||||
} else {
|
||||
rx_buf = dspi->rx_tmp_buf;
|
||||
rx_buf_count = sizeof(dspi->rx_tmp_buf);
|
||||
@@ -636,19 +653,19 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
|
||||
dev_dbg(sdev, "Couldn't DMA map a %d bytes RX buffer\n",
|
||||
rx_buf_count);
|
||||
if (t->tx_buf)
|
||||
dma_unmap_single(NULL, t->tx_dma, dspi->wcount,
|
||||
dma_unmap_single(NULL, t->tx_dma, t->len,
|
||||
DMA_TO_DEVICE);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
param.opt = TCINTEN | EDMA_TCC(dma->rx_channel);
|
||||
param.src = rx_reg;
|
||||
param.a_b_cnt = dspi->rcount << 16 | data_type;
|
||||
param.a_b_cnt = b << 16 | data_type;
|
||||
param.dst = t->rx_dma;
|
||||
param.src_dst_bidx = (t->rx_buf ? data_type : 0) << 16;
|
||||
param.link_bcntrld = 0xffff;
|
||||
param.src_dst_cidx = 0;
|
||||
param.ccnt = 1;
|
||||
param.link_bcntrld = 0xffffffff;
|
||||
param.src_dst_cidx = (t->rx_buf ? data_type : 0) << 16;
|
||||
param.ccnt = c;
|
||||
edma_write_slot(dma->rx_channel, ¶m);
|
||||
|
||||
if (pdata->cshold_bug)
|
||||
@@ -675,7 +692,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
|
||||
if (spicfg->io_type == SPI_IO_TYPE_DMA) {
|
||||
|
||||
if (t->tx_buf)
|
||||
dma_unmap_single(NULL, t->tx_dma, dspi->wcount,
|
||||
dma_unmap_single(NULL, t->tx_dma, t->len,
|
||||
DMA_TO_DEVICE);
|
||||
|
||||
dma_unmap_single(NULL, t->rx_dma, rx_buf_count,
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <linux/spi/dw_spi.h>
|
||||
#include <linux/spi/spi.h>
|
||||
|
||||
#include "dw_spi.h"
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#include <linux/debugfs.h>
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user