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;
} }
......
This diff is collapsed.
...@@ -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;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -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