Commit f5b19425 authored by Mark Brown's avatar Mark Brown

spi: switch to use modern name (part2)

Merge series from Yang Yingliang <yangyingliang@huawei.com>:

I'm trying to rename the legacy name to modern name used in SPI drivers,
this is part2 patchset.

After introducing devm_spi_alloc_host/spi_alloc_host(), the legacy
named function devm_spi_alloc_master/spi_alloc_master() can be replaced.
And also change other legacy name master/slave to modern name host/target
or controller. All compile test passed.

Yang Yingliang (20):
  spi: amlogic-spifc-a1: switch to use devm_spi_alloc_host()
  spi: au1550: switch to use modern name
  spi: ep93xx: switch to use modern name
  spi: falcon: switch to use modern name
  spi: fsi: switch to use spi_alloc_host()
  spi: fsl-dspi: switch to use modern name
  spi: fsl-espi: switch to use modern name
  spi: fsl-lpspi: switch to use modern name
  spi: fsl-qspi: switch to use modern name
  spi: fsl-spi: switch to use modern name
  spi: gpio: switch to use modern name
  spi: gxp: switch to use modern name
  spi: bcmbca-hsspi: switch to use modern name
  spi: hisi-sfc-v3xx: switch to use modern name
  spi: img-spfi: switch to use modern name
  spi: imx: switch to use modern name
  spi: ingenic: switch to use devm_spi_alloc_host()
  spi: intel: switch to use modern name
  spi: jcore: switch to use modern name
  spi: lantiq: switch to use modern name

 drivers/spi/spi-amlogic-spifc-a1.c |   2 +-
 drivers/spi/spi-au1550.c           |  74 ++++++------
 drivers/spi/spi-bcmbca-hsspi.c     |  66 +++++------
 drivers/spi/spi-ep93xx.c           | 174 ++++++++++++++---------------
 drivers/spi/spi-falcon.c           |  34 +++---
 drivers/spi/spi-fsi.c              |   2 +-
 drivers/spi/spi-fsl-dspi.c         |  24 ++--
 drivers/spi/spi-fsl-espi.c         |  76 ++++++-------
 drivers/spi/spi-fsl-lpspi.c        |  54 ++++-----
 drivers/spi/spi-fsl-qspi.c         |  10 +-
 drivers/spi/spi-fsl-spi.c          |  76 ++++++-------
 drivers/spi/spi-gpio.c             |  72 ++++++------
 drivers/spi/spi-gxp.c              |   6 +-
 drivers/spi/spi-hisi-sfc-v3xx.c    |  18 +--
 drivers/spi/spi-img-spfi.c         | 118 +++++++++----------
 drivers/spi/spi-imx.c              | 114 +++++++++----------
 drivers/spi/spi-ingenic.c          |   2 +-
 drivers/spi/spi-intel.c            |  42 +++----
 drivers/spi/spi-jcore.c            |  44 ++++----
 drivers/spi/spi-lantiq-ssc.c       |  96 ++++++++--------
 20 files changed, 552 insertions(+), 552 deletions(-)

