Commit 6e07b917 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'spi/topic/imx', 'spi/topic/init',...

Merge remote-tracking branches 'spi/topic/imx', 'spi/topic/init', 'spi/topic/mpc512x-psc', 'spi/topic/mpc52xx', 'spi/topic/mxs', 'spi/topic/nuc900', 'spi/topic/oc-tiny' and 'spi/topic/octeon' into spi-next
...@@ -212,7 +212,6 @@ config SPI_IMX ...@@ -212,7 +212,6 @@ config SPI_IMX
tristate "Freescale i.MX SPI controllers" tristate "Freescale i.MX SPI controllers"
depends on ARCH_MXC || COMPILE_TEST depends on ARCH_MXC || COMPILE_TEST
select SPI_BITBANG select SPI_BITBANG
default m if IMX_HAVE_PLATFORM_SPI_IMX
help help
This enables using the Freescale i.MX SPI controllers in master This enables using the Freescale i.MX SPI controllers in master
mode. mode.
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
* Licensed under the GPL-2 or later. * Licensed under the GPL-2 or later.
*/ */
#include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/init.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/of.h> #include <linux/of.h>
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/irq.h> #include <linux/irq.h>
...@@ -880,12 +879,12 @@ static int spi_imx_probe(struct platform_device *pdev) ...@@ -880,12 +879,12 @@ static int spi_imx_probe(struct platform_device *pdev)
spi_imx->irq = platform_get_irq(pdev, 0); spi_imx->irq = platform_get_irq(pdev, 0);
if (spi_imx->irq < 0) { if (spi_imx->irq < 0) {
ret = -EINVAL; ret = spi_imx->irq;
goto out_master_put; goto out_master_put;
} }
ret = devm_request_irq(&pdev->dev, spi_imx->irq, spi_imx_isr, 0, ret = devm_request_irq(&pdev->dev, spi_imx->irq, spi_imx_isr, 0,
DRIVER_NAME, spi_imx); dev_name(&pdev->dev), spi_imx);
if (ret) { if (ret) {
dev_err(&pdev->dev, "can't get irq%d: %d\n", spi_imx->irq, ret); dev_err(&pdev->dev, "can't get irq%d: %d\n", spi_imx->irq, ret);
goto out_master_put; goto out_master_put;
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_address.h> #include <linux/of_address.h>
...@@ -466,10 +465,8 @@ static void mpc512x_spi_cs_control(struct spi_device *spi, bool onoff) ...@@ -466,10 +465,8 @@ static void mpc512x_spi_cs_control(struct spi_device *spi, bool onoff)
gpio_set_value(spi->cs_gpio, onoff); gpio_set_value(spi->cs_gpio, onoff);
} }
/* bus_num is used only for the case dev->platform_data == NULL */
static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
u32 size, unsigned int irq, u32 size, unsigned int irq)
s16 bus_num)
{ {
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
struct mpc512x_psc_spi *mps; struct mpc512x_psc_spi *mps;
...@@ -488,7 +485,6 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, ...@@ -488,7 +485,6 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
if (pdata == NULL) { if (pdata == NULL) {
mps->cs_control = mpc512x_spi_cs_control; mps->cs_control = mpc512x_spi_cs_control;
master->bus_num = bus_num;
} else { } else {
mps->cs_control = pdata->cs_control; mps->cs_control = pdata->cs_control;
master->bus_num = pdata->bus_num; master->bus_num = pdata->bus_num;
...@@ -574,7 +570,6 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op) ...@@ -574,7 +570,6 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
{ {
const u32 *regaddr_p; const u32 *regaddr_p;
u64 regaddr64, size64; u64 regaddr64, size64;
s16 id = -1;
regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL);
if (!regaddr_p) { if (!regaddr_p) {
...@@ -583,16 +578,8 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op) ...@@ -583,16 +578,8 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
} }
regaddr64 = of_translate_address(op->dev.of_node, regaddr_p); regaddr64 = of_translate_address(op->dev.of_node, regaddr_p);
/* get PSC id (0..11, used by port_config) */
id = of_alias_get_id(op->dev.of_node, "spi");
if (id < 0) {
dev_err(&op->dev, "no alias id for %s\n",
op->dev.of_node->full_name);
return id;
}
return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64, return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
irq_of_parse_and_map(op->dev.of_node, 0), id); irq_of_parse_and_map(op->dev.of_node, 0));
} }
static int mpc512x_psc_spi_of_remove(struct platform_device *op) static int mpc512x_psc_spi_of_remove(struct platform_device *op)
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -357,17 +356,6 @@ static void mpc52xx_spi_wq(struct work_struct *work) ...@@ -357,17 +356,6 @@ static void mpc52xx_spi_wq(struct work_struct *work)
* spi_master ops * spi_master ops
*/ */
static int mpc52xx_spi_setup(struct spi_device *spi)
{
if (spi->bits_per_word % 8)
return -EINVAL;
if (spi->mode & ~(SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST))
return -EINVAL;
return 0;
}
static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m) static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m)
{ {
struct mpc52xx_spi *ms = spi_master_get_devdata(spi->master); struct mpc52xx_spi *ms = spi_master_get_devdata(spi->master);
...@@ -430,9 +418,9 @@ static int mpc52xx_spi_probe(struct platform_device *op) ...@@ -430,9 +418,9 @@ static int mpc52xx_spi_probe(struct platform_device *op)
goto err_alloc; goto err_alloc;
} }
master->setup = mpc52xx_spi_setup;
master->transfer = mpc52xx_spi_transfer; master->transfer = mpc52xx_spi_transfer;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
master->bits_per_word_mask = SPI_BPW_MASK(8);
master->dev.of_node = op->dev.of_node; master->dev.of_node = op->dev.of_node;
platform_set_drvdata(op, master); platform_set_drvdata(op, master);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -371,7 +370,7 @@ static int mxs_spi_transfer_one(struct spi_master *master, ...@@ -371,7 +370,7 @@ static int mxs_spi_transfer_one(struct spi_master *master,
{ {
struct mxs_spi *spi = spi_master_get_devdata(master); struct mxs_spi *spi = spi_master_get_devdata(master);
struct mxs_ssp *ssp = &spi->ssp; struct mxs_ssp *ssp = &spi->ssp;
struct spi_transfer *t, *tmp_t; struct spi_transfer *t;
unsigned int flag; unsigned int flag;
int status = 0; int status = 0;
...@@ -381,7 +380,7 @@ static int mxs_spi_transfer_one(struct spi_master *master, ...@@ -381,7 +380,7 @@ static int mxs_spi_transfer_one(struct spi_master *master,
writel(mxs_spi_cs_to_reg(m->spi->chip_select), writel(mxs_spi_cs_to_reg(m->spi->chip_select),
ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET); ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
list_for_each_entry_safe(t, tmp_t, &m->transfers, transfer_list) { list_for_each_entry(t, &m->transfers, transfer_list) {
status = mxs_spi_setup_transfer(m->spi, t); status = mxs_spi_setup_transfer(m->spi, t);
if (status) if (status)
...@@ -473,7 +472,7 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -473,7 +472,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq_err = platform_get_irq(pdev, 0); irq_err = platform_get_irq(pdev, 0);
if (irq_err < 0) if (irq_err < 0)
return -EINVAL; return irq_err;
base = devm_ioremap_resource(&pdev->dev, iores); base = devm_ioremap_resource(&pdev->dev, iores);
if (IS_ERR(base)) if (IS_ERR(base))
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -38,7 +37,9 @@ ...@@ -38,7 +37,9 @@
/* usi register bit */ /* usi register bit */
#define ENINT (0x01 << 17) #define ENINT (0x01 << 17)
#define ENFLG (0x01 << 16) #define ENFLG (0x01 << 16)
#define SLEEP (0x0f << 12)
#define TXNUM (0x03 << 8) #define TXNUM (0x03 << 8)
#define TXBITLEN (0x1f << 3)
#define TXNEG (0x01 << 2) #define TXNEG (0x01 << 2)
#define RXNEG (0x01 << 1) #define RXNEG (0x01 << 1)
#define LSB (0x01 << 10) #define LSB (0x01 << 10)
...@@ -58,11 +59,8 @@ struct nuc900_spi { ...@@ -58,11 +59,8 @@ struct nuc900_spi {
unsigned char *rx; unsigned char *rx;
struct clk *clk; struct clk *clk;
struct spi_master *master; struct spi_master *master;
struct spi_device *curdev;
struct device *dev;
struct nuc900_spi_info *pdata; struct nuc900_spi_info *pdata;
spinlock_t lock; spinlock_t lock;
struct resource *res;
}; };
static inline struct nuc900_spi *to_hw(struct spi_device *sdev) static inline struct nuc900_spi *to_hw(struct spi_device *sdev)
...@@ -119,19 +117,16 @@ static void nuc900_spi_chipsel(struct spi_device *spi, int value) ...@@ -119,19 +117,16 @@ static void nuc900_spi_chipsel(struct spi_device *spi, int value)
} }
} }
static void nuc900_spi_setup_txnum(struct nuc900_spi *hw, static void nuc900_spi_setup_txnum(struct nuc900_spi *hw, unsigned int txnum)
unsigned int txnum)
{ {
unsigned int val; unsigned int val;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&hw->lock, flags); spin_lock_irqsave(&hw->lock, flags);
val = __raw_readl(hw->regs + USI_CNT); val = __raw_readl(hw->regs + USI_CNT) & ~TXNUM;
if (!txnum) if (txnum)
val &= ~TXNUM;
else
val |= txnum << 0x08; val |= txnum << 0x08;
__raw_writel(val, hw->regs + USI_CNT); __raw_writel(val, hw->regs + USI_CNT);
...@@ -148,7 +143,7 @@ static void nuc900_spi_setup_txbitlen(struct nuc900_spi *hw, ...@@ -148,7 +143,7 @@ static void nuc900_spi_setup_txbitlen(struct nuc900_spi *hw,
spin_lock_irqsave(&hw->lock, flags); spin_lock_irqsave(&hw->lock, flags);
val = __raw_readl(hw->regs + USI_CNT); val = __raw_readl(hw->regs + USI_CNT) & ~TXBITLEN;
val |= (txbitlen << 0x03); val |= (txbitlen << 0x03);
...@@ -287,12 +282,11 @@ static void nuc900_set_sleep(struct nuc900_spi *hw, unsigned int sleep) ...@@ -287,12 +282,11 @@ static void nuc900_set_sleep(struct nuc900_spi *hw, unsigned int sleep)
spin_lock_irqsave(&hw->lock, flags); spin_lock_irqsave(&hw->lock, flags);
val = __raw_readl(hw->regs + USI_CNT); val = __raw_readl(hw->regs + USI_CNT) & ~SLEEP;
if (sleep) if (sleep)
val |= (sleep << 12); val |= (sleep << 12);
else
val &= ~(0x0f << 12);
__raw_writel(val, hw->regs + USI_CNT); __raw_writel(val, hw->regs + USI_CNT);
spin_unlock_irqrestore(&hw->lock, flags); spin_unlock_irqrestore(&hw->lock, flags);
...@@ -338,6 +332,7 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -338,6 +332,7 @@ static int nuc900_spi_probe(struct platform_device *pdev)
{ {
struct nuc900_spi *hw; struct nuc900_spi *hw;
struct spi_master *master; struct spi_master *master;
struct resource *res;
int err = 0; int err = 0;
master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi));
...@@ -349,7 +344,6 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -349,7 +344,6 @@ static int nuc900_spi_probe(struct platform_device *pdev)
hw = spi_master_get_devdata(master); hw = spi_master_get_devdata(master);
hw->master = master; hw->master = master;
hw->pdata = dev_get_platdata(&pdev->dev); hw->pdata = dev_get_platdata(&pdev->dev);
hw->dev = &pdev->dev;
if (hw->pdata == NULL) { if (hw->pdata == NULL) {
dev_err(&pdev->dev, "No platform data supplied\n"); dev_err(&pdev->dev, "No platform data supplied\n");
...@@ -369,8 +363,8 @@ static int nuc900_spi_probe(struct platform_device *pdev) ...@@ -369,8 +363,8 @@ static int nuc900_spi_probe(struct platform_device *pdev)
hw->bitbang.chipselect = nuc900_spi_chipsel; hw->bitbang.chipselect = nuc900_spi_chipsel;
hw->bitbang.txrx_bufs = nuc900_spi_txrx; hw->bitbang.txrx_bufs = nuc900_spi_txrx;
hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hw->regs = devm_ioremap_resource(&pdev->dev, hw->res); hw->regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->regs)) { if (IS_ERR(hw->regs)) {
err = PTR_ERR(hw->regs); err = PTR_ERR(hw->regs);
goto err_pdata; goto err_pdata;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -267,8 +266,6 @@ static int tiny_spi_probe(struct platform_device *pdev) ...@@ -267,8 +266,6 @@ static int tiny_spi_probe(struct platform_device *pdev)
/* setup the state for the bitbang driver */ /* setup the state for the bitbang driver */
hw->bitbang.master = master; hw->bitbang.master = master;
if (!hw->bitbang.master)
return err;
hw->bitbang.setup_transfer = tiny_spi_setup_transfer; hw->bitbang.setup_transfer = tiny_spi_setup_transfer;
hw->bitbang.chipselect = tiny_spi_chipselect; hw->bitbang.chipselect = tiny_spi_chipselect;
hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs; hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -33,13 +32,6 @@ struct octeon_spi { ...@@ -33,13 +32,6 @@ struct octeon_spi {
u64 cs_enax; u64 cs_enax;
}; };
struct octeon_spi_setup {
u32 max_speed_hz;
u8 chip_select;
u8 mode;
u8 bits_per_word;
};
static void octeon_spi_wait_ready(struct octeon_spi *p) static void octeon_spi_wait_ready(struct octeon_spi *p)
{ {
union cvmx_mpi_sts mpi_sts; union cvmx_mpi_sts mpi_sts;
...@@ -57,6 +49,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, ...@@ -57,6 +49,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
struct spi_transfer *xfer, struct spi_transfer *xfer,
bool last_xfer) bool last_xfer)
{ {
struct spi_device *spi = msg->spi;
union cvmx_mpi_cfg mpi_cfg; union cvmx_mpi_cfg mpi_cfg;
union cvmx_mpi_tx mpi_tx; union cvmx_mpi_tx mpi_tx;
unsigned int clkdiv; unsigned int clkdiv;
...@@ -68,18 +61,11 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, ...@@ -68,18 +61,11 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
int len; int len;
int i; int i;
struct octeon_spi_setup *msg_setup = spi_get_ctldata(msg->spi); mode = spi->mode;
speed_hz = msg_setup->max_speed_hz;
mode = msg_setup->mode;
cpha = mode & SPI_CPHA; cpha = mode & SPI_CPHA;
cpol = mode & SPI_CPOL; cpol = mode & SPI_CPOL;
if (xfer->speed_hz) speed_hz = xfer->speed_hz ? : spi->max_speed_hz;
speed_hz = xfer->speed_hz;
if (speed_hz > OCTEON_SPI_MAX_CLOCK_HZ)
speed_hz = OCTEON_SPI_MAX_CLOCK_HZ;
clkdiv = octeon_get_io_clock_rate() / (2 * speed_hz); clkdiv = octeon_get_io_clock_rate() / (2 * speed_hz);
...@@ -93,8 +79,8 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, ...@@ -93,8 +79,8 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
mpi_cfg.s.cslate = cpha ? 1 : 0; mpi_cfg.s.cslate = cpha ? 1 : 0;
mpi_cfg.s.enable = 1; mpi_cfg.s.enable = 1;
if (msg_setup->chip_select < 4) if (spi->chip_select < 4)
p->cs_enax |= 1ull << (12 + msg_setup->chip_select); p->cs_enax |= 1ull << (12 + spi->chip_select);
mpi_cfg.u64 |= p->cs_enax; mpi_cfg.u64 |= p->cs_enax;
if (mpi_cfg.u64 != p->last_cfg) { if (mpi_cfg.u64 != p->last_cfg) {
...@@ -114,7 +100,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, ...@@ -114,7 +100,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
cvmx_write_csr(p->register_base + OCTEON_SPI_DAT0 + (8 * i), d); cvmx_write_csr(p->register_base + OCTEON_SPI_DAT0 + (8 * i), d);
} }
mpi_tx.u64 = 0; mpi_tx.u64 = 0;
mpi_tx.s.csid = msg_setup->chip_select; mpi_tx.s.csid = spi->chip_select;
mpi_tx.s.leavecs = 1; mpi_tx.s.leavecs = 1;
mpi_tx.s.txnum = tx_buf ? OCTEON_SPI_MAX_BYTES : 0; mpi_tx.s.txnum = tx_buf ? OCTEON_SPI_MAX_BYTES : 0;
mpi_tx.s.totnum = OCTEON_SPI_MAX_BYTES; mpi_tx.s.totnum = OCTEON_SPI_MAX_BYTES;
...@@ -139,7 +125,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p, ...@@ -139,7 +125,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
} }
mpi_tx.u64 = 0; mpi_tx.u64 = 0;
mpi_tx.s.csid = msg_setup->chip_select; mpi_tx.s.csid = spi->chip_select;
if (last_xfer) if (last_xfer)
mpi_tx.s.leavecs = xfer->cs_change; mpi_tx.s.leavecs = xfer->cs_change;
else else
...@@ -169,17 +155,9 @@ static int octeon_spi_transfer_one_message(struct spi_master *master, ...@@ -169,17 +155,9 @@ static int octeon_spi_transfer_one_message(struct spi_master *master,
int status = 0; int status = 0;
struct spi_transfer *xfer; struct spi_transfer *xfer;
/*
* We better have set the configuration via a call to .setup
* before we get here.
*/
if (spi_get_ctldata(msg->spi) == NULL) {
status = -EINVAL;
goto err;
}
list_for_each_entry(xfer, &msg->transfers, transfer_list) { list_for_each_entry(xfer, &msg->transfers, transfer_list) {
bool last_xfer = &xfer->transfer_list == msg->transfers.prev; bool last_xfer = list_is_last(&xfer->transfer_list,
&msg->transfers);
int r = octeon_spi_do_transfer(p, msg, xfer, last_xfer); int r = octeon_spi_do_transfer(p, msg, xfer, last_xfer);
if (r < 0) { if (r < 0) {
status = r; status = r;
...@@ -194,41 +172,6 @@ static int octeon_spi_transfer_one_message(struct spi_master *master, ...@@ -194,41 +172,6 @@ static int octeon_spi_transfer_one_message(struct spi_master *master,
return status; return status;
} }
static struct octeon_spi_setup *octeon_spi_new_setup(struct spi_device *spi)
{
struct octeon_spi_setup *setup = kzalloc(sizeof(*setup), GFP_KERNEL);
if (!setup)
return NULL;
setup->max_speed_hz = spi->max_speed_hz;
setup->chip_select = spi->chip_select;
setup->mode = spi->mode;
setup->bits_per_word = spi->bits_per_word;
return setup;
}
static int octeon_spi_setup(struct spi_device *spi)
{
struct octeon_spi_setup *new_setup;
struct octeon_spi_setup *old_setup = spi_get_ctldata(spi);
new_setup = octeon_spi_new_setup(spi);
if (!new_setup)
return -ENOMEM;
spi_set_ctldata(spi, new_setup);
kfree(old_setup);
return 0;
}
static void octeon_spi_cleanup(struct spi_device *spi)
{
struct octeon_spi_setup *old_setup = spi_get_ctldata(spi);
spi_set_ctldata(spi, NULL);
kfree(old_setup);
}
static int octeon_spi_probe(struct platform_device *pdev) static int octeon_spi_probe(struct platform_device *pdev)
{ {
struct resource *res_mem; struct resource *res_mem;
...@@ -264,10 +207,9 @@ static int octeon_spi_probe(struct platform_device *pdev) ...@@ -264,10 +207,9 @@ static int octeon_spi_probe(struct platform_device *pdev)
SPI_LSB_FIRST | SPI_LSB_FIRST |
SPI_3WIRE; SPI_3WIRE;
master->setup = octeon_spi_setup;
master->cleanup = octeon_spi_cleanup;
master->transfer_one_message = octeon_spi_transfer_one_message; master->transfer_one_message = octeon_spi_transfer_one_message;
master->bits_per_word_mask = SPI_BPW_MASK(8); master->bits_per_word_mask = SPI_BPW_MASK(8);
master->max_speed_hz = OCTEON_SPI_MAX_CLOCK_HZ;
master->dev.of_node = pdev->dev.of_node; master->dev.of_node = pdev->dev.of_node;
err = devm_spi_register_master(&pdev->dev, master); err = devm_spi_register_master(&pdev->dev, master);
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/device.h> #include <linux/device.h>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/errno.h> #include <linux/errno.h>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/init.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
* *
*/ */
#include <linux/init.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmapool.h> #include <linux/dmapool.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmapool.h> #include <linux/dmapool.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
......
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