Commit fffae3af authored by Mark Brown's avatar Mark Brown

spi: switch to use modern name (part3)

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 part3 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. Each patch compile test passed.
parents 7a4feff7 ee0f793c
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* the SPI/Microwire bus interface. This driver specifically supports an * the SPI/Microwire bus interface. This driver specifically supports an
* NS LM70 LLP Evaluation Board, interfacing to a PC using its parallel * NS LM70 LLP Evaluation Board, interfacing to a PC using its parallel
* port to bitbang an SPI-parport bridge. Accordingly, this is an SPI * port to bitbang an SPI-parport bridge. Accordingly, this is an SPI
* master controller driver. The hwmon/lm70 driver is a "SPI protocol * host controller driver. The hwmon/lm70 driver is a "SPI protocol
* driver", layered on top of this one and usable without the lm70llp. * driver", layered on top of this one and usable without the lm70llp.
* *
* Datasheet and Schematic: * Datasheet and Schematic:
...@@ -189,7 +189,7 @@ static void spi_lm70llp_attach(struct parport *p) ...@@ -189,7 +189,7 @@ static void spi_lm70llp_attach(struct parport *p)
{ {
struct pardevice *pd; struct pardevice *pd;
struct spi_lm70llp *pp; struct spi_lm70llp *pp;
struct spi_master *master; struct spi_controller *host;
int status; int status;
struct pardev_cb lm70llp_cb; struct pardev_cb lm70llp_cb;
...@@ -202,17 +202,17 @@ static void spi_lm70llp_attach(struct parport *p) ...@@ -202,17 +202,17 @@ static void spi_lm70llp_attach(struct parport *p)
* the lm70 driver could verify it, reading the manf ID. * the lm70 driver could verify it, reading the manf ID.
*/ */
master = spi_alloc_master(p->physport->dev, sizeof(*pp)); host = spi_alloc_host(p->physport->dev, sizeof(*pp));
if (!master) { if (!host) {
status = -ENOMEM; status = -ENOMEM;
goto out_fail; goto out_fail;
} }
pp = spi_master_get_devdata(master); pp = spi_controller_get_devdata(host);
/* /*
* SPI and bitbang hookup. * SPI and bitbang hookup.
*/ */
pp->bitbang.master = master; pp->bitbang.master = host;
pp->bitbang.chipselect = lm70_chipselect; pp->bitbang.chipselect = lm70_chipselect;
pp->bitbang.txrx_word[SPI_MODE_0] = lm70_txrx; pp->bitbang.txrx_word[SPI_MODE_0] = lm70_txrx;
pp->bitbang.flags = SPI_3WIRE; pp->bitbang.flags = SPI_3WIRE;
...@@ -228,7 +228,7 @@ static void spi_lm70llp_attach(struct parport *p) ...@@ -228,7 +228,7 @@ static void spi_lm70llp_attach(struct parport *p)
if (!pd) { if (!pd) {
status = -ENOMEM; status = -ENOMEM;
goto out_free_master; goto out_free_host;
} }
pp->pd = pd; pp->pd = pd;
...@@ -287,8 +287,8 @@ static void spi_lm70llp_attach(struct parport *p) ...@@ -287,8 +287,8 @@ static void spi_lm70llp_attach(struct parport *p)
parport_release(pp->pd); parport_release(pp->pd);
out_parport_unreg: out_parport_unreg:
parport_unregister_device(pd); parport_unregister_device(pd);
out_free_master: out_free_host:
spi_master_put(master); spi_controller_put(host);
out_fail: out_fail:
pr_info("spi_lm70llp probe fail, status %d\n", status); pr_info("spi_lm70llp probe fail, status %d\n", status);
} }
...@@ -309,7 +309,7 @@ static void spi_lm70llp_detach(struct parport *p) ...@@ -309,7 +309,7 @@ static void spi_lm70llp_detach(struct parport *p)
parport_release(pp->pd); parport_release(pp->pd);
parport_unregister_device(pp->pd); parport_unregister_device(pp->pd);
spi_master_put(pp->bitbang.master); spi_controller_put(pp->bitbang.master);
lm70llp = NULL; lm70llp = NULL;
} }
......
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* SPI master driver for ICP DAS LP-8841 RTC * SPI host driver for ICP DAS LP-8841 RTC
* *
* Copyright (C) 2016 Sergei Ianovich * Copyright (C) 2016 Sergei Ianovich
* *
...@@ -73,13 +73,13 @@ bitbang_txrx_be_cpha0_lsb(struct spi_lp8841_rtc *data, ...@@ -73,13 +73,13 @@ bitbang_txrx_be_cpha0_lsb(struct spi_lp8841_rtc *data,
/* clock starts at inactive polarity */ /* clock starts at inactive polarity */
for (; likely(bits); bits--) { for (; likely(bits); bits--) {
/* setup LSB (to slave) on leading edge */ /* setup LSB (to target) on leading edge */
if ((flags & SPI_CONTROLLER_NO_TX) == 0) if ((flags & SPI_CONTROLLER_NO_TX) == 0)
setmosi(data, (word & 1)); setmosi(data, (word & 1));
usleep_range(usecs, usecs + 1); /* T(setup) */ usleep_range(usecs, usecs + 1); /* T(setup) */
/* sample LSB (from slave) on trailing edge */ /* sample LSB (from target) on trailing edge */
word >>= 1; word >>= 1;
if ((flags & SPI_CONTROLLER_NO_RX) == 0) if ((flags & SPI_CONTROLLER_NO_RX) == 0)
word |= (getmiso(data) << 31); word |= (getmiso(data) << 31);
...@@ -95,11 +95,11 @@ bitbang_txrx_be_cpha0_lsb(struct spi_lp8841_rtc *data, ...@@ -95,11 +95,11 @@ bitbang_txrx_be_cpha0_lsb(struct spi_lp8841_rtc *data,
} }
static int static int
spi_lp8841_rtc_transfer_one(struct spi_master *master, spi_lp8841_rtc_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct spi_lp8841_rtc *data = spi_master_get_devdata(master); struct spi_lp8841_rtc *data = spi_controller_get_devdata(host);
unsigned count = t->len; unsigned count = t->len;
const u8 *tx = t->tx_buf; const u8 *tx = t->tx_buf;
u8 *rx = t->rx_buf; u8 *rx = t->rx_buf;
...@@ -128,7 +128,7 @@ spi_lp8841_rtc_transfer_one(struct spi_master *master, ...@@ -128,7 +128,7 @@ spi_lp8841_rtc_transfer_one(struct spi_master *master,
ret = -EINVAL; ret = -EINVAL;
} }
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
return ret; return ret;
} }
...@@ -136,7 +136,7 @@ spi_lp8841_rtc_transfer_one(struct spi_master *master, ...@@ -136,7 +136,7 @@ spi_lp8841_rtc_transfer_one(struct spi_master *master,
static void static void
spi_lp8841_rtc_set_cs(struct spi_device *spi, bool enable) spi_lp8841_rtc_set_cs(struct spi_device *spi, bool enable)
{ {
struct spi_lp8841_rtc *data = spi_master_get_devdata(spi->master); struct spi_lp8841_rtc *data = spi_controller_get_devdata(spi->controller);
data->state = 0; data->state = 0;
writeb(data->state, data->iomem); writeb(data->state, data->iomem);
...@@ -182,48 +182,48 @@ static int ...@@ -182,48 +182,48 @@ static int
spi_lp8841_rtc_probe(struct platform_device *pdev) spi_lp8841_rtc_probe(struct platform_device *pdev)
{ {
int ret; int ret;
struct spi_master *master; struct spi_controller *host;
struct spi_lp8841_rtc *data; struct spi_lp8841_rtc *data;
master = spi_alloc_master(&pdev->dev, sizeof(*data)); host = spi_alloc_host(&pdev->dev, sizeof(*data));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->mode_bits = SPI_CS_HIGH | SPI_3WIRE | SPI_LSB_FIRST; host->mode_bits = SPI_CS_HIGH | SPI_3WIRE | SPI_LSB_FIRST;
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->num_chipselect = 1; host->num_chipselect = 1;
master->setup = spi_lp8841_rtc_setup; host->setup = spi_lp8841_rtc_setup;
master->set_cs = spi_lp8841_rtc_set_cs; host->set_cs = spi_lp8841_rtc_set_cs;
master->transfer_one = spi_lp8841_rtc_transfer_one; host->transfer_one = spi_lp8841_rtc_transfer_one;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
#ifdef CONFIG_OF #ifdef CONFIG_OF
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
#endif #endif
data = spi_master_get_devdata(master); data = spi_controller_get_devdata(host);
data->iomem = devm_platform_ioremap_resource(pdev, 0); data->iomem = devm_platform_ioremap_resource(pdev, 0);
ret = PTR_ERR_OR_ZERO(data->iomem); ret = PTR_ERR_OR_ZERO(data->iomem);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to get IO address\n"); dev_err(&pdev->dev, "failed to get IO address\n");
goto err_put_master; goto err_put_host;
} }
/* register with the SPI framework */ /* register with the SPI framework */
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (ret) { if (ret) {
dev_err(&pdev->dev, "cannot register spi master\n"); dev_err(&pdev->dev, "cannot register spi host\n");
goto err_put_master; goto err_put_host;
} }
return ret; return ret;
err_put_master: err_put_host:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
...@@ -239,6 +239,6 @@ static struct platform_driver spi_lp8841_rtc_driver = { ...@@ -239,6 +239,6 @@ static struct platform_driver spi_lp8841_rtc_driver = {
}; };
module_platform_driver(spi_lp8841_rtc_driver); module_platform_driver(spi_lp8841_rtc_driver);
MODULE_DESCRIPTION("SPI master driver for ICP DAS LP-8841 RTC"); MODULE_DESCRIPTION("SPI host driver for ICP DAS LP-8841 RTC");
MODULE_AUTHOR("Sergei Ianovich"); MODULE_AUTHOR("Sergei Ianovich");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -151,7 +151,7 @@ struct meson_spicc_data { ...@@ -151,7 +151,7 @@ struct meson_spicc_data {
}; };
struct meson_spicc_device { struct meson_spicc_device {
struct spi_master *master; struct spi_controller *host;
struct platform_device *pdev; struct platform_device *pdev;
void __iomem *base; void __iomem *base;
struct clk *core; struct clk *core;
...@@ -399,11 +399,11 @@ static void meson_spicc_reset_fifo(struct meson_spicc_device *spicc) ...@@ -399,11 +399,11 @@ static void meson_spicc_reset_fifo(struct meson_spicc_device *spicc)
spicc->base + SPICC_ENH_CTL0); spicc->base + SPICC_ENH_CTL0);
} }
static int meson_spicc_transfer_one(struct spi_master *master, static int meson_spicc_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct meson_spicc_device *spicc = spi_master_get_devdata(master); struct meson_spicc_device *spicc = spi_controller_get_devdata(host);
uint64_t timeout; uint64_t timeout;
/* Store current transfer */ /* Store current transfer */
...@@ -454,10 +454,10 @@ static int meson_spicc_transfer_one(struct spi_master *master, ...@@ -454,10 +454,10 @@ static int meson_spicc_transfer_one(struct spi_master *master,
return 0; return 0;
} }
static int meson_spicc_prepare_message(struct spi_master *master, static int meson_spicc_prepare_message(struct spi_controller *host,
struct spi_message *message) struct spi_message *message)
{ {
struct meson_spicc_device *spicc = spi_master_get_devdata(master); struct meson_spicc_device *spicc = spi_controller_get_devdata(host);
struct spi_device *spi = message->spi; struct spi_device *spi = message->spi;
u32 conf = readl_relaxed(spicc->base + SPICC_CONREG) & SPICC_DATARATE_MASK; u32 conf = readl_relaxed(spicc->base + SPICC_CONREG) & SPICC_DATARATE_MASK;
...@@ -519,9 +519,9 @@ static int meson_spicc_prepare_message(struct spi_master *master, ...@@ -519,9 +519,9 @@ static int meson_spicc_prepare_message(struct spi_master *master,
return 0; return 0;
} }
static int meson_spicc_unprepare_transfer(struct spi_master *master) static int meson_spicc_unprepare_transfer(struct spi_controller *host)
{ {
struct meson_spicc_device *spicc = spi_master_get_devdata(master); struct meson_spicc_device *spicc = spi_controller_get_devdata(host);
u32 conf = readl_relaxed(spicc->base + SPICC_CONREG) & SPICC_DATARATE_MASK; u32 conf = readl_relaxed(spicc->base + SPICC_CONREG) & SPICC_DATARATE_MASK;
/* Disable all IRQs */ /* Disable all IRQs */
...@@ -541,7 +541,7 @@ static int meson_spicc_unprepare_transfer(struct spi_master *master) ...@@ -541,7 +541,7 @@ static int meson_spicc_unprepare_transfer(struct spi_master *master)
static int meson_spicc_setup(struct spi_device *spi) static int meson_spicc_setup(struct spi_device *spi)
{ {
if (!spi->controller_state) if (!spi->controller_state)
spi->controller_state = spi_master_get_devdata(spi->master); spi->controller_state = spi_controller_get_devdata(spi->controller);
return 0; return 0;
} }
...@@ -585,7 +585,7 @@ static unsigned long meson_spicc_pow2_recalc_rate(struct clk_hw *hw, ...@@ -585,7 +585,7 @@ static unsigned long meson_spicc_pow2_recalc_rate(struct clk_hw *hw,
struct clk_divider *divider = to_clk_divider(hw); struct clk_divider *divider = to_clk_divider(hw);
struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider); struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider);
if (!spicc->master->cur_msg) if (!spicc->host->cur_msg)
return 0; return 0;
return clk_divider_ops.recalc_rate(hw, parent_rate); return clk_divider_ops.recalc_rate(hw, parent_rate);
...@@ -597,7 +597,7 @@ static int meson_spicc_pow2_determine_rate(struct clk_hw *hw, ...@@ -597,7 +597,7 @@ static int meson_spicc_pow2_determine_rate(struct clk_hw *hw,
struct clk_divider *divider = to_clk_divider(hw); struct clk_divider *divider = to_clk_divider(hw);
struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider); struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider);
if (!spicc->master->cur_msg) if (!spicc->host->cur_msg)
return -EINVAL; return -EINVAL;
return clk_divider_ops.determine_rate(hw, req); return clk_divider_ops.determine_rate(hw, req);
...@@ -609,7 +609,7 @@ static int meson_spicc_pow2_set_rate(struct clk_hw *hw, unsigned long rate, ...@@ -609,7 +609,7 @@ static int meson_spicc_pow2_set_rate(struct clk_hw *hw, unsigned long rate,
struct clk_divider *divider = to_clk_divider(hw); struct clk_divider *divider = to_clk_divider(hw);
struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider); struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider);
if (!spicc->master->cur_msg) if (!spicc->host->cur_msg)
return -EINVAL; return -EINVAL;
return clk_divider_ops.set_rate(hw, rate, parent_rate); return clk_divider_ops.set_rate(hw, rate, parent_rate);
...@@ -769,23 +769,23 @@ static int meson_spicc_enh_clk_init(struct meson_spicc_device *spicc) ...@@ -769,23 +769,23 @@ static int meson_spicc_enh_clk_init(struct meson_spicc_device *spicc)
static int meson_spicc_probe(struct platform_device *pdev) static int meson_spicc_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct meson_spicc_device *spicc; struct meson_spicc_device *spicc;
int ret, irq; int ret, irq;
master = spi_alloc_master(&pdev->dev, sizeof(*spicc)); host = spi_alloc_host(&pdev->dev, sizeof(*spicc));
if (!master) { if (!host) {
dev_err(&pdev->dev, "master allocation failed\n"); dev_err(&pdev->dev, "host allocation failed\n");
return -ENOMEM; return -ENOMEM;
} }
spicc = spi_master_get_devdata(master); spicc = spi_controller_get_devdata(host);
spicc->master = master; spicc->host = host;
spicc->data = of_device_get_match_data(&pdev->dev); spicc->data = of_device_get_match_data(&pdev->dev);
if (!spicc->data) { if (!spicc->data) {
dev_err(&pdev->dev, "failed to get match data\n"); dev_err(&pdev->dev, "failed to get match data\n");
ret = -EINVAL; ret = -EINVAL;
goto out_master; goto out_host;
} }
spicc->pdev = pdev; spicc->pdev = pdev;
...@@ -797,7 +797,7 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -797,7 +797,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
if (IS_ERR(spicc->base)) { if (IS_ERR(spicc->base)) {
dev_err(&pdev->dev, "io resource mapping failed\n"); dev_err(&pdev->dev, "io resource mapping failed\n");
ret = PTR_ERR(spicc->base); ret = PTR_ERR(spicc->base);
goto out_master; goto out_host;
} }
/* Set master mode and enable controller */ /* Set master mode and enable controller */
...@@ -810,21 +810,21 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -810,21 +810,21 @@ static int meson_spicc_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
ret = irq; ret = irq;
goto out_master; goto out_host;
} }
ret = devm_request_irq(&pdev->dev, irq, meson_spicc_irq, ret = devm_request_irq(&pdev->dev, irq, meson_spicc_irq,
0, NULL, spicc); 0, NULL, spicc);
if (ret) { if (ret) {
dev_err(&pdev->dev, "irq request failed\n"); dev_err(&pdev->dev, "irq request failed\n");
goto out_master; goto out_host;
} }
spicc->core = devm_clk_get(&pdev->dev, "core"); spicc->core = devm_clk_get(&pdev->dev, "core");
if (IS_ERR(spicc->core)) { if (IS_ERR(spicc->core)) {
dev_err(&pdev->dev, "core clock request failed\n"); dev_err(&pdev->dev, "core clock request failed\n");
ret = PTR_ERR(spicc->core); ret = PTR_ERR(spicc->core);
goto out_master; goto out_host;
} }
if (spicc->data->has_pclk) { if (spicc->data->has_pclk) {
...@@ -832,14 +832,14 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -832,14 +832,14 @@ static int meson_spicc_probe(struct platform_device *pdev)
if (IS_ERR(spicc->pclk)) { if (IS_ERR(spicc->pclk)) {
dev_err(&pdev->dev, "pclk clock request failed\n"); dev_err(&pdev->dev, "pclk clock request failed\n");
ret = PTR_ERR(spicc->pclk); ret = PTR_ERR(spicc->pclk);
goto out_master; goto out_host;
} }
} }
ret = clk_prepare_enable(spicc->core); ret = clk_prepare_enable(spicc->core);
if (ret) { if (ret) {
dev_err(&pdev->dev, "core clock enable failed\n"); dev_err(&pdev->dev, "core clock enable failed\n");
goto out_master; goto out_host;
} }
ret = clk_prepare_enable(spicc->pclk); ret = clk_prepare_enable(spicc->pclk);
...@@ -856,22 +856,22 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -856,22 +856,22 @@ static int meson_spicc_probe(struct platform_device *pdev)
device_reset_optional(&pdev->dev); device_reset_optional(&pdev->dev);
master->num_chipselect = 4; host->num_chipselect = 4;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH; host->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH;
master->bits_per_word_mask = SPI_BPW_MASK(32) | host->bits_per_word_mask = SPI_BPW_MASK(32) |
SPI_BPW_MASK(24) | SPI_BPW_MASK(24) |
SPI_BPW_MASK(16) | SPI_BPW_MASK(16) |
SPI_BPW_MASK(8); SPI_BPW_MASK(8);
master->flags = (SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX); host->flags = (SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX);
master->min_speed_hz = spicc->data->min_speed_hz; host->min_speed_hz = spicc->data->min_speed_hz;
master->max_speed_hz = spicc->data->max_speed_hz; host->max_speed_hz = spicc->data->max_speed_hz;
master->setup = meson_spicc_setup; host->setup = meson_spicc_setup;
master->cleanup = meson_spicc_cleanup; host->cleanup = meson_spicc_cleanup;
master->prepare_message = meson_spicc_prepare_message; host->prepare_message = meson_spicc_prepare_message;
master->unprepare_transfer_hardware = meson_spicc_unprepare_transfer; host->unprepare_transfer_hardware = meson_spicc_unprepare_transfer;
master->transfer_one = meson_spicc_transfer_one; host->transfer_one = meson_spicc_transfer_one;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
meson_spicc_oen_enable(spicc); meson_spicc_oen_enable(spicc);
...@@ -889,9 +889,9 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -889,9 +889,9 @@ static int meson_spicc_probe(struct platform_device *pdev)
} }
} }
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (ret) { if (ret) {
dev_err(&pdev->dev, "spi master registration failed\n"); dev_err(&pdev->dev, "spi host registration failed\n");
goto out_clk; goto out_clk;
} }
...@@ -903,8 +903,8 @@ static int meson_spicc_probe(struct platform_device *pdev) ...@@ -903,8 +903,8 @@ static int meson_spicc_probe(struct platform_device *pdev)
out_core_clk: out_core_clk:
clk_disable_unprepare(spicc->core); clk_disable_unprepare(spicc->core);
out_master: out_host:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
...@@ -919,7 +919,7 @@ static void meson_spicc_remove(struct platform_device *pdev) ...@@ -919,7 +919,7 @@ static void meson_spicc_remove(struct platform_device *pdev)
clk_disable_unprepare(spicc->core); clk_disable_unprepare(spicc->core);
clk_disable_unprepare(spicc->pclk); clk_disable_unprepare(spicc->pclk);
spi_master_put(spicc->master); spi_controller_put(spicc->host);
} }
static const struct meson_spicc_data meson_spicc_gx_data = { static const struct meson_spicc_data meson_spicc_gx_data = {
......
...@@ -67,13 +67,13 @@ ...@@ -67,13 +67,13 @@
/** /**
* struct meson_spifc * struct meson_spifc
* @master: the SPI master * @host: the SPI host
* @regmap: regmap for device registers * @regmap: regmap for device registers
* @clk: input clock of the built-in baud rate generator * @clk: input clock of the built-in baud rate generator
* @dev: the device structure * @dev: the device structure
*/ */
struct meson_spifc { struct meson_spifc {
struct spi_master *master; struct spi_controller *host;
struct regmap *regmap; struct regmap *regmap;
struct clk *clk; struct clk *clk;
struct device *dev; struct device *dev;
...@@ -237,16 +237,16 @@ static int meson_spifc_txrx(struct meson_spifc *spifc, ...@@ -237,16 +237,16 @@ static int meson_spifc_txrx(struct meson_spifc *spifc,
/** /**
* meson_spifc_transfer_one() - perform a single transfer * meson_spifc_transfer_one() - perform a single transfer
* @master: the SPI master * @host: the SPI host
* @spi: the SPI device * @spi: the SPI device
* @xfer: the current SPI transfer * @xfer: the current SPI transfer
* Return: 0 on success, a negative value on error * Return: 0 on success, a negative value on error
*/ */
static int meson_spifc_transfer_one(struct spi_master *master, static int meson_spifc_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct meson_spifc *spifc = spi_master_get_devdata(master); struct meson_spifc *spifc = spi_controller_get_devdata(host);
int len, done = 0, ret = 0; int len, done = 0, ret = 0;
meson_spifc_setup_speed(spifc, xfer->speed_hz); meson_spifc_setup_speed(spifc, xfer->speed_hz);
...@@ -256,7 +256,7 @@ static int meson_spifc_transfer_one(struct spi_master *master, ...@@ -256,7 +256,7 @@ static int meson_spifc_transfer_one(struct spi_master *master,
while (done < xfer->len && !ret) { while (done < xfer->len && !ret) {
len = min_t(int, xfer->len - done, SPIFC_BUFFER_SIZE); len = min_t(int, xfer->len - done, SPIFC_BUFFER_SIZE);
ret = meson_spifc_txrx(spifc, xfer, done, len, ret = meson_spifc_txrx(spifc, xfer, done, len,
spi_transfer_is_last(master, xfer), spi_transfer_is_last(host, xfer),
done + len >= xfer->len); done + len >= xfer->len);
done += len; done += len;
} }
...@@ -284,19 +284,19 @@ static void meson_spifc_hw_init(struct meson_spifc *spifc) ...@@ -284,19 +284,19 @@ static void meson_spifc_hw_init(struct meson_spifc *spifc)
static int meson_spifc_probe(struct platform_device *pdev) static int meson_spifc_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct meson_spifc *spifc; struct meson_spifc *spifc;
void __iomem *base; void __iomem *base;
unsigned int rate; unsigned int rate;
int ret = 0; int ret = 0;
master = spi_alloc_master(&pdev->dev, sizeof(struct meson_spifc)); host = spi_alloc_host(&pdev->dev, sizeof(struct meson_spifc));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
spifc = spi_master_get_devdata(master); spifc = spi_controller_get_devdata(host);
spifc->dev = &pdev->dev; spifc->dev = &pdev->dev;
base = devm_platform_ioremap_resource(pdev, 0); base = devm_platform_ioremap_resource(pdev, 0);
...@@ -327,22 +327,22 @@ static int meson_spifc_probe(struct platform_device *pdev) ...@@ -327,22 +327,22 @@ static int meson_spifc_probe(struct platform_device *pdev)
rate = clk_get_rate(spifc->clk); rate = clk_get_rate(spifc->clk);
master->num_chipselect = 1; host->num_chipselect = 1;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
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;
master->transfer_one = meson_spifc_transfer_one; host->transfer_one = meson_spifc_transfer_one;
master->min_speed_hz = rate >> 6; host->min_speed_hz = rate >> 6;
master->max_speed_hz = rate >> 1; host->max_speed_hz = rate >> 1;
meson_spifc_hw_init(spifc); meson_spifc_hw_init(spifc);
pm_runtime_set_active(spifc->dev); pm_runtime_set_active(spifc->dev);
pm_runtime_enable(spifc->dev); pm_runtime_enable(spifc->dev);
ret = devm_spi_register_master(spifc->dev, master); ret = devm_spi_register_controller(spifc->dev, host);
if (ret) { if (ret) {
dev_err(spifc->dev, "failed to register spi master\n"); dev_err(spifc->dev, "failed to register spi host\n");
goto out_clk; goto out_clk;
} }
...@@ -351,14 +351,14 @@ static int meson_spifc_probe(struct platform_device *pdev) ...@@ -351,14 +351,14 @@ static int meson_spifc_probe(struct platform_device *pdev)
clk_disable_unprepare(spifc->clk); clk_disable_unprepare(spifc->clk);
pm_runtime_disable(spifc->dev); pm_runtime_disable(spifc->dev);
out_err: out_err:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void meson_spifc_remove(struct platform_device *pdev) static void meson_spifc_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct meson_spifc *spifc = spi_master_get_devdata(master); struct meson_spifc *spifc = spi_controller_get_devdata(host);
pm_runtime_get_sync(&pdev->dev); pm_runtime_get_sync(&pdev->dev);
clk_disable_unprepare(spifc->clk); clk_disable_unprepare(spifc->clk);
...@@ -368,11 +368,11 @@ static void meson_spifc_remove(struct platform_device *pdev) ...@@ -368,11 +368,11 @@ static void meson_spifc_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int meson_spifc_suspend(struct device *dev) static int meson_spifc_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct meson_spifc *spifc = spi_master_get_devdata(master); struct meson_spifc *spifc = spi_controller_get_devdata(host);
int ret; int ret;
ret = spi_master_suspend(master); ret = spi_controller_suspend(host);
if (ret) if (ret)
return ret; return ret;
...@@ -384,8 +384,8 @@ static int meson_spifc_suspend(struct device *dev) ...@@ -384,8 +384,8 @@ static int meson_spifc_suspend(struct device *dev)
static int meson_spifc_resume(struct device *dev) static int meson_spifc_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct meson_spifc *spifc = spi_master_get_devdata(master); struct meson_spifc *spifc = spi_controller_get_devdata(host);
int ret; int ret;
if (!pm_runtime_suspended(dev)) { if (!pm_runtime_suspended(dev)) {
...@@ -396,7 +396,7 @@ static int meson_spifc_resume(struct device *dev) ...@@ -396,7 +396,7 @@ static int meson_spifc_resume(struct device *dev)
meson_spifc_hw_init(spifc); meson_spifc_hw_init(spifc);
ret = spi_master_resume(master); ret = spi_controller_resume(host);
if (ret) if (ret)
clk_disable_unprepare(spifc->clk); clk_disable_unprepare(spifc->clk);
...@@ -407,8 +407,8 @@ static int meson_spifc_resume(struct device *dev) ...@@ -407,8 +407,8 @@ static int meson_spifc_resume(struct device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int meson_spifc_runtime_suspend(struct device *dev) static int meson_spifc_runtime_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct meson_spifc *spifc = spi_master_get_devdata(master); struct meson_spifc *spifc = spi_controller_get_devdata(host);
clk_disable_unprepare(spifc->clk); clk_disable_unprepare(spifc->clk);
...@@ -417,8 +417,8 @@ static int meson_spifc_runtime_suspend(struct device *dev) ...@@ -417,8 +417,8 @@ static int meson_spifc_runtime_suspend(struct device *dev)
static int meson_spifc_runtime_resume(struct device *dev) static int meson_spifc_runtime_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct meson_spifc *spifc = spi_master_get_devdata(master); struct meson_spifc *spifc = spi_controller_get_devdata(host);
return clk_prepare_enable(spifc->clk); return clk_prepare_enable(spifc->clk);
} }
......
...@@ -299,7 +299,7 @@ static int mchp_coreqspi_setup_clock(struct mchp_coreqspi *qspi, struct spi_devi ...@@ -299,7 +299,7 @@ static int mchp_coreqspi_setup_clock(struct mchp_coreqspi *qspi, struct spi_devi
static int mchp_coreqspi_setup_op(struct spi_device *spi_dev) static int mchp_coreqspi_setup_op(struct spi_device *spi_dev)
{ {
struct spi_controller *ctlr = spi_dev->master; struct spi_controller *ctlr = spi_dev->controller;
struct mchp_coreqspi *qspi = spi_controller_get_devdata(ctlr); struct mchp_coreqspi *qspi = spi_controller_get_devdata(ctlr);
u32 control = readl_relaxed(qspi->regs + REG_CONTROL); u32 control = readl_relaxed(qspi->regs + REG_CONTROL);
...@@ -368,7 +368,7 @@ static inline void mchp_coreqspi_config_op(struct mchp_coreqspi *qspi, const str ...@@ -368,7 +368,7 @@ static inline void mchp_coreqspi_config_op(struct mchp_coreqspi *qspi, const str
static int mchp_qspi_wait_for_ready(struct spi_mem *mem) static int mchp_qspi_wait_for_ready(struct spi_mem *mem)
{ {
struct mchp_coreqspi *qspi = spi_controller_get_devdata struct mchp_coreqspi *qspi = spi_controller_get_devdata
(mem->spi->master); (mem->spi->controller);
u32 status; u32 status;
int ret; int ret;
...@@ -387,7 +387,7 @@ static int mchp_qspi_wait_for_ready(struct spi_mem *mem) ...@@ -387,7 +387,7 @@ static int mchp_qspi_wait_for_ready(struct spi_mem *mem)
static int mchp_coreqspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static int mchp_coreqspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct mchp_coreqspi *qspi = spi_controller_get_devdata struct mchp_coreqspi *qspi = spi_controller_get_devdata
(mem->spi->master); (mem->spi->controller);
u32 address = op->addr.val; u32 address = op->addr.val;
u8 opcode = op->cmd.opcode; u8 opcode = op->cmd.opcode;
u8 opaddr[5]; u8 opaddr[5];
...@@ -505,10 +505,10 @@ static int mchp_coreqspi_probe(struct platform_device *pdev) ...@@ -505,10 +505,10 @@ static int mchp_coreqspi_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
int ret; int ret;
ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*qspi)); ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*qspi));
if (!ctlr) if (!ctlr)
return dev_err_probe(&pdev->dev, -ENOMEM, return dev_err_probe(&pdev->dev, -ENOMEM,
"unable to allocate master for QSPI controller\n"); "unable to allocate host for QSPI controller\n");
qspi = spi_controller_get_devdata(ctlr); qspi = spi_controller_get_devdata(ctlr);
platform_set_drvdata(pdev, qspi); platform_set_drvdata(pdev, qspi);
......
...@@ -244,7 +244,7 @@ static inline void mchp_corespi_set_framesize(struct mchp_corespi *spi, int bt) ...@@ -244,7 +244,7 @@ static inline void mchp_corespi_set_framesize(struct mchp_corespi *spi, int bt)
static void mchp_corespi_set_cs(struct spi_device *spi, bool disable) static void mchp_corespi_set_cs(struct spi_device *spi, bool disable)
{ {
u32 reg; u32 reg;
struct mchp_corespi *corespi = spi_master_get_devdata(spi->master); struct mchp_corespi *corespi = spi_controller_get_devdata(spi->controller);
reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT); reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT);
reg &= ~BIT(spi_get_chipselect(spi, 0)); reg &= ~BIT(spi_get_chipselect(spi, 0));
...@@ -255,11 +255,11 @@ static void mchp_corespi_set_cs(struct spi_device *spi, bool disable) ...@@ -255,11 +255,11 @@ static void mchp_corespi_set_cs(struct spi_device *spi, bool disable)
static int mchp_corespi_setup(struct spi_device *spi) static int mchp_corespi_setup(struct spi_device *spi)
{ {
struct mchp_corespi *corespi = spi_master_get_devdata(spi->master); struct mchp_corespi *corespi = spi_controller_get_devdata(spi->controller);
u32 reg; u32 reg;
/* /*
* Active high slaves need to be specifically set to their inactive * Active high targets need to be specifically set to their inactive
* states during probe by adding them to the "control group" & thus * states during probe by adding them to the "control group" & thus
* driving their select line low. * driving their select line low.
*/ */
...@@ -271,7 +271,7 @@ static int mchp_corespi_setup(struct spi_device *spi) ...@@ -271,7 +271,7 @@ static int mchp_corespi_setup(struct spi_device *spi)
return 0; return 0;
} }
static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *spi) static void mchp_corespi_init(struct spi_controller *host, struct mchp_corespi *spi)
{ {
unsigned long clk_hz; unsigned long clk_hz;
u32 control = mchp_corespi_read(spi, REG_CONTROL); u32 control = mchp_corespi_read(spi, REG_CONTROL);
...@@ -285,7 +285,7 @@ static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *sp ...@@ -285,7 +285,7 @@ static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *sp
/* max. possible spi clock rate is the apb clock rate */ /* max. possible spi clock rate is the apb clock rate */
clk_hz = clk_get_rate(spi->clk); clk_hz = clk_get_rate(spi->clk);
master->max_speed_hz = clk_hz; host->max_speed_hz = clk_hz;
/* /*
* The controller must be configured so that it doesn't remove Chip * The controller must be configured so that it doesn't remove Chip
...@@ -305,7 +305,7 @@ static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *sp ...@@ -305,7 +305,7 @@ static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *sp
/* /*
* It is required to enable direct mode, otherwise control over the chip * It is required to enable direct mode, otherwise control over the chip
* select is relinquished to the hardware. SSELOUT is enabled too so we * select is relinquished to the hardware. SSELOUT is enabled too so we
* can deal with active high slaves. * can deal with active high targets.
*/ */
mchp_corespi_write(spi, REG_SLAVE_SELECT, SSELOUT | SSEL_DIRECT); mchp_corespi_write(spi, REG_SLAVE_SELECT, SSELOUT | SSEL_DIRECT);
...@@ -371,8 +371,8 @@ static inline void mchp_corespi_set_mode(struct mchp_corespi *spi, unsigned int ...@@ -371,8 +371,8 @@ static inline void mchp_corespi_set_mode(struct mchp_corespi *spi, unsigned int
static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id) static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)
{ {
struct spi_master *master = dev_id; struct spi_controller *host = dev_id;
struct mchp_corespi *spi = spi_master_get_devdata(master); struct mchp_corespi *spi = spi_controller_get_devdata(host);
u32 intfield = mchp_corespi_read(spi, REG_MIS) & 0xf; u32 intfield = mchp_corespi_read(spi, REG_MIS) & 0xf;
bool finalise = false; bool finalise = false;
...@@ -399,7 +399,7 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id) ...@@ -399,7 +399,7 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)
if (intfield & INT_RX_CHANNEL_OVERFLOW) { if (intfield & INT_RX_CHANNEL_OVERFLOW) {
mchp_corespi_write(spi, REG_INT_CLEAR, INT_RX_CHANNEL_OVERFLOW); mchp_corespi_write(spi, REG_INT_CLEAR, INT_RX_CHANNEL_OVERFLOW);
finalise = true; finalise = true;
dev_err(&master->dev, dev_err(&host->dev,
"%s: RX OVERFLOW: rxlen: %d, txlen: %d\n", __func__, "%s: RX OVERFLOW: rxlen: %d, txlen: %d\n", __func__,
spi->rx_len, spi->tx_len); spi->rx_len, spi->tx_len);
} }
...@@ -407,13 +407,13 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id) ...@@ -407,13 +407,13 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)
if (intfield & INT_TX_CHANNEL_UNDERRUN) { if (intfield & INT_TX_CHANNEL_UNDERRUN) {
mchp_corespi_write(spi, REG_INT_CLEAR, INT_TX_CHANNEL_UNDERRUN); mchp_corespi_write(spi, REG_INT_CLEAR, INT_TX_CHANNEL_UNDERRUN);
finalise = true; finalise = true;
dev_err(&master->dev, dev_err(&host->dev,
"%s: TX UNDERFLOW: rxlen: %d, txlen: %d\n", __func__, "%s: TX UNDERFLOW: rxlen: %d, txlen: %d\n", __func__,
spi->rx_len, spi->tx_len); spi->rx_len, spi->tx_len);
} }
if (finalise) if (finalise)
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -455,16 +455,16 @@ static int mchp_corespi_calculate_clkgen(struct mchp_corespi *spi, ...@@ -455,16 +455,16 @@ static int mchp_corespi_calculate_clkgen(struct mchp_corespi *spi,
return 0; return 0;
} }
static int mchp_corespi_transfer_one(struct spi_master *master, static int mchp_corespi_transfer_one(struct spi_controller *host,
struct spi_device *spi_dev, struct spi_device *spi_dev,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct mchp_corespi *spi = spi_master_get_devdata(master); struct mchp_corespi *spi = spi_controller_get_devdata(host);
int ret; int ret;
ret = mchp_corespi_calculate_clkgen(spi, (unsigned long)xfer->speed_hz); ret = mchp_corespi_calculate_clkgen(spi, (unsigned long)xfer->speed_hz);
if (ret) { if (ret) {
dev_err(&master->dev, "failed to set clk_gen for target %u Hz\n", xfer->speed_hz); dev_err(&host->dev, "failed to set clk_gen for target %u Hz\n", xfer->speed_hz);
return ret; return ret;
} }
...@@ -484,11 +484,11 @@ static int mchp_corespi_transfer_one(struct spi_master *master, ...@@ -484,11 +484,11 @@ static int mchp_corespi_transfer_one(struct spi_master *master,
return 1; return 1;
} }
static int mchp_corespi_prepare_message(struct spi_master *master, static int mchp_corespi_prepare_message(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct spi_device *spi_dev = msg->spi; struct spi_device *spi_dev = msg->spi;
struct mchp_corespi *spi = spi_master_get_devdata(master); struct mchp_corespi *spi = spi_controller_get_devdata(host);
mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE); mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE);
mchp_corespi_set_mode(spi, spi_dev->mode); mchp_corespi_set_mode(spi, spi_dev->mode);
...@@ -498,32 +498,32 @@ static int mchp_corespi_prepare_message(struct spi_master *master, ...@@ -498,32 +498,32 @@ static int mchp_corespi_prepare_message(struct spi_master *master,
static int mchp_corespi_probe(struct platform_device *pdev) static int mchp_corespi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct mchp_corespi *spi; struct mchp_corespi *spi;
struct resource *res; struct resource *res;
u32 num_cs; u32 num_cs;
int ret = 0; int ret = 0;
master = devm_spi_alloc_master(&pdev->dev, sizeof(*spi)); host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi));
if (!master) if (!host)
return dev_err_probe(&pdev->dev, -ENOMEM, return dev_err_probe(&pdev->dev, -ENOMEM,
"unable to allocate master for SPI controller\n"); "unable to allocate host for SPI controller\n");
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
if (of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs)) if (of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs))
num_cs = MAX_CS; num_cs = MAX_CS;
master->num_chipselect = num_cs; host->num_chipselect = num_cs;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
master->setup = mchp_corespi_setup; host->setup = mchp_corespi_setup;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->transfer_one = mchp_corespi_transfer_one; host->transfer_one = mchp_corespi_transfer_one;
master->prepare_message = mchp_corespi_prepare_message; host->prepare_message = mchp_corespi_prepare_message;
master->set_cs = mchp_corespi_set_cs; host->set_cs = mchp_corespi_set_cs;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
spi = spi_master_get_devdata(master); spi = spi_controller_get_devdata(host);
spi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); spi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(spi->regs)) if (IS_ERR(spi->regs))
...@@ -534,7 +534,7 @@ static int mchp_corespi_probe(struct platform_device *pdev) ...@@ -534,7 +534,7 @@ static int mchp_corespi_probe(struct platform_device *pdev)
return spi->irq; return spi->irq;
ret = devm_request_irq(&pdev->dev, spi->irq, mchp_corespi_interrupt, ret = devm_request_irq(&pdev->dev, spi->irq, mchp_corespi_interrupt,
IRQF_SHARED, dev_name(&pdev->dev), master); IRQF_SHARED, dev_name(&pdev->dev), host);
if (ret) if (ret)
return dev_err_probe(&pdev->dev, ret, return dev_err_probe(&pdev->dev, ret,
"could not request irq\n"); "could not request irq\n");
...@@ -549,25 +549,25 @@ static int mchp_corespi_probe(struct platform_device *pdev) ...@@ -549,25 +549,25 @@ static int mchp_corespi_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, ret, return dev_err_probe(&pdev->dev, ret,
"failed to enable clock\n"); "failed to enable clock\n");
mchp_corespi_init(master, spi); mchp_corespi_init(host, spi);
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (ret) { if (ret) {
mchp_corespi_disable(spi); mchp_corespi_disable(spi);
clk_disable_unprepare(spi->clk); clk_disable_unprepare(spi->clk);
return dev_err_probe(&pdev->dev, ret, return dev_err_probe(&pdev->dev, ret,
"unable to register master for SPI controller\n"); "unable to register host for SPI controller\n");
} }
dev_info(&pdev->dev, "Registered SPI controller %d\n", master->bus_num); dev_info(&pdev->dev, "Registered SPI controller %d\n", host->bus_num);
return 0; return 0;
} }
static void mchp_corespi_remove(struct platform_device *pdev) static void mchp_corespi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct mchp_corespi *spi = spi_master_get_devdata(master); struct mchp_corespi *spi = spi_controller_get_devdata(host);
mchp_corespi_disable_ints(spi); mchp_corespi_disable_ints(spi);
clk_disable_unprepare(spi->clk); clk_disable_unprepare(spi->clk);
......
...@@ -85,7 +85,7 @@ static int mpc512x_psc_spi_transfer_setup(struct spi_device *spi, ...@@ -85,7 +85,7 @@ static int mpc512x_psc_spi_transfer_setup(struct spi_device *spi,
static void mpc512x_psc_spi_activate_cs(struct spi_device *spi) static void mpc512x_psc_spi_activate_cs(struct spi_device *spi)
{ {
struct mpc512x_psc_spi_cs *cs = spi->controller_state; struct mpc512x_psc_spi_cs *cs = spi->controller_state;
struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); struct mpc512x_psc_spi *mps = spi_controller_get_devdata(spi->controller);
u32 sicr; u32 sicr;
u32 ccr; u32 ccr;
int speed; int speed;
...@@ -143,7 +143,7 @@ static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi) ...@@ -143,7 +143,7 @@ static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi)
static int mpc512x_psc_spi_transfer_rxtx(struct spi_device *spi, static int mpc512x_psc_spi_transfer_rxtx(struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); struct mpc512x_psc_spi *mps = spi_controller_get_devdata(spi->controller);
struct mpc512x_psc_fifo __iomem *fifo = mps->fifo; struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
size_t tx_len = t->len; size_t tx_len = t->len;
size_t rx_len = t->len; size_t rx_len = t->len;
...@@ -280,7 +280,7 @@ static int mpc512x_psc_spi_transfer_rxtx(struct spi_device *spi, ...@@ -280,7 +280,7 @@ static int mpc512x_psc_spi_transfer_rxtx(struct spi_device *spi,
return 0; return 0;
} }
static int mpc512x_psc_spi_msg_xfer(struct spi_master *master, static int mpc512x_psc_spi_msg_xfer(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
struct spi_device *spi; struct spi_device *spi;
...@@ -320,15 +320,15 @@ static int mpc512x_psc_spi_msg_xfer(struct spi_master *master, ...@@ -320,15 +320,15 @@ static int mpc512x_psc_spi_msg_xfer(struct spi_master *master,
mpc512x_psc_spi_transfer_setup(spi, NULL); mpc512x_psc_spi_transfer_setup(spi, NULL);
spi_finalize_current_message(master); spi_finalize_current_message(host);
return status; return status;
} }
static int mpc512x_psc_spi_prep_xfer_hw(struct spi_master *master) static int mpc512x_psc_spi_prep_xfer_hw(struct spi_controller *host)
{ {
struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); struct mpc512x_psc_spi *mps = spi_controller_get_devdata(host);
dev_dbg(&master->dev, "%s()\n", __func__); dev_dbg(&host->dev, "%s()\n", __func__);
/* Zero MR2 */ /* Zero MR2 */
in_8(psc_addr(mps, mr2)); in_8(psc_addr(mps, mr2));
...@@ -340,12 +340,12 @@ static int mpc512x_psc_spi_prep_xfer_hw(struct spi_master *master) ...@@ -340,12 +340,12 @@ static int mpc512x_psc_spi_prep_xfer_hw(struct spi_master *master)
return 0; return 0;
} }
static int mpc512x_psc_spi_unprep_xfer_hw(struct spi_master *master) static int mpc512x_psc_spi_unprep_xfer_hw(struct spi_controller *host)
{ {
struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); struct mpc512x_psc_spi *mps = spi_controller_get_devdata(host);
struct mpc512x_psc_fifo __iomem *fifo = mps->fifo; struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
dev_dbg(&master->dev, "%s()\n", __func__); dev_dbg(&host->dev, "%s()\n", __func__);
/* disable transmitter/receiver and fifo interrupt */ /* disable transmitter/receiver and fifo interrupt */
out_8(psc_addr(mps, command), MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE); out_8(psc_addr(mps, command), MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE);
...@@ -380,7 +380,7 @@ static void mpc512x_psc_spi_cleanup(struct spi_device *spi) ...@@ -380,7 +380,7 @@ static void mpc512x_psc_spi_cleanup(struct spi_device *spi)
kfree(spi->controller_state); kfree(spi->controller_state);
} }
static int mpc512x_psc_spi_port_config(struct spi_master *master, static int mpc512x_psc_spi_port_config(struct spi_controller *host,
struct mpc512x_psc_spi *mps) struct mpc512x_psc_spi *mps)
{ {
struct mpc512x_psc_fifo __iomem *fifo = mps->fifo; struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
...@@ -408,7 +408,7 @@ static int mpc512x_psc_spi_port_config(struct spi_master *master, ...@@ -408,7 +408,7 @@ static int mpc512x_psc_spi_port_config(struct spi_master *master,
sicr = 0x01000000 | /* SIM = 0001 -- 8 bit */ sicr = 0x01000000 | /* SIM = 0001 -- 8 bit */
0x00800000 | /* GenClk = 1 -- internal clk */ 0x00800000 | /* GenClk = 1 -- internal clk */
0x00008000 | /* SPI = 1 */ 0x00008000 | /* SPI = 1 */
0x00004000 | /* MSTR = 1 -- SPI master */ 0x00004000 | /* MSTR = 1 -- SPI host */
0x00000800; /* UseEOF = 1 -- SS low until EOF */ 0x00000800; /* UseEOF = 1 -- SS low until EOF */
out_be32(psc_addr(mps, sicr), sicr); out_be32(psc_addr(mps, sicr), sicr);
...@@ -459,28 +459,28 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev) ...@@ -459,28 +459,28 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct mpc512x_psc_spi *mps; struct mpc512x_psc_spi *mps;
struct spi_master *master; struct spi_controller *host;
int ret; int ret;
void *tempp; void *tempp;
struct clk *clk; struct clk *clk;
master = devm_spi_alloc_master(dev, sizeof(*mps)); host = devm_spi_alloc_host(dev, sizeof(*mps));
if (master == NULL) if (host == NULL)
return -ENOMEM; return -ENOMEM;
dev_set_drvdata(dev, master); dev_set_drvdata(dev, host);
mps = spi_master_get_devdata(master); mps = spi_controller_get_devdata(host);
mps->type = (int)device_get_match_data(dev); mps->type = (int)device_get_match_data(dev);
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->setup = mpc512x_psc_spi_setup; host->setup = mpc512x_psc_spi_setup;
master->prepare_transfer_hardware = mpc512x_psc_spi_prep_xfer_hw; host->prepare_transfer_hardware = mpc512x_psc_spi_prep_xfer_hw;
master->transfer_one_message = mpc512x_psc_spi_msg_xfer; host->transfer_one_message = mpc512x_psc_spi_msg_xfer;
master->unprepare_transfer_hardware = mpc512x_psc_spi_unprep_xfer_hw; host->unprepare_transfer_hardware = mpc512x_psc_spi_unprep_xfer_hw;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->cleanup = mpc512x_psc_spi_cleanup; host->cleanup = mpc512x_psc_spi_cleanup;
device_set_node(&master->dev, dev_fwnode(dev)); device_set_node(&host->dev, dev_fwnode(dev));
tempp = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); tempp = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(tempp)) if (IS_ERR(tempp))
...@@ -509,11 +509,11 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev) ...@@ -509,11 +509,11 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *pdev)
if (IS_ERR(clk)) if (IS_ERR(clk))
return PTR_ERR(clk); return PTR_ERR(clk);
ret = mpc512x_psc_spi_port_config(master, mps); ret = mpc512x_psc_spi_port_config(host, mps);
if (ret < 0) if (ret < 0)
return ret; return ret;
return devm_spi_register_master(dev, master); return devm_spi_register_controller(dev, host);
} }
static const struct of_device_id mpc512x_psc_spi_of_match[] = { static const struct of_device_id mpc512x_psc_spi_of_match[] = {
......
...@@ -60,7 +60,7 @@ static int mpc52xx_psc_spi_transfer_setup(struct spi_device *spi, ...@@ -60,7 +60,7 @@ static int mpc52xx_psc_spi_transfer_setup(struct spi_device *spi,
static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi) static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi)
{ {
struct mpc52xx_psc_spi_cs *cs = spi->controller_state; struct mpc52xx_psc_spi_cs *cs = spi->controller_state;
struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); struct mpc52xx_psc_spi *mps = spi_controller_get_devdata(spi->controller);
struct mpc52xx_psc __iomem *psc = mps->psc; struct mpc52xx_psc __iomem *psc = mps->psc;
u32 sicr; u32 sicr;
u16 ccr; u16 ccr;
...@@ -104,7 +104,7 @@ static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi) ...@@ -104,7 +104,7 @@ static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi)
static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi, static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); struct mpc52xx_psc_spi *mps = spi_controller_get_devdata(spi->controller);
struct mpc52xx_psc __iomem *psc = mps->psc; struct mpc52xx_psc __iomem *psc = mps->psc;
struct mpc52xx_psc_fifo __iomem *fifo = mps->fifo; struct mpc52xx_psc_fifo __iomem *fifo = mps->fifo;
unsigned rb = 0; /* number of bytes receieved */ unsigned rb = 0; /* number of bytes receieved */
...@@ -263,7 +263,7 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) ...@@ -263,7 +263,7 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps)
out_8(&fifo->rfcntl, 0); out_8(&fifo->rfcntl, 0);
out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL); out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL);
/* Configure 8bit codec mode as a SPI master and use EOF flags */ /* Configure 8bit codec mode as a SPI host and use EOF flags */
/* SICR_SIM_CODEC8|SICR_GENCLK|SICR_SPI|SICR_MSTR|SICR_USEEOF */ /* SICR_SIM_CODEC8|SICR_GENCLK|SICR_SPI|SICR_MSTR|SICR_USEEOF */
out_be32(&psc->sicr, 0x0180C800); out_be32(&psc->sicr, 0x0180C800);
out_be16((u16 __iomem *)&psc->ccr, 0x070F); /* default SPI Clk 1MHz */ out_be16((u16 __iomem *)&psc->ccr, 0x070F); /* default SPI Clk 1MHz */
...@@ -295,31 +295,31 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev) ...@@ -295,31 +295,31 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct mpc52xx_psc_spi *mps; struct mpc52xx_psc_spi *mps;
struct spi_master *master; struct spi_controller *host;
u32 bus_num; u32 bus_num;
int ret; int ret;
master = devm_spi_alloc_master(dev, sizeof(*mps)); host = devm_spi_alloc_host(dev, sizeof(*mps));
if (master == NULL) if (host == NULL)
return -ENOMEM; return -ENOMEM;
dev_set_drvdata(dev, master); dev_set_drvdata(dev, host);
mps = spi_master_get_devdata(master); mps = spi_controller_get_devdata(host);
/* 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;
ret = device_property_read_u32(dev, "cell-index", &bus_num); ret = device_property_read_u32(dev, "cell-index", &bus_num);
if (ret || bus_num > 5) if (ret || bus_num > 5)
return dev_err_probe(dev, ret ? : -EINVAL, "Invalid cell-index property\n"); return dev_err_probe(dev, ret ? : -EINVAL, "Invalid cell-index property\n");
master->bus_num = bus_num + 1; host->bus_num = bus_num + 1;
master->num_chipselect = 255; host->num_chipselect = 255;
master->setup = mpc52xx_psc_spi_setup; host->setup = mpc52xx_psc_spi_setup;
master->transfer_one_message = mpc52xx_psc_spi_transfer_one_message; host->transfer_one_message = mpc52xx_psc_spi_transfer_one_message;
master->cleanup = mpc52xx_psc_spi_cleanup; host->cleanup = mpc52xx_psc_spi_cleanup;
device_set_node(&master->dev, dev_fwnode(dev)); device_set_node(&host->dev, dev_fwnode(dev));
mps->psc = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); mps->psc = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(mps->psc)) if (IS_ERR(mps->psc))
...@@ -337,13 +337,13 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev) ...@@ -337,13 +337,13 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = mpc52xx_psc_spi_port_config(master->bus_num, mps); ret = mpc52xx_psc_spi_port_config(host->bus_num, mps);
if (ret < 0) if (ret < 0)
return dev_err_probe(dev, ret, "can't configure PSC! Is it capable of SPI?\n"); return dev_err_probe(dev, ret, "can't configure PSC! Is it capable of SPI?\n");
init_completion(&mps->done); init_completion(&mps->done);
return devm_spi_register_master(dev, master); return devm_spi_register_controller(dev, host);
} }
static const struct of_device_id mpc52xx_psc_spi_of_match[] = { static const struct of_device_id mpc52xx_psc_spi_of_match[] = {
......
...@@ -62,7 +62,7 @@ MODULE_LICENSE("GPL"); ...@@ -62,7 +62,7 @@ MODULE_LICENSE("GPL");
/* Driver internal data */ /* Driver internal data */
struct mpc52xx_spi { struct mpc52xx_spi {
struct spi_master *master; struct spi_controller *host;
void __iomem *regs; void __iomem *regs;
int irq0; /* MODF irq */ int irq0; /* MODF irq */
int irq1; /* SPIF irq */ int irq1; /* SPIF irq */
...@@ -152,7 +152,7 @@ mpc52xx_spi_fsmstate_idle(int irq, struct mpc52xx_spi *ms, u8 status, u8 data) ...@@ -152,7 +152,7 @@ mpc52xx_spi_fsmstate_idle(int irq, struct mpc52xx_spi *ms, u8 status, u8 data)
u8 ctrl1; u8 ctrl1;
if (status && irq) if (status && irq)
dev_err(&ms->master->dev, "spurious irq, status=0x%.2x\n", dev_err(&ms->host->dev, "spurious irq, status=0x%.2x\n",
status); status);
/* Check if there is another transfer waiting. */ /* Check if there is another transfer waiting. */
...@@ -235,7 +235,7 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms, ...@@ -235,7 +235,7 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms,
return FSM_CONTINUE; return FSM_CONTINUE;
} else if (status & SPI_STATUS_MODF) { } else if (status & SPI_STATUS_MODF) {
ms->modf_count++; ms->modf_count++;
dev_err(&ms->master->dev, "mode fault\n"); dev_err(&ms->host->dev, "mode fault\n");
mpc52xx_spi_chipsel(ms, 0); mpc52xx_spi_chipsel(ms, 0);
ms->message->status = -EIO; ms->message->status = -EIO;
if (ms->message->complete) if (ms->message->complete)
...@@ -280,7 +280,7 @@ static int ...@@ -280,7 +280,7 @@ static int
mpc52xx_spi_fsmstate_wait(int irq, struct mpc52xx_spi *ms, u8 status, u8 data) mpc52xx_spi_fsmstate_wait(int irq, struct mpc52xx_spi *ms, u8 status, u8 data)
{ {
if (status && irq) if (status && irq)
dev_err(&ms->master->dev, "spurious irq, status=0x%.2x\n", dev_err(&ms->host->dev, "spurious irq, status=0x%.2x\n",
status); status);
if (((int)mftb()) - ms->timestamp < 0) if (((int)mftb()) - ms->timestamp < 0)
...@@ -361,12 +361,12 @@ static void mpc52xx_spi_wq(struct work_struct *work) ...@@ -361,12 +361,12 @@ static void mpc52xx_spi_wq(struct work_struct *work)
} }
/* /*
* spi_master ops * spi_controller ops
*/ */
static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m) static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m)
{ {
struct mpc52xx_spi *ms = spi_master_get_devdata(spi->master); struct mpc52xx_spi *ms = spi_controller_get_devdata(spi->controller);
unsigned long flags; unsigned long flags;
m->actual_length = 0; m->actual_length = 0;
...@@ -385,7 +385,7 @@ static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m) ...@@ -385,7 +385,7 @@ static int mpc52xx_spi_transfer(struct spi_device *spi, struct spi_message *m)
*/ */
static int mpc52xx_spi_probe(struct platform_device *op) static int mpc52xx_spi_probe(struct platform_device *op)
{ {
struct spi_master *master; struct spi_controller *host;
struct mpc52xx_spi *ms; struct mpc52xx_spi *ms;
struct gpio_desc *gpio_cs; struct gpio_desc *gpio_cs;
void __iomem *regs; void __iomem *regs;
...@@ -406,7 +406,7 @@ static int mpc52xx_spi_probe(struct platform_device *op) ...@@ -406,7 +406,7 @@ static int mpc52xx_spi_probe(struct platform_device *op)
out_8(regs + SPI_PORTDATA, 0x8); /* Deassert /SS signal */ out_8(regs + SPI_PORTDATA, 0x8); /* Deassert /SS signal */
/* Clear the status register and re-read it to check for a MODF /* Clear the status register and re-read it to check for a MODF
* failure. This driver cannot currently handle multiple masters * failure. This driver cannot currently handle multiple hosts
* on the SPI bus. This fault will also occur if the SPI signals * on the SPI bus. This fault will also occur if the SPI signals
* are not connected to any pins (port_config setting) */ * are not connected to any pins (port_config setting) */
in_8(regs + SPI_STATUS); in_8(regs + SPI_STATUS);
...@@ -419,22 +419,22 @@ static int mpc52xx_spi_probe(struct platform_device *op) ...@@ -419,22 +419,22 @@ static int mpc52xx_spi_probe(struct platform_device *op)
goto err_init; goto err_init;
} }
dev_dbg(&op->dev, "allocating spi_master struct\n"); dev_dbg(&op->dev, "allocating spi_controller struct\n");
master = spi_alloc_master(&op->dev, sizeof(*ms)); host = spi_alloc_host(&op->dev, sizeof(*ms));
if (!master) { if (!host) {
rc = -ENOMEM; rc = -ENOMEM;
goto err_alloc; goto err_alloc;
} }
master->transfer = mpc52xx_spi_transfer; host->transfer = mpc52xx_spi_transfer;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->dev.of_node = op->dev.of_node; host->dev.of_node = op->dev.of_node;
platform_set_drvdata(op, master); platform_set_drvdata(op, host);
ms = spi_master_get_devdata(master); ms = spi_controller_get_devdata(host);
ms->master = master; ms->host = host;
ms->regs = regs; ms->regs = regs;
ms->irq0 = irq_of_parse_and_map(op->dev.of_node, 0); ms->irq0 = irq_of_parse_and_map(op->dev.of_node, 0);
ms->irq1 = irq_of_parse_and_map(op->dev.of_node, 1); ms->irq1 = irq_of_parse_and_map(op->dev.of_node, 1);
...@@ -442,7 +442,7 @@ static int mpc52xx_spi_probe(struct platform_device *op) ...@@ -442,7 +442,7 @@ static int mpc52xx_spi_probe(struct platform_device *op)
ms->ipb_freq = mpc5xxx_get_bus_frequency(&op->dev); ms->ipb_freq = mpc5xxx_get_bus_frequency(&op->dev);
ms->gpio_cs_count = gpiod_count(&op->dev, NULL); ms->gpio_cs_count = gpiod_count(&op->dev, NULL);
if (ms->gpio_cs_count > 0) { if (ms->gpio_cs_count > 0) {
master->num_chipselect = ms->gpio_cs_count; host->num_chipselect = ms->gpio_cs_count;
ms->gpio_cs = kmalloc_array(ms->gpio_cs_count, ms->gpio_cs = kmalloc_array(ms->gpio_cs_count,
sizeof(*ms->gpio_cs), sizeof(*ms->gpio_cs),
GFP_KERNEL); GFP_KERNEL);
...@@ -489,24 +489,24 @@ static int mpc52xx_spi_probe(struct platform_device *op) ...@@ -489,24 +489,24 @@ static int mpc52xx_spi_probe(struct platform_device *op)
if (!ms->irq0) if (!ms->irq0)
dev_info(&op->dev, "using polled mode\n"); dev_info(&op->dev, "using polled mode\n");
dev_dbg(&op->dev, "registering spi_master struct\n"); dev_dbg(&op->dev, "registering spi_controller struct\n");
rc = spi_register_master(master); rc = spi_register_controller(host);
if (rc) if (rc)
goto err_register; goto err_register;
dev_info(&ms->master->dev, "registered MPC5200 SPI bus\n"); dev_info(&ms->host->dev, "registered MPC5200 SPI bus\n");
return rc; return rc;
err_register: err_register:
dev_err(&ms->master->dev, "initialization failed\n"); dev_err(&ms->host->dev, "initialization failed\n");
err_gpio: err_gpio:
while (i-- > 0) while (i-- > 0)
gpiod_put(ms->gpio_cs[i]); gpiod_put(ms->gpio_cs[i]);
kfree(ms->gpio_cs); kfree(ms->gpio_cs);
err_alloc_gpio: err_alloc_gpio:
spi_master_put(master); spi_controller_put(host);
err_alloc: err_alloc:
err_init: err_init:
iounmap(regs); iounmap(regs);
...@@ -515,8 +515,8 @@ static int mpc52xx_spi_probe(struct platform_device *op) ...@@ -515,8 +515,8 @@ static int mpc52xx_spi_probe(struct platform_device *op)
static void mpc52xx_spi_remove(struct platform_device *op) static void mpc52xx_spi_remove(struct platform_device *op)
{ {
struct spi_master *master = spi_master_get(platform_get_drvdata(op)); struct spi_controller *host = spi_controller_get(platform_get_drvdata(op));
struct mpc52xx_spi *ms = spi_master_get_devdata(master); struct mpc52xx_spi *ms = spi_controller_get_devdata(host);
int i; int i;
free_irq(ms->irq0, ms); free_irq(ms->irq0, ms);
...@@ -526,9 +526,9 @@ static void mpc52xx_spi_remove(struct platform_device *op) ...@@ -526,9 +526,9 @@ static void mpc52xx_spi_remove(struct platform_device *op)
gpiod_put(ms->gpio_cs[i]); gpiod_put(ms->gpio_cs[i]);
kfree(ms->gpio_cs); kfree(ms->gpio_cs);
spi_unregister_master(master); spi_unregister_controller(host);
iounmap(ms->regs); iounmap(ms->regs);
spi_master_put(master); spi_controller_put(host);
} }
static const struct of_device_id mpc52xx_spi_match[] = { static const struct of_device_id mpc52xx_spi_match[] = {
......
This diff is collapsed.
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#define MT7621_LSB_FIRST BIT(3) #define MT7621_LSB_FIRST BIT(3)
struct mt7621_spi { struct mt7621_spi {
struct spi_controller *master; struct spi_controller *host;
void __iomem *base; void __iomem *base;
unsigned int sys_freq; unsigned int sys_freq;
unsigned int speed; unsigned int speed;
...@@ -62,7 +62,7 @@ struct mt7621_spi { ...@@ -62,7 +62,7 @@ struct mt7621_spi {
static inline struct mt7621_spi *spidev_to_mt7621_spi(struct spi_device *spi) static inline struct mt7621_spi *spidev_to_mt7621_spi(struct spi_device *spi)
{ {
return spi_controller_get_devdata(spi->master); return spi_controller_get_devdata(spi->controller);
} }
static inline u32 mt7621_spi_read(struct mt7621_spi *rs, u32 reg) static inline u32 mt7621_spi_read(struct mt7621_spi *rs, u32 reg)
...@@ -80,17 +80,17 @@ static void mt7621_spi_set_cs(struct spi_device *spi, int enable) ...@@ -80,17 +80,17 @@ static void mt7621_spi_set_cs(struct spi_device *spi, int enable)
struct mt7621_spi *rs = spidev_to_mt7621_spi(spi); struct mt7621_spi *rs = spidev_to_mt7621_spi(spi);
int cs = spi_get_chipselect(spi, 0); int cs = spi_get_chipselect(spi, 0);
u32 polar = 0; u32 polar = 0;
u32 master; u32 host;
/* /*
* Select SPI device 7, enable "more buffer mode" and disable * Select SPI device 7, enable "more buffer mode" and disable
* full-duplex (only half-duplex really works on this chip * full-duplex (only half-duplex really works on this chip
* reliably) * reliably)
*/ */
master = mt7621_spi_read(rs, MT7621_SPI_MASTER); host = mt7621_spi_read(rs, MT7621_SPI_MASTER);
master |= MASTER_RS_SLAVE_SEL | MASTER_MORE_BUFMODE; host |= MASTER_RS_SLAVE_SEL | MASTER_MORE_BUFMODE;
master &= ~MASTER_FULL_DUPLEX; host &= ~MASTER_FULL_DUPLEX;
mt7621_spi_write(rs, MT7621_SPI_MASTER, master); mt7621_spi_write(rs, MT7621_SPI_MASTER, host);
rs->pending_write = 0; rs->pending_write = 0;
...@@ -245,10 +245,10 @@ static void mt7621_spi_write_half_duplex(struct mt7621_spi *rs, ...@@ -245,10 +245,10 @@ static void mt7621_spi_write_half_duplex(struct mt7621_spi *rs,
rs->pending_write = len; rs->pending_write = len;
} }
static int mt7621_spi_transfer_one_message(struct spi_controller *master, static int mt7621_spi_transfer_one_message(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
struct mt7621_spi *rs = spi_controller_get_devdata(master); struct mt7621_spi *rs = spi_controller_get_devdata(host);
struct spi_device *spi = m->spi; struct spi_device *spi = m->spi;
unsigned int speed = spi->max_speed_hz; unsigned int speed = spi->max_speed_hz;
struct spi_transfer *t = NULL; struct spi_transfer *t = NULL;
...@@ -294,7 +294,7 @@ static int mt7621_spi_transfer_one_message(struct spi_controller *master, ...@@ -294,7 +294,7 @@ static int mt7621_spi_transfer_one_message(struct spi_controller *master,
msg_done: msg_done:
m->status = status; m->status = status;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return 0; return 0;
} }
...@@ -325,7 +325,7 @@ MODULE_DEVICE_TABLE(of, mt7621_spi_match); ...@@ -325,7 +325,7 @@ MODULE_DEVICE_TABLE(of, mt7621_spi_match);
static int mt7621_spi_probe(struct platform_device *pdev) static int mt7621_spi_probe(struct platform_device *pdev)
{ {
const struct of_device_id *match; const struct of_device_id *match;
struct spi_controller *master; struct spi_controller *host;
struct mt7621_spi *rs; struct mt7621_spi *rs;
void __iomem *base; void __iomem *base;
struct clk *clk; struct clk *clk;
...@@ -344,25 +344,25 @@ static int mt7621_spi_probe(struct platform_device *pdev) ...@@ -344,25 +344,25 @@ static int mt7621_spi_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(clk), return dev_err_probe(&pdev->dev, PTR_ERR(clk),
"unable to get SYS clock\n"); "unable to get SYS clock\n");
master = devm_spi_alloc_master(&pdev->dev, sizeof(*rs)); host = devm_spi_alloc_host(&pdev->dev, sizeof(*rs));
if (!master) { if (!host) {
dev_info(&pdev->dev, "master allocation failed\n"); dev_info(&pdev->dev, "host allocation failed\n");
return -ENOMEM; return -ENOMEM;
} }
master->mode_bits = SPI_LSB_FIRST; host->mode_bits = SPI_LSB_FIRST;
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->setup = mt7621_spi_setup; host->setup = mt7621_spi_setup;
master->transfer_one_message = mt7621_spi_transfer_one_message; host->transfer_one_message = mt7621_spi_transfer_one_message;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->num_chipselect = 2; host->num_chipselect = 2;
dev_set_drvdata(&pdev->dev, master); dev_set_drvdata(&pdev->dev, host);
rs = spi_controller_get_devdata(master); rs = spi_controller_get_devdata(host);
rs->base = base; rs->base = base;
rs->master = master; rs->host = host;
rs->sys_freq = clk_get_rate(clk); rs->sys_freq = clk_get_rate(clk);
rs->pending_write = 0; rs->pending_write = 0;
dev_info(&pdev->dev, "sys_freq: %u\n", rs->sys_freq); dev_info(&pdev->dev, "sys_freq: %u\n", rs->sys_freq);
...@@ -373,7 +373,7 @@ static int mt7621_spi_probe(struct platform_device *pdev) ...@@ -373,7 +373,7 @@ static int mt7621_spi_probe(struct platform_device *pdev)
return ret; return ret;
} }
return devm_spi_register_controller(&pdev->dev, master); return devm_spi_register_controller(&pdev->dev, host);
} }
MODULE_ALIAS("platform:" DRIVER_NAME); MODULE_ALIAS("platform:" DRIVER_NAME);
......
...@@ -275,7 +275,7 @@ static void mtk_nor_adj_prg_size(struct spi_mem_op *op) ...@@ -275,7 +275,7 @@ static void mtk_nor_adj_prg_size(struct spi_mem_op *op)
static int mtk_nor_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) static int mtk_nor_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{ {
struct mtk_nor *sp = spi_controller_get_devdata(mem->spi->master); struct mtk_nor *sp = spi_controller_get_devdata(mem->spi->controller);
if (!op->data.nbytes) if (!op->data.nbytes)
return 0; return 0;
...@@ -598,7 +598,7 @@ static int mtk_nor_spi_mem_prg(struct mtk_nor *sp, const struct spi_mem_op *op) ...@@ -598,7 +598,7 @@ static int mtk_nor_spi_mem_prg(struct mtk_nor *sp, const struct spi_mem_op *op)
static int mtk_nor_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static int mtk_nor_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct mtk_nor *sp = spi_controller_get_devdata(mem->spi->master); struct mtk_nor *sp = spi_controller_get_devdata(mem->spi->controller);
int ret; int ret;
if ((op->data.nbytes == 0) || if ((op->data.nbytes == 0) ||
...@@ -639,7 +639,7 @@ static int mtk_nor_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) ...@@ -639,7 +639,7 @@ static int mtk_nor_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
static int mtk_nor_setup(struct spi_device *spi) static int mtk_nor_setup(struct spi_device *spi)
{ {
struct mtk_nor *sp = spi_controller_get_devdata(spi->master); struct mtk_nor *sp = spi_controller_get_devdata(spi->controller);
if (spi->max_speed_hz && (spi->max_speed_hz < sp->spi_freq)) { if (spi->max_speed_hz && (spi->max_speed_hz < sp->spi_freq)) {
dev_err(&spi->dev, "spi clock should be %u Hz.\n", dev_err(&spi->dev, "spi clock should be %u Hz.\n",
...@@ -651,10 +651,10 @@ static int mtk_nor_setup(struct spi_device *spi) ...@@ -651,10 +651,10 @@ static int mtk_nor_setup(struct spi_device *spi)
return 0; return 0;
} }
static int mtk_nor_transfer_one_message(struct spi_controller *master, static int mtk_nor_transfer_one_message(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
struct mtk_nor *sp = spi_controller_get_devdata(master); struct mtk_nor *sp = spi_controller_get_devdata(host);
struct spi_transfer *t = NULL; struct spi_transfer *t = NULL;
unsigned long trx_len = 0; unsigned long trx_len = 0;
int stat = 0; int stat = 0;
...@@ -696,7 +696,7 @@ static int mtk_nor_transfer_one_message(struct spi_controller *master, ...@@ -696,7 +696,7 @@ static int mtk_nor_transfer_one_message(struct spi_controller *master,
m->actual_length = trx_len; m->actual_length = trx_len;
msg_done: msg_done:
m->status = stat; m->status = stat;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return 0; return 0;
} }
...@@ -844,7 +844,7 @@ static int mtk_nor_probe(struct platform_device *pdev) ...@@ -844,7 +844,7 @@ static int mtk_nor_probe(struct platform_device *pdev)
return ret; return ret;
} }
ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*sp)); ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*sp));
if (!ctlr) { if (!ctlr) {
dev_err(&pdev->dev, "failed to allocate spi controller\n"); dev_err(&pdev->dev, "failed to allocate spi controller\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -1255,7 +1255,7 @@ static bool mtk_snand_supports_op(struct spi_mem *mem, ...@@ -1255,7 +1255,7 @@ static bool mtk_snand_supports_op(struct spi_mem *mem,
static int mtk_snand_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) static int mtk_snand_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{ {
struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->master); struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->controller);
// page ops transfer size must be exactly ((sector_size + spare_size) * // page ops transfer size must be exactly ((sector_size + spare_size) *
// nsectors). Limit the op size if the caller requests more than that. // nsectors). Limit the op size if the caller requests more than that.
// exec_op will read more than needed and discard the leftover if the // exec_op will read more than needed and discard the leftover if the
...@@ -1282,7 +1282,7 @@ static int mtk_snand_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) ...@@ -1282,7 +1282,7 @@ static int mtk_snand_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
static int mtk_snand_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static int mtk_snand_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->master); struct mtk_snand *ms = spi_controller_get_devdata(mem->spi->controller);
dev_dbg(ms->dev, "OP %02x ADDR %08llX@%d:%u DATA %d:%u", op->cmd.opcode, dev_dbg(ms->dev, "OP %02x ADDR %08llX@%d:%u DATA %d:%u", op->cmd.opcode,
op->addr.val, op->addr.buswidth, op->addr.nbytes, op->addr.val, op->addr.buswidth, op->addr.nbytes,
...@@ -1382,7 +1382,7 @@ static int mtk_snand_probe(struct platform_device *pdev) ...@@ -1382,7 +1382,7 @@ static int mtk_snand_probe(struct platform_device *pdev)
if (!dev_id) if (!dev_id)
return -EINVAL; return -EINVAL;
ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*ms)); ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*ms));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, ctlr); platform_set_drvdata(pdev, ctlr);
......
...@@ -129,7 +129,7 @@ static int spi_mux_probe(struct spi_device *spi) ...@@ -129,7 +129,7 @@ static int spi_mux_probe(struct spi_device *spi)
struct spi_mux_priv *priv; struct spi_mux_priv *priv;
int ret; int ret;
ctlr = spi_alloc_master(&spi->dev, sizeof(*priv)); ctlr = spi_alloc_host(&spi->dev, sizeof(*priv));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
......
...@@ -390,7 +390,7 @@ static int mxic_spi_data_xfer(struct mxic_spi *mxic, const void *txbuf, ...@@ -390,7 +390,7 @@ static int mxic_spi_data_xfer(struct mxic_spi *mxic, const void *txbuf,
static ssize_t mxic_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc, static ssize_t mxic_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
u64 offs, size_t len, void *buf) u64 offs, size_t len, void *buf)
{ {
struct mxic_spi *mxic = spi_master_get_devdata(desc->mem->spi->master); struct mxic_spi *mxic = spi_controller_get_devdata(desc->mem->spi->controller);
int ret; int ret;
u32 sts; u32 sts;
...@@ -434,7 +434,7 @@ static ssize_t mxic_spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc, ...@@ -434,7 +434,7 @@ static ssize_t mxic_spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc,
u64 offs, size_t len, u64 offs, size_t len,
const void *buf) const void *buf)
{ {
struct mxic_spi *mxic = spi_master_get_devdata(desc->mem->spi->master); struct mxic_spi *mxic = spi_controller_get_devdata(desc->mem->spi->controller);
u32 sts; u32 sts;
int ret; int ret;
...@@ -493,7 +493,7 @@ static bool mxic_spi_mem_supports_op(struct spi_mem *mem, ...@@ -493,7 +493,7 @@ static bool mxic_spi_mem_supports_op(struct spi_mem *mem,
static int mxic_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc) static int mxic_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc)
{ {
struct mxic_spi *mxic = spi_master_get_devdata(desc->mem->spi->master); struct mxic_spi *mxic = spi_controller_get_devdata(desc->mem->spi->controller);
if (!mxic->linear.map) if (!mxic->linear.map)
return -EINVAL; return -EINVAL;
...@@ -510,7 +510,7 @@ static int mxic_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc) ...@@ -510,7 +510,7 @@ static int mxic_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc)
static int mxic_spi_mem_exec_op(struct spi_mem *mem, static int mxic_spi_mem_exec_op(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct mxic_spi *mxic = spi_master_get_devdata(mem->spi->master); struct mxic_spi *mxic = spi_controller_get_devdata(mem->spi->controller);
int i, ret; int i, ret;
u8 addr[8], cmd[2]; u8 addr[8], cmd[2];
...@@ -577,7 +577,7 @@ static const struct spi_controller_mem_caps mxic_spi_mem_caps = { ...@@ -577,7 +577,7 @@ static const struct spi_controller_mem_caps mxic_spi_mem_caps = {
static void mxic_spi_set_cs(struct spi_device *spi, bool lvl) static void mxic_spi_set_cs(struct spi_device *spi, bool lvl)
{ {
struct mxic_spi *mxic = spi_master_get_devdata(spi->master); struct mxic_spi *mxic = spi_controller_get_devdata(spi->controller);
if (!lvl) { if (!lvl) {
writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_EN, writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_EN,
...@@ -592,11 +592,11 @@ static void mxic_spi_set_cs(struct spi_device *spi, bool lvl) ...@@ -592,11 +592,11 @@ static void mxic_spi_set_cs(struct spi_device *spi, bool lvl)
} }
} }
static int mxic_spi_transfer_one(struct spi_master *master, static int mxic_spi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct mxic_spi *mxic = spi_master_get_devdata(master); struct mxic_spi *mxic = spi_controller_get_devdata(host);
unsigned int busw = OP_BUSW_1; unsigned int busw = OP_BUSW_1;
int ret; int ret;
...@@ -632,7 +632,7 @@ static int mxic_spi_transfer_one(struct spi_master *master, ...@@ -632,7 +632,7 @@ static int mxic_spi_transfer_one(struct spi_master *master,
if (ret) if (ret)
return ret; return ret;
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
return 0; return 0;
} }
...@@ -713,8 +713,8 @@ static int mxic_spi_mem_ecc_probe(struct platform_device *pdev, ...@@ -713,8 +713,8 @@ static int mxic_spi_mem_ecc_probe(struct platform_device *pdev,
static int __maybe_unused mxic_spi_runtime_suspend(struct device *dev) static int __maybe_unused mxic_spi_runtime_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mxic_spi *mxic = spi_master_get_devdata(master); struct mxic_spi *mxic = spi_controller_get_devdata(host);
mxic_spi_clk_disable(mxic); mxic_spi_clk_disable(mxic);
clk_disable_unprepare(mxic->ps_clk); clk_disable_unprepare(mxic->ps_clk);
...@@ -724,8 +724,8 @@ static int __maybe_unused mxic_spi_runtime_suspend(struct device *dev) ...@@ -724,8 +724,8 @@ static int __maybe_unused mxic_spi_runtime_suspend(struct device *dev)
static int __maybe_unused mxic_spi_runtime_resume(struct device *dev) static int __maybe_unused mxic_spi_runtime_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mxic_spi *mxic = spi_master_get_devdata(master); struct mxic_spi *mxic = spi_controller_get_devdata(host);
int ret; int ret;
ret = clk_prepare_enable(mxic->ps_clk); ret = clk_prepare_enable(mxic->ps_clk);
...@@ -744,21 +744,21 @@ static const struct dev_pm_ops mxic_spi_dev_pm_ops = { ...@@ -744,21 +744,21 @@ static const struct dev_pm_ops mxic_spi_dev_pm_ops = {
static int mxic_spi_probe(struct platform_device *pdev) static int mxic_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct resource *res; struct resource *res;
struct mxic_spi *mxic; struct mxic_spi *mxic;
int ret; int ret;
master = devm_spi_alloc_master(&pdev->dev, sizeof(struct mxic_spi)); host = devm_spi_alloc_host(&pdev->dev, sizeof(struct mxic_spi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
mxic = spi_master_get_devdata(master); mxic = spi_controller_get_devdata(host);
mxic->dev = &pdev->dev; mxic->dev = &pdev->dev;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
mxic->ps_clk = devm_clk_get(&pdev->dev, "ps_clk"); mxic->ps_clk = devm_clk_get(&pdev->dev, "ps_clk");
if (IS_ERR(mxic->ps_clk)) if (IS_ERR(mxic->ps_clk))
...@@ -786,19 +786,19 @@ static int mxic_spi_probe(struct platform_device *pdev) ...@@ -786,19 +786,19 @@ static int mxic_spi_probe(struct platform_device *pdev)
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
master->num_chipselect = 1; host->num_chipselect = 1;
master->mem_ops = &mxic_spi_mem_ops; host->mem_ops = &mxic_spi_mem_ops;
master->mem_caps = &mxic_spi_mem_caps; host->mem_caps = &mxic_spi_mem_caps;
master->set_cs = mxic_spi_set_cs; host->set_cs = mxic_spi_set_cs;
master->transfer_one = mxic_spi_transfer_one; host->transfer_one = mxic_spi_transfer_one;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->mode_bits = SPI_CPOL | SPI_CPHA | host->mode_bits = SPI_CPOL | SPI_CPHA |
SPI_RX_DUAL | SPI_TX_DUAL | SPI_RX_DUAL | SPI_TX_DUAL |
SPI_RX_QUAD | SPI_TX_QUAD | SPI_RX_QUAD | SPI_TX_QUAD |
SPI_RX_OCTAL | SPI_TX_OCTAL; SPI_RX_OCTAL | SPI_TX_OCTAL;
mxic_spi_hw_init(mxic); mxic_spi_hw_init(mxic);
...@@ -808,9 +808,9 @@ static int mxic_spi_probe(struct platform_device *pdev) ...@@ -808,9 +808,9 @@ static int mxic_spi_probe(struct platform_device *pdev)
return ret; return ret;
} }
ret = spi_register_master(master); ret = spi_register_controller(host);
if (ret) { if (ret) {
dev_err(&pdev->dev, "spi_register_master failed\n"); dev_err(&pdev->dev, "spi_register_controller failed\n");
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
mxic_spi_mem_ecc_remove(mxic); mxic_spi_mem_ecc_remove(mxic);
} }
...@@ -820,12 +820,12 @@ static int mxic_spi_probe(struct platform_device *pdev) ...@@ -820,12 +820,12 @@ static int mxic_spi_probe(struct platform_device *pdev)
static void mxic_spi_remove(struct platform_device *pdev) static void mxic_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct mxic_spi *mxic = spi_master_get_devdata(master); struct mxic_spi *mxic = spi_controller_get_devdata(host);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
mxic_spi_mem_ecc_remove(mxic); mxic_spi_mem_ecc_remove(mxic);
spi_unregister_master(master); spi_unregister_controller(host);
} }
static const struct of_device_id mxic_spi_of_ids[] = { static const struct of_device_id mxic_spi_of_ids[] = {
......
// SPDX-License-Identifier: GPL-2.0+ // SPDX-License-Identifier: GPL-2.0+
// //
// Freescale MXS SPI master driver // Freescale MXS SPI host driver
// //
// Copyright 2012 DENX Software Engineering, GmbH. // Copyright 2012 DENX Software Engineering, GmbH.
// Copyright 2012 Freescale Semiconductor, Inc. // Copyright 2012 Freescale Semiconductor, Inc.
...@@ -63,7 +63,7 @@ struct mxs_spi { ...@@ -63,7 +63,7 @@ struct mxs_spi {
static int mxs_spi_setup_transfer(struct spi_device *dev, static int mxs_spi_setup_transfer(struct spi_device *dev,
const struct spi_transfer *t) const struct spi_transfer *t)
{ {
struct mxs_spi *spi = spi_master_get_devdata(dev->master); struct mxs_spi *spi = spi_controller_get_devdata(dev->controller);
struct mxs_ssp *ssp = &spi->ssp; struct mxs_ssp *ssp = &spi->ssp;
const unsigned int hz = min(dev->max_speed_hz, t->speed_hz); const unsigned int hz = min(dev->max_speed_hz, t->speed_hz);
...@@ -357,10 +357,10 @@ static int mxs_spi_txrx_pio(struct mxs_spi *spi, ...@@ -357,10 +357,10 @@ static int mxs_spi_txrx_pio(struct mxs_spi *spi,
return -ETIMEDOUT; return -ETIMEDOUT;
} }
static int mxs_spi_transfer_one(struct spi_master *master, static int mxs_spi_transfer_one(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
struct mxs_spi *spi = spi_master_get_devdata(master); struct mxs_spi *spi = spi_controller_get_devdata(host);
struct mxs_ssp *ssp = &spi->ssp; struct mxs_ssp *ssp = &spi->ssp;
struct spi_transfer *t; struct spi_transfer *t;
unsigned int flag; unsigned int flag;
...@@ -432,15 +432,15 @@ static int mxs_spi_transfer_one(struct spi_master *master, ...@@ -432,15 +432,15 @@ static int mxs_spi_transfer_one(struct spi_master *master,
} }
m->status = status; m->status = status;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return status; return status;
} }
static int mxs_spi_runtime_suspend(struct device *dev) static int mxs_spi_runtime_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mxs_spi *spi = spi_master_get_devdata(master); struct mxs_spi *spi = spi_controller_get_devdata(host);
struct mxs_ssp *ssp = &spi->ssp; struct mxs_ssp *ssp = &spi->ssp;
int ret; int ret;
...@@ -460,8 +460,8 @@ static int mxs_spi_runtime_suspend(struct device *dev) ...@@ -460,8 +460,8 @@ static int mxs_spi_runtime_suspend(struct device *dev)
static int mxs_spi_runtime_resume(struct device *dev) static int mxs_spi_runtime_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mxs_spi *spi = spi_master_get_devdata(master); struct mxs_spi *spi = spi_controller_get_devdata(host);
struct mxs_ssp *ssp = &spi->ssp; struct mxs_ssp *ssp = &spi->ssp;
int ret; int ret;
...@@ -478,10 +478,10 @@ static int mxs_spi_runtime_resume(struct device *dev) ...@@ -478,10 +478,10 @@ static int mxs_spi_runtime_resume(struct device *dev)
static int __maybe_unused mxs_spi_suspend(struct device *dev) static int __maybe_unused mxs_spi_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;
...@@ -493,7 +493,7 @@ static int __maybe_unused mxs_spi_suspend(struct device *dev) ...@@ -493,7 +493,7 @@ static int __maybe_unused mxs_spi_suspend(struct device *dev)
static int __maybe_unused mxs_spi_resume(struct device *dev) static int __maybe_unused mxs_spi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
int ret; int ret;
if (!pm_runtime_suspended(dev)) if (!pm_runtime_suspended(dev))
...@@ -503,7 +503,7 @@ static int __maybe_unused mxs_spi_resume(struct device *dev) ...@@ -503,7 +503,7 @@ static int __maybe_unused mxs_spi_resume(struct device *dev)
if (ret) if (ret)
return ret; return ret;
ret = spi_master_resume(master); ret = spi_controller_resume(host);
if (ret < 0 && !pm_runtime_suspended(dev)) if (ret < 0 && !pm_runtime_suspended(dev))
mxs_spi_runtime_suspend(dev); mxs_spi_runtime_suspend(dev);
...@@ -528,7 +528,7 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -528,7 +528,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
const struct of_device_id *of_id = const struct of_device_id *of_id =
of_match_device(mxs_spi_dt_ids, &pdev->dev); of_match_device(mxs_spi_dt_ids, &pdev->dev);
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct spi_master *master; struct spi_controller *host;
struct mxs_spi *spi; struct mxs_spi *spi;
struct mxs_ssp *ssp; struct mxs_ssp *ssp;
struct clk *clk; struct clk *clk;
...@@ -561,21 +561,21 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -561,21 +561,21 @@ static int mxs_spi_probe(struct platform_device *pdev)
if (ret) if (ret)
clk_freq = clk_freq_default; clk_freq = clk_freq_default;
master = spi_alloc_master(&pdev->dev, sizeof(*spi)); host = spi_alloc_host(&pdev->dev, sizeof(*spi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
master->transfer_one_message = mxs_spi_transfer_one; host->transfer_one_message = mxs_spi_transfer_one;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->mode_bits = SPI_CPOL | SPI_CPHA; host->mode_bits = SPI_CPOL | SPI_CPHA;
master->num_chipselect = 3; host->num_chipselect = 3;
master->dev.of_node = np; host->dev.of_node = np;
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
spi = spi_master_get_devdata(master); spi = spi_controller_get_devdata(host);
ssp = &spi->ssp; ssp = &spi->ssp;
ssp->dev = &pdev->dev; ssp->dev = &pdev->dev;
ssp->clk = clk; ssp->clk = clk;
...@@ -587,13 +587,13 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -587,13 +587,13 @@ static int mxs_spi_probe(struct platform_device *pdev)
ret = devm_request_irq(&pdev->dev, irq_err, mxs_ssp_irq_handler, 0, ret = devm_request_irq(&pdev->dev, irq_err, mxs_ssp_irq_handler, 0,
dev_name(&pdev->dev), ssp); dev_name(&pdev->dev), ssp);
if (ret) if (ret)
goto out_master_free; goto out_host_free;
ssp->dmach = dma_request_chan(&pdev->dev, "rx-tx"); ssp->dmach = dma_request_chan(&pdev->dev, "rx-tx");
if (IS_ERR(ssp->dmach)) { if (IS_ERR(ssp->dmach)) {
dev_err(ssp->dev, "Failed to request DMA\n"); dev_err(ssp->dev, "Failed to request DMA\n");
ret = PTR_ERR(ssp->dmach); ret = PTR_ERR(ssp->dmach);
goto out_master_free; goto out_host_free;
} }
pm_runtime_enable(ssp->dev); pm_runtime_enable(ssp->dev);
...@@ -617,9 +617,9 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -617,9 +617,9 @@ static int mxs_spi_probe(struct platform_device *pdev)
if (ret) if (ret)
goto out_pm_runtime_put; goto out_pm_runtime_put;
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Cannot register SPI master, %d\n", ret); dev_err(&pdev->dev, "Cannot register SPI host, %d\n", ret);
goto out_pm_runtime_put; goto out_pm_runtime_put;
} }
...@@ -633,19 +633,19 @@ static int mxs_spi_probe(struct platform_device *pdev) ...@@ -633,19 +633,19 @@ static int mxs_spi_probe(struct platform_device *pdev)
pm_runtime_disable(ssp->dev); pm_runtime_disable(ssp->dev);
out_dma_release: out_dma_release:
dma_release_channel(ssp->dmach); dma_release_channel(ssp->dmach);
out_master_free: out_host_free:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void mxs_spi_remove(struct platform_device *pdev) static void mxs_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct mxs_spi *spi; struct mxs_spi *spi;
struct mxs_ssp *ssp; struct mxs_ssp *ssp;
master = platform_get_drvdata(pdev); host = platform_get_drvdata(pdev);
spi = spi_master_get_devdata(master); spi = spi_controller_get_devdata(host);
ssp = &spi->ssp; ssp = &spi->ssp;
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
...@@ -668,6 +668,6 @@ static struct platform_driver mxs_spi_driver = { ...@@ -668,6 +668,6 @@ static struct platform_driver mxs_spi_driver = {
module_platform_driver(mxs_spi_driver); module_platform_driver(mxs_spi_driver);
MODULE_AUTHOR("Marek Vasut <marex@denx.de>"); MODULE_AUTHOR("Marek Vasut <marex@denx.de>");
MODULE_DESCRIPTION("MXS SPI master driver"); MODULE_DESCRIPTION("MXS SPI host driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:mxs-spi"); MODULE_ALIAS("platform:mxs-spi");
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
struct npcm_pspi { struct npcm_pspi {
struct completion xfer_done; struct completion xfer_done;
struct reset_control *reset; struct reset_control *reset;
struct spi_master *master; struct spi_controller *host;
unsigned int tx_bytes; unsigned int tx_bytes;
unsigned int rx_bytes; unsigned int rx_bytes;
void __iomem *base; void __iomem *base;
...@@ -101,7 +101,7 @@ static inline void npcm_pspi_disable(struct npcm_pspi *priv) ...@@ -101,7 +101,7 @@ static inline void npcm_pspi_disable(struct npcm_pspi *priv)
static void npcm_pspi_set_mode(struct spi_device *spi) static void npcm_pspi_set_mode(struct spi_device *spi)
{ {
struct npcm_pspi *priv = spi_master_get_devdata(spi->master); struct npcm_pspi *priv = spi_controller_get_devdata(spi->controller);
u16 regtemp; u16 regtemp;
u16 mode_val; u16 mode_val;
...@@ -159,7 +159,7 @@ static void npcm_pspi_set_baudrate(struct npcm_pspi *priv, unsigned int speed) ...@@ -159,7 +159,7 @@ static void npcm_pspi_set_baudrate(struct npcm_pspi *priv, unsigned int speed)
static void npcm_pspi_setup_transfer(struct spi_device *spi, static void npcm_pspi_setup_transfer(struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct npcm_pspi *priv = spi_master_get_devdata(spi->master); struct npcm_pspi *priv = spi_controller_get_devdata(spi->controller);
priv->tx_buf = t->tx_buf; priv->tx_buf = t->tx_buf;
priv->rx_buf = t->rx_buf; priv->rx_buf = t->rx_buf;
...@@ -245,11 +245,11 @@ static void npcm_pspi_recv(struct npcm_pspi *priv) ...@@ -245,11 +245,11 @@ static void npcm_pspi_recv(struct npcm_pspi *priv)
} }
} }
static int npcm_pspi_transfer_one(struct spi_master *master, static int npcm_pspi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct npcm_pspi *priv = spi_master_get_devdata(master); struct npcm_pspi *priv = spi_controller_get_devdata(host);
int status; int status;
npcm_pspi_setup_transfer(spi, t); npcm_pspi_setup_transfer(spi, t);
...@@ -266,18 +266,18 @@ static int npcm_pspi_transfer_one(struct spi_master *master, ...@@ -266,18 +266,18 @@ static int npcm_pspi_transfer_one(struct spi_master *master,
return 0; return 0;
} }
static int npcm_pspi_prepare_transfer_hardware(struct spi_master *master) static int npcm_pspi_prepare_transfer_hardware(struct spi_controller *host)
{ {
struct npcm_pspi *priv = spi_master_get_devdata(master); struct npcm_pspi *priv = spi_controller_get_devdata(host);
npcm_pspi_irq_enable(priv, NPCM_PSPI_CTL1_EIR | NPCM_PSPI_CTL1_EIW); npcm_pspi_irq_enable(priv, NPCM_PSPI_CTL1_EIR | NPCM_PSPI_CTL1_EIW);
return 0; return 0;
} }
static int npcm_pspi_unprepare_transfer_hardware(struct spi_master *master) static int npcm_pspi_unprepare_transfer_hardware(struct spi_controller *host)
{ {
struct npcm_pspi *priv = spi_master_get_devdata(master); struct npcm_pspi *priv = spi_controller_get_devdata(host);
npcm_pspi_irq_disable(priv, NPCM_PSPI_CTL1_EIR | NPCM_PSPI_CTL1_EIW); npcm_pspi_irq_disable(priv, NPCM_PSPI_CTL1_EIR | NPCM_PSPI_CTL1_EIW);
...@@ -340,37 +340,37 @@ static irqreturn_t npcm_pspi_handler(int irq, void *dev_id) ...@@ -340,37 +340,37 @@ static irqreturn_t npcm_pspi_handler(int irq, void *dev_id)
static int npcm_pspi_probe(struct platform_device *pdev) static int npcm_pspi_probe(struct platform_device *pdev)
{ {
struct npcm_pspi *priv; struct npcm_pspi *priv;
struct spi_master *master; struct spi_controller *host;
unsigned long clk_hz; unsigned long clk_hz;
int irq; int irq;
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;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
priv = spi_master_get_devdata(master); priv = spi_controller_get_devdata(host);
priv->master = master; priv->host = host;
priv->is_save_param = false; priv->is_save_param = false;
priv->base = devm_platform_ioremap_resource(pdev, 0); priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base)) { if (IS_ERR(priv->base)) {
ret = PTR_ERR(priv->base); ret = PTR_ERR(priv->base);
goto out_master_put; goto out_host_put;
} }
priv->clk = devm_clk_get(&pdev->dev, NULL); priv->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "failed to get clock\n"); dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(priv->clk); ret = PTR_ERR(priv->clk);
goto out_master_put; goto out_host_put;
} }
ret = clk_prepare_enable(priv->clk); ret = clk_prepare_enable(priv->clk);
if (ret) if (ret)
goto out_master_put; goto out_host_put;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
...@@ -398,42 +398,42 @@ static int npcm_pspi_probe(struct platform_device *pdev) ...@@ -398,42 +398,42 @@ static int npcm_pspi_probe(struct platform_device *pdev)
clk_hz = clk_get_rate(priv->clk); clk_hz = clk_get_rate(priv->clk);
master->max_speed_hz = DIV_ROUND_UP(clk_hz, NPCM_PSPI_MIN_CLK_DIVIDER); host->max_speed_hz = DIV_ROUND_UP(clk_hz, NPCM_PSPI_MIN_CLK_DIVIDER);
master->min_speed_hz = DIV_ROUND_UP(clk_hz, NPCM_PSPI_MAX_CLK_DIVIDER); host->min_speed_hz = DIV_ROUND_UP(clk_hz, NPCM_PSPI_MAX_CLK_DIVIDER);
master->mode_bits = SPI_CPHA | SPI_CPOL; host->mode_bits = SPI_CPHA | SPI_CPOL;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->bus_num = -1; host->bus_num = -1;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); host->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->transfer_one = npcm_pspi_transfer_one; host->transfer_one = npcm_pspi_transfer_one;
master->prepare_transfer_hardware = host->prepare_transfer_hardware =
npcm_pspi_prepare_transfer_hardware; npcm_pspi_prepare_transfer_hardware;
master->unprepare_transfer_hardware = host->unprepare_transfer_hardware =
npcm_pspi_unprepare_transfer_hardware; npcm_pspi_unprepare_transfer_hardware;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
/* set to default clock rate */ /* set to default clock rate */
npcm_pspi_set_baudrate(priv, NPCM_PSPI_DEFAULT_CLK); npcm_pspi_set_baudrate(priv, NPCM_PSPI_DEFAULT_CLK);
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (ret) if (ret)
goto out_disable_clk; goto out_disable_clk;
pr_info("NPCM Peripheral SPI %d probed\n", master->bus_num); pr_info("NPCM Peripheral SPI %d probed\n", host->bus_num);
return 0; return 0;
out_disable_clk: out_disable_clk:
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
out_master_put: out_host_put:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void npcm_pspi_remove(struct platform_device *pdev) static void npcm_pspi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct npcm_pspi *priv = spi_master_get_devdata(master); struct npcm_pspi *priv = spi_controller_get_devdata(host);
npcm_pspi_reset_hw(priv); npcm_pspi_reset_hw(priv);
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
......
...@@ -451,7 +451,7 @@ static int nxp_fspi_check_buswidth(struct nxp_fspi *f, u8 width) ...@@ -451,7 +451,7 @@ static int nxp_fspi_check_buswidth(struct nxp_fspi *f, u8 width)
static bool nxp_fspi_supports_op(struct spi_mem *mem, static bool nxp_fspi_supports_op(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->controller);
int ret; int ret;
ret = nxp_fspi_check_buswidth(f, op->cmd.buswidth); ret = nxp_fspi_check_buswidth(f, op->cmd.buswidth);
...@@ -520,7 +520,7 @@ static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base, ...@@ -520,7 +520,7 @@ static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base,
} }
/* /*
* If the slave device content being changed by Write/Erase, need to * If the target device content being changed by Write/Erase, need to
* invalidate the AHB buffer. This can be achieved by doing the reset * invalidate the AHB buffer. This can be achieved by doing the reset
* of controller after setting MCR0[SWRESET] bit. * of controller after setting MCR0[SWRESET] bit.
*/ */
...@@ -661,7 +661,7 @@ static void nxp_fspi_dll_calibration(struct nxp_fspi *f) ...@@ -661,7 +661,7 @@ static void nxp_fspi_dll_calibration(struct nxp_fspi *f)
/* /*
* In FlexSPI controller, flash access is based on value of FSPI_FLSHXXCR0 * In FlexSPI controller, flash access is based on value of FSPI_FLSHXXCR0
* register and start base address of the slave device. * register and start base address of the target device.
* *
* (Higher address) * (Higher address)
* -------- <-- FLSHB2CR0 * -------- <-- FLSHB2CR0
...@@ -680,15 +680,15 @@ static void nxp_fspi_dll_calibration(struct nxp_fspi *f) ...@@ -680,15 +680,15 @@ static void nxp_fspi_dll_calibration(struct nxp_fspi *f)
* *
* *
* Start base address defines the starting address range for given CS and * Start base address defines the starting address range for given CS and
* FSPI_FLSHXXCR0 defines the size of the slave device connected at given CS. * FSPI_FLSHXXCR0 defines the size of the target device connected at given CS.
* *
* But, different targets are having different combinations of number of CS, * But, different targets are having different combinations of number of CS,
* some targets only have single CS or two CS covering controller's full * some targets only have single CS or two CS covering controller's full
* memory mapped space area. * memory mapped space area.
* Thus, implementation is being done as independent of the size and number * Thus, implementation is being done as independent of the size and number
* of the connected slave device. * of the connected target device.
* Assign controller memory mapped space size as the size to the connected * Assign controller memory mapped space size as the size to the connected
* slave device. * target device.
* Mark FLSHxxCR0 as zero initially and then assign value only to the selected * Mark FLSHxxCR0 as zero initially and then assign value only to the selected
* chip-select Flash configuration register. * chip-select Flash configuration register.
* *
...@@ -704,8 +704,8 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi) ...@@ -704,8 +704,8 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
uint64_t size_kb; uint64_t size_kb;
/* /*
* Return, if previously selected slave device is same as current * Return, if previously selected target device is same as current
* requested slave device. * requested target device.
*/ */
if (f->selected == spi_get_chipselect(spi, 0)) if (f->selected == spi_get_chipselect(spi, 0))
return; return;
...@@ -722,7 +722,7 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi) ...@@ -722,7 +722,7 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 + fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 +
4 * spi_get_chipselect(spi, 0)); 4 * spi_get_chipselect(spi, 0));
dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi_get_chipselect(spi, 0)); dev_dbg(f->dev, "Target device [CS:%x] selected\n", spi_get_chipselect(spi, 0));
nxp_fspi_clk_disable_unprep(f); nxp_fspi_clk_disable_unprep(f);
...@@ -912,7 +912,7 @@ static int nxp_fspi_do_op(struct nxp_fspi *f, const struct spi_mem_op *op) ...@@ -912,7 +912,7 @@ static int nxp_fspi_do_op(struct nxp_fspi *f, const struct spi_mem_op *op)
static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->controller);
int err = 0; int err = 0;
mutex_lock(&f->lock); mutex_lock(&f->lock);
...@@ -952,7 +952,7 @@ static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) ...@@ -952,7 +952,7 @@ static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{ {
struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); struct nxp_fspi *f = 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 > f->devtype_data->txfifo) if (op->data.nbytes > f->devtype_data->txfifo)
...@@ -1049,7 +1049,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f) ...@@ -1049,7 +1049,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
fspi_writel(f, FSPI_MCR0_MDIS, base + FSPI_MCR0); fspi_writel(f, FSPI_MCR0_MDIS, base + FSPI_MCR0);
/* /*
* Config the DLL register to default value, enable the slave clock delay * Config the DLL register to default value, enable the target clock delay
* line delay cell override mode, and use 1 fixed delay cell in DLL delay * line delay cell override mode, and use 1 fixed delay cell in DLL delay
* chain, this is the suggested setting when clock rate < 100MHz. * chain, this is the suggested setting when clock rate < 100MHz.
*/ */
...@@ -1062,7 +1062,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f) ...@@ -1062,7 +1062,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
base + FSPI_MCR0); base + FSPI_MCR0);
/* /*
* Disable same device enable bit and configure all slave devices * Disable same device enable bit and configure all target devices
* independently. * independently.
*/ */
reg = fspi_readl(f, f->iobase + FSPI_MCR2); reg = fspi_readl(f, f->iobase + FSPI_MCR2);
...@@ -1100,7 +1100,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f) ...@@ -1100,7 +1100,7 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
static const char *nxp_fspi_get_name(struct spi_mem *mem) static const char *nxp_fspi_get_name(struct spi_mem *mem)
{ {
struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master); struct nxp_fspi *f = 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;
...@@ -1137,7 +1137,7 @@ static int nxp_fspi_probe(struct platform_device *pdev) ...@@ -1137,7 +1137,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
int ret; int ret;
u32 reg; u32 reg;
ctlr = spi_alloc_master(&pdev->dev, sizeof(*f)); ctlr = spi_alloc_host(&pdev->dev, sizeof(*f));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
......
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* OpenCores tiny SPI master driver * OpenCores tiny SPI host driver
* *
* https://opencores.org/project,tiny_spi * https://opencores.org/project,tiny_spi
* *
...@@ -53,7 +53,7 @@ struct tiny_spi { ...@@ -53,7 +53,7 @@ struct tiny_spi {
static inline struct tiny_spi *tiny_spi_to_hw(struct spi_device *sdev) static inline struct tiny_spi *tiny_spi_to_hw(struct spi_device *sdev)
{ {
return spi_master_get_devdata(sdev->master); return spi_controller_get_devdata(sdev->controller);
} }
static unsigned int tiny_spi_baud(struct spi_device *spi, unsigned int hz) static unsigned int tiny_spi_baud(struct spi_device *spi, unsigned int hz)
...@@ -212,24 +212,24 @@ static int tiny_spi_probe(struct platform_device *pdev) ...@@ -212,24 +212,24 @@ static int tiny_spi_probe(struct platform_device *pdev)
{ {
struct tiny_spi_platform_data *platp = dev_get_platdata(&pdev->dev); struct tiny_spi_platform_data *platp = dev_get_platdata(&pdev->dev);
struct tiny_spi *hw; struct tiny_spi *hw;
struct spi_master *master; struct spi_controller *host;
int err = -ENODEV; int err = -ENODEV;
master = spi_alloc_master(&pdev->dev, sizeof(struct tiny_spi)); host = spi_alloc_host(&pdev->dev, sizeof(struct tiny_spi));
if (!master) if (!host)
return err; return err;
/* setup the master state. */ /* setup the host state. */
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
master->setup = tiny_spi_setup; host->setup = tiny_spi_setup;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
hw = spi_master_get_devdata(master); hw = spi_controller_get_devdata(host);
platform_set_drvdata(pdev, hw); platform_set_drvdata(pdev, hw);
/* setup the state for the bitbang driver */ /* setup the state for the bitbang driver */
hw->bitbang.master = master; hw->bitbang.master = host;
hw->bitbang.setup_transfer = tiny_spi_setup_transfer; hw->bitbang.setup_transfer = tiny_spi_setup_transfer;
hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs; hw->bitbang.txrx_bufs = tiny_spi_txrx_bufs;
...@@ -267,17 +267,17 @@ static int tiny_spi_probe(struct platform_device *pdev) ...@@ -267,17 +267,17 @@ static int tiny_spi_probe(struct platform_device *pdev)
return 0; return 0;
exit: exit:
spi_master_put(master); spi_controller_put(host);
return err; return err;
} }
static void tiny_spi_remove(struct platform_device *pdev) static void tiny_spi_remove(struct platform_device *pdev)
{ {
struct tiny_spi *hw = platform_get_drvdata(pdev); struct tiny_spi *hw = platform_get_drvdata(pdev);
struct spi_master *master = hw->bitbang.master; struct spi_controller *host = hw->bitbang.master;
spi_bitbang_stop(&hw->bitbang); spi_bitbang_stop(&hw->bitbang);
spi_master_put(master); spi_controller_put(host);
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
......
...@@ -315,7 +315,7 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t) ...@@ -315,7 +315,7 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
int div2; int div2;
int status; int status;
uwire = spi_master_get_devdata(spi->master); uwire = spi_controller_get_devdata(spi->controller);
/* mode 0..3, clock inverted separately; /* mode 0..3, clock inverted separately;
* standard nCS signaling; * standard nCS signaling;
...@@ -448,25 +448,25 @@ static void uwire_off(struct uwire_spi *uwire) ...@@ -448,25 +448,25 @@ static void uwire_off(struct uwire_spi *uwire)
{ {
uwire_write_reg(UWIRE_SR3, 0); uwire_write_reg(UWIRE_SR3, 0);
clk_disable_unprepare(uwire->ck); clk_disable_unprepare(uwire->ck);
spi_master_put(uwire->bitbang.master); spi_controller_put(uwire->bitbang.master);
} }
static int uwire_probe(struct platform_device *pdev) static int uwire_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct uwire_spi *uwire; struct uwire_spi *uwire;
int status; int status;
master = spi_alloc_master(&pdev->dev, sizeof(*uwire)); host = spi_alloc_host(&pdev->dev, sizeof(*uwire));
if (!master) if (!host)
return -ENODEV; return -ENODEV;
uwire = spi_master_get_devdata(master); uwire = spi_controller_get_devdata(host);
uwire_base = devm_ioremap(&pdev->dev, UWIRE_BASE_PHYS, UWIRE_IO_SIZE); uwire_base = devm_ioremap(&pdev->dev, UWIRE_BASE_PHYS, UWIRE_IO_SIZE);
if (!uwire_base) { if (!uwire_base) {
dev_dbg(&pdev->dev, "can't ioremap UWIRE\n"); dev_dbg(&pdev->dev, "can't ioremap UWIRE\n");
spi_master_put(master); spi_controller_put(host);
return -ENOMEM; return -ENOMEM;
} }
...@@ -476,7 +476,7 @@ static int uwire_probe(struct platform_device *pdev) ...@@ -476,7 +476,7 @@ static int uwire_probe(struct platform_device *pdev)
if (IS_ERR(uwire->ck)) { if (IS_ERR(uwire->ck)) {
status = PTR_ERR(uwire->ck); status = PTR_ERR(uwire->ck);
dev_dbg(&pdev->dev, "no functional clock?\n"); dev_dbg(&pdev->dev, "no functional clock?\n");
spi_master_put(master); spi_controller_put(host);
return status; return status;
} }
clk_prepare_enable(uwire->ck); clk_prepare_enable(uwire->ck);
...@@ -484,16 +484,16 @@ static int uwire_probe(struct platform_device *pdev) ...@@ -484,16 +484,16 @@ static int uwire_probe(struct platform_device *pdev)
uwire_write_reg(UWIRE_SR3, 1); uwire_write_reg(UWIRE_SR3, 1);
/* 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; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 16); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 16);
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->bus_num = 2; /* "official" */ host->bus_num = 2; /* "official" */
master->num_chipselect = 4; host->num_chipselect = 4;
master->setup = uwire_setup; host->setup = uwire_setup;
master->cleanup = uwire_cleanup; host->cleanup = uwire_cleanup;
uwire->bitbang.master = master; uwire->bitbang.master = host;
uwire->bitbang.chipselect = uwire_chipselect; uwire->bitbang.chipselect = uwire_chipselect;
uwire->bitbang.setup_transfer = uwire_setup_transfer; uwire->bitbang.setup_transfer = uwire_setup_transfer;
uwire->bitbang.txrx_bufs = uwire_txrx; uwire->bitbang.txrx_bufs = uwire_txrx;
......
This diff is collapsed.
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