Commit 3a11ea66 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by Mark Brown

spi: spi-fsl-dspi: Replace legacy spi_master names with spi_controller

This adapts the spi-fsl-dspi driver to the API changes introduced in
commit 8caab75f ("spi: Generalize SPI "master" to "controller"").
Signed-off-by: default avatarVladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/20190818180115.31114-10-olteanv@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent bee44359
...@@ -171,7 +171,7 @@ struct fsl_dspi_dma { ...@@ -171,7 +171,7 @@ struct fsl_dspi_dma {
}; };
struct fsl_dspi { struct fsl_dspi {
struct spi_master *master; struct spi_controller *ctlr;
struct platform_device *pdev; struct platform_device *pdev;
struct regmap *regmap; struct regmap *regmap;
...@@ -219,7 +219,7 @@ static u32 dspi_pop_tx_pushr(struct fsl_dspi *dspi) ...@@ -219,7 +219,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->master)) if (spi_controller_is_slave(dspi->ctlr))
return data; return data;
if (dspi->len > 0) if (dspi->len > 0)
...@@ -318,7 +318,7 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi) ...@@ -318,7 +318,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->master)) { if (spi_controller_is_slave(dspi->ctlr)) {
wait_for_completion_interruptible(&dspi->dma->cmd_rx_complete); wait_for_completion_interruptible(&dspi->dma->cmd_rx_complete);
return 0; return 0;
} }
...@@ -647,10 +647,10 @@ static void dspi_eoq_read(struct fsl_dspi *dspi) ...@@ -647,10 +647,10 @@ static void dspi_eoq_read(struct fsl_dspi *dspi)
dspi_push_rx(dspi, fifo_read(dspi)); dspi_push_rx(dspi, fifo_read(dspi));
} }
static int dspi_transfer_one_message(struct spi_master *master, static int dspi_transfer_one_message(struct spi_controller *ctlr,
struct spi_message *message) struct spi_message *message)
{ {
struct fsl_dspi *dspi = spi_master_get_devdata(master); struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
struct spi_device *spi = message->spi; struct spi_device *spi = message->spi;
struct spi_transfer *transfer; struct spi_transfer *transfer;
int status = 0; int status = 0;
...@@ -745,7 +745,7 @@ static int dspi_transfer_one_message(struct spi_master *master, ...@@ -745,7 +745,7 @@ static int dspi_transfer_one_message(struct spi_master *master,
out: out:
message->status = status; message->status = status;
spi_finalize_current_message(master); spi_finalize_current_message(ctlr);
return status; return status;
} }
...@@ -753,7 +753,7 @@ static int dspi_transfer_one_message(struct spi_master *master, ...@@ -753,7 +753,7 @@ static int dspi_transfer_one_message(struct spi_master *master,
static int dspi_setup(struct spi_device *spi) static int dspi_setup(struct spi_device *spi)
{ {
struct chip_data *chip; struct chip_data *chip;
struct fsl_dspi *dspi = spi_master_get_devdata(spi->master); struct fsl_dspi *dspi = spi_controller_get_devdata(spi->controller);
struct fsl_dspi_platform_data *pdata; struct fsl_dspi_platform_data *pdata;
u32 cs_sck_delay = 0, sck_cs_delay = 0; u32 cs_sck_delay = 0, sck_cs_delay = 0;
unsigned char br = 0, pbr = 0, pcssck = 0, cssck = 0; unsigned char br = 0, pbr = 0, pcssck = 0, cssck = 0;
...@@ -798,7 +798,7 @@ static int dspi_setup(struct spi_device *spi) ...@@ -798,7 +798,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->master)) { if (!spi_controller_is_slave(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) |
...@@ -820,7 +820,7 @@ static void dspi_cleanup(struct spi_device *spi) ...@@ -820,7 +820,7 @@ static void dspi_cleanup(struct spi_device *spi)
struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi); struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
dev_dbg(&spi->dev, "spi_device %u.%u cleanup\n", dev_dbg(&spi->dev, "spi_device %u.%u cleanup\n",
spi->master->bus_num, spi->chip_select); spi->controller->bus_num, spi->chip_select);
kfree(chip); kfree(chip);
} }
...@@ -893,10 +893,10 @@ MODULE_DEVICE_TABLE(of, fsl_dspi_dt_ids); ...@@ -893,10 +893,10 @@ MODULE_DEVICE_TABLE(of, fsl_dspi_dt_ids);
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int dspi_suspend(struct device *dev) static int dspi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *ctlr = dev_get_drvdata(dev);
struct fsl_dspi *dspi = spi_master_get_devdata(master); struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
spi_master_suspend(master); spi_controller_suspend(ctlr);
clk_disable_unprepare(dspi->clk); clk_disable_unprepare(dspi->clk);
pinctrl_pm_select_sleep_state(dev); pinctrl_pm_select_sleep_state(dev);
...@@ -906,8 +906,8 @@ static int dspi_suspend(struct device *dev) ...@@ -906,8 +906,8 @@ static int dspi_suspend(struct device *dev)
static int dspi_resume(struct device *dev) static int dspi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *ctlr = dev_get_drvdata(dev);
struct fsl_dspi *dspi = spi_master_get_devdata(master); struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
int ret; int ret;
pinctrl_pm_select_default_state(dev); pinctrl_pm_select_default_state(dev);
...@@ -915,7 +915,7 @@ static int dspi_resume(struct device *dev) ...@@ -915,7 +915,7 @@ static int dspi_resume(struct device *dev)
ret = clk_prepare_enable(dspi->clk); ret = clk_prepare_enable(dspi->clk);
if (ret) if (ret)
return ret; return ret;
spi_master_resume(master); spi_controller_resume(ctlr);
return 0; return 0;
} }
...@@ -977,7 +977,7 @@ static void dspi_init(struct fsl_dspi *dspi) ...@@ -977,7 +977,7 @@ static void dspi_init(struct fsl_dspi *dspi)
if (dspi->devtype_data->xspi_mode) if (dspi->devtype_data->xspi_mode)
mcr |= SPI_MCR_XSPI; mcr |= SPI_MCR_XSPI;
if (!spi_controller_is_slave(dspi->master)) if (!spi_controller_is_slave(dspi->ctlr))
mcr |= SPI_MCR_MASTER; mcr |= SPI_MCR_MASTER;
regmap_write(dspi->regmap, SPI_MCR, mcr); regmap_write(dspi->regmap, SPI_MCR, mcr);
...@@ -990,7 +990,7 @@ static void dspi_init(struct fsl_dspi *dspi) ...@@ -990,7 +990,7 @@ static void dspi_init(struct fsl_dspi *dspi)
static int dspi_probe(struct platform_device *pdev) static int dspi_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct spi_master *master; struct spi_controller *ctlr;
struct fsl_dspi *dspi; struct fsl_dspi *dspi;
struct resource *res; struct resource *res;
const struct regmap_config *regmap_config; const struct regmap_config *regmap_config;
...@@ -998,25 +998,25 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -998,25 +998,25 @@ static int dspi_probe(struct platform_device *pdev)
struct fsl_dspi_platform_data *pdata; struct fsl_dspi_platform_data *pdata;
int ret, cs_num, bus_num; int ret, cs_num, bus_num;
master = spi_alloc_master(&pdev->dev, sizeof(struct fsl_dspi)); ctlr = spi_alloc_master(&pdev->dev, sizeof(struct fsl_dspi));
if (!master) if (!ctlr)
return -ENOMEM; return -ENOMEM;
dspi = spi_master_get_devdata(master); dspi = spi_controller_get_devdata(ctlr);
dspi->pdev = pdev; dspi->pdev = pdev;
dspi->master = master; dspi->ctlr = ctlr;
master->setup = dspi_setup; ctlr->setup = dspi_setup;
master->transfer_one_message = dspi_transfer_one_message; ctlr->transfer_one_message = dspi_transfer_one_message;
master->dev.of_node = pdev->dev.of_node; ctlr->dev.of_node = pdev->dev.of_node;
master->cleanup = dspi_cleanup; ctlr->cleanup = dspi_cleanup;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
if (pdata) { if (pdata) {
master->num_chipselect = pdata->cs_num; ctlr->num_chipselect = pdata->cs_num;
master->bus_num = pdata->bus_num; ctlr->bus_num = pdata->bus_num;
dspi->devtype_data = &coldfire_data; dspi->devtype_data = &coldfire_data;
} else { } else {
...@@ -1024,38 +1024,38 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1024,38 +1024,38 @@ static int dspi_probe(struct platform_device *pdev)
ret = of_property_read_u32(np, "spi-num-chipselects", &cs_num); ret = of_property_read_u32(np, "spi-num-chipselects", &cs_num);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't get spi-num-chipselects\n"); dev_err(&pdev->dev, "can't get spi-num-chipselects\n");
goto out_master_put; goto out_ctlr_put;
} }
master->num_chipselect = cs_num; ctlr->num_chipselect = cs_num;
ret = of_property_read_u32(np, "bus-num", &bus_num); ret = of_property_read_u32(np, "bus-num", &bus_num);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't get bus-num\n"); dev_err(&pdev->dev, "can't get bus-num\n");
goto out_master_put; goto out_ctlr_put;
} }
master->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"))
master->slave = true; ctlr->slave = 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) {
dev_err(&pdev->dev, "can't get devtype_data\n"); dev_err(&pdev->dev, "can't get devtype_data\n");
ret = -EFAULT; ret = -EFAULT;
goto out_master_put; goto out_ctlr_put;
} }
} }
if (dspi->devtype_data->xspi_mode) if (dspi->devtype_data->xspi_mode)
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); ctlr->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
else else
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); ctlr->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res); base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base)) { if (IS_ERR(base)) {
ret = PTR_ERR(base); ret = PTR_ERR(base);
goto out_master_put; goto out_ctlr_put;
} }
if (dspi->devtype_data->xspi_mode) if (dspi->devtype_data->xspi_mode)
...@@ -1067,7 +1067,7 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1067,7 +1067,7 @@ static int dspi_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to init regmap: %ld\n", dev_err(&pdev->dev, "failed to init regmap: %ld\n",
PTR_ERR(dspi->regmap)); PTR_ERR(dspi->regmap));
ret = PTR_ERR(dspi->regmap); ret = PTR_ERR(dspi->regmap);
goto out_master_put; goto out_ctlr_put;
} }
if (dspi->devtype_data->xspi_mode) { if (dspi->devtype_data->xspi_mode) {
...@@ -1079,7 +1079,7 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1079,7 +1079,7 @@ static int dspi_probe(struct platform_device *pdev)
"failed to init pushr regmap: %ld\n", "failed to init pushr regmap: %ld\n",
PTR_ERR(dspi->regmap_pushr)); PTR_ERR(dspi->regmap_pushr));
ret = PTR_ERR(dspi->regmap_pushr); ret = PTR_ERR(dspi->regmap_pushr);
goto out_master_put; goto out_ctlr_put;
} }
} }
...@@ -1087,11 +1087,11 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1087,11 +1087,11 @@ static int dspi_probe(struct platform_device *pdev)
if (IS_ERR(dspi->clk)) { if (IS_ERR(dspi->clk)) {
ret = PTR_ERR(dspi->clk); ret = PTR_ERR(dspi->clk);
dev_err(&pdev->dev, "unable to get clock\n"); dev_err(&pdev->dev, "unable to get clock\n");
goto out_master_put; goto out_ctlr_put;
} }
ret = clk_prepare_enable(dspi->clk); ret = clk_prepare_enable(dspi->clk);
if (ret) if (ret)
goto out_master_put; goto out_ctlr_put;
dspi_init(dspi); dspi_init(dspi);
dspi->irq = platform_get_irq(pdev, 0); dspi->irq = platform_get_irq(pdev, 0);
...@@ -1115,15 +1115,15 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1115,15 +1115,15 @@ static int dspi_probe(struct platform_device *pdev)
} }
} }
master->max_speed_hz = ctlr->max_speed_hz =
clk_get_rate(dspi->clk) / dspi->devtype_data->max_clock_factor; clk_get_rate(dspi->clk) / dspi->devtype_data->max_clock_factor;
init_waitqueue_head(&dspi->waitq); init_waitqueue_head(&dspi->waitq);
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, ctlr);
ret = spi_register_master(master); ret = spi_register_controller(ctlr);
if (ret != 0) { if (ret != 0) {
dev_err(&pdev->dev, "Problem registering DSPI master\n"); dev_err(&pdev->dev, "Problem registering DSPI ctlr\n");
goto out_clk_put; goto out_clk_put;
} }
...@@ -1131,21 +1131,21 @@ static int dspi_probe(struct platform_device *pdev) ...@@ -1131,21 +1131,21 @@ static int dspi_probe(struct platform_device *pdev)
out_clk_put: out_clk_put:
clk_disable_unprepare(dspi->clk); clk_disable_unprepare(dspi->clk);
out_master_put: out_ctlr_put:
spi_master_put(master); spi_controller_put(ctlr);
return ret; return ret;
} }
static int dspi_remove(struct platform_device *pdev) static int dspi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *ctlr = platform_get_drvdata(pdev);
struct fsl_dspi *dspi = spi_master_get_devdata(master); struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
/* Disconnect from the SPI framework */ /* Disconnect from the SPI framework */
dspi_release_dma(dspi); dspi_release_dma(dspi);
clk_disable_unprepare(dspi->clk); clk_disable_unprepare(dspi->clk);
spi_unregister_master(dspi->master); spi_unregister_controller(dspi->ctlr);
return 0; return 0;
} }
......
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