--
2.25.1
parents 675b8e35 ea11a8bb
...@@ -326,7 +326,7 @@ static int amlogic_spifc_a1_probe(struct platform_device *pdev) ...@@ -326,7 +326,7 @@ static int amlogic_spifc_a1_probe(struct platform_device *pdev)
struct amlogic_spifc_a1 *spifc; struct amlogic_spifc_a1 *spifc;
int ret; int ret;
ctrl = devm_spi_alloc_master(&pdev->dev, sizeof(*spifc)); ctrl = devm_spi_alloc_host(&pdev->dev, sizeof(*spifc));
if (!ctrl) if (!ctrl)
return -ENOMEM; return -ENOMEM;
......
...@@ -54,7 +54,7 @@ struct au1550_spi { ...@@ -54,7 +54,7 @@ struct au1550_spi {
int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t); int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t);
irqreturn_t (*irq_callback)(struct au1550_spi *hw); irqreturn_t (*irq_callback)(struct au1550_spi *hw);
struct completion master_done; struct completion host_done;
unsigned int usedma; unsigned int usedma;
u32 dma_tx_id; u32 dma_tx_id;
...@@ -66,7 +66,7 @@ struct au1550_spi { ...@@ -66,7 +66,7 @@ struct au1550_spi {
unsigned int dma_rx_tmpbuf_size; unsigned int dma_rx_tmpbuf_size;
u32 dma_rx_tmpbuf_addr; u32 dma_rx_tmpbuf_addr;
struct spi_master *master; struct spi_controller *host;
struct device *dev; struct device *dev;
struct au1550_spi_info *pdata; struct au1550_spi_info *pdata;
struct resource *ioarea; struct resource *ioarea;
...@@ -159,7 +159,7 @@ static void au1550_spi_reset_fifos(struct au1550_spi *hw) ...@@ -159,7 +159,7 @@ static void au1550_spi_reset_fifos(struct au1550_spi *hw)
*/ */
static void au1550_spi_chipsel(struct spi_device *spi, int value) static void au1550_spi_chipsel(struct spi_device *spi, int value)
{ {
struct au1550_spi *hw = spi_master_get_devdata(spi->master); struct au1550_spi *hw = spi_controller_get_devdata(spi->controller);
unsigned int cspol = spi->mode & SPI_CS_HIGH ? 1 : 0; unsigned int cspol = spi->mode & SPI_CS_HIGH ? 1 : 0;
u32 cfg, stat; u32 cfg, stat;
...@@ -219,7 +219,7 @@ static void au1550_spi_chipsel(struct spi_device *spi, int value) ...@@ -219,7 +219,7 @@ static void au1550_spi_chipsel(struct spi_device *spi, int value)
static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t) static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
{ {
struct au1550_spi *hw = spi_master_get_devdata(spi->master); struct au1550_spi *hw = spi_controller_get_devdata(spi->controller);
unsigned int bpw, hz; unsigned int bpw, hz;
u32 cfg, stat; u32 cfg, stat;
...@@ -272,7 +272,7 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t) ...@@ -272,7 +272,7 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
* no reliable way how to recognize that spi transfer is done * no reliable way how to recognize that spi transfer is done
* dma complete callbacks are called before real spi transfer is finished * dma complete callbacks are called before real spi transfer is finished
* and if only tx dma channel is set up (and rx fifo overflow event masked) * and if only tx dma channel is set up (and rx fifo overflow event masked)
* spi master done event irq is not generated unless rx fifo is empty (emptied) * spi host done event irq is not generated unless rx fifo is empty (emptied)
* so we need rx tmp buffer to use for rx dma if user does not provide one * so we need rx tmp buffer to use for rx dma if user does not provide one
*/ */
static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned int size) static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned int size)
...@@ -303,7 +303,7 @@ static void au1550_spi_dma_rxtmp_free(struct au1550_spi *hw) ...@@ -303,7 +303,7 @@ static void au1550_spi_dma_rxtmp_free(struct au1550_spi *hw)
static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
{ {
struct au1550_spi *hw = spi_master_get_devdata(spi->master); struct au1550_spi *hw = spi_controller_get_devdata(spi->controller);
dma_addr_t dma_tx_addr; dma_addr_t dma_tx_addr;
dma_addr_t dma_rx_addr; dma_addr_t dma_rx_addr;
u32 res; u32 res;
...@@ -387,7 +387,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t) ...@@ -387,7 +387,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
hw->regs->psc_spipcr = PSC_SPIPCR_MS; hw->regs->psc_spipcr = PSC_SPIPCR_MS;
wmb(); /* drain writebuffer */ wmb(); /* drain writebuffer */
wait_for_completion(&hw->master_done); wait_for_completion(&hw->host_done);
au1xxx_dbdma_stop(hw->dma_tx_ch); au1xxx_dbdma_stop(hw->dma_tx_ch);
au1xxx_dbdma_stop(hw->dma_rx_ch); au1xxx_dbdma_stop(hw->dma_rx_ch);
...@@ -449,7 +449,7 @@ static irqreturn_t au1550_spi_dma_irq_callback(struct au1550_spi *hw) ...@@ -449,7 +449,7 @@ static irqreturn_t au1550_spi_dma_irq_callback(struct au1550_spi *hw)
"dma transfer: unexpected SPI error (event=0x%x stat=0x%x)!\n", "dma transfer: unexpected SPI error (event=0x%x stat=0x%x)!\n",
evnt, stat); evnt, stat);
complete(&hw->master_done); complete(&hw->host_done);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -458,7 +458,7 @@ static irqreturn_t au1550_spi_dma_irq_callback(struct au1550_spi *hw) ...@@ -458,7 +458,7 @@ static irqreturn_t au1550_spi_dma_irq_callback(struct au1550_spi *hw)
au1550_spi_mask_ack_all(hw); au1550_spi_mask_ack_all(hw);
hw->rx_count = hw->len; hw->rx_count = hw->len;
hw->tx_count = hw->len; hw->tx_count = hw->len;
complete(&hw->master_done); complete(&hw->host_done);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -502,7 +502,7 @@ AU1550_SPI_TX_WORD(32, 0xffffff) ...@@ -502,7 +502,7 @@ AU1550_SPI_TX_WORD(32, 0xffffff)
static int au1550_spi_pio_txrxb(struct spi_device *spi, struct spi_transfer *t) static int au1550_spi_pio_txrxb(struct spi_device *spi, struct spi_transfer *t)
{ {
u32 stat, mask; u32 stat, mask;
struct au1550_spi *hw = spi_master_get_devdata(spi->master); struct au1550_spi *hw = spi_controller_get_devdata(spi->controller);
hw->tx = t->tx_buf; hw->tx = t->tx_buf;
hw->rx = t->rx_buf; hw->rx = t->rx_buf;
...@@ -537,7 +537,7 @@ static int au1550_spi_pio_txrxb(struct spi_device *spi, struct spi_transfer *t) ...@@ -537,7 +537,7 @@ static int au1550_spi_pio_txrxb(struct spi_device *spi, struct spi_transfer *t)
hw->regs->psc_spipcr = PSC_SPIPCR_MS; hw->regs->psc_spipcr = PSC_SPIPCR_MS;
wmb(); /* drain writebuffer */ wmb(); /* drain writebuffer */
wait_for_completion(&hw->master_done); wait_for_completion(&hw->host_done);
return min(hw->rx_count, hw->tx_count); return min(hw->rx_count, hw->tx_count);
} }
...@@ -568,7 +568,7 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw) ...@@ -568,7 +568,7 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw)
dev_err(hw->dev, dev_err(hw->dev,
"pio transfer: unexpected SPI error (event=0x%x stat=0x%x)!\n", "pio transfer: unexpected SPI error (event=0x%x stat=0x%x)!\n",
evnt, stat); evnt, stat);
complete(&hw->master_done); complete(&hw->host_done);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -605,11 +605,11 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw) ...@@ -605,11 +605,11 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw)
/* /*
* Restart the SPI transmission in case of a transmit underflow. * Restart the SPI transmission in case of a transmit underflow.
* This seems to work despite the notes in the Au1550 data book * This seems to work despite the notes in the Au1550 data book
* of Figure 8-4 with flowchart for SPI master operation: * of Figure 8-4 with flowchart for SPI host operation:
* *
* """Note 1: An XFR Error Interrupt occurs, unless masked, * """Note 1: An XFR Error Interrupt occurs, unless masked,
* for any of the following events: Tx FIFO Underflow, * for any of the following events: Tx FIFO Underflow,
* Rx FIFO Overflow, or Multiple-master Error * Rx FIFO Overflow, or Multiple-host Error
* Note 2: In case of a Tx Underflow Error, all zeroes are * Note 2: In case of a Tx Underflow Error, all zeroes are
* transmitted.""" * transmitted."""
* *
...@@ -627,14 +627,14 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw) ...@@ -627,14 +627,14 @@ static irqreturn_t au1550_spi_pio_irq_callback(struct au1550_spi *hw)
if (hw->rx_count >= hw->len) { if (hw->rx_count >= hw->len) {
/* transfer completed successfully */ /* transfer completed successfully */
au1550_spi_mask_ack_all(hw); au1550_spi_mask_ack_all(hw);
complete(&hw->master_done); complete(&hw->host_done);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int au1550_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) static int au1550_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
{ {
struct au1550_spi *hw = spi_master_get_devdata(spi->master); struct au1550_spi *hw = spi_controller_get_devdata(spi->controller);
return hw->txrx_bufs(spi, t); return hw->txrx_bufs(spi, t);
} }
...@@ -723,24 +723,24 @@ static void au1550_spi_setup_psc_as_spi(struct au1550_spi *hw) ...@@ -723,24 +723,24 @@ static void au1550_spi_setup_psc_as_spi(struct au1550_spi *hw)
static int au1550_spi_probe(struct platform_device *pdev) static int au1550_spi_probe(struct platform_device *pdev)
{ {
struct au1550_spi *hw; struct au1550_spi *hw;
struct spi_master *master; struct spi_controller *host;
struct resource *r; struct resource *r;
int err = 0; int err = 0;
master = spi_alloc_master(&pdev->dev, sizeof(struct au1550_spi)); host = spi_alloc_host(&pdev->dev, sizeof(struct au1550_spi));
if (master == NULL) { if (host == NULL) {
dev_err(&pdev->dev, "No memory for spi_master\n"); dev_err(&pdev->dev, "No memory for spi_controller\n");
err = -ENOMEM; err = -ENOMEM;
goto err_nomem; goto err_nomem;
} }
/* the spi->mode bits understood by this driver: */ /* the spi->mode bits understood by this driver: */
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 24); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 24);
hw = spi_master_get_devdata(master); hw = spi_controller_get_devdata(host);
hw->master = master; hw->host = host;
hw->pdata = dev_get_platdata(&pdev->dev); hw->pdata = dev_get_platdata(&pdev->dev);
hw->dev = &pdev->dev; hw->dev = &pdev->dev;
...@@ -798,9 +798,9 @@ static int au1550_spi_probe(struct platform_device *pdev) ...@@ -798,9 +798,9 @@ static int au1550_spi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, hw); platform_set_drvdata(pdev, hw);
init_completion(&hw->master_done); init_completion(&hw->host_done);
hw->bitbang.master = hw->master; hw->bitbang.master = hw->host;
hw->bitbang.setup_transfer = au1550_spi_setupxfer; hw->bitbang.setup_transfer = au1550_spi_setupxfer;
hw->bitbang.chipselect = au1550_spi_chipsel; hw->bitbang.chipselect = au1550_spi_chipsel;
hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs; hw->bitbang.txrx_bufs = au1550_spi_txrx_bufs;
...@@ -858,8 +858,8 @@ static int au1550_spi_probe(struct platform_device *pdev) ...@@ -858,8 +858,8 @@ static int au1550_spi_probe(struct platform_device *pdev)
goto err_no_irq; goto err_no_irq;
} }
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->num_chipselect = hw->pdata->num_chipselect; host->num_chipselect = hw->pdata->num_chipselect;
/* /*
* precompute valid range for spi freq - from au1550 datasheet: * precompute valid range for spi freq - from au1550 datasheet:
...@@ -874,8 +874,8 @@ static int au1550_spi_probe(struct platform_device *pdev) ...@@ -874,8 +874,8 @@ static int au1550_spi_probe(struct platform_device *pdev)
int min_div = (2 << 0) * (2 * (4 + 1)); int min_div = (2 << 0) * (2 * (4 + 1));
int max_div = (2 << 3) * (2 * (63 + 1)); int max_div = (2 << 3) * (2 * (63 + 1));
master->max_speed_hz = hw->pdata->mainclk_hz / min_div; host->max_speed_hz = hw->pdata->mainclk_hz / min_div;
master->min_speed_hz = host->min_speed_hz =
hw->pdata->mainclk_hz / (max_div + 1) + 1; hw->pdata->mainclk_hz / (max_div + 1) + 1;
} }
...@@ -883,13 +883,13 @@ static int au1550_spi_probe(struct platform_device *pdev) ...@@ -883,13 +883,13 @@ static int au1550_spi_probe(struct platform_device *pdev)
err = spi_bitbang_start(&hw->bitbang); err = spi_bitbang_start(&hw->bitbang);
if (err) { if (err) {
dev_err(&pdev->dev, "Failed to register SPI master\n"); dev_err(&pdev->dev, "Failed to register SPI host\n");
goto err_register; goto err_register;
} }
dev_info(&pdev->dev, dev_info(&pdev->dev,
"spi master registered: bus_num=%d num_chipselect=%d\n", "spi host registered: bus_num=%d num_chipselect=%d\n",
master->bus_num, master->num_chipselect); host->bus_num, host->num_chipselect);
return 0; return 0;
...@@ -917,7 +917,7 @@ static int au1550_spi_probe(struct platform_device *pdev) ...@@ -917,7 +917,7 @@ static int au1550_spi_probe(struct platform_device *pdev)
err_no_iores: err_no_iores:
err_no_pdata: err_no_pdata:
spi_master_put(hw->master); spi_controller_put(hw->host);
err_nomem: err_nomem:
return err; return err;
...@@ -927,8 +927,8 @@ static void au1550_spi_remove(struct platform_device *pdev) ...@@ -927,8 +927,8 @@ static void au1550_spi_remove(struct platform_device *pdev)
{ {
struct au1550_spi *hw = platform_get_drvdata(pdev); struct au1550_spi *hw = platform_get_drvdata(pdev);
dev_info(&pdev->dev, "spi master remove: bus_num=%d\n", dev_info(&pdev->dev, "spi host remove: bus_num=%d\n",
hw->master->bus_num); hw->host->bus_num);
spi_bitbang_stop(&hw->bitbang); spi_bitbang_stop(&hw->bitbang);
free_irq(hw->irq, hw); free_irq(hw->irq, hw);
...@@ -941,7 +941,7 @@ static void au1550_spi_remove(struct platform_device *pdev) ...@@ -941,7 +941,7 @@ static void au1550_spi_remove(struct platform_device *pdev)
au1xxx_dbdma_chan_free(hw->dma_tx_ch); au1xxx_dbdma_chan_free(hw->dma_tx_ch);
} }
spi_master_put(hw->master); spi_controller_put(hw->host);
} }
/* work with hotplug and coldplug */ /* work with hotplug and coldplug */
......
...@@ -127,7 +127,7 @@ static ssize_t wait_mode_show(struct device *dev, struct device_attribute *attr, ...@@ -127,7 +127,7 @@ static ssize_t wait_mode_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct spi_controller *ctrl = dev_get_drvdata(dev); struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcmbca_hsspi *bs = spi_master_get_devdata(ctrl); struct bcmbca_hsspi *bs = spi_controller_get_devdata(ctrl);
return sprintf(buf, "%d\n", bs->wait_mode); return sprintf(buf, "%d\n", bs->wait_mode);
} }
...@@ -136,7 +136,7 @@ static ssize_t wait_mode_store(struct device *dev, struct device_attribute *attr ...@@ -136,7 +136,7 @@ static ssize_t wait_mode_store(struct device *dev, struct device_attribute *attr
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct spi_controller *ctrl = dev_get_drvdata(dev); struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcmbca_hsspi *bs = spi_master_get_devdata(ctrl); struct bcmbca_hsspi *bs = spi_controller_get_devdata(ctrl);
u32 val; u32 val;
if (kstrtou32(buf, 10, &val)) if (kstrtou32(buf, 10, &val))
...@@ -250,7 +250,7 @@ static int bcmbca_hsspi_wait_cmd(struct bcmbca_hsspi *bs, unsigned int cs) ...@@ -250,7 +250,7 @@ static int bcmbca_hsspi_wait_cmd(struct bcmbca_hsspi *bs, unsigned int cs)
static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t, static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t,
struct spi_message *msg) struct spi_message *msg)
{ {
struct bcmbca_hsspi *bs = spi_master_get_devdata(spi->master); struct bcmbca_hsspi *bs = spi_controller_get_devdata(spi->controller);
unsigned int chip_select = spi_get_chipselect(spi, 0); unsigned int chip_select = spi_get_chipselect(spi, 0);
u16 opcode = 0, val; u16 opcode = 0, val;
int pending = t->len; int pending = t->len;
...@@ -328,7 +328,7 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t, ...@@ -328,7 +328,7 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t,
static int bcmbca_hsspi_setup(struct spi_device *spi) static int bcmbca_hsspi_setup(struct spi_device *spi)
{ {
struct bcmbca_hsspi *bs = spi_master_get_devdata(spi->master); struct bcmbca_hsspi *bs = spi_controller_get_devdata(spi->controller);
u32 reg; u32 reg;
reg = __raw_readl(bs->regs + reg = __raw_readl(bs->regs +
...@@ -366,10 +366,10 @@ static int bcmbca_hsspi_setup(struct spi_device *spi) ...@@ -366,10 +366,10 @@ static int bcmbca_hsspi_setup(struct spi_device *spi)
return 0; return 0;
} }
static int bcmbca_hsspi_transfer_one(struct spi_master *master, static int bcmbca_hsspi_transfer_one(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct bcmbca_hsspi *bs = spi_master_get_devdata(master); struct bcmbca_hsspi *bs = spi_controller_get_devdata(host);
struct spi_transfer *t; struct spi_transfer *t;
struct spi_device *spi = msg->spi; struct spi_device *spi = msg->spi;
int status = -EINVAL; int status = -EINVAL;
...@@ -409,7 +409,7 @@ static int bcmbca_hsspi_transfer_one(struct spi_master *master, ...@@ -409,7 +409,7 @@ static int bcmbca_hsspi_transfer_one(struct spi_master *master,
bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false); bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false);
msg->status = status; msg->status = status;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return 0; return 0;
} }
...@@ -431,7 +431,7 @@ static irqreturn_t bcmbca_hsspi_interrupt(int irq, void *dev_id) ...@@ -431,7 +431,7 @@ static irqreturn_t bcmbca_hsspi_interrupt(int irq, void *dev_id)
static int bcmbca_hsspi_probe(struct platform_device *pdev) static int bcmbca_hsspi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct bcmbca_hsspi *bs; struct bcmbca_hsspi *bs;
struct resource *res_mem; struct resource *res_mem;
void __iomem *spim_ctrl; void __iomem *spim_ctrl;
...@@ -487,13 +487,13 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ...@@ -487,13 +487,13 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
} }
} }
master = spi_alloc_master(&pdev->dev, sizeof(*bs)); host = spi_alloc_host(&pdev->dev, sizeof(*bs));
if (!master) { if (!host) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_disable_pll_clk; goto out_disable_pll_clk;
} }
bs = spi_master_get_devdata(master); bs = spi_controller_get_devdata(host);
bs->pdev = pdev; bs->pdev = pdev;
bs->clk = clk; bs->clk = clk;
bs->pll_clk = pll_clk; bs->pll_clk = pll_clk;
...@@ -507,9 +507,9 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ...@@ -507,9 +507,9 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
mutex_init(&bs->msg_mutex); mutex_init(&bs->msg_mutex);
init_completion(&bs->done); init_completion(&bs->done);
master->dev.of_node = dev->of_node; host->dev.of_node = dev->of_node;
if (!dev->of_node) if (!dev->of_node)
master->bus_num = HSSPI_BUS_NUM; host->bus_num = HSSPI_BUS_NUM;
of_property_read_u32(dev->of_node, "num-cs", &num_cs); of_property_read_u32(dev->of_node, "num-cs", &num_cs);
if (num_cs > 8) { if (num_cs > 8) {
...@@ -517,15 +517,15 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ...@@ -517,15 +517,15 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
num_cs); num_cs);
num_cs = HSSPI_SPI_MAX_CS; num_cs = HSSPI_SPI_MAX_CS;
} }
master->num_chipselect = num_cs; host->num_chipselect = num_cs;
master->setup = bcmbca_hsspi_setup; host->setup = bcmbca_hsspi_setup;
master->transfer_one_message = bcmbca_hsspi_transfer_one; host->transfer_one_message = bcmbca_hsspi_transfer_one;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH |
SPI_RX_DUAL | SPI_TX_DUAL; SPI_RX_DUAL | SPI_TX_DUAL;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
/* Initialize the hardware */ /* Initialize the hardware */
__raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG);
...@@ -543,7 +543,7 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ...@@ -543,7 +543,7 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
ret = devm_request_irq(dev, irq, bcmbca_hsspi_interrupt, IRQF_SHARED, ret = devm_request_irq(dev, irq, bcmbca_hsspi_interrupt, IRQF_SHARED,
pdev->name, bs); pdev->name, bs);
if (ret) if (ret)
goto out_put_master; goto out_put_host;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
...@@ -555,7 +555,7 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ...@@ -555,7 +555,7 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
} }
/* register and we are done */ /* register and we are done */
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret) if (ret)
goto out_sysgroup_disable; goto out_sysgroup_disable;
...@@ -567,8 +567,8 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ...@@ -567,8 +567,8 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
sysfs_remove_group(&pdev->dev.kobj, &bcmbca_hsspi_group); sysfs_remove_group(&pdev->dev.kobj, &bcmbca_hsspi_group);
out_pm_disable: out_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
out_put_master: out_put_host:
spi_master_put(master); spi_controller_put(host);
out_disable_pll_clk: out_disable_pll_clk:
clk_disable_unprepare(pll_clk); clk_disable_unprepare(pll_clk);
out_disable_clk: out_disable_clk:
...@@ -578,8 +578,8 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ...@@ -578,8 +578,8 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)
static void bcmbca_hsspi_remove(struct platform_device *pdev) static void bcmbca_hsspi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct bcmbca_hsspi *bs = spi_master_get_devdata(master); struct bcmbca_hsspi *bs = spi_controller_get_devdata(host);
/* reset the hardware and block queue progress */ /* reset the hardware and block queue progress */
__raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG);
...@@ -591,10 +591,10 @@ static void bcmbca_hsspi_remove(struct platform_device *pdev) ...@@ -591,10 +591,10 @@ static void bcmbca_hsspi_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int bcmbca_hsspi_suspend(struct device *dev) static int bcmbca_hsspi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct bcmbca_hsspi *bs = spi_master_get_devdata(master); struct bcmbca_hsspi *bs = spi_controller_get_devdata(host);
spi_master_suspend(master); spi_controller_suspend(host);
clk_disable_unprepare(bs->pll_clk); clk_disable_unprepare(bs->pll_clk);
clk_disable_unprepare(bs->clk); clk_disable_unprepare(bs->clk);
...@@ -603,8 +603,8 @@ static int bcmbca_hsspi_suspend(struct device *dev) ...@@ -603,8 +603,8 @@ static int bcmbca_hsspi_suspend(struct device *dev)
static int bcmbca_hsspi_resume(struct device *dev) static int bcmbca_hsspi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct bcmbca_hsspi *bs = spi_master_get_devdata(master); struct bcmbca_hsspi *bs = spi_controller_get_devdata(host);
int ret; int ret;
ret = clk_prepare_enable(bs->clk); ret = clk_prepare_enable(bs->clk);
...@@ -619,7 +619,7 @@ static int bcmbca_hsspi_resume(struct device *dev) ...@@ -619,7 +619,7 @@ static int bcmbca_hsspi_resume(struct device *dev)
} }
} }
spi_master_resume(master); spi_controller_resume(host);
return 0; return 0;
} }
......
...@@ -104,15 +104,15 @@ struct ep93xx_spi { ...@@ -104,15 +104,15 @@ struct ep93xx_spi {
/** /**
* ep93xx_spi_calc_divisors() - calculates SPI clock divisors * ep93xx_spi_calc_divisors() - calculates SPI clock divisors
* @master: SPI master * @host: SPI host
* @rate: desired SPI output clock rate * @rate: desired SPI output clock rate
* @div_cpsr: pointer to return the cpsr (pre-scaler) divider * @div_cpsr: pointer to return the cpsr (pre-scaler) divider
* @div_scr: pointer to return the scr divider * @div_scr: pointer to return the scr divider
*/ */
static int ep93xx_spi_calc_divisors(struct spi_master *master, static int ep93xx_spi_calc_divisors(struct spi_controller *host,
u32 rate, u8 *div_cpsr, u8 *div_scr) u32 rate, u8 *div_cpsr, u8 *div_scr)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
unsigned long spi_clk_rate = clk_get_rate(espi->clk); unsigned long spi_clk_rate = clk_get_rate(espi->clk);
int cpsr, scr; int cpsr, scr;
...@@ -120,7 +120,7 @@ static int ep93xx_spi_calc_divisors(struct spi_master *master, ...@@ -120,7 +120,7 @@ static int ep93xx_spi_calc_divisors(struct spi_master *master,
* Make sure that max value is between values supported by the * Make sure that max value is between values supported by the
* controller. * controller.
*/ */
rate = clamp(rate, master->min_speed_hz, master->max_speed_hz); rate = clamp(rate, host->min_speed_hz, host->max_speed_hz);
/* /*
* Calculate divisors so that we can get speed according the * Calculate divisors so that we can get speed according the
...@@ -143,18 +143,18 @@ static int ep93xx_spi_calc_divisors(struct spi_master *master, ...@@ -143,18 +143,18 @@ static int ep93xx_spi_calc_divisors(struct spi_master *master,
return -EINVAL; return -EINVAL;
} }
static int ep93xx_spi_chip_setup(struct spi_master *master, static int ep93xx_spi_chip_setup(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
u8 dss = bits_per_word_to_dss(xfer->bits_per_word); u8 dss = bits_per_word_to_dss(xfer->bits_per_word);
u8 div_cpsr = 0; u8 div_cpsr = 0;
u8 div_scr = 0; u8 div_scr = 0;
u16 cr0; u16 cr0;
int err; int err;
err = ep93xx_spi_calc_divisors(master, xfer->speed_hz, err = ep93xx_spi_calc_divisors(host, xfer->speed_hz,
&div_cpsr, &div_scr); &div_cpsr, &div_scr);
if (err) if (err)
return err; return err;
...@@ -166,9 +166,9 @@ static int ep93xx_spi_chip_setup(struct spi_master *master, ...@@ -166,9 +166,9 @@ static int ep93xx_spi_chip_setup(struct spi_master *master,
cr0 |= SSPCR0_SPH; cr0 |= SSPCR0_SPH;
cr0 |= dss; cr0 |= dss;
dev_dbg(&master->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n", dev_dbg(&host->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
spi->mode, div_cpsr, div_scr, dss); spi->mode, div_cpsr, div_scr, dss);
dev_dbg(&master->dev, "setup: cr0 %#x\n", cr0); dev_dbg(&host->dev, "setup: cr0 %#x\n", cr0);
writel(div_cpsr, espi->mmio + SSPCPSR); writel(div_cpsr, espi->mmio + SSPCPSR);
writel(cr0, espi->mmio + SSPCR0); writel(cr0, espi->mmio + SSPCR0);
...@@ -176,10 +176,10 @@ static int ep93xx_spi_chip_setup(struct spi_master *master, ...@@ -176,10 +176,10 @@ static int ep93xx_spi_chip_setup(struct spi_master *master,
return 0; return 0;
} }
static void ep93xx_do_write(struct spi_master *master) static void ep93xx_do_write(struct spi_controller *host)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
struct spi_transfer *xfer = master->cur_msg->state; struct spi_transfer *xfer = host->cur_msg->state;
u32 val = 0; u32 val = 0;
if (xfer->bits_per_word > 8) { if (xfer->bits_per_word > 8) {
...@@ -194,10 +194,10 @@ static void ep93xx_do_write(struct spi_master *master) ...@@ -194,10 +194,10 @@ static void ep93xx_do_write(struct spi_master *master)
writel(val, espi->mmio + SSPDR); writel(val, espi->mmio + SSPDR);
} }
static void ep93xx_do_read(struct spi_master *master) static void ep93xx_do_read(struct spi_controller *host)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
struct spi_transfer *xfer = master->cur_msg->state; struct spi_transfer *xfer = host->cur_msg->state;
u32 val; u32 val;
val = readl(espi->mmio + SSPDR); val = readl(espi->mmio + SSPDR);
...@@ -214,7 +214,7 @@ static void ep93xx_do_read(struct spi_master *master) ...@@ -214,7 +214,7 @@ static void ep93xx_do_read(struct spi_master *master)
/** /**
* ep93xx_spi_read_write() - perform next RX/TX transfer * ep93xx_spi_read_write() - perform next RX/TX transfer
* @master: SPI master * @host: SPI host
* *
* This function transfers next bytes (or half-words) to/from RX/TX FIFOs. If * This function transfers next bytes (or half-words) to/from RX/TX FIFOs. If
* called several times, the whole transfer will be completed. Returns * called several times, the whole transfer will be completed. Returns
...@@ -223,20 +223,20 @@ static void ep93xx_do_read(struct spi_master *master) ...@@ -223,20 +223,20 @@ static void ep93xx_do_read(struct spi_master *master)
* When this function is finished, RX FIFO should be empty and TX FIFO should be * When this function is finished, RX FIFO should be empty and TX FIFO should be
* full. * full.
*/ */
static int ep93xx_spi_read_write(struct spi_master *master) static int ep93xx_spi_read_write(struct spi_controller *host)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
struct spi_transfer *xfer = master->cur_msg->state; struct spi_transfer *xfer = host->cur_msg->state;
/* read as long as RX FIFO has frames in it */ /* read as long as RX FIFO has frames in it */
while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) { while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) {
ep93xx_do_read(master); ep93xx_do_read(host);
espi->fifo_level--; espi->fifo_level--;
} }
/* write as long as TX FIFO has room */ /* write as long as TX FIFO has room */
while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < xfer->len) { while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < xfer->len) {
ep93xx_do_write(master); ep93xx_do_write(host);
espi->fifo_level++; espi->fifo_level++;
} }
...@@ -261,7 +261,7 @@ ep93xx_dma_data_to_trans_dir(enum dma_data_direction dir) ...@@ -261,7 +261,7 @@ ep93xx_dma_data_to_trans_dir(enum dma_data_direction dir)
/** /**
* ep93xx_spi_dma_prepare() - prepares a DMA transfer * ep93xx_spi_dma_prepare() - prepares a DMA transfer
* @master: SPI master * @host: SPI host
* @dir: DMA transfer direction * @dir: DMA transfer direction
* *
* Function configures the DMA, maps the buffer and prepares the DMA * Function configures the DMA, maps the buffer and prepares the DMA
...@@ -269,11 +269,11 @@ ep93xx_dma_data_to_trans_dir(enum dma_data_direction dir) ...@@ -269,11 +269,11 @@ ep93xx_dma_data_to_trans_dir(enum dma_data_direction dir)
* in case of failure. * in case of failure.
*/ */
static struct dma_async_tx_descriptor * static struct dma_async_tx_descriptor *
ep93xx_spi_dma_prepare(struct spi_master *master, ep93xx_spi_dma_prepare(struct spi_controller *host,
enum dma_data_direction dir) enum dma_data_direction dir)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
struct spi_transfer *xfer = master->cur_msg->state; struct spi_transfer *xfer = host->cur_msg->state;
struct dma_async_tx_descriptor *txd; struct dma_async_tx_descriptor *txd;
enum dma_slave_buswidth buswidth; enum dma_slave_buswidth buswidth;
struct dma_slave_config conf; struct dma_slave_config conf;
...@@ -348,7 +348,7 @@ ep93xx_spi_dma_prepare(struct spi_master *master, ...@@ -348,7 +348,7 @@ ep93xx_spi_dma_prepare(struct spi_master *master,
} }
if (WARN_ON(len)) { if (WARN_ON(len)) {
dev_warn(&master->dev, "len = %zu expected 0!\n", len); dev_warn(&host->dev, "len = %zu expected 0!\n", len);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -367,16 +367,16 @@ ep93xx_spi_dma_prepare(struct spi_master *master, ...@@ -367,16 +367,16 @@ ep93xx_spi_dma_prepare(struct spi_master *master,
/** /**
* ep93xx_spi_dma_finish() - finishes with a DMA transfer * ep93xx_spi_dma_finish() - finishes with a DMA transfer
* @master: SPI master * @host: SPI host
* @dir: DMA transfer direction * @dir: DMA transfer direction
* *
* Function finishes with the DMA transfer. After this, the DMA buffer is * Function finishes with the DMA transfer. After this, the DMA buffer is
* unmapped. * unmapped.
*/ */
static void ep93xx_spi_dma_finish(struct spi_master *master, static void ep93xx_spi_dma_finish(struct spi_controller *host,
enum dma_data_direction dir) enum dma_data_direction dir)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
struct dma_chan *chan; struct dma_chan *chan;
struct sg_table *sgt; struct sg_table *sgt;
...@@ -393,35 +393,35 @@ static void ep93xx_spi_dma_finish(struct spi_master *master, ...@@ -393,35 +393,35 @@ static void ep93xx_spi_dma_finish(struct spi_master *master,
static void ep93xx_spi_dma_callback(void *callback_param) static void ep93xx_spi_dma_callback(void *callback_param)
{ {
struct spi_master *master = callback_param; struct spi_controller *host = callback_param;
ep93xx_spi_dma_finish(master, DMA_TO_DEVICE); ep93xx_spi_dma_finish(host, DMA_TO_DEVICE);
ep93xx_spi_dma_finish(master, DMA_FROM_DEVICE); ep93xx_spi_dma_finish(host, DMA_FROM_DEVICE);
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
} }
static int ep93xx_spi_dma_transfer(struct spi_master *master) static int ep93xx_spi_dma_transfer(struct spi_controller *host)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
struct dma_async_tx_descriptor *rxd, *txd; struct dma_async_tx_descriptor *rxd, *txd;
rxd = ep93xx_spi_dma_prepare(master, DMA_FROM_DEVICE); rxd = ep93xx_spi_dma_prepare(host, DMA_FROM_DEVICE);
if (IS_ERR(rxd)) { if (IS_ERR(rxd)) {
dev_err(&master->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd)); dev_err(&host->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
return PTR_ERR(rxd); return PTR_ERR(rxd);
} }
txd = ep93xx_spi_dma_prepare(master, DMA_TO_DEVICE); txd = ep93xx_spi_dma_prepare(host, DMA_TO_DEVICE);
if (IS_ERR(txd)) { if (IS_ERR(txd)) {
ep93xx_spi_dma_finish(master, DMA_FROM_DEVICE); ep93xx_spi_dma_finish(host, DMA_FROM_DEVICE);
dev_err(&master->dev, "DMA TX failed: %ld\n", PTR_ERR(txd)); dev_err(&host->dev, "DMA TX failed: %ld\n", PTR_ERR(txd));
return PTR_ERR(txd); return PTR_ERR(txd);
} }
/* We are ready when RX is done */ /* We are ready when RX is done */
rxd->callback = ep93xx_spi_dma_callback; rxd->callback = ep93xx_spi_dma_callback;
rxd->callback_param = master; rxd->callback_param = host;
/* Now submit both descriptors and start DMA */ /* Now submit both descriptors and start DMA */
dmaengine_submit(rxd); dmaengine_submit(rxd);
...@@ -436,8 +436,8 @@ static int ep93xx_spi_dma_transfer(struct spi_master *master) ...@@ -436,8 +436,8 @@ static int ep93xx_spi_dma_transfer(struct spi_master *master)
static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id) static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
{ {
struct spi_master *master = dev_id; struct spi_controller *host = dev_id;
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
u32 val; u32 val;
/* /*
...@@ -447,15 +447,15 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id) ...@@ -447,15 +447,15 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) { if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) {
/* clear the overrun interrupt */ /* clear the overrun interrupt */
writel(0, espi->mmio + SSPICR); writel(0, espi->mmio + SSPICR);
dev_warn(&master->dev, dev_warn(&host->dev,
"receive overrun, aborting the message\n"); "receive overrun, aborting the message\n");
master->cur_msg->status = -EIO; host->cur_msg->status = -EIO;
} else { } else {
/* /*
* Interrupt is either RX (RIS) or TX (TIS). For both cases we * Interrupt is either RX (RIS) or TX (TIS). For both cases we
* simply execute next data transfer. * simply execute next data transfer.
*/ */
if (ep93xx_spi_read_write(master)) { if (ep93xx_spi_read_write(host)) {
/* /*
* In normal case, there still is some processing left * In normal case, there still is some processing left
* for current transfer. Let's wait for the next * for current transfer. Let's wait for the next
...@@ -474,26 +474,26 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id) ...@@ -474,26 +474,26 @@ static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
val &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE); val &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
writel(val, espi->mmio + SSPCR1); writel(val, espi->mmio + SSPCR1);
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int ep93xx_spi_transfer_one(struct spi_master *master, static int ep93xx_spi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
u32 val; u32 val;
int ret; int ret;
ret = ep93xx_spi_chip_setup(master, spi, xfer); ret = ep93xx_spi_chip_setup(host, spi, xfer);
if (ret) { if (ret) {
dev_err(&master->dev, "failed to setup chip for transfer\n"); dev_err(&host->dev, "failed to setup chip for transfer\n");
return ret; return ret;
} }
master->cur_msg->state = xfer; host->cur_msg->state = xfer;
espi->rx = 0; espi->rx = 0;
espi->tx = 0; espi->tx = 0;
...@@ -503,10 +503,10 @@ static int ep93xx_spi_transfer_one(struct spi_master *master, ...@@ -503,10 +503,10 @@ static int ep93xx_spi_transfer_one(struct spi_master *master,
* So in these cases we will be using PIO and don't bother for DMA. * So in these cases we will be using PIO and don't bother for DMA.
*/ */
if (espi->dma_rx && xfer->len > SPI_FIFO_SIZE) if (espi->dma_rx && xfer->len > SPI_FIFO_SIZE)
return ep93xx_spi_dma_transfer(master); return ep93xx_spi_dma_transfer(host);
/* Using PIO so prime the TX FIFO and enable interrupts */ /* Using PIO so prime the TX FIFO and enable interrupts */
ep93xx_spi_read_write(master); ep93xx_spi_read_write(host);
val = readl(espi->mmio + SSPCR1); val = readl(espi->mmio + SSPCR1);
val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE); val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
...@@ -516,10 +516,10 @@ static int ep93xx_spi_transfer_one(struct spi_master *master, ...@@ -516,10 +516,10 @@ static int ep93xx_spi_transfer_one(struct spi_master *master,
return 1; return 1;
} }
static int ep93xx_spi_prepare_message(struct spi_master *master, static int ep93xx_spi_prepare_message(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
unsigned long timeout; unsigned long timeout;
/* /*
...@@ -528,7 +528,7 @@ static int ep93xx_spi_prepare_message(struct spi_master *master, ...@@ -528,7 +528,7 @@ static int ep93xx_spi_prepare_message(struct spi_master *master,
timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT); timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT);
while (readl(espi->mmio + SSPSR) & SSPSR_RNE) { while (readl(espi->mmio + SSPSR) & SSPSR_RNE) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
dev_warn(&master->dev, dev_warn(&host->dev,
"timeout while flushing RX FIFO\n"); "timeout while flushing RX FIFO\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -544,9 +544,9 @@ static int ep93xx_spi_prepare_message(struct spi_master *master, ...@@ -544,9 +544,9 @@ static int ep93xx_spi_prepare_message(struct spi_master *master,
return 0; return 0;
} }
static int ep93xx_spi_prepare_hardware(struct spi_master *master) static int ep93xx_spi_prepare_hardware(struct spi_controller *host)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
u32 val; u32 val;
int ret; int ret;
...@@ -561,9 +561,9 @@ static int ep93xx_spi_prepare_hardware(struct spi_master *master) ...@@ -561,9 +561,9 @@ static int ep93xx_spi_prepare_hardware(struct spi_master *master)
return 0; return 0;
} }
static int ep93xx_spi_unprepare_hardware(struct spi_master *master) static int ep93xx_spi_unprepare_hardware(struct spi_controller *host)
{ {
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
u32 val; u32 val;
val = readl(espi->mmio + SSPCR1); val = readl(espi->mmio + SSPCR1);
...@@ -646,7 +646,7 @@ static void ep93xx_spi_release_dma(struct ep93xx_spi *espi) ...@@ -646,7 +646,7 @@ static void ep93xx_spi_release_dma(struct ep93xx_spi *espi)
static int ep93xx_spi_probe(struct platform_device *pdev) static int ep93xx_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct ep93xx_spi_info *info; struct ep93xx_spi_info *info;
struct ep93xx_spi *espi; struct ep93xx_spi *espi;
struct resource *res; struct resource *res;
...@@ -663,54 +663,54 @@ static int ep93xx_spi_probe(struct platform_device *pdev) ...@@ -663,54 +663,54 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
master = spi_alloc_master(&pdev->dev, sizeof(*espi)); host = spi_alloc_host(&pdev->dev, sizeof(*espi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->prepare_transfer_hardware = ep93xx_spi_prepare_hardware; host->prepare_transfer_hardware = ep93xx_spi_prepare_hardware;
master->unprepare_transfer_hardware = ep93xx_spi_unprepare_hardware; host->unprepare_transfer_hardware = ep93xx_spi_unprepare_hardware;
master->prepare_message = ep93xx_spi_prepare_message; host->prepare_message = ep93xx_spi_prepare_message;
master->transfer_one = ep93xx_spi_transfer_one; host->transfer_one = ep93xx_spi_transfer_one;
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
/* /*
* The SPI core will count the number of GPIO descriptors to figure * The SPI core will count the number of GPIO descriptors to figure
* out the number of chip selects available on the platform. * out the number of chip selects available on the platform.
*/ */
master->num_chipselect = 0; host->num_chipselect = 0;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
espi = spi_master_get_devdata(master); espi = spi_controller_get_devdata(host);
espi->clk = devm_clk_get(&pdev->dev, NULL); espi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(espi->clk)) { if (IS_ERR(espi->clk)) {
dev_err(&pdev->dev, "unable to get spi clock\n"); dev_err(&pdev->dev, "unable to get spi clock\n");
error = PTR_ERR(espi->clk); error = PTR_ERR(espi->clk);
goto fail_release_master; goto fail_release_host;
} }
/* /*
* Calculate maximum and minimum supported clock rates * Calculate maximum and minimum supported clock rates
* for the controller. * for the controller.
*/ */
master->max_speed_hz = clk_get_rate(espi->clk) / 2; host->max_speed_hz = clk_get_rate(espi->clk) / 2;
master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); host->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256);
espi->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res); espi->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(espi->mmio)) { if (IS_ERR(espi->mmio)) {
error = PTR_ERR(espi->mmio); error = PTR_ERR(espi->mmio);
goto fail_release_master; goto fail_release_host;
} }
espi->sspdr_phys = res->start + SSPDR; espi->sspdr_phys = res->start + SSPDR;
error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt, error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt,
0, "ep93xx-spi", master); 0, "ep93xx-spi", host);
if (error) { if (error) {
dev_err(&pdev->dev, "failed to request irq\n"); dev_err(&pdev->dev, "failed to request irq\n");
goto fail_release_master; goto fail_release_host;
} }
if (info->use_dma && ep93xx_spi_setup_dma(espi)) if (info->use_dma && ep93xx_spi_setup_dma(espi))
...@@ -719,9 +719,9 @@ static int ep93xx_spi_probe(struct platform_device *pdev) ...@@ -719,9 +719,9 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
/* make sure that the hardware is disabled */ /* make sure that the hardware is disabled */
writel(0, espi->mmio + SSPCR1); writel(0, espi->mmio + SSPCR1);
error = devm_spi_register_master(&pdev->dev, master); error = devm_spi_register_controller(&pdev->dev, host);
if (error) { if (error) {
dev_err(&pdev->dev, "failed to register SPI master\n"); dev_err(&pdev->dev, "failed to register SPI host\n");
goto fail_free_dma; goto fail_free_dma;
} }
...@@ -732,16 +732,16 @@ static int ep93xx_spi_probe(struct platform_device *pdev) ...@@ -732,16 +732,16 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
fail_free_dma: fail_free_dma:
ep93xx_spi_release_dma(espi); ep93xx_spi_release_dma(espi);
fail_release_master: fail_release_host:
spi_master_put(master); spi_controller_put(host);
return error; return error;
} }
static void ep93xx_spi_remove(struct platform_device *pdev) static void ep93xx_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct ep93xx_spi *espi = spi_master_get_devdata(master); struct ep93xx_spi *espi = spi_controller_get_devdata(host);
ep93xx_spi_release_dma(espi); ep93xx_spi_release_dma(espi);
} }
......
...@@ -91,14 +91,14 @@ ...@@ -91,14 +91,14 @@
struct falcon_sflash { struct falcon_sflash {
u32 sfcmd; /* for caching of opcode, direction, ... */ u32 sfcmd; /* for caching of opcode, direction, ... */
struct spi_master *master; struct spi_controller *host;
}; };
int falcon_sflash_xfer(struct spi_device *spi, struct spi_transfer *t, int falcon_sflash_xfer(struct spi_device *spi, struct spi_transfer *t,
unsigned long flags) unsigned long flags)
{ {
struct device *dev = &spi->dev; struct device *dev = &spi->dev;
struct falcon_sflash *priv = spi_master_get_devdata(spi->master); struct falcon_sflash *priv = spi_controller_get_devdata(spi->controller);
const u8 *txp = t->tx_buf; const u8 *txp = t->tx_buf;
u8 *rxp = t->rx_buf; u8 *rxp = t->rx_buf;
unsigned int bytelen = ((8 * t->len + 7) / 8); unsigned int bytelen = ((8 * t->len + 7) / 8);
...@@ -351,10 +351,10 @@ static int falcon_sflash_setup(struct spi_device *spi) ...@@ -351,10 +351,10 @@ static int falcon_sflash_setup(struct spi_device *spi)
return 0; return 0;
} }
static int falcon_sflash_xfer_one(struct spi_master *master, static int falcon_sflash_xfer_one(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
struct falcon_sflash *priv = spi_master_get_devdata(master); struct falcon_sflash *priv = spi_controller_get_devdata(host);
struct spi_transfer *t; struct spi_transfer *t;
unsigned long spi_flags; unsigned long spi_flags;
unsigned long flags; unsigned long flags;
...@@ -382,7 +382,7 @@ static int falcon_sflash_xfer_one(struct spi_master *master, ...@@ -382,7 +382,7 @@ static int falcon_sflash_xfer_one(struct spi_master *master,
} }
m->status = ret; m->status = ret;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return 0; return 0;
} }
...@@ -390,25 +390,25 @@ static int falcon_sflash_xfer_one(struct spi_master *master, ...@@ -390,25 +390,25 @@ static int falcon_sflash_xfer_one(struct spi_master *master,
static int falcon_sflash_probe(struct platform_device *pdev) static int falcon_sflash_probe(struct platform_device *pdev)
{ {
struct falcon_sflash *priv; struct falcon_sflash *priv;
struct spi_master *master; struct spi_controller *host;
int ret; int ret;
master = spi_alloc_master(&pdev->dev, sizeof(*priv)); host = spi_alloc_host(&pdev->dev, sizeof(*priv));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
priv = spi_master_get_devdata(master); priv = spi_controller_get_devdata(host);
priv->master = master; priv->host = host;
master->mode_bits = SPI_MODE_3; host->mode_bits = SPI_MODE_3;
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->setup = falcon_sflash_setup; host->setup = falcon_sflash_setup;
master->transfer_one_message = falcon_sflash_xfer_one; host->transfer_one_message = falcon_sflash_xfer_one;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (ret) if (ret)
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
......
...@@ -542,7 +542,7 @@ static int fsi_spi_probe(struct device *dev) ...@@ -542,7 +542,7 @@ static int fsi_spi_probe(struct device *dev)
if (of_property_read_u32(np, "reg", &base)) if (of_property_read_u32(np, "reg", &base))
continue; continue;
ctlr = spi_alloc_master(dev, sizeof(*ctx)); ctlr = spi_alloc_host(dev, sizeof(*ctx));
if (!ctlr) { if (!ctlr) {
of_node_put(np); of_node_put(np);
break; break;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define DRIVER_NAME "fsl-dspi" #define DRIVER_NAME "fsl-dspi"
#define SPI_MCR 0x00 #define SPI_MCR 0x00
#define SPI_MCR_MASTER BIT(31) #define SPI_MCR_HOST BIT(31)
#define SPI_MCR_PCSIS(x) ((x) << 16) #define SPI_MCR_PCSIS(x) ((x) << 16)
#define SPI_MCR_CLR_TXF BIT(11) #define SPI_MCR_CLR_TXF BIT(11)
#define SPI_MCR_CLR_RXF BIT(10) #define SPI_MCR_CLR_RXF BIT(10)
...@@ -340,7 +340,7 @@ static u32 dspi_pop_tx_pushr(struct fsl_dspi *dspi) ...@@ -340,7 +340,7 @@ static u32 dspi_pop_tx_pushr(struct fsl_dspi *dspi)
{ {
u16 cmd = dspi->tx_cmd, data = dspi_pop_tx(dspi); u16 cmd = dspi->tx_cmd, data = dspi_pop_tx(dspi);
if (spi_controller_is_slave(dspi->ctlr)) if (spi_controller_is_target(dspi->ctlr))
return data; return data;
if (dspi->len > 0) if (dspi->len > 0)
...@@ -430,7 +430,7 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi) ...@@ -430,7 +430,7 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi)
dma_async_issue_pending(dma->chan_rx); dma_async_issue_pending(dma->chan_rx);
dma_async_issue_pending(dma->chan_tx); dma_async_issue_pending(dma->chan_tx);
if (spi_controller_is_slave(dspi->ctlr)) { if (spi_controller_is_target(dspi->ctlr)) {
wait_for_completion_interruptible(&dspi->dma->cmd_rx_complete); wait_for_completion_interruptible(&dspi->dma->cmd_rx_complete);
return 0; return 0;
} }
...@@ -1061,7 +1061,7 @@ static int dspi_setup(struct spi_device *spi) ...@@ -1061,7 +1061,7 @@ static int dspi_setup(struct spi_device *spi)
if (spi->mode & SPI_CPHA) if (spi->mode & SPI_CPHA)
chip->ctar_val |= SPI_CTAR_CPHA; chip->ctar_val |= SPI_CTAR_CPHA;
if (!spi_controller_is_slave(dspi->ctlr)) { if (!spi_controller_is_target(dspi->ctlr)) {
chip->ctar_val |= SPI_CTAR_PCSSCK(pcssck) | chip->ctar_val |= SPI_CTAR_PCSSCK(pcssck) |
SPI_CTAR_CSSCK(cssck) | SPI_CTAR_CSSCK(cssck) |
SPI_CTAR_PASC(pasc) | SPI_CTAR_PASC(pasc) |
...@@ -1216,8 +1216,8 @@ static int dspi_init(struct fsl_dspi *dspi) ...@@ -1216,8 +1216,8 @@ static int dspi_init(struct fsl_dspi *dspi)
if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE) if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE)
mcr |= SPI_MCR_XSPI; mcr |= SPI_MCR_XSPI;
if (!spi_controller_is_slave(dspi->ctlr)) if (!spi_controller_is_target(dspi->ctlr))
mcr |= SPI_MCR_MASTER; mcr |= SPI_MCR_HOST;
regmap_write(dspi->regmap, SPI_MCR, mcr); regmap_write(dspi->regmap, SPI_MCR, mcr);
regmap_write(dspi->regmap, SPI_SR, SPI_SR_CLEAR); regmap_write(dspi->regmap, SPI_SR, SPI_SR_CLEAR);
...@@ -1240,13 +1240,13 @@ static int dspi_init(struct fsl_dspi *dspi) ...@@ -1240,13 +1240,13 @@ static int dspi_init(struct fsl_dspi *dspi)
return 0; return 0;
} }
static int dspi_slave_abort(struct spi_master *master) static int dspi_target_abort(struct spi_controller *host)
{ {
struct fsl_dspi *dspi = spi_master_get_devdata(master); struct fsl_dspi *dspi = spi_controller_get_devdata(host);
/* /*
* Terminate all pending DMA transactions for the SPI working * Terminate all pending DMA transactions for the SPI working
* in SLAVE mode. * in TARGET mode.
*/ */
if (dspi->devtype_data->trans_mode == DSPI_DMA_MODE) { if (dspi->devtype_data->trans_mode == DSPI_DMA_MODE) {
dmaengine_terminate_sync(dspi->dma->chan_rx); dmaengine_terminate_sync(dspi->dma->chan_rx);
...@@ -1277,7 +1277,7 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1277,7 +1277,7 @@ static int dspi_probe(struct platform_device *pdev)
if (!dspi) if (!dspi)
return -ENOMEM; return -ENOMEM;
ctlr = spi_alloc_master(&pdev->dev, 0); ctlr = spi_alloc_host(&pdev->dev, 0);
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
...@@ -1292,7 +1292,7 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1292,7 +1292,7 @@ static int dspi_probe(struct platform_device *pdev)
ctlr->dev.of_node = pdev->dev.of_node; ctlr->dev.of_node = pdev->dev.of_node;
ctlr->cleanup = dspi_cleanup; ctlr->cleanup = dspi_cleanup;
ctlr->slave_abort = dspi_slave_abort; ctlr->target_abort = dspi_target_abort;
ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
ctlr->use_gpio_descriptors = true; ctlr->use_gpio_descriptors = true;
...@@ -1317,7 +1317,7 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1317,7 +1317,7 @@ static int dspi_probe(struct platform_device *pdev)
ctlr->bus_num = bus_num; ctlr->bus_num = bus_num;
if (of_property_read_bool(np, "spi-slave")) if (of_property_read_bool(np, "spi-slave"))
ctlr->slave = true; ctlr->target = true;
dspi->devtype_data = of_device_get_match_data(&pdev->dev); dspi->devtype_data = of_device_get_match_data(&pdev->dev);
if (!dspi->devtype_data) { if (!dspi->devtype_data) {
......
...@@ -148,7 +148,7 @@ static inline void fsl_espi_write_reg8(struct fsl_espi *espi, int offset, ...@@ -148,7 +148,7 @@ static inline void fsl_espi_write_reg8(struct fsl_espi *espi, int offset,
static int fsl_espi_check_message(struct spi_message *m) static int fsl_espi_check_message(struct spi_message *m)
{ {
struct fsl_espi *espi = spi_master_get_devdata(m->spi->master); struct fsl_espi *espi = spi_controller_get_devdata(m->spi->controller);
struct spi_transfer *t, *first; struct spi_transfer *t, *first;
if (m->frame_length > SPCOM_TRANLEN_MAX) { if (m->frame_length > SPCOM_TRANLEN_MAX) {
...@@ -323,7 +323,7 @@ static void fsl_espi_read_rx_fifo(struct fsl_espi *espi, u32 events) ...@@ -323,7 +323,7 @@ static void fsl_espi_read_rx_fifo(struct fsl_espi *espi, u32 events)
static void fsl_espi_setup_transfer(struct spi_device *spi, static void fsl_espi_setup_transfer(struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct fsl_espi *espi = spi_master_get_devdata(spi->master); struct fsl_espi *espi = spi_controller_get_devdata(spi->controller);
int bits_per_word = t ? t->bits_per_word : spi->bits_per_word; int bits_per_word = t ? t->bits_per_word : spi->bits_per_word;
u32 pm, hz = t ? t->speed_hz : spi->max_speed_hz; u32 pm, hz = t ? t->speed_hz : spi->max_speed_hz;
struct fsl_espi_cs *cs = spi_get_ctldata(spi); struct fsl_espi_cs *cs = spi_get_ctldata(spi);
...@@ -351,7 +351,7 @@ static void fsl_espi_setup_transfer(struct spi_device *spi, ...@@ -351,7 +351,7 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,
static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
{ {
struct fsl_espi *espi = spi_master_get_devdata(spi->master); struct fsl_espi *espi = spi_controller_get_devdata(spi->controller);
unsigned int rx_len = t->len; unsigned int rx_len = t->len;
u32 mask, spcom; u32 mask, spcom;
int ret; int ret;
...@@ -396,7 +396,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -396,7 +396,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans) static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans)
{ {
struct fsl_espi *espi = spi_master_get_devdata(m->spi->master); struct fsl_espi *espi = spi_controller_get_devdata(m->spi->controller);
struct spi_device *spi = m->spi; struct spi_device *spi = m->spi;
int ret; int ret;
...@@ -432,7 +432,7 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans) ...@@ -432,7 +432,7 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans)
return ret; return ret;
} }
static int fsl_espi_do_one_msg(struct spi_master *master, static int fsl_espi_do_one_msg(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
unsigned int rx_nbits = 0, delay_nsecs = 0; unsigned int rx_nbits = 0, delay_nsecs = 0;
...@@ -470,7 +470,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ...@@ -470,7 +470,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master,
if (m->status == -EINPROGRESS) if (m->status == -EINPROGRESS)
m->status = ret; m->status = ret;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return ret; return ret;
} }
...@@ -488,7 +488,7 @@ static int fsl_espi_setup(struct spi_device *spi) ...@@ -488,7 +488,7 @@ static int fsl_espi_setup(struct spi_device *spi)
spi_set_ctldata(spi, cs); spi_set_ctldata(spi, cs);
} }
espi = spi_master_get_devdata(spi->master); espi = spi_controller_get_devdata(spi->controller);
pm_runtime_get_sync(espi->dev); pm_runtime_get_sync(espi->dev);
...@@ -584,8 +584,8 @@ static irqreturn_t fsl_espi_irq(s32 irq, void *context_data) ...@@ -584,8 +584,8 @@ static irqreturn_t fsl_espi_irq(s32 irq, void *context_data)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int fsl_espi_runtime_suspend(struct device *dev) static int fsl_espi_runtime_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct fsl_espi *espi = spi_master_get_devdata(master); struct fsl_espi *espi = spi_controller_get_devdata(host);
u32 regval; u32 regval;
regval = fsl_espi_read_reg(espi, ESPI_SPMODE); regval = fsl_espi_read_reg(espi, ESPI_SPMODE);
...@@ -597,8 +597,8 @@ static int fsl_espi_runtime_suspend(struct device *dev) ...@@ -597,8 +597,8 @@ static int fsl_espi_runtime_suspend(struct device *dev)
static int fsl_espi_runtime_resume(struct device *dev) static int fsl_espi_runtime_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct fsl_espi *espi = spi_master_get_devdata(master); struct fsl_espi *espi = spi_controller_get_devdata(host);
u32 regval; u32 regval;
regval = fsl_espi_read_reg(espi, ESPI_SPMODE); regval = fsl_espi_read_reg(espi, ESPI_SPMODE);
...@@ -616,8 +616,8 @@ static size_t fsl_espi_max_message_size(struct spi_device *spi) ...@@ -616,8 +616,8 @@ static size_t fsl_espi_max_message_size(struct spi_device *spi)
static void fsl_espi_init_regs(struct device *dev, bool initial) static void fsl_espi_init_regs(struct device *dev, bool initial)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct fsl_espi *espi = spi_master_get_devdata(master); struct fsl_espi *espi = spi_controller_get_devdata(host);
struct device_node *nc; struct device_node *nc;
u32 csmode, cs, prop; u32 csmode, cs, prop;
int ret; int ret;
...@@ -629,10 +629,10 @@ static void fsl_espi_init_regs(struct device *dev, bool initial) ...@@ -629,10 +629,10 @@ static void fsl_espi_init_regs(struct device *dev, bool initial)
fsl_espi_write_reg(espi, ESPI_SPIE, 0xffffffff); fsl_espi_write_reg(espi, ESPI_SPIE, 0xffffffff);
/* Init eSPI CS mode register */ /* Init eSPI CS mode register */
for_each_available_child_of_node(master->dev.of_node, nc) { for_each_available_child_of_node(host->dev.of_node, nc) {
/* get chip select */ /* get chip select */
ret = of_property_read_u32(nc, "reg", &cs); ret = of_property_read_u32(nc, "reg", &cs);
if (ret || cs >= master->num_chipselect) if (ret || cs >= host->num_chipselect)
continue; continue;
csmode = CSMODE_INIT_VAL; csmode = CSMODE_INIT_VAL;
...@@ -664,28 +664,28 @@ static void fsl_espi_init_regs(struct device *dev, bool initial) ...@@ -664,28 +664,28 @@ static void fsl_espi_init_regs(struct device *dev, bool initial)
static int fsl_espi_probe(struct device *dev, struct resource *mem, static int fsl_espi_probe(struct device *dev, struct resource *mem,
unsigned int irq, unsigned int num_cs) unsigned int irq, unsigned int num_cs)
{ {
struct spi_master *master; struct spi_controller *host;
struct fsl_espi *espi; struct fsl_espi *espi;
int ret; int ret;
master = spi_alloc_master(dev, sizeof(struct fsl_espi)); host = spi_alloc_host(dev, sizeof(struct fsl_espi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
dev_set_drvdata(dev, master); dev_set_drvdata(dev, host);
master->mode_bits = SPI_RX_DUAL | SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | host->mode_bits = SPI_RX_DUAL | SPI_CPOL | SPI_CPHA | SPI_CS_HIGH |
SPI_LSB_FIRST | SPI_LOOP; SPI_LSB_FIRST | SPI_LOOP;
master->dev.of_node = dev->of_node; host->dev.of_node = dev->of_node;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
master->setup = fsl_espi_setup; host->setup = fsl_espi_setup;
master->cleanup = fsl_espi_cleanup; host->cleanup = fsl_espi_cleanup;
master->transfer_one_message = fsl_espi_do_one_msg; host->transfer_one_message = fsl_espi_do_one_msg;
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
master->max_message_size = fsl_espi_max_message_size; host->max_message_size = fsl_espi_max_message_size;
master->num_chipselect = num_cs; host->num_chipselect = num_cs;
espi = spi_master_get_devdata(master); espi = spi_controller_get_devdata(host);
spin_lock_init(&espi->lock); spin_lock_init(&espi->lock);
espi->dev = dev; espi->dev = dev;
...@@ -696,8 +696,8 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem, ...@@ -696,8 +696,8 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
goto err_probe; goto err_probe;
} }
/* determined by clock divider fields DIV16/PM in register SPMODEx */ /* determined by clock divider fields DIV16/PM in register SPMODEx */
master->min_speed_hz = DIV_ROUND_UP(espi->spibrg, 4 * 16 * 16); host->min_speed_hz = DIV_ROUND_UP(espi->spibrg, 4 * 16 * 16);
master->max_speed_hz = DIV_ROUND_UP(espi->spibrg, 4); host->max_speed_hz = DIV_ROUND_UP(espi->spibrg, 4);
init_completion(&espi->done); init_completion(&espi->done);
...@@ -720,7 +720,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem, ...@@ -720,7 +720,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
pm_runtime_enable(dev); pm_runtime_enable(dev);
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret < 0) if (ret < 0)
goto err_pm; goto err_pm;
...@@ -736,7 +736,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem, ...@@ -736,7 +736,7 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
pm_runtime_disable(dev); pm_runtime_disable(dev);
pm_runtime_set_suspended(dev); pm_runtime_set_suspended(dev);
err_probe: err_probe:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
...@@ -791,10 +791,10 @@ static void of_fsl_espi_remove(struct platform_device *dev) ...@@ -791,10 +791,10 @@ static void of_fsl_espi_remove(struct platform_device *dev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int of_fsl_espi_suspend(struct device *dev) static int of_fsl_espi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
int ret; int ret;
ret = spi_master_suspend(master); ret = spi_controller_suspend(host);
if (ret) if (ret)
return ret; return ret;
...@@ -803,7 +803,7 @@ static int of_fsl_espi_suspend(struct device *dev) ...@@ -803,7 +803,7 @@ static int of_fsl_espi_suspend(struct device *dev)
static int of_fsl_espi_resume(struct device *dev) static int of_fsl_espi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
int ret; int ret;
fsl_espi_init_regs(dev, false); fsl_espi_init_regs(dev, false);
...@@ -812,7 +812,7 @@ static int of_fsl_espi_resume(struct device *dev) ...@@ -812,7 +812,7 @@ static int of_fsl_espi_resume(struct device *dev)
if (ret < 0) if (ret < 0)
return ret; return ret;
return spi_master_resume(master); return spi_controller_resume(host);
} }
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
#define CFGR1_PINCFG (BIT(24)|BIT(25)) #define CFGR1_PINCFG (BIT(24)|BIT(25))
#define CFGR1_PCSPOL BIT(8) #define CFGR1_PCSPOL BIT(8)
#define CFGR1_NOSTALL BIT(3) #define CFGR1_NOSTALL BIT(3)
#define CFGR1_MASTER BIT(0) #define CFGR1_HOST BIT(0)
#define FSR_TXCOUNT (0xFF) #define FSR_TXCOUNT (0xFF)
#define RSR_RXEMPTY BIT(1) #define RSR_RXEMPTY BIT(1)
#define TCR_CPOL BIT(31) #define TCR_CPOL BIT(31)
...@@ -96,7 +96,7 @@ struct fsl_lpspi_data { ...@@ -96,7 +96,7 @@ struct fsl_lpspi_data {
unsigned long base_phys; unsigned long base_phys;
struct clk *clk_ipg; struct clk *clk_ipg;
struct clk *clk_per; struct clk *clk_per;
bool is_slave; bool is_target;
bool is_only_cs1; bool is_only_cs1;
bool is_first_byte; bool is_first_byte;
...@@ -113,7 +113,7 @@ struct fsl_lpspi_data { ...@@ -113,7 +113,7 @@ struct fsl_lpspi_data {
struct lpspi_config config; struct lpspi_config config;
struct completion xfer_done; struct completion xfer_done;
bool slave_aborted; bool target_aborted;
/* DMA */ /* DMA */
bool usedma; bool usedma;
...@@ -234,7 +234,7 @@ static void fsl_lpspi_write_tx_fifo(struct fsl_lpspi_data *fsl_lpspi) ...@@ -234,7 +234,7 @@ static void fsl_lpspi_write_tx_fifo(struct fsl_lpspi_data *fsl_lpspi)
} }
if (txfifo_cnt < fsl_lpspi->txfifosize) { if (txfifo_cnt < fsl_lpspi->txfifosize) {
if (!fsl_lpspi->is_slave) { if (!fsl_lpspi->is_target) {
temp = readl(fsl_lpspi->base + IMX7ULP_TCR); temp = readl(fsl_lpspi->base + IMX7ULP_TCR);
temp &= ~TCR_CONTC; temp &= ~TCR_CONTC;
writel(temp, fsl_lpspi->base + IMX7ULP_TCR); writel(temp, fsl_lpspi->base + IMX7ULP_TCR);
...@@ -258,7 +258,7 @@ static void fsl_lpspi_set_cmd(struct fsl_lpspi_data *fsl_lpspi) ...@@ -258,7 +258,7 @@ static void fsl_lpspi_set_cmd(struct fsl_lpspi_data *fsl_lpspi)
temp |= fsl_lpspi->config.bpw - 1; temp |= fsl_lpspi->config.bpw - 1;
temp |= (fsl_lpspi->config.mode & 0x3) << 30; temp |= (fsl_lpspi->config.mode & 0x3) << 30;
temp |= (fsl_lpspi->config.chip_select & 0x3) << 24; temp |= (fsl_lpspi->config.chip_select & 0x3) << 24;
if (!fsl_lpspi->is_slave) { if (!fsl_lpspi->is_target) {
temp |= fsl_lpspi->config.prescale << 27; temp |= fsl_lpspi->config.prescale << 27;
/* /*
* Set TCR_CONT will keep SS asserted after current transfer. * Set TCR_CONT will keep SS asserted after current transfer.
...@@ -385,7 +385,7 @@ static int fsl_lpspi_config(struct fsl_lpspi_data *fsl_lpspi) ...@@ -385,7 +385,7 @@ static int fsl_lpspi_config(struct fsl_lpspi_data *fsl_lpspi)
u32 temp; u32 temp;
int ret; int ret;
if (!fsl_lpspi->is_slave) { if (!fsl_lpspi->is_target) {
ret = fsl_lpspi_set_bitrate(fsl_lpspi); ret = fsl_lpspi_set_bitrate(fsl_lpspi);
if (ret) if (ret)
return ret; return ret;
...@@ -393,8 +393,8 @@ static int fsl_lpspi_config(struct fsl_lpspi_data *fsl_lpspi) ...@@ -393,8 +393,8 @@ static int fsl_lpspi_config(struct fsl_lpspi_data *fsl_lpspi)
fsl_lpspi_set_watermark(fsl_lpspi); fsl_lpspi_set_watermark(fsl_lpspi);
if (!fsl_lpspi->is_slave) if (!fsl_lpspi->is_target)
temp = CFGR1_MASTER; temp = CFGR1_HOST;
else else
temp = CFGR1_PINCFG; temp = CFGR1_PINCFG;
if (fsl_lpspi->config.mode & SPI_CS_HIGH) if (fsl_lpspi->config.mode & SPI_CS_HIGH)
...@@ -461,12 +461,12 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller, ...@@ -461,12 +461,12 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
return fsl_lpspi_config(fsl_lpspi); return fsl_lpspi_config(fsl_lpspi);
} }
static int fsl_lpspi_slave_abort(struct spi_controller *controller) static int fsl_lpspi_target_abort(struct spi_controller *controller)
{ {
struct fsl_lpspi_data *fsl_lpspi = struct fsl_lpspi_data *fsl_lpspi =
spi_controller_get_devdata(controller); spi_controller_get_devdata(controller);
fsl_lpspi->slave_aborted = true; fsl_lpspi->target_aborted = true;
if (!fsl_lpspi->usedma) if (!fsl_lpspi->usedma)
complete(&fsl_lpspi->xfer_done); complete(&fsl_lpspi->xfer_done);
else { else {
...@@ -482,9 +482,9 @@ static int fsl_lpspi_wait_for_completion(struct spi_controller *controller) ...@@ -482,9 +482,9 @@ static int fsl_lpspi_wait_for_completion(struct spi_controller *controller)
struct fsl_lpspi_data *fsl_lpspi = struct fsl_lpspi_data *fsl_lpspi =
spi_controller_get_devdata(controller); spi_controller_get_devdata(controller);
if (fsl_lpspi->is_slave) { if (fsl_lpspi->is_target) {
if (wait_for_completion_interruptible(&fsl_lpspi->xfer_done) || if (wait_for_completion_interruptible(&fsl_lpspi->xfer_done) ||
fsl_lpspi->slave_aborted) { fsl_lpspi->target_aborted) {
dev_dbg(fsl_lpspi->dev, "interrupted\n"); dev_dbg(fsl_lpspi->dev, "interrupted\n");
return -EINTR; return -EINTR;
} }
...@@ -587,9 +587,9 @@ static int fsl_lpspi_dma_transfer(struct spi_controller *controller, ...@@ -587,9 +587,9 @@ static int fsl_lpspi_dma_transfer(struct spi_controller *controller,
reinit_completion(&fsl_lpspi->dma_tx_completion); reinit_completion(&fsl_lpspi->dma_tx_completion);
dma_async_issue_pending(controller->dma_tx); dma_async_issue_pending(controller->dma_tx);
fsl_lpspi->slave_aborted = false; fsl_lpspi->target_aborted = false;
if (!fsl_lpspi->is_slave) { if (!fsl_lpspi->is_target) {
transfer_timeout = fsl_lpspi_calculate_timeout(fsl_lpspi, transfer_timeout = fsl_lpspi_calculate_timeout(fsl_lpspi,
transfer->len); transfer->len);
...@@ -615,7 +615,7 @@ static int fsl_lpspi_dma_transfer(struct spi_controller *controller, ...@@ -615,7 +615,7 @@ static int fsl_lpspi_dma_transfer(struct spi_controller *controller,
} }
} else { } else {
if (wait_for_completion_interruptible(&fsl_lpspi->dma_tx_completion) || if (wait_for_completion_interruptible(&fsl_lpspi->dma_tx_completion) ||
fsl_lpspi->slave_aborted) { fsl_lpspi->target_aborted) {
dev_dbg(fsl_lpspi->dev, dev_dbg(fsl_lpspi->dev,
"I/O Error in DMA TX interrupted\n"); "I/O Error in DMA TX interrupted\n");
dmaengine_terminate_all(controller->dma_tx); dmaengine_terminate_all(controller->dma_tx);
...@@ -625,7 +625,7 @@ static int fsl_lpspi_dma_transfer(struct spi_controller *controller, ...@@ -625,7 +625,7 @@ static int fsl_lpspi_dma_transfer(struct spi_controller *controller,
} }
if (wait_for_completion_interruptible(&fsl_lpspi->dma_rx_completion) || if (wait_for_completion_interruptible(&fsl_lpspi->dma_rx_completion) ||
fsl_lpspi->slave_aborted) { fsl_lpspi->target_aborted) {
dev_dbg(fsl_lpspi->dev, dev_dbg(fsl_lpspi->dev,
"I/O Error in DMA RX interrupted\n"); "I/O Error in DMA RX interrupted\n");
dmaengine_terminate_all(controller->dma_tx); dmaengine_terminate_all(controller->dma_tx);
...@@ -700,7 +700,7 @@ static int fsl_lpspi_pio_transfer(struct spi_controller *controller, ...@@ -700,7 +700,7 @@ static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
fsl_lpspi->remain = t->len; fsl_lpspi->remain = t->len;
reinit_completion(&fsl_lpspi->xfer_done); reinit_completion(&fsl_lpspi->xfer_done);
fsl_lpspi->slave_aborted = false; fsl_lpspi->target_aborted = false;
fsl_lpspi_write_tx_fifo(fsl_lpspi); fsl_lpspi_write_tx_fifo(fsl_lpspi);
...@@ -826,15 +826,15 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -826,15 +826,15 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
int ret, irq; int ret, irq;
u32 num_cs; u32 num_cs;
u32 temp; u32 temp;
bool is_slave; bool is_target;
is_slave = of_property_read_bool((&pdev->dev)->of_node, "spi-slave"); is_target = of_property_read_bool((&pdev->dev)->of_node, "spi-slave");
if (is_slave) if (is_target)
controller = spi_alloc_slave(&pdev->dev, controller = spi_alloc_target(&pdev->dev,
sizeof(struct fsl_lpspi_data)); sizeof(struct fsl_lpspi_data));
else else
controller = spi_alloc_master(&pdev->dev, controller = spi_alloc_host(&pdev->dev,
sizeof(struct fsl_lpspi_data)); sizeof(struct fsl_lpspi_data));
if (!controller) if (!controller)
return -ENOMEM; return -ENOMEM;
...@@ -843,7 +843,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -843,7 +843,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
fsl_lpspi = spi_controller_get_devdata(controller); fsl_lpspi = spi_controller_get_devdata(controller);
fsl_lpspi->dev = &pdev->dev; fsl_lpspi->dev = &pdev->dev;
fsl_lpspi->is_slave = is_slave; fsl_lpspi->is_target = is_target;
fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node, fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node,
"fsl,spi-only-use-cs1-sel"); "fsl,spi-only-use-cs1-sel");
...@@ -912,8 +912,8 @@ static int fsl_lpspi_probe(struct platform_device *pdev) ...@@ -912,8 +912,8 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
controller->dev.of_node = pdev->dev.of_node; controller->dev.of_node = pdev->dev.of_node;
controller->bus_num = pdev->id; controller->bus_num = pdev->id;
controller->num_chipselect = num_cs; controller->num_chipselect = num_cs;
controller->slave_abort = fsl_lpspi_slave_abort; controller->target_abort = fsl_lpspi_target_abort;
if (!fsl_lpspi->is_slave) if (!fsl_lpspi->is_target)
controller->use_gpio_descriptors = true; controller->use_gpio_descriptors = true;
ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller); ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller);
......
...@@ -367,7 +367,7 @@ static int fsl_qspi_check_buswidth(struct fsl_qspi *q, u8 width) ...@@ -367,7 +367,7 @@ static int fsl_qspi_check_buswidth(struct fsl_qspi *q, u8 width)
static bool fsl_qspi_supports_op(struct spi_mem *mem, static bool fsl_qspi_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->master); struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->controller);
int ret; int ret;
ret = fsl_qspi_check_buswidth(q, op->cmd.buswidth); ret = fsl_qspi_check_buswidth(q, op->cmd.buswidth);
...@@ -640,7 +640,7 @@ static int fsl_qspi_readl_poll_tout(struct fsl_qspi *q, void __iomem *base, ...@@ -640,7 +640,7 @@ static int fsl_qspi_readl_poll_tout(struct fsl_qspi *q, void __iomem *base,
static int fsl_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static int fsl_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->master); struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->controller);
void __iomem *base = q->iobase; void __iomem *base = q->iobase;
u32 addr_offset = 0; u32 addr_offset = 0;
int err = 0; int err = 0;
...@@ -702,7 +702,7 @@ static int fsl_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) ...@@ -702,7 +702,7 @@ static int fsl_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
static int fsl_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) static int fsl_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{ {
struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->master); struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->controller);
if (op->data.dir == SPI_MEM_DATA_OUT) { if (op->data.dir == SPI_MEM_DATA_OUT) {
if (op->data.nbytes > q->devtype_data->txfifo) if (op->data.nbytes > q->devtype_data->txfifo)
...@@ -808,7 +808,7 @@ static int fsl_qspi_default_setup(struct fsl_qspi *q) ...@@ -808,7 +808,7 @@ static int fsl_qspi_default_setup(struct fsl_qspi *q)
static const char *fsl_qspi_get_name(struct spi_mem *mem) static const char *fsl_qspi_get_name(struct spi_mem *mem)
{ {
struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->master); struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->controller);
struct device *dev = &mem->spi->dev; struct device *dev = &mem->spi->dev;
const char *name; const char *name;
...@@ -848,7 +848,7 @@ static int fsl_qspi_probe(struct platform_device *pdev) ...@@ -848,7 +848,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
struct fsl_qspi *q; struct fsl_qspi *q;
int ret; int ret;
ctlr = spi_alloc_master(&pdev->dev, sizeof(*q)); ctlr = spi_alloc_host(&pdev->dev, sizeof(*q));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
......
...@@ -88,7 +88,7 @@ static int fsl_spi_get_type(struct device *dev) ...@@ -88,7 +88,7 @@ static int fsl_spi_get_type(struct device *dev)
static void fsl_spi_change_mode(struct spi_device *spi) static void fsl_spi_change_mode(struct spi_device *spi)
{ {
struct mpc8xxx_spi *mspi = spi_master_get_devdata(spi->master); struct mpc8xxx_spi *mspi = spi_controller_get_devdata(spi->controller);
struct spi_mpc8xxx_cs *cs = spi->controller_state; struct spi_mpc8xxx_cs *cs = spi->controller_state;
struct fsl_spi_reg __iomem *reg_base = mspi->reg_base; struct fsl_spi_reg __iomem *reg_base = mspi->reg_base;
__be32 __iomem *mode = &reg_base->mode; __be32 __iomem *mode = &reg_base->mode;
...@@ -183,7 +183,7 @@ static int fsl_spi_setup_transfer(struct spi_device *spi, ...@@ -183,7 +183,7 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,
u32 hz = 0; u32 hz = 0;
struct spi_mpc8xxx_cs *cs = spi->controller_state; struct spi_mpc8xxx_cs *cs = spi->controller_state;
mpc8xxx_spi = spi_master_get_devdata(spi->master); mpc8xxx_spi = spi_controller_get_devdata(spi->controller);
if (t) { if (t) {
bits_per_word = t->bits_per_word; bits_per_word = t->bits_per_word;
...@@ -252,7 +252,7 @@ static int fsl_spi_cpu_bufs(struct mpc8xxx_spi *mspi, ...@@ -252,7 +252,7 @@ static int fsl_spi_cpu_bufs(struct mpc8xxx_spi *mspi,
static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t, static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t,
bool is_dma_mapped) bool is_dma_mapped)
{ {
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(spi->controller);
struct fsl_spi_reg __iomem *reg_base; struct fsl_spi_reg __iomem *reg_base;
unsigned int len = t->len; unsigned int len = t->len;
u8 bits_per_word; u8 bits_per_word;
...@@ -385,7 +385,7 @@ static int fsl_spi_setup(struct spi_device *spi) ...@@ -385,7 +385,7 @@ static int fsl_spi_setup(struct spi_device *spi)
spi_set_ctldata(spi, cs); spi_set_ctldata(spi, cs);
initial_setup = true; initial_setup = true;
} }
mpc8xxx_spi = spi_master_get_devdata(spi->master); mpc8xxx_spi = spi_controller_get_devdata(spi->controller);
reg_base = mpc8xxx_spi->reg_base; reg_base = mpc8xxx_spi->reg_base;
...@@ -479,7 +479,7 @@ static irqreturn_t fsl_spi_irq(s32 irq, void *context_data) ...@@ -479,7 +479,7 @@ static irqreturn_t fsl_spi_irq(s32 irq, void *context_data)
static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on) static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on)
{ {
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master); struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(spi->controller);
struct fsl_spi_reg __iomem *reg_base = mpc8xxx_spi->reg_base; struct fsl_spi_reg __iomem *reg_base = mpc8xxx_spi->reg_base;
u32 slvsel; u32 slvsel;
u16 cs = spi_get_chipselect(spi, 0); u16 cs = spi_get_chipselect(spi, 0);
...@@ -493,8 +493,8 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on) ...@@ -493,8 +493,8 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on)
static void fsl_spi_grlib_probe(struct device *dev) static void fsl_spi_grlib_probe(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(master); struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(host);
struct fsl_spi_reg __iomem *reg_base = mpc8xxx_spi->reg_base; struct fsl_spi_reg __iomem *reg_base = mpc8xxx_spi->reg_base;
int mbits; int mbits;
u32 capabilities; u32 capabilities;
...@@ -511,8 +511,8 @@ static void fsl_spi_grlib_probe(struct device *dev) ...@@ -511,8 +511,8 @@ static void fsl_spi_grlib_probe(struct device *dev)
mpc8xxx_spi->native_chipselects = SPCAP_SSSZ(capabilities); mpc8xxx_spi->native_chipselects = SPCAP_SSSZ(capabilities);
mpc8xxx_spi_write_reg(&reg_base->slvsel, 0xffffffff); mpc8xxx_spi_write_reg(&reg_base->slvsel, 0xffffffff);
} }
master->num_chipselect = mpc8xxx_spi->native_chipselects; host->num_chipselect = mpc8xxx_spi->native_chipselects;
master->set_cs = fsl_spi_grlib_cs_control; host->set_cs = fsl_spi_grlib_cs_control;
} }
static void fsl_spi_cs_control(struct spi_device *spi, bool on) static void fsl_spi_cs_control(struct spi_device *spi, bool on)
...@@ -526,35 +526,35 @@ static void fsl_spi_cs_control(struct spi_device *spi, bool on) ...@@ -526,35 +526,35 @@ static void fsl_spi_cs_control(struct spi_device *spi, bool on)
iowrite32be(on ? 0 : SPI_BOOT_SEL_BIT, pinfo->immr_spi_cs); iowrite32be(on ? 0 : SPI_BOOT_SEL_BIT, pinfo->immr_spi_cs);
} }
static struct spi_master *fsl_spi_probe(struct device *dev, static struct spi_controller *fsl_spi_probe(struct device *dev,
struct resource *mem, unsigned int irq) struct resource *mem, unsigned int irq)
{ {
struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
struct spi_master *master; struct spi_controller *host;
struct mpc8xxx_spi *mpc8xxx_spi; struct mpc8xxx_spi *mpc8xxx_spi;
struct fsl_spi_reg __iomem *reg_base; struct fsl_spi_reg __iomem *reg_base;
u32 regval; u32 regval;
int ret = 0; int ret = 0;
master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi)); host = spi_alloc_host(dev, sizeof(struct mpc8xxx_spi));
if (master == NULL) { if (host == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
dev_set_drvdata(dev, master); dev_set_drvdata(dev, host);
mpc8xxx_spi_probe(dev, mem, irq); mpc8xxx_spi_probe(dev, mem, irq);
master->setup = fsl_spi_setup; host->setup = fsl_spi_setup;
master->cleanup = fsl_spi_cleanup; host->cleanup = fsl_spi_cleanup;
master->prepare_message = fsl_spi_prepare_message; host->prepare_message = fsl_spi_prepare_message;
master->transfer_one = fsl_spi_transfer_one; host->transfer_one = fsl_spi_transfer_one;
master->unprepare_message = fsl_spi_unprepare_message; host->unprepare_message = fsl_spi_unprepare_message;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->set_cs = fsl_spi_cs_control; host->set_cs = fsl_spi_cs_control;
mpc8xxx_spi = spi_master_get_devdata(master); mpc8xxx_spi = spi_controller_get_devdata(host);
mpc8xxx_spi->max_bits_per_word = 32; mpc8xxx_spi->max_bits_per_word = 32;
mpc8xxx_spi->type = fsl_spi_get_type(dev); mpc8xxx_spi->type = fsl_spi_get_type(dev);
...@@ -572,13 +572,13 @@ static struct spi_master *fsl_spi_probe(struct device *dev, ...@@ -572,13 +572,13 @@ static struct spi_master *fsl_spi_probe(struct device *dev,
fsl_spi_grlib_probe(dev); fsl_spi_grlib_probe(dev);
if (mpc8xxx_spi->flags & SPI_CPM_MODE) if (mpc8xxx_spi->flags & SPI_CPM_MODE)
master->bits_per_word_mask = host->bits_per_word_mask =
(SPI_BPW_RANGE_MASK(4, 8) | SPI_BPW_MASK(16) | SPI_BPW_MASK(32)); (SPI_BPW_RANGE_MASK(4, 8) | SPI_BPW_MASK(16) | SPI_BPW_MASK(32));
else else
master->bits_per_word_mask = host->bits_per_word_mask =
(SPI_BPW_RANGE_MASK(4, 16) | SPI_BPW_MASK(32)); (SPI_BPW_RANGE_MASK(4, 16) | SPI_BPW_MASK(32));
master->bits_per_word_mask &= host->bits_per_word_mask &=
SPI_BPW_RANGE_MASK(1, mpc8xxx_spi->max_bits_per_word); SPI_BPW_RANGE_MASK(1, mpc8xxx_spi->max_bits_per_word);
if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE)
...@@ -615,19 +615,19 @@ static struct spi_master *fsl_spi_probe(struct device *dev, ...@@ -615,19 +615,19 @@ static struct spi_master *fsl_spi_probe(struct device *dev,
mpc8xxx_spi_write_reg(&reg_base->mode, regval); mpc8xxx_spi_write_reg(&reg_base->mode, regval);
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret < 0) if (ret < 0)
goto err_probe; goto err_probe;
dev_info(dev, "at 0x%p (irq = %d), %s mode\n", reg_base, dev_info(dev, "at 0x%p (irq = %d), %s mode\n", reg_base,
mpc8xxx_spi->irq, mpc8xxx_spi_strmode(mpc8xxx_spi->flags)); mpc8xxx_spi->irq, mpc8xxx_spi_strmode(mpc8xxx_spi->flags));
return master; return host;
err_probe: err_probe:
fsl_spi_cpm_free(mpc8xxx_spi); fsl_spi_cpm_free(mpc8xxx_spi);
err_cpm_init: err_cpm_init:
spi_master_put(master); spi_controller_put(host);
err: err:
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -636,7 +636,7 @@ static int of_fsl_spi_probe(struct platform_device *ofdev) ...@@ -636,7 +636,7 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
{ {
struct device *dev = &ofdev->dev; struct device *dev = &ofdev->dev;
struct device_node *np = ofdev->dev.of_node; struct device_node *np = ofdev->dev.of_node;
struct spi_master *master; struct spi_controller *host;
struct resource mem; struct resource mem;
int irq, type; int irq, type;
int ret; int ret;
...@@ -689,9 +689,9 @@ static int of_fsl_spi_probe(struct platform_device *ofdev) ...@@ -689,9 +689,9 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
goto unmap_out; goto unmap_out;
} }
master = fsl_spi_probe(dev, &mem, irq); host = fsl_spi_probe(dev, &mem, irq);
return PTR_ERR_OR_ZERO(master); return PTR_ERR_OR_ZERO(host);
unmap_out: unmap_out:
#if IS_ENABLED(CONFIG_FSL_SOC) #if IS_ENABLED(CONFIG_FSL_SOC)
...@@ -703,8 +703,8 @@ static int of_fsl_spi_probe(struct platform_device *ofdev) ...@@ -703,8 +703,8 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
static void of_fsl_spi_remove(struct platform_device *ofdev) static void of_fsl_spi_remove(struct platform_device *ofdev)
{ {
struct spi_master *master = platform_get_drvdata(ofdev); struct spi_controller *host = platform_get_drvdata(ofdev);
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(master); struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(host);
fsl_spi_cpm_free(mpc8xxx_spi); fsl_spi_cpm_free(mpc8xxx_spi);
} }
...@@ -730,7 +730,7 @@ static int plat_mpc8xxx_spi_probe(struct platform_device *pdev) ...@@ -730,7 +730,7 @@ static int plat_mpc8xxx_spi_probe(struct platform_device *pdev)
{ {
struct resource *mem; struct resource *mem;
int irq; int irq;
struct spi_master *master; struct spi_controller *host;
if (!dev_get_platdata(&pdev->dev)) if (!dev_get_platdata(&pdev->dev))
return -EINVAL; return -EINVAL;
...@@ -743,14 +743,14 @@ static int plat_mpc8xxx_spi_probe(struct platform_device *pdev) ...@@ -743,14 +743,14 @@ static int plat_mpc8xxx_spi_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
master = fsl_spi_probe(&pdev->dev, mem, irq); host = fsl_spi_probe(&pdev->dev, mem, irq);
return PTR_ERR_OR_ZERO(master); return PTR_ERR_OR_ZERO(host);
} }
static void plat_mpc8xxx_spi_remove(struct platform_device *pdev) static void plat_mpc8xxx_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(master); struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(host);
fsl_spi_cpm_free(mpc8xxx_spi); fsl_spi_cpm_free(mpc8xxx_spi);
} }
......
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* SPI master driver using generic bitbanged GPIO * SPI host driver using generic bitbanged GPIO
* *
* Copyright (C) 2006,2008 David Brownell * Copyright (C) 2006,2008 David Brownell
* Copyright (C) 2017 Linus Walleij * Copyright (C) 2017 Linus Walleij
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
/* /*
* This bitbanging SPI master driver should help make systems usable * This bitbanging SPI host driver should help make systems usable
* when a native hardware SPI engine is not available, perhaps because * when a native hardware SPI engine is not available, perhaps because
* its driver isn't yet working or because the I/O pins it requires * its driver isn't yet working or because the I/O pins it requires
* are used for other purposes. * are used for other purposes.
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* spi->controller_state ... reserved for bitbang framework code * spi->controller_state ... reserved for bitbang framework code
* *
* spi->master->dev.driver_data ... points to spi_gpio->bitbang * spi->controller->dev.driver_data ... points to spi_gpio->bitbang
*/ */
struct spi_gpio { struct spi_gpio {
...@@ -77,7 +77,7 @@ spi_to_spi_gpio(const struct spi_device *spi) ...@@ -77,7 +77,7 @@ spi_to_spi_gpio(const struct spi_device *spi)
const struct spi_bitbang *bang; const struct spi_bitbang *bang;
struct spi_gpio *spi_gpio; struct spi_gpio *spi_gpio;
bang = spi_master_get_devdata(spi->master); bang = spi_controller_get_devdata(spi->controller);
spi_gpio = container_of(bang, struct spi_gpio, bitbang); spi_gpio = container_of(bang, struct spi_gpio, bitbang);
return spi_gpio; return spi_gpio;
} }
...@@ -180,7 +180,7 @@ static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi, ...@@ -180,7 +180,7 @@ static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi,
static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi, static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits, unsigned flags) unsigned nsecs, u32 word, u8 bits, unsigned flags)
{ {
flags = spi->master->flags; flags = spi->controller->flags;
if (unlikely(spi->mode & SPI_LSB_FIRST)) if (unlikely(spi->mode & SPI_LSB_FIRST))
return bitbang_txrx_le_cpha0(spi, nsecs, 0, flags, word, bits); return bitbang_txrx_le_cpha0(spi, nsecs, 0, flags, word, bits);
else else
...@@ -190,7 +190,7 @@ static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi, ...@@ -190,7 +190,7 @@ static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi,
static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi, static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits, unsigned flags) unsigned nsecs, u32 word, u8 bits, unsigned flags)
{ {
flags = spi->master->flags; flags = spi->controller->flags;
if (unlikely(spi->mode & SPI_LSB_FIRST)) if (unlikely(spi->mode & SPI_LSB_FIRST))
return bitbang_txrx_le_cpha1(spi, nsecs, 0, flags, word, bits); return bitbang_txrx_le_cpha1(spi, nsecs, 0, flags, word, bits);
else else
...@@ -200,7 +200,7 @@ static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi, ...@@ -200,7 +200,7 @@ static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi,
static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi, static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits, unsigned flags) unsigned nsecs, u32 word, u8 bits, unsigned flags)
{ {
flags = spi->master->flags; flags = spi->controller->flags;
if (unlikely(spi->mode & SPI_LSB_FIRST)) if (unlikely(spi->mode & SPI_LSB_FIRST))
return bitbang_txrx_le_cpha0(spi, nsecs, 1, flags, word, bits); return bitbang_txrx_le_cpha0(spi, nsecs, 1, flags, word, bits);
else else
...@@ -210,7 +210,7 @@ static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi, ...@@ -210,7 +210,7 @@ static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi,
static u32 spi_gpio_spec_txrx_word_mode3(struct spi_device *spi, static u32 spi_gpio_spec_txrx_word_mode3(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits, unsigned flags) unsigned nsecs, u32 word, u8 bits, unsigned flags)
{ {
flags = spi->master->flags; flags = spi->controller->flags;
if (unlikely(spi->mode & SPI_LSB_FIRST)) if (unlikely(spi->mode & SPI_LSB_FIRST))
return bitbang_txrx_le_cpha1(spi, nsecs, 1, flags, word, bits); return bitbang_txrx_le_cpha1(spi, nsecs, 1, flags, word, bits);
else else
...@@ -310,7 +310,7 @@ static void spi_gpio_cleanup(struct spi_device *spi) ...@@ -310,7 +310,7 @@ static void spi_gpio_cleanup(struct spi_device *spi)
* On platforms which can do so, configure MISO with a weak pullup unless * On platforms which can do so, configure MISO with a weak pullup unless
* there's an external pullup on that signal. That saves power by avoiding * there's an external pullup on that signal. That saves power by avoiding
* floating signals. (A weak pulldown would save power too, but many * floating signals. (A weak pulldown would save power too, but many
* drivers expect to see all-ones data as the no slave "response".) * drivers expect to see all-ones data as the no target "response".)
*/ */
static int spi_gpio_request(struct device *dev, struct spi_gpio *spi_gpio) static int spi_gpio_request(struct device *dev, struct spi_gpio *spi_gpio)
{ {
...@@ -334,27 +334,27 @@ static const struct of_device_id spi_gpio_dt_ids[] = { ...@@ -334,27 +334,27 @@ static const struct of_device_id spi_gpio_dt_ids[] = {
MODULE_DEVICE_TABLE(of, spi_gpio_dt_ids); MODULE_DEVICE_TABLE(of, spi_gpio_dt_ids);
static int spi_gpio_probe_dt(struct platform_device *pdev, static int spi_gpio_probe_dt(struct platform_device *pdev,
struct spi_master *master) struct spi_controller *host)
{ {
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
return 0; return 0;
} }
#else #else
static inline int spi_gpio_probe_dt(struct platform_device *pdev, static inline int spi_gpio_probe_dt(struct platform_device *pdev,
struct spi_master *master) struct spi_controller *host)
{ {
return 0; return 0;
} }
#endif #endif
static int spi_gpio_probe_pdata(struct platform_device *pdev, static int spi_gpio_probe_pdata(struct platform_device *pdev,
struct spi_master *master) struct spi_controller *host)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_gpio_platform_data *pdata = dev_get_platdata(dev); struct spi_gpio_platform_data *pdata = dev_get_platdata(dev);
struct spi_gpio *spi_gpio = spi_master_get_devdata(master); struct spi_gpio *spi_gpio = spi_controller_get_devdata(host);
int i; int i;
#ifdef GENERIC_BITBANG #ifdef GENERIC_BITBANG
...@@ -362,18 +362,18 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev, ...@@ -362,18 +362,18 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev,
return -ENODEV; return -ENODEV;
#endif #endif
/* /*
* The master needs to think there is a chipselect even if not * The host needs to think there is a chipselect even if not
* connected * connected
*/ */
master->num_chipselect = pdata->num_chipselect ?: 1; host->num_chipselect = pdata->num_chipselect ?: 1;
spi_gpio->cs_gpios = devm_kcalloc(dev, master->num_chipselect, spi_gpio->cs_gpios = devm_kcalloc(dev, host->num_chipselect,
sizeof(*spi_gpio->cs_gpios), sizeof(*spi_gpio->cs_gpios),
GFP_KERNEL); GFP_KERNEL);
if (!spi_gpio->cs_gpios) if (!spi_gpio->cs_gpios)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < master->num_chipselect; i++) { for (i = 0; i < host->num_chipselect; i++) {
spi_gpio->cs_gpios[i] = devm_gpiod_get_index(dev, "cs", i, spi_gpio->cs_gpios[i] = devm_gpiod_get_index(dev, "cs", i,
GPIOD_OUT_HIGH); GPIOD_OUT_HIGH);
if (IS_ERR(spi_gpio->cs_gpios[i])) if (IS_ERR(spi_gpio->cs_gpios[i]))
...@@ -386,31 +386,31 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev, ...@@ -386,31 +386,31 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev,
static int spi_gpio_probe(struct platform_device *pdev) static int spi_gpio_probe(struct platform_device *pdev)
{ {
int status; int status;
struct spi_master *master; struct spi_controller *host;
struct spi_gpio *spi_gpio; struct spi_gpio *spi_gpio;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_bitbang *bb; struct spi_bitbang *bb;
master = devm_spi_alloc_master(dev, sizeof(*spi_gpio)); host = devm_spi_alloc_host(dev, sizeof(*spi_gpio));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
if (pdev->dev.of_node) if (pdev->dev.of_node)
status = spi_gpio_probe_dt(pdev, master); status = spi_gpio_probe_dt(pdev, host);
else else
status = spi_gpio_probe_pdata(pdev, master); status = spi_gpio_probe_pdata(pdev, host);
if (status) if (status)
return status; return status;
spi_gpio = spi_master_get_devdata(master); spi_gpio = spi_controller_get_devdata(host);
status = spi_gpio_request(dev, spi_gpio); status = spi_gpio_request(dev, spi_gpio);
if (status) if (status)
return status; return status;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
master->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL | host->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL |
SPI_CS_HIGH | SPI_LSB_FIRST; SPI_CS_HIGH | SPI_LSB_FIRST;
if (!spi_gpio->mosi) { if (!spi_gpio->mosi) {
/* HW configuration without MOSI pin /* HW configuration without MOSI pin
...@@ -419,25 +419,25 @@ static int spi_gpio_probe(struct platform_device *pdev) ...@@ -419,25 +419,25 @@ static int spi_gpio_probe(struct platform_device *pdev)
* a MOSI pin connected the host can still do RX by * a MOSI pin connected the host can still do RX by
* changing the direction of the line. * changing the direction of the line.
*/ */
master->flags = SPI_CONTROLLER_NO_TX; host->flags = SPI_CONTROLLER_NO_TX;
} }
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->setup = spi_gpio_setup; host->setup = spi_gpio_setup;
master->cleanup = spi_gpio_cleanup; host->cleanup = spi_gpio_cleanup;
bb = &spi_gpio->bitbang; bb = &spi_gpio->bitbang;
bb->master = master; bb->master = host;
/* /*
* There is some additional business, apart from driving the CS GPIO * There is some additional business, apart from driving the CS GPIO
* line, that we need to do on selection. This makes the local * line, that we need to do on selection. This makes the local
* callback for chipselect always get called. * callback for chipselect always get called.
*/ */
master->flags |= SPI_CONTROLLER_GPIO_SS; host->flags |= SPI_CONTROLLER_GPIO_SS;
bb->chipselect = spi_gpio_chipselect; bb->chipselect = spi_gpio_chipselect;
bb->set_line_direction = spi_gpio_set_direction; bb->set_line_direction = spi_gpio_set_direction;
if (master->flags & SPI_CONTROLLER_NO_TX) { if (host->flags & SPI_CONTROLLER_NO_TX) {
bb->txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0; bb->txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0;
bb->txrx_word[SPI_MODE_1] = spi_gpio_spec_txrx_word_mode1; bb->txrx_word[SPI_MODE_1] = spi_gpio_spec_txrx_word_mode1;
bb->txrx_word[SPI_MODE_2] = spi_gpio_spec_txrx_word_mode2; bb->txrx_word[SPI_MODE_2] = spi_gpio_spec_txrx_word_mode2;
...@@ -454,7 +454,7 @@ static int spi_gpio_probe(struct platform_device *pdev) ...@@ -454,7 +454,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
if (status) if (status)
return status; return status;
return devm_spi_register_master(&pdev->dev, master); return devm_spi_register_controller(&pdev->dev, host);
} }
MODULE_ALIAS("platform:" DRIVER_NAME); MODULE_ALIAS("platform:" DRIVER_NAME);
...@@ -468,6 +468,6 @@ static struct platform_driver spi_gpio_driver = { ...@@ -468,6 +468,6 @@ static struct platform_driver spi_gpio_driver = {
}; };
module_platform_driver(spi_gpio_driver); module_platform_driver(spi_gpio_driver);
MODULE_DESCRIPTION("SPI master driver using generic bitbanged GPIO "); MODULE_DESCRIPTION("SPI host driver using generic bitbanged GPIO ");
MODULE_AUTHOR("David Brownell"); MODULE_AUTHOR("David Brownell");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -199,7 +199,7 @@ static ssize_t gxp_spi_write(struct gxp_spi_chip *chip, const struct spi_mem_op ...@@ -199,7 +199,7 @@ static ssize_t gxp_spi_write(struct gxp_spi_chip *chip, const struct spi_mem_op
static int do_gxp_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) static int do_gxp_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct gxp_spi *spifi = spi_controller_get_devdata(mem->spi->master); struct gxp_spi *spifi = spi_controller_get_devdata(mem->spi->controller);
struct gxp_spi_chip *chip = &spifi->chips[spi_get_chipselect(mem->spi, 0)]; struct gxp_spi_chip *chip = &spifi->chips[spi_get_chipselect(mem->spi, 0)];
int ret; int ret;
...@@ -235,7 +235,7 @@ static const struct spi_controller_mem_ops gxp_spi_mem_ops = { ...@@ -235,7 +235,7 @@ static const struct spi_controller_mem_ops gxp_spi_mem_ops = {
static int gxp_spi_setup(struct spi_device *spi) static int gxp_spi_setup(struct spi_device *spi)
{ {
struct gxp_spi *spifi = spi_controller_get_devdata(spi->master); struct gxp_spi *spifi = spi_controller_get_devdata(spi->controller);
unsigned int cs = spi_get_chipselect(spi, 0); unsigned int cs = spi_get_chipselect(spi, 0);
struct gxp_spi_chip *chip = &spifi->chips[cs]; struct gxp_spi_chip *chip = &spifi->chips[cs];
...@@ -257,7 +257,7 @@ static int gxp_spifi_probe(struct platform_device *pdev) ...@@ -257,7 +257,7 @@ static int gxp_spifi_probe(struct platform_device *pdev)
data = of_device_get_match_data(&pdev->dev); data = of_device_get_match_data(&pdev->dev);
ctlr = devm_spi_alloc_master(dev, sizeof(*spifi)); ctlr = devm_spi_alloc_host(dev, sizeof(*spifi));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
......
...@@ -152,7 +152,7 @@ static int hisi_sfc_v3xx_adjust_op_size(struct spi_mem *mem, ...@@ -152,7 +152,7 @@ static int hisi_sfc_v3xx_adjust_op_size(struct spi_mem *mem,
uintptr_t addr = (uintptr_t)op->data.buf.in; uintptr_t addr = (uintptr_t)op->data.buf.in;
int max_byte_count; int max_byte_count;
host = spi_controller_get_devdata(spi->master); host = spi_controller_get_devdata(spi->controller);
max_byte_count = host->max_cmd_dword * 4; max_byte_count = host->max_cmd_dword * 4;
...@@ -174,7 +174,7 @@ static bool hisi_sfc_v3xx_supports_op(struct spi_mem *mem, ...@@ -174,7 +174,7 @@ static bool hisi_sfc_v3xx_supports_op(struct spi_mem *mem,
struct spi_device *spi = mem->spi; struct spi_device *spi = mem->spi;
struct hisi_sfc_v3xx_host *host; struct hisi_sfc_v3xx_host *host;
host = spi_controller_get_devdata(spi->master); host = spi_controller_get_devdata(spi->controller);
if (op->data.buswidth > 4 || op->dummy.buswidth > 4 || if (op->data.buswidth > 4 || op->dummy.buswidth > 4 ||
op->addr.buswidth > 4 || op->cmd.buswidth > 4) op->addr.buswidth > 4 || op->cmd.buswidth > 4)
...@@ -363,7 +363,7 @@ static int hisi_sfc_v3xx_exec_op(struct spi_mem *mem, ...@@ -363,7 +363,7 @@ static int hisi_sfc_v3xx_exec_op(struct spi_mem *mem,
struct spi_device *spi = mem->spi; struct spi_device *spi = mem->spi;
u8 chip_select = spi_get_chipselect(spi, 0); u8 chip_select = spi_get_chipselect(spi, 0);
host = spi_controller_get_devdata(spi->master); host = spi_controller_get_devdata(spi->controller);
return hisi_sfc_v3xx_generic_exec_op(host, op, chip_select); return hisi_sfc_v3xx_generic_exec_op(host, op, chip_select);
} }
...@@ -431,7 +431,7 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev) ...@@ -431,7 +431,7 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
u32 version, glb_config; u32 version, glb_config;
int ret; int ret;
ctlr = spi_alloc_master(&pdev->dev, sizeof(*host)); ctlr = spi_alloc_host(&pdev->dev, sizeof(*host));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
...@@ -448,13 +448,13 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev) ...@@ -448,13 +448,13 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
host->regbase = devm_platform_ioremap_resource(pdev, 0); host->regbase = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(host->regbase)) { if (IS_ERR(host->regbase)) {
ret = PTR_ERR(host->regbase); ret = PTR_ERR(host->regbase);
goto err_put_master; goto err_put_host;
} }
host->irq = platform_get_irq_optional(pdev, 0); host->irq = platform_get_irq_optional(pdev, 0);
if (host->irq == -EPROBE_DEFER) { if (host->irq == -EPROBE_DEFER) {
ret = -EPROBE_DEFER; ret = -EPROBE_DEFER;
goto err_put_master; goto err_put_host;
} }
hisi_sfc_v3xx_disable_int(host); hisi_sfc_v3xx_disable_int(host);
...@@ -496,15 +496,15 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev) ...@@ -496,15 +496,15 @@ static int hisi_sfc_v3xx_probe(struct platform_device *pdev)
ret = devm_spi_register_controller(dev, ctlr); ret = devm_spi_register_controller(dev, ctlr);
if (ret) if (ret)
goto err_put_master; goto err_put_host;
dev_info(&pdev->dev, "hw version 0x%x, %s mode.\n", dev_info(&pdev->dev, "hw version 0x%x, %s mode.\n",
version, host->irq ? "irq" : "polling"); version, host->irq ? "irq" : "polling");
return 0; return 0;
err_put_master: err_put_host:
spi_master_put(ctlr); spi_controller_put(ctlr);
return ret; return ret;
} }
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
struct img_spfi { struct img_spfi {
struct device *dev; struct device *dev;
struct spi_master *master; struct spi_controller *host;
spinlock_t lock; spinlock_t lock;
void __iomem *regs; void __iomem *regs;
...@@ -221,11 +221,11 @@ static unsigned int spfi_pio_read8(struct img_spfi *spfi, u8 *buf, ...@@ -221,11 +221,11 @@ static unsigned int spfi_pio_read8(struct img_spfi *spfi, u8 *buf,
return count; return count;
} }
static int img_spfi_start_pio(struct spi_master *master, static int img_spfi_start_pio(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct img_spfi *spfi = spi_master_get_devdata(spi->master); struct img_spfi *spfi = spi_controller_get_devdata(spi->controller);
unsigned int tx_bytes = 0, rx_bytes = 0; unsigned int tx_bytes = 0, rx_bytes = 0;
const void *tx_buf = xfer->tx_buf; const void *tx_buf = xfer->tx_buf;
void *rx_buf = xfer->rx_buf; void *rx_buf = xfer->rx_buf;
...@@ -285,7 +285,7 @@ static void img_spfi_dma_rx_cb(void *data) ...@@ -285,7 +285,7 @@ static void img_spfi_dma_rx_cb(void *data)
spin_lock_irqsave(&spfi->lock, flags); spin_lock_irqsave(&spfi->lock, flags);
spfi->rx_dma_busy = false; spfi->rx_dma_busy = false;
if (!spfi->tx_dma_busy) if (!spfi->tx_dma_busy)
spi_finalize_current_transfer(spfi->master); spi_finalize_current_transfer(spfi->host);
spin_unlock_irqrestore(&spfi->lock, flags); spin_unlock_irqrestore(&spfi->lock, flags);
} }
...@@ -299,15 +299,15 @@ static void img_spfi_dma_tx_cb(void *data) ...@@ -299,15 +299,15 @@ static void img_spfi_dma_tx_cb(void *data)
spin_lock_irqsave(&spfi->lock, flags); spin_lock_irqsave(&spfi->lock, flags);
spfi->tx_dma_busy = false; spfi->tx_dma_busy = false;
if (!spfi->rx_dma_busy) if (!spfi->rx_dma_busy)
spi_finalize_current_transfer(spfi->master); spi_finalize_current_transfer(spfi->host);
spin_unlock_irqrestore(&spfi->lock, flags); spin_unlock_irqrestore(&spfi->lock, flags);
} }
static int img_spfi_start_dma(struct spi_master *master, static int img_spfi_start_dma(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct img_spfi *spfi = spi_master_get_devdata(spi->master); struct img_spfi *spfi = spi_controller_get_devdata(spi->controller);
struct dma_async_tx_descriptor *rxdesc = NULL, *txdesc = NULL; struct dma_async_tx_descriptor *rxdesc = NULL, *txdesc = NULL;
struct dma_slave_config rxconf, txconf; struct dma_slave_config rxconf, txconf;
...@@ -384,10 +384,10 @@ static int img_spfi_start_dma(struct spi_master *master, ...@@ -384,10 +384,10 @@ static int img_spfi_start_dma(struct spi_master *master,
return -EIO; return -EIO;
} }
static void img_spfi_handle_err(struct spi_master *master, static void img_spfi_handle_err(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct img_spfi *spfi = spi_master_get_devdata(master); struct img_spfi *spfi = spi_controller_get_devdata(host);
unsigned long flags; unsigned long flags;
/* /*
...@@ -405,9 +405,9 @@ static void img_spfi_handle_err(struct spi_master *master, ...@@ -405,9 +405,9 @@ static void img_spfi_handle_err(struct spi_master *master,
spin_unlock_irqrestore(&spfi->lock, flags); spin_unlock_irqrestore(&spfi->lock, flags);
} }
static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg) static int img_spfi_prepare(struct spi_controller *host, struct spi_message *msg)
{ {
struct img_spfi *spfi = spi_master_get_devdata(master); struct img_spfi *spfi = spi_controller_get_devdata(host);
u32 val; u32 val;
val = spfi_readl(spfi, SPFI_PORT_STATE); val = spfi_readl(spfi, SPFI_PORT_STATE);
...@@ -427,20 +427,20 @@ static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg) ...@@ -427,20 +427,20 @@ static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg)
return 0; return 0;
} }
static int img_spfi_unprepare(struct spi_master *master, static int img_spfi_unprepare(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct img_spfi *spfi = spi_master_get_devdata(master); struct img_spfi *spfi = spi_controller_get_devdata(host);
spfi_reset(spfi); spfi_reset(spfi);
return 0; return 0;
} }
static void img_spfi_config(struct spi_master *master, struct spi_device *spi, static void img_spfi_config(struct spi_controller *host, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct img_spfi *spfi = spi_master_get_devdata(spi->master); struct img_spfi *spfi = spi_controller_get_devdata(spi->controller);
u32 val, div; u32 val, div;
/* /*
...@@ -476,11 +476,11 @@ static void img_spfi_config(struct spi_master *master, struct spi_device *spi, ...@@ -476,11 +476,11 @@ static void img_spfi_config(struct spi_master *master, struct spi_device *spi,
spfi_writel(spfi, val, SPFI_CONTROL); spfi_writel(spfi, val, SPFI_CONTROL);
} }
static int img_spfi_transfer_one(struct spi_master *master, static int img_spfi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct img_spfi *spfi = spi_master_get_devdata(spi->master); struct img_spfi *spfi = spi_controller_get_devdata(spi->controller);
int ret; int ret;
if (xfer->len > SPFI_TRANSACTION_TSIZE_MASK) { if (xfer->len > SPFI_TRANSACTION_TSIZE_MASK) {
...@@ -490,16 +490,16 @@ static int img_spfi_transfer_one(struct spi_master *master, ...@@ -490,16 +490,16 @@ static int img_spfi_transfer_one(struct spi_master *master,
return -EINVAL; return -EINVAL;
} }
img_spfi_config(master, spi, xfer); img_spfi_config(host, spi, xfer);
if (master->can_dma && master->can_dma(master, spi, xfer)) if (host->can_dma && host->can_dma(host, spi, xfer))
ret = img_spfi_start_dma(master, spi, xfer); ret = img_spfi_start_dma(host, spi, xfer);
else else
ret = img_spfi_start_pio(master, spi, xfer); ret = img_spfi_start_pio(host, spi, xfer);
return ret; return ret;
} }
static bool img_spfi_can_dma(struct spi_master *master, struct spi_device *spi, static bool img_spfi_can_dma(struct spi_controller *host, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
if (xfer->len > SPFI_32BIT_FIFO_SIZE) if (xfer->len > SPFI_32BIT_FIFO_SIZE)
...@@ -524,20 +524,20 @@ static irqreturn_t img_spfi_irq(int irq, void *dev_id) ...@@ -524,20 +524,20 @@ static irqreturn_t img_spfi_irq(int irq, void *dev_id)
static int img_spfi_probe(struct platform_device *pdev) static int img_spfi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct img_spfi *spfi; struct img_spfi *spfi;
struct resource *res; struct resource *res;
int ret; int ret;
u32 max_speed_hz; u32 max_speed_hz;
master = spi_alloc_master(&pdev->dev, sizeof(*spfi)); host = spi_alloc_host(&pdev->dev, sizeof(*spfi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
spfi = spi_master_get_devdata(master); spfi = spi_controller_get_devdata(host);
spfi->dev = &pdev->dev; spfi->dev = &pdev->dev;
spfi->master = master; spfi->host = host;
spin_lock_init(&spfi->lock); spin_lock_init(&spfi->lock);
spfi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); spfi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
...@@ -582,15 +582,15 @@ static int img_spfi_probe(struct platform_device *pdev) ...@@ -582,15 +582,15 @@ static int img_spfi_probe(struct platform_device *pdev)
*/ */
spfi_writel(spfi, SPFI_INTERRUPT_IACCESS, SPFI_INTERRUPT_ENABLE); spfi_writel(spfi, SPFI_INTERRUPT_IACCESS, SPFI_INTERRUPT_ENABLE);
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_DUAL | SPI_RX_DUAL; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_DUAL | SPI_RX_DUAL;
if (of_property_read_bool(spfi->dev->of_node, "img,supports-quad-mode")) if (of_property_read_bool(spfi->dev->of_node, "img,supports-quad-mode"))
master->mode_bits |= SPI_TX_QUAD | SPI_RX_QUAD; host->mode_bits |= SPI_TX_QUAD | SPI_RX_QUAD;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(8);
master->max_speed_hz = clk_get_rate(spfi->spfi_clk) / 4; host->max_speed_hz = clk_get_rate(spfi->spfi_clk) / 4;
master->min_speed_hz = clk_get_rate(spfi->spfi_clk) / 512; host->min_speed_hz = clk_get_rate(spfi->spfi_clk) / 512;
/* /*
* Maximum speed supported by spfi is limited to the lower value * Maximum speed supported by spfi is limited to the lower value
...@@ -601,15 +601,15 @@ static int img_spfi_probe(struct platform_device *pdev) ...@@ -601,15 +601,15 @@ static int img_spfi_probe(struct platform_device *pdev)
*/ */
if (!of_property_read_u32(spfi->dev->of_node, "spfi-max-frequency", if (!of_property_read_u32(spfi->dev->of_node, "spfi-max-frequency",
&max_speed_hz)) { &max_speed_hz)) {
if (master->max_speed_hz > max_speed_hz) if (host->max_speed_hz > max_speed_hz)
master->max_speed_hz = max_speed_hz; host->max_speed_hz = max_speed_hz;
} }
master->transfer_one = img_spfi_transfer_one; host->transfer_one = img_spfi_transfer_one;
master->prepare_message = img_spfi_prepare; host->prepare_message = img_spfi_prepare;
master->unprepare_message = img_spfi_unprepare; host->unprepare_message = img_spfi_unprepare;
master->handle_err = img_spfi_handle_err; host->handle_err = img_spfi_handle_err;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
spfi->tx_ch = dma_request_chan(spfi->dev, "tx"); spfi->tx_ch = dma_request_chan(spfi->dev, "tx");
if (IS_ERR(spfi->tx_ch)) { if (IS_ERR(spfi->tx_ch)) {
...@@ -636,15 +636,15 @@ static int img_spfi_probe(struct platform_device *pdev) ...@@ -636,15 +636,15 @@ static int img_spfi_probe(struct platform_device *pdev)
spfi->rx_ch = NULL; spfi->rx_ch = NULL;
dev_warn(spfi->dev, "Failed to get DMA channels, falling back to PIO mode\n"); dev_warn(spfi->dev, "Failed to get DMA channels, falling back to PIO mode\n");
} else { } else {
master->dma_tx = spfi->tx_ch; host->dma_tx = spfi->tx_ch;
master->dma_rx = spfi->rx_ch; host->dma_rx = spfi->rx_ch;
master->can_dma = img_spfi_can_dma; host->can_dma = img_spfi_can_dma;
} }
pm_runtime_set_active(spfi->dev); pm_runtime_set_active(spfi->dev);
pm_runtime_enable(spfi->dev); pm_runtime_enable(spfi->dev);
ret = devm_spi_register_master(spfi->dev, master); ret = devm_spi_register_controller(spfi->dev, host);
if (ret) if (ret)
goto disable_pm; goto disable_pm;
...@@ -660,15 +660,15 @@ static int img_spfi_probe(struct platform_device *pdev) ...@@ -660,15 +660,15 @@ static int img_spfi_probe(struct platform_device *pdev)
disable_pclk: disable_pclk:
clk_disable_unprepare(spfi->sys_clk); clk_disable_unprepare(spfi->sys_clk);
put_spi: put_spi:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void img_spfi_remove(struct platform_device *pdev) static void img_spfi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct img_spfi *spfi = spi_master_get_devdata(master); struct img_spfi *spfi = spi_controller_get_devdata(host);
if (spfi->tx_ch) if (spfi->tx_ch)
dma_release_channel(spfi->tx_ch); dma_release_channel(spfi->tx_ch);
...@@ -685,8 +685,8 @@ static void img_spfi_remove(struct platform_device *pdev) ...@@ -685,8 +685,8 @@ static void img_spfi_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int img_spfi_runtime_suspend(struct device *dev) static int img_spfi_runtime_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct img_spfi *spfi = spi_master_get_devdata(master); struct img_spfi *spfi = spi_controller_get_devdata(host);
clk_disable_unprepare(spfi->spfi_clk); clk_disable_unprepare(spfi->spfi_clk);
clk_disable_unprepare(spfi->sys_clk); clk_disable_unprepare(spfi->sys_clk);
...@@ -696,8 +696,8 @@ static int img_spfi_runtime_suspend(struct device *dev) ...@@ -696,8 +696,8 @@ static int img_spfi_runtime_suspend(struct device *dev)
static int img_spfi_runtime_resume(struct device *dev) static int img_spfi_runtime_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct img_spfi *spfi = spi_master_get_devdata(master); struct img_spfi *spfi = spi_controller_get_devdata(host);
int ret; int ret;
ret = clk_prepare_enable(spfi->sys_clk); ret = clk_prepare_enable(spfi->sys_clk);
...@@ -716,15 +716,15 @@ static int img_spfi_runtime_resume(struct device *dev) ...@@ -716,15 +716,15 @@ static int img_spfi_runtime_resume(struct device *dev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int img_spfi_suspend(struct device *dev) static int img_spfi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
return spi_master_suspend(master); return spi_controller_suspend(host);
} }
static int img_spfi_resume(struct device *dev) static int img_spfi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct img_spfi *spfi = spi_master_get_devdata(master); struct img_spfi *spfi = spi_controller_get_devdata(host);
int ret; int ret;
ret = pm_runtime_resume_and_get(dev); ret = pm_runtime_resume_and_get(dev);
...@@ -733,7 +733,7 @@ static int img_spfi_resume(struct device *dev) ...@@ -733,7 +733,7 @@ static int img_spfi_resume(struct device *dev)
spfi_reset(spfi); spfi_reset(spfi);
pm_runtime_put(dev); pm_runtime_put(dev);
return spi_master_resume(master); return spi_controller_resume(host);
} }
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
......
...@@ -52,7 +52,7 @@ MODULE_PARM_DESC(polling_limit_us, ...@@ -52,7 +52,7 @@ MODULE_PARM_DESC(polling_limit_us,
/* The maximum bytes that a sdma BD can transfer. */ /* The maximum bytes that a sdma BD can transfer. */
#define MAX_SDMA_BD_BYTES (1 << 15) #define MAX_SDMA_BD_BYTES (1 << 15)
#define MX51_ECSPI_CTRL_MAX_BURST 512 #define MX51_ECSPI_CTRL_MAX_BURST 512
/* The maximum bytes that IMX53_ECSPI can transfer in slave mode.*/ /* The maximum bytes that IMX53_ECSPI can transfer in target mode.*/
#define MX53_MAX_TRANSFER_BYTES 512 #define MX53_MAX_TRANSFER_BYTES 512
enum spi_imx_devtype { enum spi_imx_devtype {
...@@ -77,7 +77,7 @@ struct spi_imx_devtype_data { ...@@ -77,7 +77,7 @@ struct spi_imx_devtype_data {
void (*setup_wml)(struct spi_imx_data *spi_imx); void (*setup_wml)(struct spi_imx_data *spi_imx);
void (*disable)(struct spi_imx_data *spi_imx); void (*disable)(struct spi_imx_data *spi_imx);
bool has_dmamode; bool has_dmamode;
bool has_slavemode; bool has_targetmode;
unsigned int fifo_size; unsigned int fifo_size;
bool dynamic_burst; bool dynamic_burst;
/* /*
...@@ -113,10 +113,10 @@ struct spi_imx_data { ...@@ -113,10 +113,10 @@ struct spi_imx_data {
unsigned int dynamic_burst; unsigned int dynamic_burst;
bool rx_only; bool rx_only;
/* Slave mode */ /* Target mode */
bool slave_mode; bool target_mode;
bool slave_aborted; bool target_aborted;
unsigned int slave_burst; unsigned int target_burst;
/* DMA */ /* DMA */
bool usedma; bool usedma;
...@@ -240,7 +240,7 @@ static bool spi_imx_can_dma(struct spi_controller *controller, struct spi_device ...@@ -240,7 +240,7 @@ static bool spi_imx_can_dma(struct spi_controller *controller, struct spi_device
if (!controller->dma_rx) if (!controller->dma_rx)
return false; return false;
if (spi_imx->slave_mode) if (spi_imx->target_mode)
return false; return false;
if (transfer->len < spi_imx->devtype_data->fifo_size) if (transfer->len < spi_imx->devtype_data->fifo_size)
...@@ -404,12 +404,12 @@ static void spi_imx_buf_tx_swap(struct spi_imx_data *spi_imx) ...@@ -404,12 +404,12 @@ static void spi_imx_buf_tx_swap(struct spi_imx_data *spi_imx)
writel(val, spi_imx->base + MXC_CSPITXDATA); writel(val, spi_imx->base + MXC_CSPITXDATA);
} }
static void mx53_ecspi_rx_slave(struct spi_imx_data *spi_imx) static void mx53_ecspi_rx_target(struct spi_imx_data *spi_imx)
{ {
u32 val = be32_to_cpu(readl(spi_imx->base + MXC_CSPIRXDATA)); u32 val = be32_to_cpu(readl(spi_imx->base + MXC_CSPIRXDATA));
if (spi_imx->rx_buf) { if (spi_imx->rx_buf) {
int n_bytes = spi_imx->slave_burst % sizeof(val); int n_bytes = spi_imx->target_burst % sizeof(val);
if (!n_bytes) if (!n_bytes)
n_bytes = sizeof(val); n_bytes = sizeof(val);
...@@ -418,13 +418,13 @@ static void mx53_ecspi_rx_slave(struct spi_imx_data *spi_imx) ...@@ -418,13 +418,13 @@ static void mx53_ecspi_rx_slave(struct spi_imx_data *spi_imx)
((u8 *)&val) + sizeof(val) - n_bytes, n_bytes); ((u8 *)&val) + sizeof(val) - n_bytes, n_bytes);
spi_imx->rx_buf += n_bytes; spi_imx->rx_buf += n_bytes;
spi_imx->slave_burst -= n_bytes; spi_imx->target_burst -= n_bytes;
} }
spi_imx->remainder -= sizeof(u32); spi_imx->remainder -= sizeof(u32);
} }
static void mx53_ecspi_tx_slave(struct spi_imx_data *spi_imx) static void mx53_ecspi_tx_target(struct spi_imx_data *spi_imx)
{ {
u32 val = 0; u32 val = 0;
int n_bytes = spi_imx->count % sizeof(val); int n_bytes = spi_imx->count % sizeof(val);
...@@ -535,8 +535,8 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx, ...@@ -535,8 +535,8 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
u32 current_cfg = cfg; u32 current_cfg = cfg;
int channel = mx51_ecspi_channel(spi); int channel = mx51_ecspi_channel(spi);
/* set Master or Slave mode */ /* set Host or Target mode */
if (spi_imx->slave_mode) if (spi_imx->target_mode)
ctrl &= ~MX51_ECSPI_CTRL_MODE_MASK; ctrl &= ~MX51_ECSPI_CTRL_MODE_MASK;
else else
ctrl |= MX51_ECSPI_CTRL_MODE_MASK; ctrl |= MX51_ECSPI_CTRL_MODE_MASK;
...@@ -564,11 +564,11 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx, ...@@ -564,11 +564,11 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
writel(testreg, spi_imx->base + MX51_ECSPI_TESTREG); writel(testreg, spi_imx->base + MX51_ECSPI_TESTREG);
/* /*
* eCSPI burst completion by Chip Select signal in Slave mode * eCSPI burst completion by Chip Select signal in Target mode
* is not functional for imx53 Soc, config SPI burst completed when * is not functional for imx53 Soc, config SPI burst completed when
* BURST_LENGTH + 1 bits are received * BURST_LENGTH + 1 bits are received
*/ */
if (spi_imx->slave_mode && is_imx53_ecspi(spi_imx)) if (spi_imx->target_mode && is_imx53_ecspi(spi_imx))
cfg &= ~MX51_ECSPI_CONFIG_SBBCTRL(channel); cfg &= ~MX51_ECSPI_CONFIG_SBBCTRL(channel);
else else
cfg |= MX51_ECSPI_CONFIG_SBBCTRL(channel); cfg |= MX51_ECSPI_CONFIG_SBBCTRL(channel);
...@@ -655,8 +655,8 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, ...@@ -655,8 +655,8 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
/* Clear BL field and set the right value */ /* Clear BL field and set the right value */
ctrl &= ~MX51_ECSPI_CTRL_BL_MASK; ctrl &= ~MX51_ECSPI_CTRL_BL_MASK;
if (spi_imx->slave_mode && is_imx53_ecspi(spi_imx)) if (spi_imx->target_mode && is_imx53_ecspi(spi_imx))
ctrl |= (spi_imx->slave_burst * 8 - 1) ctrl |= (spi_imx->target_burst * 8 - 1)
<< MX51_ECSPI_CTRL_BL_OFFSET; << MX51_ECSPI_CTRL_BL_OFFSET;
else { else {
if (spi_imx->count >= 512) if (spi_imx->count >= 512)
...@@ -721,7 +721,7 @@ static void mx51_ecspi_reset(struct spi_imx_data *spi_imx) ...@@ -721,7 +721,7 @@ static void mx51_ecspi_reset(struct spi_imx_data *spi_imx)
#define MX31_INTREG_RREN (1 << 3) #define MX31_INTREG_RREN (1 << 3)
#define MX31_CSPICTRL_ENABLE (1 << 0) #define MX31_CSPICTRL_ENABLE (1 << 0)
#define MX31_CSPICTRL_MASTER (1 << 1) #define MX31_CSPICTRL_HOST (1 << 1)
#define MX31_CSPICTRL_XCH (1 << 2) #define MX31_CSPICTRL_XCH (1 << 2)
#define MX31_CSPICTRL_SMC (1 << 3) #define MX31_CSPICTRL_SMC (1 << 3)
#define MX31_CSPICTRL_POL (1 << 4) #define MX31_CSPICTRL_POL (1 << 4)
...@@ -778,7 +778,7 @@ static int mx31_prepare_message(struct spi_imx_data *spi_imx, ...@@ -778,7 +778,7 @@ static int mx31_prepare_message(struct spi_imx_data *spi_imx,
static int mx31_prepare_transfer(struct spi_imx_data *spi_imx, static int mx31_prepare_transfer(struct spi_imx_data *spi_imx,
struct spi_device *spi) struct spi_device *spi)
{ {
unsigned int reg = MX31_CSPICTRL_ENABLE | MX31_CSPICTRL_MASTER; unsigned int reg = MX31_CSPICTRL_ENABLE | MX31_CSPICTRL_HOST;
unsigned int clk; unsigned int clk;
reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, spi_imx->spi_bus_clk, &clk) << reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, spi_imx->spi_bus_clk, &clk) <<
...@@ -848,7 +848,7 @@ static void mx31_reset(struct spi_imx_data *spi_imx) ...@@ -848,7 +848,7 @@ static void mx31_reset(struct spi_imx_data *spi_imx)
#define MX21_CSPICTRL_SSPOL (1 << 8) #define MX21_CSPICTRL_SSPOL (1 << 8)
#define MX21_CSPICTRL_XCH (1 << 9) #define MX21_CSPICTRL_XCH (1 << 9)
#define MX21_CSPICTRL_ENABLE (1 << 10) #define MX21_CSPICTRL_ENABLE (1 << 10)
#define MX21_CSPICTRL_MASTER (1 << 11) #define MX21_CSPICTRL_HOST (1 << 11)
#define MX21_CSPICTRL_DR_SHIFT 14 #define MX21_CSPICTRL_DR_SHIFT 14
#define MX21_CSPICTRL_CS_SHIFT 19 #define MX21_CSPICTRL_CS_SHIFT 19
...@@ -882,7 +882,7 @@ static int mx21_prepare_message(struct spi_imx_data *spi_imx, ...@@ -882,7 +882,7 @@ static int mx21_prepare_message(struct spi_imx_data *spi_imx,
static int mx21_prepare_transfer(struct spi_imx_data *spi_imx, static int mx21_prepare_transfer(struct spi_imx_data *spi_imx,
struct spi_device *spi) struct spi_device *spi)
{ {
unsigned int reg = MX21_CSPICTRL_ENABLE | MX21_CSPICTRL_MASTER; unsigned int reg = MX21_CSPICTRL_ENABLE | MX21_CSPICTRL_HOST;
unsigned int max = is_imx27_cspi(spi_imx) ? 16 : 18; unsigned int max = is_imx27_cspi(spi_imx) ? 16 : 18;
unsigned int clk; unsigned int clk;
...@@ -924,7 +924,7 @@ static void mx21_reset(struct spi_imx_data *spi_imx) ...@@ -924,7 +924,7 @@ static void mx21_reset(struct spi_imx_data *spi_imx)
#define MX1_CSPICTRL_PHA (1 << 5) #define MX1_CSPICTRL_PHA (1 << 5)
#define MX1_CSPICTRL_XCH (1 << 8) #define MX1_CSPICTRL_XCH (1 << 8)
#define MX1_CSPICTRL_ENABLE (1 << 9) #define MX1_CSPICTRL_ENABLE (1 << 9)
#define MX1_CSPICTRL_MASTER (1 << 10) #define MX1_CSPICTRL_HOST (1 << 10)
#define MX1_CSPICTRL_DR_SHIFT 13 #define MX1_CSPICTRL_DR_SHIFT 13
static void mx1_intctrl(struct spi_imx_data *spi_imx, int enable) static void mx1_intctrl(struct spi_imx_data *spi_imx, int enable)
...@@ -957,7 +957,7 @@ static int mx1_prepare_message(struct spi_imx_data *spi_imx, ...@@ -957,7 +957,7 @@ static int mx1_prepare_message(struct spi_imx_data *spi_imx,
static int mx1_prepare_transfer(struct spi_imx_data *spi_imx, static int mx1_prepare_transfer(struct spi_imx_data *spi_imx,
struct spi_device *spi) struct spi_device *spi)
{ {
unsigned int reg = MX1_CSPICTRL_ENABLE | MX1_CSPICTRL_MASTER; unsigned int reg = MX1_CSPICTRL_ENABLE | MX1_CSPICTRL_HOST;
unsigned int clk; unsigned int clk;
reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, spi_imx->spi_bus_clk, &clk) << reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, spi_imx->spi_bus_clk, &clk) <<
...@@ -996,7 +996,7 @@ static struct spi_imx_devtype_data imx1_cspi_devtype_data = { ...@@ -996,7 +996,7 @@ static struct spi_imx_devtype_data imx1_cspi_devtype_data = {
.fifo_size = 8, .fifo_size = 8,
.has_dmamode = false, .has_dmamode = false,
.dynamic_burst = false, .dynamic_burst = false,
.has_slavemode = false, .has_targetmode = false,
.devtype = IMX1_CSPI, .devtype = IMX1_CSPI,
}; };
...@@ -1010,7 +1010,7 @@ static struct spi_imx_devtype_data imx21_cspi_devtype_data = { ...@@ -1010,7 +1010,7 @@ static struct spi_imx_devtype_data imx21_cspi_devtype_data = {
.fifo_size = 8, .fifo_size = 8,
.has_dmamode = false, .has_dmamode = false,
.dynamic_burst = false, .dynamic_burst = false,
.has_slavemode = false, .has_targetmode = false,
.devtype = IMX21_CSPI, .devtype = IMX21_CSPI,
}; };
...@@ -1025,7 +1025,7 @@ static struct spi_imx_devtype_data imx27_cspi_devtype_data = { ...@@ -1025,7 +1025,7 @@ static struct spi_imx_devtype_data imx27_cspi_devtype_data = {
.fifo_size = 8, .fifo_size = 8,
.has_dmamode = false, .has_dmamode = false,
.dynamic_burst = false, .dynamic_burst = false,
.has_slavemode = false, .has_targetmode = false,
.devtype = IMX27_CSPI, .devtype = IMX27_CSPI,
}; };
...@@ -1039,7 +1039,7 @@ static struct spi_imx_devtype_data imx31_cspi_devtype_data = { ...@@ -1039,7 +1039,7 @@ static struct spi_imx_devtype_data imx31_cspi_devtype_data = {
.fifo_size = 8, .fifo_size = 8,
.has_dmamode = false, .has_dmamode = false,
.dynamic_burst = false, .dynamic_burst = false,
.has_slavemode = false, .has_targetmode = false,
.devtype = IMX31_CSPI, .devtype = IMX31_CSPI,
}; };
...@@ -1054,7 +1054,7 @@ static struct spi_imx_devtype_data imx35_cspi_devtype_data = { ...@@ -1054,7 +1054,7 @@ static struct spi_imx_devtype_data imx35_cspi_devtype_data = {
.fifo_size = 8, .fifo_size = 8,
.has_dmamode = true, .has_dmamode = true,
.dynamic_burst = false, .dynamic_burst = false,
.has_slavemode = false, .has_targetmode = false,
.devtype = IMX35_CSPI, .devtype = IMX35_CSPI,
}; };
...@@ -1069,7 +1069,7 @@ static struct spi_imx_devtype_data imx51_ecspi_devtype_data = { ...@@ -1069,7 +1069,7 @@ static struct spi_imx_devtype_data imx51_ecspi_devtype_data = {
.fifo_size = 64, .fifo_size = 64,
.has_dmamode = true, .has_dmamode = true,
.dynamic_burst = true, .dynamic_burst = true,
.has_slavemode = true, .has_targetmode = true,
.disable = mx51_ecspi_disable, .disable = mx51_ecspi_disable,
.devtype = IMX51_ECSPI, .devtype = IMX51_ECSPI,
}; };
...@@ -1083,7 +1083,7 @@ static struct spi_imx_devtype_data imx53_ecspi_devtype_data = { ...@@ -1083,7 +1083,7 @@ static struct spi_imx_devtype_data imx53_ecspi_devtype_data = {
.reset = mx51_ecspi_reset, .reset = mx51_ecspi_reset,
.fifo_size = 64, .fifo_size = 64,
.has_dmamode = true, .has_dmamode = true,
.has_slavemode = true, .has_targetmode = true,
.disable = mx51_ecspi_disable, .disable = mx51_ecspi_disable,
.devtype = IMX53_ECSPI, .devtype = IMX53_ECSPI,
}; };
...@@ -1099,7 +1099,7 @@ static struct spi_imx_devtype_data imx6ul_ecspi_devtype_data = { ...@@ -1099,7 +1099,7 @@ static struct spi_imx_devtype_data imx6ul_ecspi_devtype_data = {
.fifo_size = 64, .fifo_size = 64,
.has_dmamode = true, .has_dmamode = true,
.dynamic_burst = true, .dynamic_burst = true,
.has_slavemode = true, .has_targetmode = true,
.tx_glitch_fixed = true, .tx_glitch_fixed = true,
.disable = mx51_ecspi_disable, .disable = mx51_ecspi_disable,
.devtype = IMX51_ECSPI, .devtype = IMX51_ECSPI,
...@@ -1164,7 +1164,7 @@ static void spi_imx_push(struct spi_imx_data *spi_imx) ...@@ -1164,7 +1164,7 @@ static void spi_imx_push(struct spi_imx_data *spi_imx)
spi_imx->txfifo++; spi_imx->txfifo++;
} }
if (!spi_imx->slave_mode) if (!spi_imx->target_mode)
spi_imx->devtype_data->trigger(spi_imx); spi_imx->devtype_data->trigger(spi_imx);
} }
...@@ -1268,7 +1268,7 @@ static int spi_imx_setupxfer(struct spi_device *spi, ...@@ -1268,7 +1268,7 @@ static int spi_imx_setupxfer(struct spi_device *spi,
* words, we have to use multiple word-size bursts, we can't use * words, we have to use multiple word-size bursts, we can't use
* dynamic_burst in that case. * dynamic_burst in that case.
*/ */
if (spi_imx->devtype_data->dynamic_burst && !spi_imx->slave_mode && if (spi_imx->devtype_data->dynamic_burst && !spi_imx->target_mode &&
!(spi->mode & SPI_CS_WORD) && !(spi->mode & SPI_CS_WORD) &&
(spi_imx->bits_per_word == 8 || (spi_imx->bits_per_word == 8 ||
spi_imx->bits_per_word == 16 || spi_imx->bits_per_word == 16 ||
...@@ -1300,10 +1300,10 @@ static int spi_imx_setupxfer(struct spi_device *spi, ...@@ -1300,10 +1300,10 @@ static int spi_imx_setupxfer(struct spi_device *spi,
spi_imx->rx_only = ((t->tx_buf == NULL) spi_imx->rx_only = ((t->tx_buf == NULL)
|| (t->tx_buf == spi->controller->dummy_tx)); || (t->tx_buf == spi->controller->dummy_tx));
if (is_imx53_ecspi(spi_imx) && spi_imx->slave_mode) { if (is_imx53_ecspi(spi_imx) && spi_imx->target_mode) {
spi_imx->rx = mx53_ecspi_rx_slave; spi_imx->rx = mx53_ecspi_rx_target;
spi_imx->tx = mx53_ecspi_tx_slave; spi_imx->tx = mx53_ecspi_tx_target;
spi_imx->slave_burst = t->len; spi_imx->target_burst = t->len;
} }
spi_imx->devtype_data->prepare_transfer(spi_imx, spi); spi_imx->devtype_data->prepare_transfer(spi_imx, spi);
...@@ -1568,8 +1568,8 @@ static int spi_imx_poll_transfer(struct spi_device *spi, ...@@ -1568,8 +1568,8 @@ static int spi_imx_poll_transfer(struct spi_device *spi,
return 0; return 0;
} }
static int spi_imx_pio_transfer_slave(struct spi_device *spi, static int spi_imx_pio_transfer_target(struct spi_device *spi,
struct spi_transfer *transfer) struct spi_transfer *transfer)
{ {
struct spi_imx_data *spi_imx = spi_controller_get_devdata(spi->controller); struct spi_imx_data *spi_imx = spi_controller_get_devdata(spi->controller);
int ret = 0; int ret = 0;
...@@ -1588,22 +1588,22 @@ static int spi_imx_pio_transfer_slave(struct spi_device *spi, ...@@ -1588,22 +1588,22 @@ static int spi_imx_pio_transfer_slave(struct spi_device *spi,
spi_imx->remainder = 0; spi_imx->remainder = 0;
reinit_completion(&spi_imx->xfer_done); reinit_completion(&spi_imx->xfer_done);
spi_imx->slave_aborted = false; spi_imx->target_aborted = false;
spi_imx_push(spi_imx); spi_imx_push(spi_imx);
spi_imx->devtype_data->intctrl(spi_imx, MXC_INT_TE | MXC_INT_RDR); spi_imx->devtype_data->intctrl(spi_imx, MXC_INT_TE | MXC_INT_RDR);
if (wait_for_completion_interruptible(&spi_imx->xfer_done) || if (wait_for_completion_interruptible(&spi_imx->xfer_done) ||
spi_imx->slave_aborted) { spi_imx->target_aborted) {
dev_dbg(&spi->dev, "interrupted\n"); dev_dbg(&spi->dev, "interrupted\n");
ret = -EINTR; ret = -EINTR;
} }
/* ecspi has a HW issue when works in Slave mode, /* ecspi has a HW issue when works in Target mode,
* after 64 words writtern to TXFIFO, even TXFIFO becomes empty, * after 64 words writtern to TXFIFO, even TXFIFO becomes empty,
* ECSPI_TXDATA keeps shift out the last word data, * ECSPI_TXDATA keeps shift out the last word data,
* so we have to disable ECSPI when in slave mode after the * so we have to disable ECSPI when in target mode after the
* transfer completes * transfer completes
*/ */
if (spi_imx->devtype_data->disable) if (spi_imx->devtype_data->disable)
...@@ -1626,8 +1626,8 @@ static int spi_imx_transfer_one(struct spi_controller *controller, ...@@ -1626,8 +1626,8 @@ static int spi_imx_transfer_one(struct spi_controller *controller,
while (spi_imx->devtype_data->rx_available(spi_imx)) while (spi_imx->devtype_data->rx_available(spi_imx))
readl(spi_imx->base + MXC_CSPIRXDATA); readl(spi_imx->base + MXC_CSPIRXDATA);
if (spi_imx->slave_mode) if (spi_imx->target_mode)
return spi_imx_pio_transfer_slave(spi, transfer); return spi_imx_pio_transfer_target(spi, transfer);
/* /*
* If we decided in spi_imx_can_dma() that we want to do a DMA * If we decided in spi_imx_can_dma() that we want to do a DMA
...@@ -1693,11 +1693,11 @@ spi_imx_unprepare_message(struct spi_controller *controller, struct spi_message ...@@ -1693,11 +1693,11 @@ spi_imx_unprepare_message(struct spi_controller *controller, struct spi_message
return 0; return 0;
} }
static int spi_imx_slave_abort(struct spi_controller *controller) static int spi_imx_target_abort(struct spi_controller *controller)
{ {
struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller); struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller);
spi_imx->slave_aborted = true; spi_imx->target_aborted = true;
complete(&spi_imx->xfer_done); complete(&spi_imx->xfer_done);
return 0; return 0;
...@@ -1712,17 +1712,17 @@ static int spi_imx_probe(struct platform_device *pdev) ...@@ -1712,17 +1712,17 @@ static int spi_imx_probe(struct platform_device *pdev)
int ret, irq, spi_drctl; int ret, irq, spi_drctl;
const struct spi_imx_devtype_data *devtype_data = const struct spi_imx_devtype_data *devtype_data =
of_device_get_match_data(&pdev->dev); of_device_get_match_data(&pdev->dev);
bool slave_mode; bool target_mode;
u32 val; u32 val;
slave_mode = devtype_data->has_slavemode && target_mode = devtype_data->has_targetmode &&
of_property_read_bool(np, "spi-slave"); of_property_read_bool(np, "spi-slave");
if (slave_mode) if (target_mode)
controller = spi_alloc_slave(&pdev->dev, controller = spi_alloc_target(&pdev->dev,
sizeof(struct spi_imx_data));
else
controller = spi_alloc_master(&pdev->dev,
sizeof(struct spi_imx_data)); sizeof(struct spi_imx_data));
else
controller = spi_alloc_host(&pdev->dev,
sizeof(struct spi_imx_data));
if (!controller) if (!controller)
return -ENOMEM; return -ENOMEM;
...@@ -1741,7 +1741,7 @@ static int spi_imx_probe(struct platform_device *pdev) ...@@ -1741,7 +1741,7 @@ static int spi_imx_probe(struct platform_device *pdev)
spi_imx = spi_controller_get_devdata(controller); spi_imx = spi_controller_get_devdata(controller);
spi_imx->controller = controller; spi_imx->controller = controller;
spi_imx->dev = &pdev->dev; spi_imx->dev = &pdev->dev;
spi_imx->slave_mode = slave_mode; spi_imx->target_mode = target_mode;
spi_imx->devtype_data = devtype_data; spi_imx->devtype_data = devtype_data;
...@@ -1761,7 +1761,7 @@ static int spi_imx_probe(struct platform_device *pdev) ...@@ -1761,7 +1761,7 @@ static int spi_imx_probe(struct platform_device *pdev)
controller->cleanup = spi_imx_cleanup; controller->cleanup = spi_imx_cleanup;
controller->prepare_message = spi_imx_prepare_message; controller->prepare_message = spi_imx_prepare_message;
controller->unprepare_message = spi_imx_unprepare_message; controller->unprepare_message = spi_imx_unprepare_message;
controller->slave_abort = spi_imx_slave_abort; controller->target_abort = spi_imx_target_abort;
controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS | controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_NO_CS |
SPI_MOSI_IDLE_LOW; SPI_MOSI_IDLE_LOW;
......
...@@ -392,7 +392,7 @@ static int spi_ingenic_probe(struct platform_device *pdev) ...@@ -392,7 +392,7 @@ static int spi_ingenic_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
ctlr = devm_spi_alloc_master(dev, sizeof(*priv)); ctlr = devm_spi_alloc_host(dev, sizeof(*priv));
if (!ctlr) { if (!ctlr) {
dev_err(dev, "Unable to allocate SPI controller.\n"); dev_err(dev, "Unable to allocate SPI controller.\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
* @base: Beginning of MMIO space * @base: Beginning of MMIO space
* @pregs: Start of protection registers * @pregs: Start of protection registers
* @sregs: Start of software sequencer registers * @sregs: Start of software sequencer registers
* @master: Pointer to the SPI controller structure * @host: Pointer to the SPI controller structure
* @nregions: Maximum number of regions * @nregions: Maximum number of regions
* @pr_num: Maximum number of protected range registers * @pr_num: Maximum number of protected range registers
* @chip0_size: Size of the first flash chip in bytes * @chip0_size: Size of the first flash chip in bytes
...@@ -161,7 +161,7 @@ struct intel_spi { ...@@ -161,7 +161,7 @@ struct intel_spi {
void __iomem *base; void __iomem *base;
void __iomem *pregs; void __iomem *pregs;
void __iomem *sregs; void __iomem *sregs;
struct spi_controller *master; struct spi_controller *host;
size_t nregions; size_t nregions;
size_t pr_num; size_t pr_num;
size_t chip0_size; size_t chip0_size;
...@@ -747,7 +747,7 @@ intel_spi_match_mem_op(struct intel_spi *ispi, const struct spi_mem_op *op) ...@@ -747,7 +747,7 @@ intel_spi_match_mem_op(struct intel_spi *ispi, const struct spi_mem_op *op)
static bool intel_spi_supports_mem_op(struct spi_mem *mem, static bool intel_spi_supports_mem_op(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct intel_spi *ispi = spi_master_get_devdata(mem->spi->master); struct intel_spi *ispi = spi_controller_get_devdata(mem->spi->controller);
const struct intel_spi_mem_op *iop; const struct intel_spi_mem_op *iop;
iop = intel_spi_match_mem_op(ispi, op); iop = intel_spi_match_mem_op(ispi, op);
...@@ -778,7 +778,7 @@ static bool intel_spi_supports_mem_op(struct spi_mem *mem, ...@@ -778,7 +778,7 @@ static bool intel_spi_supports_mem_op(struct spi_mem *mem,
static int intel_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) static int intel_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct intel_spi *ispi = spi_master_get_devdata(mem->spi->master); struct intel_spi *ispi = spi_controller_get_devdata(mem->spi->controller);
const struct intel_spi_mem_op *iop; const struct intel_spi_mem_op *iop;
iop = intel_spi_match_mem_op(ispi, op); iop = intel_spi_match_mem_op(ispi, op);
...@@ -790,7 +790,7 @@ static int intel_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *o ...@@ -790,7 +790,7 @@ static int intel_spi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *o
static const char *intel_spi_get_name(struct spi_mem *mem) static const char *intel_spi_get_name(struct spi_mem *mem)
{ {
const struct intel_spi *ispi = spi_master_get_devdata(mem->spi->master); const struct intel_spi *ispi = spi_controller_get_devdata(mem->spi->controller);
/* /*
* Return name of the flash controller device to be compatible * Return name of the flash controller device to be compatible
...@@ -801,7 +801,7 @@ static const char *intel_spi_get_name(struct spi_mem *mem) ...@@ -801,7 +801,7 @@ static const char *intel_spi_get_name(struct spi_mem *mem)
static int intel_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) static int intel_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
{ {
struct intel_spi *ispi = spi_master_get_devdata(desc->mem->spi->master); struct intel_spi *ispi = spi_controller_get_devdata(desc->mem->spi->controller);
const struct intel_spi_mem_op *iop; const struct intel_spi_mem_op *iop;
iop = intel_spi_match_mem_op(ispi, &desc->info.op_tmpl); iop = intel_spi_match_mem_op(ispi, &desc->info.op_tmpl);
...@@ -815,7 +815,7 @@ static int intel_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) ...@@ -815,7 +815,7 @@ static int intel_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
static ssize_t intel_spi_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, static ssize_t intel_spi_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs,
size_t len, void *buf) size_t len, void *buf)
{ {
struct intel_spi *ispi = spi_master_get_devdata(desc->mem->spi->master); struct intel_spi *ispi = spi_controller_get_devdata(desc->mem->spi->controller);
const struct intel_spi_mem_op *iop = desc->priv; const struct intel_spi_mem_op *iop = desc->priv;
struct spi_mem_op op = desc->info.op_tmpl; struct spi_mem_op op = desc->info.op_tmpl;
int ret; int ret;
...@@ -832,7 +832,7 @@ static ssize_t intel_spi_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, ...@@ -832,7 +832,7 @@ static ssize_t intel_spi_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs,
static ssize_t intel_spi_dirmap_write(struct spi_mem_dirmap_desc *desc, u64 offs, static ssize_t intel_spi_dirmap_write(struct spi_mem_dirmap_desc *desc, u64 offs,
size_t len, const void *buf) size_t len, const void *buf)
{ {
struct intel_spi *ispi = spi_master_get_devdata(desc->mem->spi->master); struct intel_spi *ispi = spi_controller_get_devdata(desc->mem->spi->controller);
const struct intel_spi_mem_op *iop = desc->priv; const struct intel_spi_mem_op *iop = desc->priv;
struct spi_mem_op op = desc->info.op_tmpl; struct spi_mem_op op = desc->info.op_tmpl;
int ret; int ret;
...@@ -1332,14 +1332,14 @@ static int intel_spi_read_desc(struct intel_spi *ispi) ...@@ -1332,14 +1332,14 @@ static int intel_spi_read_desc(struct intel_spi *ispi)
nc = (buf[1] & FLMAP0_NC_MASK) >> FLMAP0_NC_SHIFT; nc = (buf[1] & FLMAP0_NC_MASK) >> FLMAP0_NC_SHIFT;
if (!nc) if (!nc)
ispi->master->num_chipselect = 1; ispi->host->num_chipselect = 1;
else if (nc == 1) else if (nc == 1)
ispi->master->num_chipselect = 2; ispi->host->num_chipselect = 2;
else else
return -EINVAL; return -EINVAL;
dev_dbg(ispi->dev, "%u flash components found\n", dev_dbg(ispi->dev, "%u flash components found\n",
ispi->master->num_chipselect); ispi->host->num_chipselect);
return 0; return 0;
} }
...@@ -1365,7 +1365,7 @@ static int intel_spi_populate_chip(struct intel_spi *ispi) ...@@ -1365,7 +1365,7 @@ static int intel_spi_populate_chip(struct intel_spi *ispi)
snprintf(chip.modalias, 8, "spi-nor"); snprintf(chip.modalias, 8, "spi-nor");
chip.platform_data = pdata; chip.platform_data = pdata;
if (!spi_new_device(ispi->master, &chip)) if (!spi_new_device(ispi->host, &chip))
return -ENODEV; return -ENODEV;
ret = intel_spi_read_desc(ispi); ret = intel_spi_read_desc(ispi);
...@@ -1373,13 +1373,13 @@ static int intel_spi_populate_chip(struct intel_spi *ispi) ...@@ -1373,13 +1373,13 @@ static int intel_spi_populate_chip(struct intel_spi *ispi)
return ret; return ret;
/* Add the second chip if present */ /* Add the second chip if present */
if (ispi->master->num_chipselect < 2) if (ispi->host->num_chipselect < 2)
return 0; return 0;
chip.platform_data = NULL; chip.platform_data = NULL;
chip.chip_select = 1; chip.chip_select = 1;
if (!spi_new_device(ispi->master, &chip)) if (!spi_new_device(ispi->host, &chip))
return -ENODEV; return -ENODEV;
return 0; return 0;
} }
...@@ -1396,31 +1396,31 @@ static int intel_spi_populate_chip(struct intel_spi *ispi) ...@@ -1396,31 +1396,31 @@ static int intel_spi_populate_chip(struct intel_spi *ispi)
int intel_spi_probe(struct device *dev, struct resource *mem, int intel_spi_probe(struct device *dev, struct resource *mem,
const struct intel_spi_boardinfo *info) const struct intel_spi_boardinfo *info)
{ {
struct spi_controller *master; struct spi_controller *host;
struct intel_spi *ispi; struct intel_spi *ispi;
int ret; int ret;
master = devm_spi_alloc_master(dev, sizeof(*ispi)); host = devm_spi_alloc_host(dev, sizeof(*ispi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
master->mem_ops = &intel_spi_mem_ops; host->mem_ops = &intel_spi_mem_ops;
ispi = spi_master_get_devdata(master); ispi = spi_controller_get_devdata(host);
ispi->base = devm_ioremap_resource(dev, mem); ispi->base = devm_ioremap_resource(dev, mem);
if (IS_ERR(ispi->base)) if (IS_ERR(ispi->base))
return PTR_ERR(ispi->base); return PTR_ERR(ispi->base);
ispi->dev = dev; ispi->dev = dev;
ispi->master = master; ispi->host = host;
ispi->info = info; ispi->info = info;
ret = intel_spi_init(ispi); ret = intel_spi_init(ispi);
if (ret) if (ret)
return ret; return ret;
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret) if (ret)
return ret; return ret;
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#define JCORE_SPI_WAIT_RDY_MAX_LOOP 2000000 #define JCORE_SPI_WAIT_RDY_MAX_LOOP 2000000
struct jcore_spi { struct jcore_spi {
struct spi_master *master; struct spi_controller *host;
void __iomem *base; void __iomem *base;
unsigned int cs_reg; unsigned int cs_reg;
unsigned int speed_reg; unsigned int speed_reg;
...@@ -59,7 +59,7 @@ static void jcore_spi_program(struct jcore_spi *hw) ...@@ -59,7 +59,7 @@ static void jcore_spi_program(struct jcore_spi *hw)
void __iomem *ctrl_reg = hw->base + CTRL_REG; void __iomem *ctrl_reg = hw->base + CTRL_REG;
if (jcore_spi_wait(ctrl_reg)) if (jcore_spi_wait(ctrl_reg))
dev_err(hw->master->dev.parent, dev_err(hw->host->dev.parent,
"timeout waiting to program ctrl reg.\n"); "timeout waiting to program ctrl reg.\n");
writel(hw->cs_reg | hw->speed_reg, ctrl_reg); writel(hw->cs_reg | hw->speed_reg, ctrl_reg);
...@@ -67,10 +67,10 @@ static void jcore_spi_program(struct jcore_spi *hw) ...@@ -67,10 +67,10 @@ static void jcore_spi_program(struct jcore_spi *hw)
static void jcore_spi_chipsel(struct spi_device *spi, bool value) static void jcore_spi_chipsel(struct spi_device *spi, bool value)
{ {
struct jcore_spi *hw = spi_master_get_devdata(spi->master); struct jcore_spi *hw = spi_controller_get_devdata(spi->controller);
u32 csbit = 1U << (2 * spi_get_chipselect(spi, 0)); u32 csbit = 1U << (2 * spi_get_chipselect(spi, 0));
dev_dbg(hw->master->dev.parent, "chipselect %d\n", spi_get_chipselect(spi, 0)); dev_dbg(hw->host->dev.parent, "chipselect %d\n", spi_get_chipselect(spi, 0));
if (value) if (value)
hw->cs_reg |= csbit; hw->cs_reg |= csbit;
...@@ -90,14 +90,14 @@ static void jcore_spi_baudrate(struct jcore_spi *hw, int speed) ...@@ -90,14 +90,14 @@ static void jcore_spi_baudrate(struct jcore_spi *hw, int speed)
else else
hw->speed_reg = ((hw->clock_freq / 2 / speed) - 1) << 27; hw->speed_reg = ((hw->clock_freq / 2 / speed) - 1) << 27;
jcore_spi_program(hw); jcore_spi_program(hw);
dev_dbg(hw->master->dev.parent, "speed=%d reg=0x%x\n", dev_dbg(hw->host->dev.parent, "speed=%d reg=0x%x\n",
speed, hw->speed_reg); speed, hw->speed_reg);
} }
static int jcore_spi_txrx(struct spi_master *master, struct spi_device *spi, static int jcore_spi_txrx(struct spi_controller *host, struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct jcore_spi *hw = spi_master_get_devdata(master); struct jcore_spi *hw = spi_controller_get_devdata(host);
void __iomem *ctrl_reg = hw->base + CTRL_REG; void __iomem *ctrl_reg = hw->base + CTRL_REG;
void __iomem *data_reg = hw->base + DATA_REG; void __iomem *data_reg = hw->base + DATA_REG;
...@@ -130,7 +130,7 @@ static int jcore_spi_txrx(struct spi_master *master, struct spi_device *spi, ...@@ -130,7 +130,7 @@ static int jcore_spi_txrx(struct spi_master *master, struct spi_device *spi,
*rx++ = readl(data_reg); *rx++ = readl(data_reg);
} }
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
if (count < len) if (count < len)
return -EREMOTEIO; return -EREMOTEIO;
...@@ -142,26 +142,26 @@ static int jcore_spi_probe(struct platform_device *pdev) ...@@ -142,26 +142,26 @@ static int jcore_spi_probe(struct platform_device *pdev)
{ {
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
struct jcore_spi *hw; struct jcore_spi *hw;
struct spi_master *master; struct spi_controller *host;
struct resource *res; struct resource *res;
u32 clock_freq; u32 clock_freq;
struct clk *clk; struct clk *clk;
int err = -ENODEV; int err = -ENODEV;
master = spi_alloc_master(&pdev->dev, sizeof(struct jcore_spi)); host = spi_alloc_host(&pdev->dev, sizeof(struct jcore_spi));
if (!master) if (!host)
return err; return err;
/* Setup the master state. */ /* Setup the host state. */
master->num_chipselect = 3; host->num_chipselect = 3;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
master->transfer_one = jcore_spi_txrx; host->transfer_one = jcore_spi_txrx;
master->set_cs = jcore_spi_chipsel; host->set_cs = jcore_spi_chipsel;
master->dev.of_node = node; host->dev.of_node = node;
master->bus_num = pdev->id; host->bus_num = pdev->id;
hw = spi_master_get_devdata(master); hw = spi_controller_get_devdata(host);
hw->master = master; hw->host = host;
platform_set_drvdata(pdev, hw); platform_set_drvdata(pdev, hw);
/* Find and map our resources */ /* Find and map our resources */
...@@ -200,7 +200,7 @@ static int jcore_spi_probe(struct platform_device *pdev) ...@@ -200,7 +200,7 @@ static int jcore_spi_probe(struct platform_device *pdev)
jcore_spi_baudrate(hw, 400000); jcore_spi_baudrate(hw, 400000);
/* Register our spi controller */ /* Register our spi controller */
err = devm_spi_register_master(&pdev->dev, master); err = devm_spi_register_controller(&pdev->dev, host);
if (err) if (err)
goto exit; goto exit;
...@@ -209,7 +209,7 @@ static int jcore_spi_probe(struct platform_device *pdev) ...@@ -209,7 +209,7 @@ static int jcore_spi_probe(struct platform_device *pdev)
exit_busy: exit_busy:
err = -EBUSY; err = -EBUSY;
exit: exit:
spi_master_put(master); spi_controller_put(host);
return err; return err;
} }
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
#define LTQ_SPI_STAT_RE BIT(9) /* Receive error flag */ #define LTQ_SPI_STAT_RE BIT(9) /* Receive error flag */
#define LTQ_SPI_STAT_TE BIT(8) /* Transmit error flag */ #define LTQ_SPI_STAT_TE BIT(8) /* Transmit error flag */
#define LTQ_SPI_STAT_ME BIT(7) /* Mode error flag */ #define LTQ_SPI_STAT_ME BIT(7) /* Mode error flag */
#define LTQ_SPI_STAT_MS BIT(1) /* Master/slave select bit */ #define LTQ_SPI_STAT_MS BIT(1) /* Host/target select bit */
#define LTQ_SPI_STAT_EN BIT(0) /* Enable bit */ #define LTQ_SPI_STAT_EN BIT(0) /* Enable bit */
#define LTQ_SPI_STAT_ERRORS (LTQ_SPI_STAT_ME | LTQ_SPI_STAT_TE | \ #define LTQ_SPI_STAT_ERRORS (LTQ_SPI_STAT_ME | LTQ_SPI_STAT_TE | \
LTQ_SPI_STAT_RE | LTQ_SPI_STAT_AE | \ LTQ_SPI_STAT_RE | LTQ_SPI_STAT_AE | \
...@@ -110,8 +110,8 @@ ...@@ -110,8 +110,8 @@
#define LTQ_SPI_WHBSTATE_CLRME BIT(6) /* Clear mode error flag */ #define LTQ_SPI_WHBSTATE_CLRME BIT(6) /* Clear mode error flag */
#define LTQ_SPI_WHBSTATE_SETRUE BIT(5) /* Set receive underflow error flag */ #define LTQ_SPI_WHBSTATE_SETRUE BIT(5) /* Set receive underflow error flag */
#define LTQ_SPI_WHBSTATE_CLRRUE BIT(4) /* Clear receive underflow error flag */ #define LTQ_SPI_WHBSTATE_CLRRUE BIT(4) /* Clear receive underflow error flag */
#define LTQ_SPI_WHBSTATE_SETMS BIT(3) /* Set master select bit */ #define LTQ_SPI_WHBSTATE_SETMS BIT(3) /* Set host select bit */
#define LTQ_SPI_WHBSTATE_CLRMS BIT(2) /* Clear master select bit */ #define LTQ_SPI_WHBSTATE_CLRMS BIT(2) /* Clear host select bit */
#define LTQ_SPI_WHBSTATE_SETEN BIT(1) /* Set enable bit (operational mode) */ #define LTQ_SPI_WHBSTATE_SETEN BIT(1) /* Set enable bit (operational mode) */
#define LTQ_SPI_WHBSTATE_CLREN BIT(0) /* Clear enable bit (config mode */ #define LTQ_SPI_WHBSTATE_CLREN BIT(0) /* Clear enable bit (config mode */
#define LTQ_SPI_WHBSTATE_CLR_ERRORS (LTQ_SPI_WHBSTATE_CLRRUE | \ #define LTQ_SPI_WHBSTATE_CLR_ERRORS (LTQ_SPI_WHBSTATE_CLRRUE | \
...@@ -163,7 +163,7 @@ struct lantiq_ssc_hwcfg { ...@@ -163,7 +163,7 @@ struct lantiq_ssc_hwcfg {
}; };
struct lantiq_ssc_spi { struct lantiq_ssc_spi {
struct spi_master *master; struct spi_controller *host;
struct device *dev; struct device *dev;
void __iomem *regbase; void __iomem *regbase;
struct clk *spi_clk; struct clk *spi_clk;
...@@ -367,7 +367,7 @@ static void lantiq_ssc_hw_init(const struct lantiq_ssc_spi *spi) ...@@ -367,7 +367,7 @@ static void lantiq_ssc_hw_init(const struct lantiq_ssc_spi *spi)
hw_setup_bits_per_word(spi, spi->bits_per_word); hw_setup_bits_per_word(spi, spi->bits_per_word);
hw_setup_clock_mode(spi, SPI_MODE_0); hw_setup_clock_mode(spi, SPI_MODE_0);
/* Enable master mode and clear error flags */ /* Enable host mode and clear error flags */
lantiq_ssc_writel(spi, LTQ_SPI_WHBSTATE_SETMS | lantiq_ssc_writel(spi, LTQ_SPI_WHBSTATE_SETMS |
LTQ_SPI_WHBSTATE_CLR_ERRORS, LTQ_SPI_WHBSTATE_CLR_ERRORS,
LTQ_SPI_WHBSTATE); LTQ_SPI_WHBSTATE);
...@@ -387,8 +387,8 @@ static void lantiq_ssc_hw_init(const struct lantiq_ssc_spi *spi) ...@@ -387,8 +387,8 @@ static void lantiq_ssc_hw_init(const struct lantiq_ssc_spi *spi)
static int lantiq_ssc_setup(struct spi_device *spidev) static int lantiq_ssc_setup(struct spi_device *spidev)
{ {
struct spi_master *master = spidev->master; struct spi_controller *host = spidev->controller;
struct lantiq_ssc_spi *spi = spi_master_get_devdata(master); struct lantiq_ssc_spi *spi = spi_controller_get_devdata(host);
unsigned int cs = spi_get_chipselect(spidev, 0); unsigned int cs = spi_get_chipselect(spidev, 0);
u32 gpocon; u32 gpocon;
...@@ -416,10 +416,10 @@ static int lantiq_ssc_setup(struct spi_device *spidev) ...@@ -416,10 +416,10 @@ static int lantiq_ssc_setup(struct spi_device *spidev)
return 0; return 0;
} }
static int lantiq_ssc_prepare_message(struct spi_master *master, static int lantiq_ssc_prepare_message(struct spi_controller *host,
struct spi_message *message) struct spi_message *message)
{ {
struct lantiq_ssc_spi *spi = spi_master_get_devdata(master); struct lantiq_ssc_spi *spi = spi_controller_get_devdata(host);
hw_enter_config_mode(spi); hw_enter_config_mode(spi);
hw_setup_clock_mode(spi, message->spi->mode); hw_setup_clock_mode(spi, message->spi->mode);
...@@ -461,10 +461,10 @@ static void hw_setup_transfer(struct lantiq_ssc_spi *spi, ...@@ -461,10 +461,10 @@ static void hw_setup_transfer(struct lantiq_ssc_spi *spi,
lantiq_ssc_writel(spi, con, LTQ_SPI_CON); lantiq_ssc_writel(spi, con, LTQ_SPI_CON);
} }
static int lantiq_ssc_unprepare_message(struct spi_master *master, static int lantiq_ssc_unprepare_message(struct spi_controller *host,
struct spi_message *message) struct spi_message *message)
{ {
struct lantiq_ssc_spi *spi = spi_master_get_devdata(master); struct lantiq_ssc_spi *spi = spi_controller_get_devdata(host);
flush_workqueue(spi->wq); flush_workqueue(spi->wq);
...@@ -693,8 +693,8 @@ static irqreturn_t lantiq_ssc_err_interrupt(int irq, void *data) ...@@ -693,8 +693,8 @@ static irqreturn_t lantiq_ssc_err_interrupt(int irq, void *data)
lantiq_ssc_maskl(spi, 0, LTQ_SPI_WHBSTATE_CLR_ERRORS, LTQ_SPI_WHBSTATE); lantiq_ssc_maskl(spi, 0, LTQ_SPI_WHBSTATE_CLR_ERRORS, LTQ_SPI_WHBSTATE);
/* set bad status so it can be retried */ /* set bad status so it can be retried */
if (spi->master->cur_msg) if (spi->host->cur_msg)
spi->master->cur_msg->status = -EIO; spi->host->cur_msg->status = -EIO;
queue_work(spi->wq, &spi->work); queue_work(spi->wq, &spi->work);
spin_unlock(&spi->lock); spin_unlock(&spi->lock);
...@@ -772,22 +772,22 @@ static void lantiq_ssc_bussy_work(struct work_struct *work) ...@@ -772,22 +772,22 @@ static void lantiq_ssc_bussy_work(struct work_struct *work)
u32 stat = lantiq_ssc_readl(spi, LTQ_SPI_STAT); u32 stat = lantiq_ssc_readl(spi, LTQ_SPI_STAT);
if (!(stat & LTQ_SPI_STAT_BSY)) { if (!(stat & LTQ_SPI_STAT_BSY)) {
spi_finalize_current_transfer(spi->master); spi_finalize_current_transfer(spi->host);
return; return;
} }
cond_resched(); cond_resched();
} while (!time_after_eq(jiffies, end)); } while (!time_after_eq(jiffies, end));
if (spi->master->cur_msg) if (spi->host->cur_msg)
spi->master->cur_msg->status = -EIO; spi->host->cur_msg->status = -EIO;
spi_finalize_current_transfer(spi->master); spi_finalize_current_transfer(spi->host);
} }
static void lantiq_ssc_handle_err(struct spi_master *master, static void lantiq_ssc_handle_err(struct spi_controller *host,
struct spi_message *message) struct spi_message *message)
{ {
struct lantiq_ssc_spi *spi = spi_master_get_devdata(master); struct lantiq_ssc_spi *spi = spi_controller_get_devdata(host);
/* flush FIFOs on timeout */ /* flush FIFOs on timeout */
rx_fifo_flush(spi); rx_fifo_flush(spi);
...@@ -796,7 +796,7 @@ static void lantiq_ssc_handle_err(struct spi_master *master, ...@@ -796,7 +796,7 @@ static void lantiq_ssc_handle_err(struct spi_master *master,
static void lantiq_ssc_set_cs(struct spi_device *spidev, bool enable) static void lantiq_ssc_set_cs(struct spi_device *spidev, bool enable)
{ {
struct lantiq_ssc_spi *spi = spi_master_get_devdata(spidev->master); struct lantiq_ssc_spi *spi = spi_controller_get_devdata(spidev->controller);
unsigned int cs = spi_get_chipselect(spidev, 0); unsigned int cs = spi_get_chipselect(spidev, 0);
u32 fgpo; u32 fgpo;
...@@ -808,11 +808,11 @@ static void lantiq_ssc_set_cs(struct spi_device *spidev, bool enable) ...@@ -808,11 +808,11 @@ static void lantiq_ssc_set_cs(struct spi_device *spidev, bool enable)
lantiq_ssc_writel(spi, fgpo, LTQ_SPI_FPGO); lantiq_ssc_writel(spi, fgpo, LTQ_SPI_FPGO);
} }
static int lantiq_ssc_transfer_one(struct spi_master *master, static int lantiq_ssc_transfer_one(struct spi_controller *host,
struct spi_device *spidev, struct spi_device *spidev,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct lantiq_ssc_spi *spi = spi_master_get_devdata(master); struct lantiq_ssc_spi *spi = spi_controller_get_devdata(host);
hw_setup_transfer(spi, spidev, t); hw_setup_transfer(spi, spidev, t);
...@@ -904,7 +904,7 @@ MODULE_DEVICE_TABLE(of, lantiq_ssc_match); ...@@ -904,7 +904,7 @@ MODULE_DEVICE_TABLE(of, lantiq_ssc_match);
static int lantiq_ssc_probe(struct platform_device *pdev) static int lantiq_ssc_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_master *master; struct spi_controller *host;
struct lantiq_ssc_spi *spi; struct lantiq_ssc_spi *spi;
const struct lantiq_ssc_hwcfg *hwcfg; const struct lantiq_ssc_hwcfg *hwcfg;
u32 id, supports_dma, revision; u32 id, supports_dma, revision;
...@@ -913,33 +913,33 @@ static int lantiq_ssc_probe(struct platform_device *pdev) ...@@ -913,33 +913,33 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
hwcfg = of_device_get_match_data(dev); hwcfg = of_device_get_match_data(dev);
master = spi_alloc_master(dev, sizeof(struct lantiq_ssc_spi)); host = spi_alloc_host(dev, sizeof(struct lantiq_ssc_spi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
spi = spi_master_get_devdata(master); spi = spi_controller_get_devdata(host);
spi->master = master; spi->host = host;
spi->dev = dev; spi->dev = dev;
spi->hwcfg = hwcfg; spi->hwcfg = hwcfg;
platform_set_drvdata(pdev, spi); platform_set_drvdata(pdev, spi);
spi->regbase = devm_platform_ioremap_resource(pdev, 0); spi->regbase = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(spi->regbase)) { if (IS_ERR(spi->regbase)) {
err = PTR_ERR(spi->regbase); err = PTR_ERR(spi->regbase);
goto err_master_put; goto err_host_put;
} }
err = hwcfg->cfg_irq(pdev, spi); err = hwcfg->cfg_irq(pdev, spi);
if (err) if (err)
goto err_master_put; goto err_host_put;
spi->spi_clk = devm_clk_get(dev, "gate"); spi->spi_clk = devm_clk_get(dev, "gate");
if (IS_ERR(spi->spi_clk)) { if (IS_ERR(spi->spi_clk)) {
err = PTR_ERR(spi->spi_clk); err = PTR_ERR(spi->spi_clk);
goto err_master_put; goto err_host_put;
} }
err = clk_prepare_enable(spi->spi_clk); err = clk_prepare_enable(spi->spi_clk);
if (err) if (err)
goto err_master_put; goto err_host_put;
/* /*
* Use the old clk_get_fpi() function on Lantiq platform, till it * Use the old clk_get_fpi() function on Lantiq platform, till it
...@@ -965,19 +965,19 @@ static int lantiq_ssc_probe(struct platform_device *pdev) ...@@ -965,19 +965,19 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
spi->bits_per_word = 8; spi->bits_per_word = 8;
spi->speed_hz = 0; spi->speed_hz = 0;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->num_chipselect = num_cs; host->num_chipselect = num_cs;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->setup = lantiq_ssc_setup; host->setup = lantiq_ssc_setup;
master->set_cs = lantiq_ssc_set_cs; host->set_cs = lantiq_ssc_set_cs;
master->handle_err = lantiq_ssc_handle_err; host->handle_err = lantiq_ssc_handle_err;
master->prepare_message = lantiq_ssc_prepare_message; host->prepare_message = lantiq_ssc_prepare_message;
master->unprepare_message = lantiq_ssc_unprepare_message; host->unprepare_message = lantiq_ssc_unprepare_message;
master->transfer_one = lantiq_ssc_transfer_one; host->transfer_one = lantiq_ssc_transfer_one;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | SPI_CS_HIGH | host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | SPI_CS_HIGH |
SPI_LOOP; SPI_LOOP;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 8) | host->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 8) |
SPI_BPW_MASK(16) | SPI_BPW_MASK(32); SPI_BPW_MASK(16) | SPI_BPW_MASK(32);
spi->wq = alloc_ordered_workqueue(dev_name(dev), WQ_MEM_RECLAIM); spi->wq = alloc_ordered_workqueue(dev_name(dev), WQ_MEM_RECLAIM);
if (!spi->wq) { if (!spi->wq) {
...@@ -998,9 +998,9 @@ static int lantiq_ssc_probe(struct platform_device *pdev) ...@@ -998,9 +998,9 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
"Lantiq SSC SPI controller (Rev %i, TXFS %u, RXFS %u, DMA %u)\n", "Lantiq SSC SPI controller (Rev %i, TXFS %u, RXFS %u, DMA %u)\n",
revision, spi->tx_fifo_size, spi->rx_fifo_size, supports_dma); revision, spi->tx_fifo_size, spi->rx_fifo_size, supports_dma);
err = devm_spi_register_master(dev, master); err = devm_spi_register_controller(dev, host);
if (err) { if (err) {
dev_err(dev, "failed to register spi_master\n"); dev_err(dev, "failed to register spi host\n");
goto err_wq_destroy; goto err_wq_destroy;
} }
...@@ -1012,8 +1012,8 @@ static int lantiq_ssc_probe(struct platform_device *pdev) ...@@ -1012,8 +1012,8 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
clk_put(spi->fpi_clk); clk_put(spi->fpi_clk);
err_clk_disable: err_clk_disable:
clk_disable_unprepare(spi->spi_clk); clk_disable_unprepare(spi->spi_clk);
err_master_put: err_host_put:
spi_master_put(master); spi_controller_put(host);
return err; return err;
} }
......
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