Commit f9a79886 authored by Mark Brown's avatar Mark Brown

spi: switch to use modern name

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

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.
parents 0e19118a 1f6c80a7
...@@ -215,9 +215,9 @@ static int amd_spi_execute_opcode(struct amd_spi *amd_spi) ...@@ -215,9 +215,9 @@ static int amd_spi_execute_opcode(struct amd_spi *amd_spi)
} }
} }
static int amd_spi_master_setup(struct spi_device *spi) static int amd_spi_host_setup(struct spi_device *spi)
{ {
struct amd_spi *amd_spi = spi_master_get_devdata(spi->master); struct amd_spi *amd_spi = spi_controller_get_devdata(spi->controller);
amd_spi_clear_fifo_ptr(amd_spi); amd_spi_clear_fifo_ptr(amd_spi);
...@@ -272,7 +272,7 @@ static int amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz) ...@@ -272,7 +272,7 @@ static int amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz)
} }
static inline int amd_spi_fifo_xfer(struct amd_spi *amd_spi, static inline int amd_spi_fifo_xfer(struct amd_spi *amd_spi,
struct spi_master *master, struct spi_controller *host,
struct spi_message *message) struct spi_message *message)
{ {
struct spi_transfer *xfer = NULL; struct spi_transfer *xfer = NULL;
...@@ -353,15 +353,15 @@ static inline int amd_spi_fifo_xfer(struct amd_spi *amd_spi, ...@@ -353,15 +353,15 @@ static inline int amd_spi_fifo_xfer(struct amd_spi *amd_spi,
return -ENODEV; return -ENODEV;
} }
spi_finalize_current_message(master); spi_finalize_current_message(host);
return message->status; return message->status;
} }
static int amd_spi_master_transfer(struct spi_master *master, static int amd_spi_host_transfer(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct amd_spi *amd_spi = spi_master_get_devdata(master); struct amd_spi *amd_spi = spi_controller_get_devdata(host);
struct spi_device *spi = msg->spi; struct spi_device *spi = msg->spi;
amd_spi_select_chip(amd_spi, spi_get_chipselect(spi, 0)); amd_spi_select_chip(amd_spi, spi_get_chipselect(spi, 0));
...@@ -370,7 +370,7 @@ static int amd_spi_master_transfer(struct spi_master *master, ...@@ -370,7 +370,7 @@ static int amd_spi_master_transfer(struct spi_master *master,
* Extract spi_transfers from the spi message and * Extract spi_transfers from the spi message and
* program the controller. * program the controller.
*/ */
return amd_spi_fifo_xfer(amd_spi, master, msg); return amd_spi_fifo_xfer(amd_spi, host, msg);
} }
static size_t amd_spi_max_transfer_size(struct spi_device *spi) static size_t amd_spi_max_transfer_size(struct spi_device *spi)
...@@ -381,16 +381,16 @@ static size_t amd_spi_max_transfer_size(struct spi_device *spi) ...@@ -381,16 +381,16 @@ static size_t amd_spi_max_transfer_size(struct spi_device *spi)
static int amd_spi_probe(struct platform_device *pdev) static int amd_spi_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_master *master; struct spi_controller *host;
struct amd_spi *amd_spi; struct amd_spi *amd_spi;
int err; int err;
/* Allocate storage for spi_master and driver private data */ /* Allocate storage for host and driver private data */
master = devm_spi_alloc_master(dev, sizeof(struct amd_spi)); host = devm_spi_alloc_host(dev, sizeof(struct amd_spi));
if (!master) if (!host)
return dev_err_probe(dev, -ENOMEM, "Error allocating SPI master\n"); return dev_err_probe(dev, -ENOMEM, "Error allocating SPI host\n");
amd_spi = spi_master_get_devdata(master); amd_spi = spi_controller_get_devdata(host);
amd_spi->io_remap_addr = devm_platform_ioremap_resource(pdev, 0); amd_spi->io_remap_addr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(amd_spi->io_remap_addr)) if (IS_ERR(amd_spi->io_remap_addr))
return dev_err_probe(dev, PTR_ERR(amd_spi->io_remap_addr), return dev_err_probe(dev, PTR_ERR(amd_spi->io_remap_addr),
...@@ -400,20 +400,20 @@ static int amd_spi_probe(struct platform_device *pdev) ...@@ -400,20 +400,20 @@ static int amd_spi_probe(struct platform_device *pdev)
amd_spi->version = (enum amd_spi_versions) device_get_match_data(dev); amd_spi->version = (enum amd_spi_versions) device_get_match_data(dev);
/* Initialize the spi_master fields */ /* Initialize the spi_controller fields */
master->bus_num = 0; host->bus_num = 0;
master->num_chipselect = 4; host->num_chipselect = 4;
master->mode_bits = 0; host->mode_bits = 0;
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->max_speed_hz = AMD_SPI_MAX_HZ; host->max_speed_hz = AMD_SPI_MAX_HZ;
master->min_speed_hz = AMD_SPI_MIN_HZ; host->min_speed_hz = AMD_SPI_MIN_HZ;
master->setup = amd_spi_master_setup; host->setup = amd_spi_host_setup;
master->transfer_one_message = amd_spi_master_transfer; host->transfer_one_message = amd_spi_host_transfer;
master->max_transfer_size = amd_spi_max_transfer_size; host->max_transfer_size = amd_spi_max_transfer_size;
master->max_message_size = amd_spi_max_transfer_size; host->max_message_size = amd_spi_max_transfer_size;
/* Register the controller with SPI framework */ /* Register the controller with SPI framework */
err = devm_spi_register_master(dev, master); err = devm_spi_register_controller(dev, host);
if (err) if (err)
return dev_err_probe(dev, err, "error registering SPI controller\n"); return dev_err_probe(dev, err, "error registering SPI controller\n");
......
...@@ -295,7 +295,7 @@ static const struct aspeed_spi_data ast2400_spi_data; ...@@ -295,7 +295,7 @@ static const struct aspeed_spi_data ast2400_spi_data;
static int do_aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static int do_aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->master); struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->controller);
struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(mem->spi, 0)]; struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(mem->spi, 0)];
u32 addr_mode, addr_mode_backup; u32 addr_mode, addr_mode_backup;
u32 ctl_val; u32 ctl_val;
...@@ -374,7 +374,7 @@ static int aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) ...@@ -374,7 +374,7 @@ static int aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
static const char *aspeed_spi_get_name(struct spi_mem *mem) static const char *aspeed_spi_get_name(struct spi_mem *mem)
{ {
struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->master); struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->controller);
struct device *dev = aspi->dev; struct device *dev = aspi->dev;
return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev),
...@@ -553,7 +553,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip); ...@@ -553,7 +553,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip);
static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
{ {
struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->master); struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->controller);
struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)]; struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)];
struct spi_mem_op *op = &desc->info.op_tmpl; struct spi_mem_op *op = &desc->info.op_tmpl;
u32 ctl_val; u32 ctl_val;
...@@ -620,7 +620,7 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc) ...@@ -620,7 +620,7 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
static ssize_t aspeed_spi_dirmap_read(struct spi_mem_dirmap_desc *desc, static ssize_t aspeed_spi_dirmap_read(struct spi_mem_dirmap_desc *desc,
u64 offset, size_t len, void *buf) u64 offset, size_t len, void *buf)
{ {
struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->master); struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->controller);
struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)]; struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)];
/* Switch to USER command mode if mapping window is too small */ /* Switch to USER command mode if mapping window is too small */
...@@ -669,7 +669,7 @@ static void aspeed_spi_chip_enable(struct aspeed_spi *aspi, unsigned int cs, boo ...@@ -669,7 +669,7 @@ static void aspeed_spi_chip_enable(struct aspeed_spi *aspi, unsigned int cs, boo
static int aspeed_spi_setup(struct spi_device *spi) static int aspeed_spi_setup(struct spi_device *spi)
{ {
struct aspeed_spi *aspi = spi_controller_get_devdata(spi->master); struct aspeed_spi *aspi = spi_controller_get_devdata(spi->controller);
const struct aspeed_spi_data *data = aspi->data; const struct aspeed_spi_data *data = aspi->data;
unsigned int cs = spi_get_chipselect(spi, 0); unsigned int cs = spi_get_chipselect(spi, 0);
struct aspeed_spi_chip *chip = &aspi->chips[cs]; struct aspeed_spi_chip *chip = &aspi->chips[cs];
...@@ -697,7 +697,7 @@ static int aspeed_spi_setup(struct spi_device *spi) ...@@ -697,7 +697,7 @@ static int aspeed_spi_setup(struct spi_device *spi)
static void aspeed_spi_cleanup(struct spi_device *spi) static void aspeed_spi_cleanup(struct spi_device *spi)
{ {
struct aspeed_spi *aspi = spi_controller_get_devdata(spi->master); struct aspeed_spi *aspi = spi_controller_get_devdata(spi->controller);
unsigned int cs = spi_get_chipselect(spi, 0); unsigned int cs = spi_get_chipselect(spi, 0);
aspeed_spi_chip_enable(aspi, cs, false); aspeed_spi_chip_enable(aspi, cs, false);
...@@ -726,7 +726,7 @@ static int aspeed_spi_probe(struct platform_device *pdev) ...@@ -726,7 +726,7 @@ static int aspeed_spi_probe(struct platform_device *pdev)
if (!data) if (!data)
return -ENODEV; return -ENODEV;
ctlr = devm_spi_alloc_master(dev, sizeof(*aspi)); ctlr = devm_spi_alloc_host(dev, sizeof(*aspi));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
......
...@@ -356,8 +356,8 @@ static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine) ...@@ -356,8 +356,8 @@ static bool spi_engine_read_rx_fifo(struct spi_engine *spi_engine)
static irqreturn_t spi_engine_irq(int irq, void *devid) static irqreturn_t spi_engine_irq(int irq, void *devid)
{ {
struct spi_master *master = devid; struct spi_controller *host = devid;
struct spi_engine *spi_engine = spi_master_get_devdata(master); struct spi_engine *spi_engine = spi_controller_get_devdata(host);
unsigned int disable_int = 0; unsigned int disable_int = 0;
unsigned int pending; unsigned int pending;
...@@ -396,7 +396,7 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) ...@@ -396,7 +396,7 @@ static irqreturn_t spi_engine_irq(int irq, void *devid)
msg->status = 0; msg->status = 0;
msg->actual_length = msg->frame_length; msg->actual_length = msg->frame_length;
spi_engine->msg = NULL; spi_engine->msg = NULL;
spi_finalize_current_message(master); spi_finalize_current_message(host);
disable_int |= SPI_ENGINE_INT_SYNC; disable_int |= SPI_ENGINE_INT_SYNC;
} }
} }
...@@ -412,11 +412,11 @@ static irqreturn_t spi_engine_irq(int irq, void *devid) ...@@ -412,11 +412,11 @@ static irqreturn_t spi_engine_irq(int irq, void *devid)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int spi_engine_transfer_one_message(struct spi_master *master, static int spi_engine_transfer_one_message(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct spi_engine_program p_dry, *p; struct spi_engine_program p_dry, *p;
struct spi_engine *spi_engine = spi_master_get_devdata(master); struct spi_engine *spi_engine = spi_controller_get_devdata(host);
unsigned int int_enable = 0; unsigned int int_enable = 0;
unsigned long flags; unsigned long flags;
size_t size; size_t size;
...@@ -464,7 +464,7 @@ static int spi_engine_transfer_one_message(struct spi_master *master, ...@@ -464,7 +464,7 @@ static int spi_engine_transfer_one_message(struct spi_master *master,
static int spi_engine_probe(struct platform_device *pdev) static int spi_engine_probe(struct platform_device *pdev)
{ {
struct spi_engine *spi_engine; struct spi_engine *spi_engine;
struct spi_master *master; struct spi_controller *host;
unsigned int version; unsigned int version;
int irq; int irq;
int ret; int ret;
...@@ -477,29 +477,29 @@ static int spi_engine_probe(struct platform_device *pdev) ...@@ -477,29 +477,29 @@ static int spi_engine_probe(struct platform_device *pdev)
if (!spi_engine) if (!spi_engine)
return -ENOMEM; return -ENOMEM;
master = spi_alloc_master(&pdev->dev, 0); host = spi_alloc_host(&pdev->dev, 0);
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
spi_master_set_devdata(master, spi_engine); spi_controller_set_devdata(host, spi_engine);
spin_lock_init(&spi_engine->lock); spin_lock_init(&spi_engine->lock);
spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk"); spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
if (IS_ERR(spi_engine->clk)) { if (IS_ERR(spi_engine->clk)) {
ret = PTR_ERR(spi_engine->clk); ret = PTR_ERR(spi_engine->clk);
goto err_put_master; goto err_put_host;
} }
spi_engine->ref_clk = devm_clk_get(&pdev->dev, "spi_clk"); spi_engine->ref_clk = devm_clk_get(&pdev->dev, "spi_clk");
if (IS_ERR(spi_engine->ref_clk)) { if (IS_ERR(spi_engine->ref_clk)) {
ret = PTR_ERR(spi_engine->ref_clk); ret = PTR_ERR(spi_engine->ref_clk);
goto err_put_master; goto err_put_host;
} }
ret = clk_prepare_enable(spi_engine->clk); ret = clk_prepare_enable(spi_engine->clk);
if (ret) if (ret)
goto err_put_master; goto err_put_host;
ret = clk_prepare_enable(spi_engine->ref_clk); ret = clk_prepare_enable(spi_engine->ref_clk);
if (ret) if (ret)
...@@ -525,46 +525,46 @@ static int spi_engine_probe(struct platform_device *pdev) ...@@ -525,46 +525,46 @@ static int spi_engine_probe(struct platform_device *pdev)
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
ret = request_irq(irq, spi_engine_irq, 0, pdev->name, master); ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host);
if (ret) if (ret)
goto err_ref_clk_disable; goto err_ref_clk_disable;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->max_speed_hz = clk_get_rate(spi_engine->ref_clk) / 2; host->max_speed_hz = clk_get_rate(spi_engine->ref_clk) / 2;
master->transfer_one_message = spi_engine_transfer_one_message; host->transfer_one_message = spi_engine_transfer_one_message;
master->num_chipselect = 8; host->num_chipselect = 8;
ret = spi_register_master(master); ret = spi_register_controller(host);
if (ret) if (ret)
goto err_free_irq; goto err_free_irq;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
return 0; return 0;
err_free_irq: err_free_irq:
free_irq(irq, master); free_irq(irq, host);
err_ref_clk_disable: err_ref_clk_disable:
clk_disable_unprepare(spi_engine->ref_clk); clk_disable_unprepare(spi_engine->ref_clk);
err_clk_disable: err_clk_disable:
clk_disable_unprepare(spi_engine->clk); clk_disable_unprepare(spi_engine->clk);
err_put_master: err_put_host:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void spi_engine_remove(struct platform_device *pdev) static void spi_engine_remove(struct platform_device *pdev)
{ {
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); struct spi_controller *host = spi_controller_get(platform_get_drvdata(pdev));
struct spi_engine *spi_engine = spi_master_get_devdata(master); struct spi_engine *spi_engine = spi_controller_get_devdata(host);
int irq = platform_get_irq(pdev, 0); int irq = platform_get_irq(pdev, 0);
spi_unregister_master(master); spi_unregister_controller(host);
free_irq(irq, master); free_irq(irq, host);
spi_master_put(master); spi_controller_put(host);
writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING);
writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE);
......
...@@ -220,7 +220,7 @@ struct qspi_trans { ...@@ -220,7 +220,7 @@ struct qspi_trans {
struct bcm_qspi { struct bcm_qspi {
struct platform_device *pdev; struct platform_device *pdev;
struct spi_master *master; struct spi_controller *host;
struct clk *clk; struct clk *clk;
u32 base_clk; u32 base_clk;
u32 max_speed_hz; u32 max_speed_hz;
...@@ -732,7 +732,7 @@ static bool bcm_qspi_mspi_transfer_is_last(struct bcm_qspi *qspi, ...@@ -732,7 +732,7 @@ static bool bcm_qspi_mspi_transfer_is_last(struct bcm_qspi *qspi,
struct qspi_trans *qt) struct qspi_trans *qt)
{ {
if (qt->mspi_last_trans && if (qt->mspi_last_trans &&
spi_transfer_is_last(qspi->master, qt->trans)) spi_transfer_is_last(qspi->host, qt->trans))
return true; return true;
else else
return false; return false;
...@@ -979,7 +979,7 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi) ...@@ -979,7 +979,7 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi)
mspi_cdram |= ((tp.trans->bits_per_word <= 8) ? 0 : mspi_cdram |= ((tp.trans->bits_per_word <= 8) ? 0 :
MSPI_CDRAM_BITSE_BIT); MSPI_CDRAM_BITSE_BIT);
/* set 3wrire halfduplex mode data from master to slave */ /* set 3wrire halfduplex mode data from host to target */
if ((spi->mode & SPI_3WIRE) && tp.trans->tx_buf) if ((spi->mode & SPI_3WIRE) && tp.trans->tx_buf)
mspi_cdram |= MSPI_CDRAM_OUTP; mspi_cdram |= MSPI_CDRAM_OUTP;
...@@ -1035,7 +1035,7 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi) ...@@ -1035,7 +1035,7 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi)
static int bcm_qspi_bspi_exec_mem_op(struct spi_device *spi, static int bcm_qspi_bspi_exec_mem_op(struct spi_device *spi,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct bcm_qspi *qspi = spi_master_get_devdata(spi->master); struct bcm_qspi *qspi = spi_controller_get_devdata(spi->controller);
u32 addr = 0, len, rdlen, len_words, from = 0; u32 addr = 0, len, rdlen, len_words, from = 0;
int ret = 0; int ret = 0;
unsigned long timeo = msecs_to_jiffies(100); unsigned long timeo = msecs_to_jiffies(100);
...@@ -1118,11 +1118,11 @@ static int bcm_qspi_bspi_exec_mem_op(struct spi_device *spi, ...@@ -1118,11 +1118,11 @@ static int bcm_qspi_bspi_exec_mem_op(struct spi_device *spi,
return ret; return ret;
} }
static int bcm_qspi_transfer_one(struct spi_master *master, static int bcm_qspi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *trans) struct spi_transfer *trans)
{ {
struct bcm_qspi *qspi = spi_master_get_devdata(master); struct bcm_qspi *qspi = spi_controller_get_devdata(host);
int slots; int slots;
unsigned long timeo = msecs_to_jiffies(100); unsigned long timeo = msecs_to_jiffies(100);
...@@ -1150,8 +1150,8 @@ static int bcm_qspi_transfer_one(struct spi_master *master, ...@@ -1150,8 +1150,8 @@ static int bcm_qspi_transfer_one(struct spi_master *master,
static int bcm_qspi_mspi_exec_mem_op(struct spi_device *spi, static int bcm_qspi_mspi_exec_mem_op(struct spi_device *spi,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct spi_master *master = spi->master; struct spi_controller *host = spi->controller;
struct bcm_qspi *qspi = spi_master_get_devdata(master); struct bcm_qspi *qspi = spi_controller_get_devdata(host);
struct spi_transfer t[2]; struct spi_transfer t[2];
u8 cmd[6] = { }; u8 cmd[6] = { };
int ret, i; int ret, i;
...@@ -1171,7 +1171,7 @@ static int bcm_qspi_mspi_exec_mem_op(struct spi_device *spi, ...@@ -1171,7 +1171,7 @@ static int bcm_qspi_mspi_exec_mem_op(struct spi_device *spi,
t[0].tx_nbits = op->cmd.buswidth; t[0].tx_nbits = op->cmd.buswidth;
/* lets mspi know that this is not last transfer */ /* lets mspi know that this is not last transfer */
qspi->trans_pos.mspi_last_trans = false; qspi->trans_pos.mspi_last_trans = false;
ret = bcm_qspi_transfer_one(master, spi, &t[0]); ret = bcm_qspi_transfer_one(host, spi, &t[0]);
/* rx */ /* rx */
qspi->trans_pos.mspi_last_trans = true; qspi->trans_pos.mspi_last_trans = true;
...@@ -1181,7 +1181,7 @@ static int bcm_qspi_mspi_exec_mem_op(struct spi_device *spi, ...@@ -1181,7 +1181,7 @@ static int bcm_qspi_mspi_exec_mem_op(struct spi_device *spi,
t[1].len = op->data.nbytes; t[1].len = op->data.nbytes;
t[1].rx_nbits = op->data.buswidth; t[1].rx_nbits = op->data.buswidth;
t[1].bits_per_word = spi->bits_per_word; t[1].bits_per_word = spi->bits_per_word;
ret = bcm_qspi_transfer_one(master, spi, &t[1]); ret = bcm_qspi_transfer_one(host, spi, &t[1]);
} }
return ret; return ret;
...@@ -1191,7 +1191,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem, ...@@ -1191,7 +1191,7 @@ static int bcm_qspi_exec_mem_op(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct spi_device *spi = mem->spi; struct spi_device *spi = mem->spi;
struct bcm_qspi *qspi = spi_master_get_devdata(spi->master); struct bcm_qspi *qspi = spi_controller_get_devdata(spi->controller);
int ret = 0; int ret = 0;
bool mspi_read = false; bool mspi_read = false;
u32 addr = 0, len; u32 addr = 0, len;
...@@ -1486,7 +1486,7 @@ int bcm_qspi_probe(struct platform_device *pdev, ...@@ -1486,7 +1486,7 @@ int bcm_qspi_probe(struct platform_device *pdev,
const struct bcm_qspi_data *data; const struct bcm_qspi_data *data;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct bcm_qspi *qspi; struct bcm_qspi *qspi;
struct spi_master *master; struct spi_controller *host;
struct resource *res; struct resource *res;
int irq, ret = 0, num_ints = 0; int irq, ret = 0, num_ints = 0;
u32 val; u32 val;
...@@ -1504,13 +1504,13 @@ int bcm_qspi_probe(struct platform_device *pdev, ...@@ -1504,13 +1504,13 @@ int bcm_qspi_probe(struct platform_device *pdev,
data = of_id->data; data = of_id->data;
master = devm_spi_alloc_master(dev, sizeof(struct bcm_qspi)); host = devm_spi_alloc_host(dev, sizeof(struct bcm_qspi));
if (!master) { if (!host) {
dev_err(dev, "error allocating spi_master\n"); dev_err(dev, "error allocating spi_controller\n");
return -ENOMEM; return -ENOMEM;
} }
qspi = spi_master_get_devdata(master); qspi = spi_controller_get_devdata(host);
qspi->clk = devm_clk_get_optional(&pdev->dev, NULL); qspi->clk = devm_clk_get_optional(&pdev->dev, NULL);
if (IS_ERR(qspi->clk)) if (IS_ERR(qspi->clk))
...@@ -1520,23 +1520,23 @@ int bcm_qspi_probe(struct platform_device *pdev, ...@@ -1520,23 +1520,23 @@ int bcm_qspi_probe(struct platform_device *pdev,
qspi->trans_pos.trans = NULL; qspi->trans_pos.trans = NULL;
qspi->trans_pos.byte = 0; qspi->trans_pos.byte = 0;
qspi->trans_pos.mspi_last_trans = true; qspi->trans_pos.mspi_last_trans = true;
qspi->master = master; qspi->host = host;
master->bus_num = -1; host->bus_num = -1;
master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_RX_DUAL | SPI_RX_QUAD | host->mode_bits = SPI_CPHA | SPI_CPOL | SPI_RX_DUAL | SPI_RX_QUAD |
SPI_3WIRE; SPI_3WIRE;
master->setup = bcm_qspi_setup; host->setup = bcm_qspi_setup;
master->transfer_one = bcm_qspi_transfer_one; host->transfer_one = bcm_qspi_transfer_one;
master->mem_ops = &bcm_qspi_mem_ops; host->mem_ops = &bcm_qspi_mem_ops;
master->cleanup = bcm_qspi_cleanup; host->cleanup = bcm_qspi_cleanup;
master->dev.of_node = dev->of_node; host->dev.of_node = dev->of_node;
master->num_chipselect = NUM_CHIPSELECT; host->num_chipselect = NUM_CHIPSELECT;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
qspi->big_endian = of_device_is_big_endian(dev->of_node); qspi->big_endian = of_device_is_big_endian(dev->of_node);
if (!of_property_read_u32(dev->of_node, "num-cs", &val)) if (!of_property_read_u32(dev->of_node, "num-cs", &val))
master->num_chipselect = val; host->num_chipselect = val;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hif_mspi"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hif_mspi");
if (!res) if (!res)
...@@ -1659,9 +1659,9 @@ int bcm_qspi_probe(struct platform_device *pdev, ...@@ -1659,9 +1659,9 @@ int bcm_qspi_probe(struct platform_device *pdev,
qspi->xfer_mode.addrlen = -1; qspi->xfer_mode.addrlen = -1;
qspi->xfer_mode.hp = -1; qspi->xfer_mode.hp = -1;
ret = spi_register_master(master); ret = spi_register_controller(host);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "can't register master\n"); dev_err(dev, "can't register host\n");
goto qspi_reg_err; goto qspi_reg_err;
} }
...@@ -1682,7 +1682,7 @@ void bcm_qspi_remove(struct platform_device *pdev) ...@@ -1682,7 +1682,7 @@ void bcm_qspi_remove(struct platform_device *pdev)
{ {
struct bcm_qspi *qspi = platform_get_drvdata(pdev); struct bcm_qspi *qspi = platform_get_drvdata(pdev);
spi_unregister_master(qspi->master); spi_unregister_controller(qspi->host);
bcm_qspi_hw_uninit(qspi); bcm_qspi_hw_uninit(qspi);
clk_disable_unprepare(qspi->clk); clk_disable_unprepare(qspi->clk);
kfree(qspi->dev_ids); kfree(qspi->dev_ids);
...@@ -1700,7 +1700,7 @@ static int __maybe_unused bcm_qspi_suspend(struct device *dev) ...@@ -1700,7 +1700,7 @@ static int __maybe_unused bcm_qspi_suspend(struct device *dev)
qspi->s3_strap_override_ctrl = qspi->s3_strap_override_ctrl =
bcm_qspi_read(qspi, BSPI, BSPI_STRAP_OVERRIDE_CTRL); bcm_qspi_read(qspi, BSPI, BSPI_STRAP_OVERRIDE_CTRL);
spi_master_suspend(qspi->master); spi_controller_suspend(qspi->host);
clk_disable_unprepare(qspi->clk); clk_disable_unprepare(qspi->clk);
bcm_qspi_hw_uninit(qspi); bcm_qspi_hw_uninit(qspi);
...@@ -1721,7 +1721,7 @@ static int __maybe_unused bcm_qspi_resume(struct device *dev) ...@@ -1721,7 +1721,7 @@ static int __maybe_unused bcm_qspi_resume(struct device *dev)
ret = clk_prepare_enable(qspi->clk); ret = clk_prepare_enable(qspi->clk);
if (!ret) if (!ret)
spi_master_resume(qspi->master); spi_controller_resume(qspi->host);
return ret; return ret;
} }
......
This diff is collapsed.
...@@ -231,8 +231,8 @@ static void bcm2835aux_spi_transfer_helper(struct bcm2835aux_spi *bs) ...@@ -231,8 +231,8 @@ static void bcm2835aux_spi_transfer_helper(struct bcm2835aux_spi *bs)
static irqreturn_t bcm2835aux_spi_interrupt(int irq, void *dev_id) static irqreturn_t bcm2835aux_spi_interrupt(int irq, void *dev_id)
{ {
struct spi_master *master = dev_id; struct spi_controller *host = dev_id;
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
/* IRQ may be shared, so return if our interrupts are disabled */ /* IRQ may be shared, so return if our interrupts are disabled */
if (!(bcm2835aux_rd(bs, BCM2835_AUX_SPI_CNTL1) & if (!(bcm2835aux_rd(bs, BCM2835_AUX_SPI_CNTL1) &
...@@ -251,17 +251,17 @@ static irqreturn_t bcm2835aux_spi_interrupt(int irq, void *dev_id) ...@@ -251,17 +251,17 @@ static irqreturn_t bcm2835aux_spi_interrupt(int irq, void *dev_id)
/* and if rx_len is 0 then disable interrupts and wake up completion */ /* and if rx_len is 0 then disable interrupts and wake up completion */
if (!bs->rx_len) { if (!bs->rx_len) {
bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]);
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int __bcm2835aux_spi_transfer_one_irq(struct spi_master *master, static int __bcm2835aux_spi_transfer_one_irq(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *tfr) struct spi_transfer *tfr)
{ {
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
/* enable interrupts */ /* enable interrupts */
bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1] | bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1] |
...@@ -272,11 +272,11 @@ static int __bcm2835aux_spi_transfer_one_irq(struct spi_master *master, ...@@ -272,11 +272,11 @@ static int __bcm2835aux_spi_transfer_one_irq(struct spi_master *master,
return 1; return 1;
} }
static int bcm2835aux_spi_transfer_one_irq(struct spi_master *master, static int bcm2835aux_spi_transfer_one_irq(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *tfr) struct spi_transfer *tfr)
{ {
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
/* update statistics */ /* update statistics */
bs->count_transfer_irq++; bs->count_transfer_irq++;
...@@ -294,14 +294,14 @@ static int bcm2835aux_spi_transfer_one_irq(struct spi_master *master, ...@@ -294,14 +294,14 @@ static int bcm2835aux_spi_transfer_one_irq(struct spi_master *master,
} }
/* now run the interrupt mode */ /* now run the interrupt mode */
return __bcm2835aux_spi_transfer_one_irq(master, spi, tfr); return __bcm2835aux_spi_transfer_one_irq(host, spi, tfr);
} }
static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master, static int bcm2835aux_spi_transfer_one_poll(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *tfr) struct spi_transfer *tfr)
{ {
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
unsigned long timeout; unsigned long timeout;
/* update statistics */ /* update statistics */
...@@ -328,7 +328,7 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master, ...@@ -328,7 +328,7 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master,
bs->tx_len, bs->rx_len); bs->tx_len, bs->rx_len);
/* forward to interrupt handler */ /* forward to interrupt handler */
bs->count_transfer_irq_after_poll++; bs->count_transfer_irq_after_poll++;
return __bcm2835aux_spi_transfer_one_irq(master, return __bcm2835aux_spi_transfer_one_irq(host,
spi, tfr); spi, tfr);
} }
} }
...@@ -337,11 +337,11 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master, ...@@ -337,11 +337,11 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master,
return 0; return 0;
} }
static int bcm2835aux_spi_transfer_one(struct spi_master *master, static int bcm2835aux_spi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *tfr) struct spi_transfer *tfr)
{ {
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
unsigned long spi_hz, clk_hz, speed; unsigned long spi_hz, clk_hz, speed;
unsigned long hz_per_byte, byte_limit; unsigned long hz_per_byte, byte_limit;
...@@ -392,17 +392,17 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master, ...@@ -392,17 +392,17 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
/* run in polling mode for short transfers */ /* run in polling mode for short transfers */
if (tfr->len < byte_limit) if (tfr->len < byte_limit)
return bcm2835aux_spi_transfer_one_poll(master, spi, tfr); return bcm2835aux_spi_transfer_one_poll(host, spi, tfr);
/* run in interrupt mode for all others */ /* run in interrupt mode for all others */
return bcm2835aux_spi_transfer_one_irq(master, spi, tfr); return bcm2835aux_spi_transfer_one_irq(host, spi, tfr);
} }
static int bcm2835aux_spi_prepare_message(struct spi_master *master, static int bcm2835aux_spi_prepare_message(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct spi_device *spi = msg->spi; struct spi_device *spi = msg->spi;
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
bs->cntl[0] = BCM2835_AUX_SPI_CNTL0_ENABLE | bs->cntl[0] = BCM2835_AUX_SPI_CNTL0_ENABLE |
BCM2835_AUX_SPI_CNTL0_VAR_WIDTH | BCM2835_AUX_SPI_CNTL0_VAR_WIDTH |
...@@ -422,20 +422,20 @@ static int bcm2835aux_spi_prepare_message(struct spi_master *master, ...@@ -422,20 +422,20 @@ static int bcm2835aux_spi_prepare_message(struct spi_master *master,
return 0; return 0;
} }
static int bcm2835aux_spi_unprepare_message(struct spi_master *master, static int bcm2835aux_spi_unprepare_message(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
bcm2835aux_spi_reset_hw(bs); bcm2835aux_spi_reset_hw(bs);
return 0; return 0;
} }
static void bcm2835aux_spi_handle_err(struct spi_master *master, static void bcm2835aux_spi_handle_err(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
bcm2835aux_spi_reset_hw(bs); bcm2835aux_spi_reset_hw(bs);
} }
...@@ -473,18 +473,18 @@ static int bcm2835aux_spi_setup(struct spi_device *spi) ...@@ -473,18 +473,18 @@ static int bcm2835aux_spi_setup(struct spi_device *spi)
static int bcm2835aux_spi_probe(struct platform_device *pdev) static int bcm2835aux_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct bcm2835aux_spi *bs; struct bcm2835aux_spi *bs;
unsigned long clk_hz; unsigned long clk_hz;
int err; int err;
master = devm_spi_alloc_master(&pdev->dev, sizeof(*bs)); host = devm_spi_alloc_host(&pdev->dev, sizeof(*bs));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
master->mode_bits = (SPI_CPOL | SPI_CS_HIGH | SPI_NO_CS); host->mode_bits = (SPI_CPOL | SPI_CS_HIGH | SPI_NO_CS);
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
/* even though the driver never officially supported native CS /* even though the driver never officially supported native CS
* allow a single native CS for legacy DT support purposes when * allow a single native CS for legacy DT support purposes when
* no cs-gpio is configured. * no cs-gpio is configured.
...@@ -496,16 +496,16 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -496,16 +496,16 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
* * cs_delay_usec: cs is always deasserted one SCK cycle after * * cs_delay_usec: cs is always deasserted one SCK cycle after
* a spi_transfer * a spi_transfer
*/ */
master->num_chipselect = 1; host->num_chipselect = 1;
master->setup = bcm2835aux_spi_setup; host->setup = bcm2835aux_spi_setup;
master->transfer_one = bcm2835aux_spi_transfer_one; host->transfer_one = bcm2835aux_spi_transfer_one;
master->handle_err = bcm2835aux_spi_handle_err; host->handle_err = bcm2835aux_spi_handle_err;
master->prepare_message = bcm2835aux_spi_prepare_message; host->prepare_message = bcm2835aux_spi_prepare_message;
master->unprepare_message = bcm2835aux_spi_unprepare_message; host->unprepare_message = bcm2835aux_spi_unprepare_message;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
bs = spi_master_get_devdata(master); bs = spi_controller_get_devdata(host);
/* the main area */ /* the main area */
bs->regs = devm_platform_ioremap_resource(pdev, 0); bs->regs = devm_platform_ioremap_resource(pdev, 0);
...@@ -544,15 +544,15 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -544,15 +544,15 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
err = devm_request_irq(&pdev->dev, bs->irq, err = devm_request_irq(&pdev->dev, bs->irq,
bcm2835aux_spi_interrupt, bcm2835aux_spi_interrupt,
IRQF_SHARED, IRQF_SHARED,
dev_name(&pdev->dev), master); dev_name(&pdev->dev), host);
if (err) { if (err) {
dev_err(&pdev->dev, "could not request IRQ: %d\n", err); dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
goto out_clk_disable; goto out_clk_disable;
} }
err = spi_register_master(master); err = spi_register_controller(host);
if (err) { if (err) {
dev_err(&pdev->dev, "could not register SPI master: %d\n", err); dev_err(&pdev->dev, "could not register SPI host: %d\n", err);
goto out_clk_disable; goto out_clk_disable;
} }
...@@ -567,12 +567,12 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) ...@@ -567,12 +567,12 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev)
static void bcm2835aux_spi_remove(struct platform_device *pdev) static void bcm2835aux_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_controller_get_devdata(host);
bcm2835aux_debugfs_remove(bs); bcm2835aux_debugfs_remove(bs);
spi_unregister_master(master); spi_unregister_controller(host);
bcm2835aux_spi_reset_hw(bs); bcm2835aux_spi_reset_hw(bs);
......
...@@ -149,7 +149,7 @@ static ssize_t wait_mode_show(struct device *dev, struct device_attribute *attr, ...@@ -149,7 +149,7 @@ static ssize_t wait_mode_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct spi_controller *ctrl = dev_get_drvdata(dev); struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcm63xx_hsspi *bs = spi_master_get_devdata(ctrl); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(ctrl);
return sprintf(buf, "%d\n", bs->wait_mode); return sprintf(buf, "%d\n", bs->wait_mode);
} }
...@@ -158,7 +158,7 @@ static ssize_t wait_mode_store(struct device *dev, struct device_attribute *attr ...@@ -158,7 +158,7 @@ static ssize_t wait_mode_store(struct device *dev, struct device_attribute *attr
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct spi_controller *ctrl = dev_get_drvdata(dev); struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcm63xx_hsspi *bs = spi_master_get_devdata(ctrl); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(ctrl);
u32 val; u32 val;
if (kstrtou32(buf, 10, &val)) if (kstrtou32(buf, 10, &val))
...@@ -185,7 +185,7 @@ static ssize_t xfer_mode_show(struct device *dev, struct device_attribute *attr, ...@@ -185,7 +185,7 @@ static ssize_t xfer_mode_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct spi_controller *ctrl = dev_get_drvdata(dev); struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcm63xx_hsspi *bs = spi_master_get_devdata(ctrl); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(ctrl);
return sprintf(buf, "%d\n", bs->xfer_mode); return sprintf(buf, "%d\n", bs->xfer_mode);
} }
...@@ -194,7 +194,7 @@ static ssize_t xfer_mode_store(struct device *dev, struct device_attribute *attr ...@@ -194,7 +194,7 @@ static ssize_t xfer_mode_store(struct device *dev, struct device_attribute *attr
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct spi_controller *ctrl = dev_get_drvdata(dev); struct spi_controller *ctrl = dev_get_drvdata(dev);
struct bcm63xx_hsspi *bs = spi_master_get_devdata(ctrl); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(ctrl);
u32 val; u32 val;
if (kstrtou32(buf, 10, &val)) if (kstrtou32(buf, 10, &val))
...@@ -262,12 +262,12 @@ static int bcm63xx_hsspi_wait_cmd(struct bcm63xx_hsspi *bs) ...@@ -262,12 +262,12 @@ static int bcm63xx_hsspi_wait_cmd(struct bcm63xx_hsspi *bs)
return rc; return rc;
} }
static bool bcm63xx_prepare_prepend_transfer(struct spi_master *master, static bool bcm63xx_prepare_prepend_transfer(struct spi_controller *host,
struct spi_message *msg, struct spi_message *msg,
struct spi_transfer *t_prepend) struct spi_transfer *t_prepend)
{ {
struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(host);
bool tx_only = false; bool tx_only = false;
struct spi_transfer *t; struct spi_transfer *t;
...@@ -348,7 +348,7 @@ static bool bcm63xx_prepare_prepend_transfer(struct spi_master *master, ...@@ -348,7 +348,7 @@ static bool bcm63xx_prepare_prepend_transfer(struct spi_master *master,
static int bcm63xx_hsspi_do_prepend_txrx(struct spi_device *spi, static int bcm63xx_hsspi_do_prepend_txrx(struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(spi->controller);
unsigned int chip_select = spi_get_chipselect(spi, 0); unsigned int chip_select = spi_get_chipselect(spi, 0);
u16 opcode = 0, val; u16 opcode = 0, val;
const u8 *tx = t->tx_buf; const u8 *tx = t->tx_buf;
...@@ -467,7 +467,7 @@ static void bcm63xx_hsspi_set_clk(struct bcm63xx_hsspi *bs, ...@@ -467,7 +467,7 @@ static void bcm63xx_hsspi_set_clk(struct bcm63xx_hsspi *bs,
static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t)
{ {
struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(spi->controller);
unsigned int chip_select = spi_get_chipselect(spi, 0); unsigned int chip_select = spi_get_chipselect(spi, 0);
u16 opcode = 0, val; u16 opcode = 0, val;
int pending = t->len; int pending = t->len;
...@@ -541,7 +541,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) ...@@ -541,7 +541,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t)
static int bcm63xx_hsspi_setup(struct spi_device *spi) static int bcm63xx_hsspi_setup(struct spi_device *spi)
{ {
struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(spi->controller);
u32 reg; u32 reg;
reg = __raw_readl(bs->regs + reg = __raw_readl(bs->regs +
...@@ -579,7 +579,7 @@ static int bcm63xx_hsspi_setup(struct spi_device *spi) ...@@ -579,7 +579,7 @@ static int bcm63xx_hsspi_setup(struct spi_device *spi)
static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_device *spi, static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_device *spi,
struct spi_message *msg) struct spi_message *msg)
{ {
struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(spi->controller);
int status = -EINVAL; int status = -EINVAL;
int dummy_cs; int dummy_cs;
bool keep_cs = false; bool keep_cs = false;
...@@ -653,10 +653,10 @@ static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_device *spi, ...@@ -653,10 +653,10 @@ static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_device *spi,
return status; return status;
} }
static int bcm63xx_hsspi_transfer_one(struct spi_master *master, static int bcm63xx_hsspi_transfer_one(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(host);
struct spi_device *spi = msg->spi; struct spi_device *spi = msg->spi;
int status = -EINVAL; int status = -EINVAL;
bool prependable = false; bool prependable = false;
...@@ -665,7 +665,7 @@ static int bcm63xx_hsspi_transfer_one(struct spi_master *master, ...@@ -665,7 +665,7 @@ static int bcm63xx_hsspi_transfer_one(struct spi_master *master,
mutex_lock(&bs->msg_mutex); mutex_lock(&bs->msg_mutex);
if (bs->xfer_mode != HSSPI_XFER_MODE_DUMMYCS) if (bs->xfer_mode != HSSPI_XFER_MODE_DUMMYCS)
prependable = bcm63xx_prepare_prepend_transfer(master, msg, &t_prepend); prependable = bcm63xx_prepare_prepend_transfer(host, msg, &t_prepend);
if (prependable) { if (prependable) {
status = bcm63xx_hsspi_do_prepend_txrx(spi, &t_prepend); status = bcm63xx_hsspi_do_prepend_txrx(spi, &t_prepend);
...@@ -681,7 +681,7 @@ static int bcm63xx_hsspi_transfer_one(struct spi_master *master, ...@@ -681,7 +681,7 @@ static int bcm63xx_hsspi_transfer_one(struct spi_master *master,
mutex_unlock(&bs->msg_mutex); mutex_unlock(&bs->msg_mutex);
msg->status = status; msg->status = status;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return 0; return 0;
} }
...@@ -723,7 +723,7 @@ static irqreturn_t bcm63xx_hsspi_interrupt(int irq, void *dev_id) ...@@ -723,7 +723,7 @@ static irqreturn_t bcm63xx_hsspi_interrupt(int irq, void *dev_id)
static int bcm63xx_hsspi_probe(struct platform_device *pdev) static int bcm63xx_hsspi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct bcm63xx_hsspi *bs; struct bcm63xx_hsspi *bs;
void __iomem *regs; void __iomem *regs;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
...@@ -779,13 +779,13 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -779,13 +779,13 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
} }
} }
master = spi_alloc_master(&pdev->dev, sizeof(*bs)); host = spi_alloc_host(&pdev->dev, sizeof(*bs));
if (!master) { if (!host) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_disable_pll_clk; goto out_disable_pll_clk;
} }
bs = spi_master_get_devdata(master); bs = spi_controller_get_devdata(host);
bs->pdev = pdev; bs->pdev = pdev;
bs->clk = clk; bs->clk = clk;
bs->pll_clk = pll_clk; bs->pll_clk = pll_clk;
...@@ -796,17 +796,17 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -796,17 +796,17 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
bs->prepend_buf = devm_kzalloc(dev, HSSPI_BUFFER_LEN, GFP_KERNEL); bs->prepend_buf = devm_kzalloc(dev, HSSPI_BUFFER_LEN, GFP_KERNEL);
if (!bs->prepend_buf) { if (!bs->prepend_buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_put_master; goto out_put_host;
} }
mutex_init(&bs->bus_mutex); mutex_init(&bs->bus_mutex);
mutex_init(&bs->msg_mutex); mutex_init(&bs->msg_mutex);
init_completion(&bs->done); init_completion(&bs->done);
master->mem_ops = &bcm63xx_hsspi_mem_ops; host->mem_ops = &bcm63xx_hsspi_mem_ops;
master->dev.of_node = dev->of_node; host->dev.of_node = dev->of_node;
if (!dev->of_node) if (!dev->of_node)
master->bus_num = HSSPI_BUS_NUM; host->bus_num = HSSPI_BUS_NUM;
of_property_read_u32(dev->of_node, "num-cs", &num_cs); of_property_read_u32(dev->of_node, "num-cs", &num_cs);
if (num_cs > 8) { if (num_cs > 8) {
...@@ -814,18 +814,18 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -814,18 +814,18 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
num_cs); num_cs);
num_cs = HSSPI_SPI_MAX_CS; num_cs = HSSPI_SPI_MAX_CS;
} }
master->num_chipselect = num_cs; host->num_chipselect = num_cs;
master->setup = bcm63xx_hsspi_setup; host->setup = bcm63xx_hsspi_setup;
master->transfer_one_message = bcm63xx_hsspi_transfer_one; host->transfer_one_message = bcm63xx_hsspi_transfer_one;
master->max_transfer_size = bcm63xx_hsspi_max_message_size; host->max_transfer_size = bcm63xx_hsspi_max_message_size;
master->max_message_size = bcm63xx_hsspi_max_message_size; host->max_message_size = bcm63xx_hsspi_max_message_size;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH |
SPI_RX_DUAL | SPI_TX_DUAL; SPI_RX_DUAL | SPI_TX_DUAL;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
/* Initialize the hardware */ /* Initialize the hardware */
__raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG);
...@@ -844,7 +844,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -844,7 +844,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
pdev->name, bs); pdev->name, bs);
if (ret) if (ret)
goto out_put_master; goto out_put_host;
} }
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
...@@ -856,7 +856,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -856,7 +856,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
} }
/* register and we are done */ /* register and we are done */
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret) if (ret)
goto out_sysgroup_disable; goto out_sysgroup_disable;
...@@ -868,8 +868,8 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -868,8 +868,8 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
sysfs_remove_group(&pdev->dev.kobj, &bcm63xx_hsspi_group); sysfs_remove_group(&pdev->dev.kobj, &bcm63xx_hsspi_group);
out_pm_disable: out_pm_disable:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
out_put_master: out_put_host:
spi_master_put(master); spi_controller_put(host);
out_disable_pll_clk: out_disable_pll_clk:
clk_disable_unprepare(pll_clk); clk_disable_unprepare(pll_clk);
out_disable_clk: out_disable_clk:
...@@ -880,8 +880,8 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev) ...@@ -880,8 +880,8 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
static void bcm63xx_hsspi_remove(struct platform_device *pdev) static void bcm63xx_hsspi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(host);
/* reset the hardware and block queue progress */ /* reset the hardware and block queue progress */
__raw_writel(0, bs->regs + HSSPI_INT_MASK_REG); __raw_writel(0, bs->regs + HSSPI_INT_MASK_REG);
...@@ -893,10 +893,10 @@ static void bcm63xx_hsspi_remove(struct platform_device *pdev) ...@@ -893,10 +893,10 @@ static void bcm63xx_hsspi_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int bcm63xx_hsspi_suspend(struct device *dev) static int bcm63xx_hsspi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(host);
spi_master_suspend(master); spi_controller_suspend(host);
clk_disable_unprepare(bs->pll_clk); clk_disable_unprepare(bs->pll_clk);
clk_disable_unprepare(bs->clk); clk_disable_unprepare(bs->clk);
...@@ -905,8 +905,8 @@ static int bcm63xx_hsspi_suspend(struct device *dev) ...@@ -905,8 +905,8 @@ static int bcm63xx_hsspi_suspend(struct device *dev)
static int bcm63xx_hsspi_resume(struct device *dev) static int bcm63xx_hsspi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct bcm63xx_hsspi *bs = spi_master_get_devdata(master); struct bcm63xx_hsspi *bs = spi_controller_get_devdata(host);
int ret; int ret;
ret = clk_prepare_enable(bs->clk); ret = clk_prepare_enable(bs->clk);
...@@ -921,7 +921,7 @@ static int bcm63xx_hsspi_resume(struct device *dev) ...@@ -921,7 +921,7 @@ static int bcm63xx_hsspi_resume(struct device *dev)
} }
} }
spi_master_resume(master); spi_controller_resume(host);
return 0; return 0;
} }
......
...@@ -186,7 +186,7 @@ static const unsigned int bcm63xx_spi_freq_table[SPI_CLK_MASK][2] = { ...@@ -186,7 +186,7 @@ static const unsigned int bcm63xx_spi_freq_table[SPI_CLK_MASK][2] = {
static void bcm63xx_spi_setup_transfer(struct spi_device *spi, static void bcm63xx_spi_setup_transfer(struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); struct bcm63xx_spi *bs = spi_controller_get_devdata(spi->controller);
u8 clk_cfg, reg; u8 clk_cfg, reg;
int i; int i;
...@@ -217,7 +217,7 @@ static void bcm63xx_spi_setup_transfer(struct spi_device *spi, ...@@ -217,7 +217,7 @@ static void bcm63xx_spi_setup_transfer(struct spi_device *spi,
static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first, static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
unsigned int num_transfers) unsigned int num_transfers)
{ {
struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); struct bcm63xx_spi *bs = spi_controller_get_devdata(spi->controller);
u16 msg_ctl; u16 msg_ctl;
u16 cmd; u16 cmd;
unsigned int i, timeout = 0, prepend_len = 0, len = 0; unsigned int i, timeout = 0, prepend_len = 0, len = 0;
...@@ -312,10 +312,10 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first, ...@@ -312,10 +312,10 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
return 0; return 0;
} }
static int bcm63xx_spi_transfer_one(struct spi_master *master, static int bcm63xx_spi_transfer_one(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
struct bcm63xx_spi *bs = spi_master_get_devdata(master); struct bcm63xx_spi *bs = spi_controller_get_devdata(host);
struct spi_transfer *t, *first = NULL; struct spi_transfer *t, *first = NULL;
struct spi_device *spi = m->spi; struct spi_device *spi = m->spi;
int status = 0; int status = 0;
...@@ -385,18 +385,18 @@ static int bcm63xx_spi_transfer_one(struct spi_master *master, ...@@ -385,18 +385,18 @@ static int bcm63xx_spi_transfer_one(struct spi_master *master,
} }
exit: exit:
m->status = status; m->status = status;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return 0; return 0;
} }
/* This driver supports single master mode only. Hence /* This driver supports single host mode only. Hence
* CMD_DONE is the only interrupt we care about * CMD_DONE is the only interrupt we care about
*/ */
static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id) static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id)
{ {
struct spi_master *master = (struct spi_master *)dev_id; struct spi_controller *host = (struct spi_controller *)dev_id;
struct bcm63xx_spi *bs = spi_master_get_devdata(master); struct bcm63xx_spi *bs = spi_controller_get_devdata(host);
u8 intr; u8 intr;
/* Read interupts and clear them immediately */ /* Read interupts and clear them immediately */
...@@ -413,7 +413,7 @@ static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id) ...@@ -413,7 +413,7 @@ static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id)
static size_t bcm63xx_spi_max_length(struct spi_device *spi) static size_t bcm63xx_spi_max_length(struct spi_device *spi)
{ {
struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master); struct bcm63xx_spi *bs = spi_controller_get_devdata(spi->controller);
return bs->fifo_size; return bs->fifo_size;
} }
...@@ -479,7 +479,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -479,7 +479,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
const unsigned long *bcm63xx_spireg; const unsigned long *bcm63xx_spireg;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int irq, bus_num; int irq, bus_num;
struct spi_master *master; struct spi_controller *host;
struct clk *clk; struct clk *clk;
struct bcm63xx_spi *bs; struct bcm63xx_spi *bs;
int ret; int ret;
...@@ -525,16 +525,16 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -525,16 +525,16 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
if (IS_ERR(reset)) if (IS_ERR(reset))
return PTR_ERR(reset); return PTR_ERR(reset);
master = spi_alloc_master(dev, sizeof(*bs)); host = spi_alloc_host(dev, sizeof(*bs));
if (!master) { if (!host) {
dev_err(dev, "out of memory\n"); dev_err(dev, "out of memory\n");
return -ENOMEM; return -ENOMEM;
} }
bs = spi_master_get_devdata(master); bs = spi_controller_get_devdata(host);
init_completion(&bs->done); init_completion(&bs->done);
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
bs->pdev = pdev; bs->pdev = pdev;
bs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r); bs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
...@@ -549,21 +549,21 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -549,21 +549,21 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
bs->fifo_size = bs->reg_offsets[SPI_MSG_DATA_SIZE]; bs->fifo_size = bs->reg_offsets[SPI_MSG_DATA_SIZE];
ret = devm_request_irq(&pdev->dev, irq, bcm63xx_spi_interrupt, 0, ret = devm_request_irq(&pdev->dev, irq, bcm63xx_spi_interrupt, 0,
pdev->name, master); pdev->name, host);
if (ret) { if (ret) {
dev_err(dev, "unable to request irq\n"); dev_err(dev, "unable to request irq\n");
goto out_err; goto out_err;
} }
master->dev.of_node = dev->of_node; host->dev.of_node = dev->of_node;
master->bus_num = bus_num; host->bus_num = bus_num;
master->num_chipselect = num_cs; host->num_chipselect = num_cs;
master->transfer_one_message = bcm63xx_spi_transfer_one; host->transfer_one_message = bcm63xx_spi_transfer_one;
master->mode_bits = MODEBITS; host->mode_bits = MODEBITS;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->max_transfer_size = bcm63xx_spi_max_length; host->max_transfer_size = bcm63xx_spi_max_length;
master->max_message_size = bcm63xx_spi_max_length; host->max_message_size = bcm63xx_spi_max_length;
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
bs->msg_type_shift = bs->reg_offsets[SPI_MSG_TYPE_SHIFT]; bs->msg_type_shift = bs->reg_offsets[SPI_MSG_TYPE_SHIFT];
bs->msg_ctl_width = bs->reg_offsets[SPI_MSG_CTL_WIDTH]; bs->msg_ctl_width = bs->reg_offsets[SPI_MSG_CTL_WIDTH];
bs->tx_io = (u8 *)(bs->regs + bs->reg_offsets[SPI_MSG_DATA]); bs->tx_io = (u8 *)(bs->regs + bs->reg_offsets[SPI_MSG_DATA]);
...@@ -585,7 +585,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -585,7 +585,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
/* register and we are done */ /* register and we are done */
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret) { if (ret) {
dev_err(dev, "spi register failed\n"); dev_err(dev, "spi register failed\n");
goto out_pm_disable; goto out_pm_disable;
...@@ -601,14 +601,14 @@ static int bcm63xx_spi_probe(struct platform_device *pdev) ...@@ -601,14 +601,14 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
out_clk_disable: out_clk_disable:
clk_disable_unprepare(clk); clk_disable_unprepare(clk);
out_err: out_err:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void bcm63xx_spi_remove(struct platform_device *pdev) static void bcm63xx_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct bcm63xx_spi *bs = spi_master_get_devdata(master); struct bcm63xx_spi *bs = spi_controller_get_devdata(host);
/* reset spi block */ /* reset spi block */
bcm_spi_writeb(bs, 0, SPI_INT_MASK); bcm_spi_writeb(bs, 0, SPI_INT_MASK);
...@@ -619,10 +619,10 @@ static void bcm63xx_spi_remove(struct platform_device *pdev) ...@@ -619,10 +619,10 @@ static void bcm63xx_spi_remove(struct platform_device *pdev)
static int bcm63xx_spi_suspend(struct device *dev) static int bcm63xx_spi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct bcm63xx_spi *bs = spi_master_get_devdata(master); struct bcm63xx_spi *bs = spi_controller_get_devdata(host);
spi_master_suspend(master); spi_controller_suspend(host);
clk_disable_unprepare(bs->clk); clk_disable_unprepare(bs->clk);
...@@ -631,15 +631,15 @@ static int bcm63xx_spi_suspend(struct device *dev) ...@@ -631,15 +631,15 @@ static int bcm63xx_spi_suspend(struct device *dev)
static int bcm63xx_spi_resume(struct device *dev) static int bcm63xx_spi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct bcm63xx_spi *bs = spi_master_get_devdata(master); struct bcm63xx_spi *bs = spi_controller_get_devdata(host);
int ret; int ret;
ret = clk_prepare_enable(bs->clk); ret = clk_prepare_enable(bs->clk);
if (ret) if (ret)
return ret; return ret;
spi_master_resume(master); spi_controller_resume(host);
return 0; return 0;
} }
......
...@@ -178,7 +178,7 @@ static void butterfly_attach(struct parport *p) ...@@ -178,7 +178,7 @@ static void butterfly_attach(struct parport *p)
struct pardevice *pd; struct pardevice *pd;
int status; int status;
struct butterfly *pp; struct butterfly *pp;
struct spi_master *master; struct spi_controller *host;
struct device *dev = p->physport->dev; struct device *dev = p->physport->dev;
struct pardev_cb butterfly_cb; struct pardev_cb butterfly_cb;
...@@ -189,12 +189,12 @@ static void butterfly_attach(struct parport *p) ...@@ -189,12 +189,12 @@ static void butterfly_attach(struct parport *p)
* and no way to be selective about what it binds to. * and no way to be selective about what it binds to.
*/ */
master = spi_alloc_master(dev, sizeof(*pp)); host = spi_alloc_host(dev, sizeof(*pp));
if (!master) { if (!host) {
status = -ENOMEM; status = -ENOMEM;
goto done; goto done;
} }
pp = spi_master_get_devdata(master); pp = spi_controller_get_devdata(host);
/* /*
* SPI and bitbang hookup * SPI and bitbang hookup
...@@ -202,10 +202,10 @@ static void butterfly_attach(struct parport *p) ...@@ -202,10 +202,10 @@ static void butterfly_attach(struct parport *p)
* use default setup(), cleanup(), and transfer() methods; and * use default setup(), cleanup(), and transfer() methods; and
* only bother implementing mode 0. Start it later. * only bother implementing mode 0. Start it later.
*/ */
master->bus_num = 42; host->bus_num = 42;
master->num_chipselect = 2; host->num_chipselect = 2;
pp->bitbang.master = master; pp->bitbang.master = host;
pp->bitbang.chipselect = butterfly_chipselect; pp->bitbang.chipselect = butterfly_chipselect;
pp->bitbang.txrx_word[SPI_MODE_0] = butterfly_txrx_word_mode0; pp->bitbang.txrx_word[SPI_MODE_0] = butterfly_txrx_word_mode0;
...@@ -280,7 +280,7 @@ static void butterfly_attach(struct parport *p) ...@@ -280,7 +280,7 @@ static void butterfly_attach(struct parport *p)
clean1: clean1:
parport_unregister_device(pd); parport_unregister_device(pd);
clean0: clean0:
spi_master_put(pp->bitbang.master); spi_controller_put(host);
done: done:
pr_debug("%s: butterfly probe, fail %d\n", p->name, status); pr_debug("%s: butterfly probe, fail %d\n", p->name, status);
} }
...@@ -308,7 +308,7 @@ static void butterfly_detach(struct parport *p) ...@@ -308,7 +308,7 @@ static void butterfly_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);
} }
static struct parport_driver butterfly_driver = { static struct parport_driver butterfly_driver = {
......
...@@ -419,7 +419,7 @@ static int cdns_xspi_mem_op_execute(struct spi_mem *mem, ...@@ -419,7 +419,7 @@ static int cdns_xspi_mem_op_execute(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct cdns_xspi_dev *cdns_xspi = struct cdns_xspi_dev *cdns_xspi =
spi_master_get_devdata(mem->spi->master); spi_controller_get_devdata(mem->spi->controller);
int ret = 0; int ret = 0;
ret = cdns_xspi_mem_op(cdns_xspi, mem, op); ret = cdns_xspi_mem_op(cdns_xspi, mem, op);
...@@ -430,7 +430,7 @@ static int cdns_xspi_mem_op_execute(struct spi_mem *mem, ...@@ -430,7 +430,7 @@ static int cdns_xspi_mem_op_execute(struct spi_mem *mem,
static int cdns_xspi_adjust_mem_op_size(struct spi_mem *mem, struct spi_mem_op *op) static int cdns_xspi_adjust_mem_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{ {
struct cdns_xspi_dev *cdns_xspi = struct cdns_xspi_dev *cdns_xspi =
spi_master_get_devdata(mem->spi->master); spi_controller_get_devdata(mem->spi->controller);
op->data.nbytes = clamp_val(op->data.nbytes, 0, cdns_xspi->sdmasize); op->data.nbytes = clamp_val(op->data.nbytes, 0, cdns_xspi->sdmasize);
...@@ -527,26 +527,26 @@ static void cdns_xspi_print_phy_config(struct cdns_xspi_dev *cdns_xspi) ...@@ -527,26 +527,26 @@ static void cdns_xspi_print_phy_config(struct cdns_xspi_dev *cdns_xspi)
static int cdns_xspi_probe(struct platform_device *pdev) static int cdns_xspi_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_master *master = NULL; struct spi_controller *host = NULL;
struct cdns_xspi_dev *cdns_xspi = NULL; struct cdns_xspi_dev *cdns_xspi = NULL;
struct resource *res; struct resource *res;
int ret; int ret;
master = devm_spi_alloc_master(dev, sizeof(*cdns_xspi)); host = devm_spi_alloc_host(dev, sizeof(*cdns_xspi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
master->mode_bits = SPI_3WIRE | SPI_TX_DUAL | SPI_TX_QUAD | host->mode_bits = SPI_3WIRE | SPI_TX_DUAL | SPI_TX_QUAD |
SPI_RX_DUAL | SPI_RX_QUAD | SPI_TX_OCTAL | SPI_RX_OCTAL | SPI_RX_DUAL | SPI_RX_QUAD | SPI_TX_OCTAL | SPI_RX_OCTAL |
SPI_MODE_0 | SPI_MODE_3; SPI_MODE_0 | SPI_MODE_3;
master->mem_ops = &cadence_xspi_mem_ops; host->mem_ops = &cadence_xspi_mem_ops;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->bus_num = -1; host->bus_num = -1;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
cdns_xspi = spi_master_get_devdata(master); cdns_xspi = spi_controller_get_devdata(host);
cdns_xspi->pdev = pdev; cdns_xspi->pdev = pdev;
cdns_xspi->dev = &pdev->dev; cdns_xspi->dev = &pdev->dev;
cdns_xspi->cur_cs = 0; cdns_xspi->cur_cs = 0;
...@@ -596,15 +596,15 @@ static int cdns_xspi_probe(struct platform_device *pdev) ...@@ -596,15 +596,15 @@ static int cdns_xspi_probe(struct platform_device *pdev)
return ret; return ret;
} }
master->num_chipselect = 1 << cdns_xspi->hw_num_banks; host->num_chipselect = 1 << cdns_xspi->hw_num_banks;
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret) { if (ret) {
dev_err(dev, "Failed to register SPI master\n"); dev_err(dev, "Failed to register SPI host\n");
return ret; return ret;
} }
dev_info(dev, "Successfully registered SPI master\n"); dev_info(dev, "Successfully registered SPI host\n");
return 0; return 0;
} }
......
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
/* /*
* Cadence SPI controller driver (master and slave mode) * Cadence SPI controller driver (host and target mode)
* *
* Copyright (C) 2008 - 2014 Xilinx, Inc. * Copyright (C) 2008 - 2014 Xilinx, Inc.
* *
...@@ -59,10 +59,10 @@ ...@@ -59,10 +59,10 @@
CDNS_SPI_CR_BAUD_DIV_4) CDNS_SPI_CR_BAUD_DIV_4)
/* /*
* SPI Configuration Register - Baud rate and slave select * SPI Configuration Register - Baud rate and target select
* *
* These are the values used in the calculation of baud rate divisor and * These are the values used in the calculation of baud rate divisor and
* setting the slave select. * setting the target select.
*/ */
#define CDNS_SPI_BAUD_DIV_MAX 7 /* Baud rate divisor maximum */ #define CDNS_SPI_BAUD_DIV_MAX 7 /* Baud rate divisor maximum */
...@@ -141,20 +141,20 @@ static inline void cdns_spi_write(struct cdns_spi *xspi, u32 offset, u32 val) ...@@ -141,20 +141,20 @@ static inline void cdns_spi_write(struct cdns_spi *xspi, u32 offset, u32 val)
/** /**
* cdns_spi_init_hw - Initialize the hardware and configure the SPI controller * cdns_spi_init_hw - Initialize the hardware and configure the SPI controller
* @xspi: Pointer to the cdns_spi structure * @xspi: Pointer to the cdns_spi structure
* @is_slave: Flag to indicate slave or master mode * @is_target: Flag to indicate target or host mode
* * On reset the SPI controller is configured to slave or master mode. * * On reset the SPI controller is configured to target or host mode.
* In master mode baud rate divisor is set to 4, threshold value for TX FIFO * In host mode baud rate divisor is set to 4, threshold value for TX FIFO
* not full interrupt is set to 1 and size of the word to be transferred as 8 bit. * not full interrupt is set to 1 and size of the word to be transferred as 8 bit.
* *
* This function initializes the SPI controller to disable and clear all the * This function initializes the SPI controller to disable and clear all the
* interrupts, enable manual slave select and manual start, deselect all the * interrupts, enable manual target select and manual start, deselect all the
* chip select lines, and enable the SPI controller. * chip select lines, and enable the SPI controller.
*/ */
static void cdns_spi_init_hw(struct cdns_spi *xspi, bool is_slave) static void cdns_spi_init_hw(struct cdns_spi *xspi, bool is_target)
{ {
u32 ctrl_reg = 0; u32 ctrl_reg = 0;
if (!is_slave) if (!is_target)
ctrl_reg |= CDNS_SPI_CR_DEFAULT; ctrl_reg |= CDNS_SPI_CR_DEFAULT;
if (xspi->is_decoded_cs) if (xspi->is_decoded_cs)
...@@ -185,10 +185,10 @@ static void cdns_spi_chipselect(struct spi_device *spi, bool is_high) ...@@ -185,10 +185,10 @@ static void cdns_spi_chipselect(struct spi_device *spi, bool is_high)
ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR); ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR);
if (is_high) { if (is_high) {
/* Deselect the slave */ /* Deselect the target */
ctrl_reg |= CDNS_SPI_CR_SSCTRL; ctrl_reg |= CDNS_SPI_CR_SSCTRL;
} else { } else {
/* Select the slave */ /* Select the target */
ctrl_reg &= ~CDNS_SPI_CR_SSCTRL; ctrl_reg &= ~CDNS_SPI_CR_SSCTRL;
if (!(xspi->is_decoded_cs)) if (!(xspi->is_decoded_cs))
ctrl_reg |= ((~(CDNS_SPI_SS0 << spi_get_chipselect(spi, 0))) << ctrl_reg |= ((~(CDNS_SPI_SS0 << spi_get_chipselect(spi, 0))) <<
...@@ -227,7 +227,7 @@ static void cdns_spi_config_clock_mode(struct spi_device *spi) ...@@ -227,7 +227,7 @@ static void cdns_spi_config_clock_mode(struct spi_device *spi)
/* /*
* Just writing the CR register does not seem to apply the clock * Just writing the CR register does not seem to apply the clock
* setting changes. This is problematic when changing the clock * setting changes. This is problematic when changing the clock
* polarity as it will cause the SPI slave to see spurious clock * polarity as it will cause the SPI target to see spurious clock
* transitions. To workaround the issue toggle the ER register. * transitions. To workaround the issue toggle the ER register.
*/ */
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE); cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
...@@ -406,7 +406,7 @@ static irqreturn_t cdns_spi_irq(int irq, void *dev_id) ...@@ -406,7 +406,7 @@ static irqreturn_t cdns_spi_irq(int irq, void *dev_id)
static int cdns_prepare_message(struct spi_controller *ctlr, static int cdns_prepare_message(struct spi_controller *ctlr,
struct spi_message *msg) struct spi_message *msg)
{ {
if (!spi_controller_is_slave(ctlr)) if (!spi_controller_is_target(ctlr))
cdns_spi_config_clock_mode(msg->spi); cdns_spi_config_clock_mode(msg->spi);
return 0; return 0;
} }
...@@ -418,9 +418,9 @@ static int cdns_prepare_message(struct spi_controller *ctlr, ...@@ -418,9 +418,9 @@ static int cdns_prepare_message(struct spi_controller *ctlr,
* @transfer: Pointer to the spi_transfer structure which provides * @transfer: Pointer to the spi_transfer structure which provides
* information about next transfer parameters * information about next transfer parameters
* *
* This function in master mode fills the TX FIFO, starts the SPI transfer and * This function in host mode fills the TX FIFO, starts the SPI transfer and
* returns a positive transfer count so that core will wait for completion. * returns a positive transfer count so that core will wait for completion.
* This function in slave mode fills the TX FIFO and wait for transfer trigger. * This function in target mode fills the TX FIFO and wait for transfer trigger.
* *
* Return: Number of bytes transferred in the last transfer * Return: Number of bytes transferred in the last transfer
*/ */
...@@ -435,7 +435,7 @@ static int cdns_transfer_one(struct spi_controller *ctlr, ...@@ -435,7 +435,7 @@ static int cdns_transfer_one(struct spi_controller *ctlr,
xspi->tx_bytes = transfer->len; xspi->tx_bytes = transfer->len;
xspi->rx_bytes = transfer->len; xspi->rx_bytes = transfer->len;
if (!spi_controller_is_slave(ctlr)) { if (!spi_controller_is_target(ctlr)) {
cdns_spi_setup_transfer(spi, transfer); cdns_spi_setup_transfer(spi, transfer);
} else { } else {
/* Set TX empty threshold to half of FIFO depth /* Set TX empty threshold to half of FIFO depth
...@@ -457,7 +457,7 @@ static int cdns_transfer_one(struct spi_controller *ctlr, ...@@ -457,7 +457,7 @@ static int cdns_transfer_one(struct spi_controller *ctlr,
* @ctlr: Pointer to the spi_controller structure which provides * @ctlr: Pointer to the spi_controller structure which provides
* information about the controller. * information about the controller.
* *
* This function enables SPI master controller. * This function enables SPI host controller.
* *
* Return: 0 always * Return: 0 always
*/ */
...@@ -475,7 +475,7 @@ static int cdns_prepare_transfer_hardware(struct spi_controller *ctlr) ...@@ -475,7 +475,7 @@ static int cdns_prepare_transfer_hardware(struct spi_controller *ctlr)
* @ctlr: Pointer to the spi_controller structure which provides * @ctlr: Pointer to the spi_controller structure which provides
* information about the controller. * information about the controller.
* *
* This function disables the SPI master controller when no slave selected. * This function disables the SPI host controller when no target selected.
* This function flush out if any pending data in FIFO. * This function flush out if any pending data in FIFO.
* *
* Return: 0 always * Return: 0 always
...@@ -486,15 +486,15 @@ static int cdns_unprepare_transfer_hardware(struct spi_controller *ctlr) ...@@ -486,15 +486,15 @@ static int cdns_unprepare_transfer_hardware(struct spi_controller *ctlr)
u32 ctrl_reg; u32 ctrl_reg;
unsigned int cnt = xspi->tx_fifo_depth; unsigned int cnt = xspi->tx_fifo_depth;
if (spi_controller_is_slave(ctlr)) { if (spi_controller_is_target(ctlr)) {
while (cnt--) while (cnt--)
cdns_spi_read(xspi, CDNS_SPI_RXD); cdns_spi_read(xspi, CDNS_SPI_RXD);
} }
/* Disable the SPI if slave is deselected */ /* Disable the SPI if target is deselected */
ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR); ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR);
ctrl_reg = (ctrl_reg & CDNS_SPI_CR_SSCTRL) >> CDNS_SPI_SS_SHIFT; ctrl_reg = (ctrl_reg & CDNS_SPI_CR_SSCTRL) >> CDNS_SPI_SS_SHIFT;
if (ctrl_reg == CDNS_SPI_NOSS || spi_controller_is_slave(ctlr)) if (ctrl_reg == CDNS_SPI_NOSS || spi_controller_is_target(ctlr))
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE); cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
/* Reset to default */ /* Reset to default */
...@@ -521,14 +521,14 @@ static void cdns_spi_detect_fifo_depth(struct cdns_spi *xspi) ...@@ -521,14 +521,14 @@ static void cdns_spi_detect_fifo_depth(struct cdns_spi *xspi)
} }
/** /**
* cdns_slave_abort - Abort slave transfer * cdns_target_abort - Abort target transfer
* @ctlr: Pointer to the spi_controller structure * @ctlr: Pointer to the spi_controller structure
* *
* This function abort slave transfer if there any transfer timeout. * This function abort target transfer if there any transfer timeout.
* *
* Return: 0 always * Return: 0 always
*/ */
static int cdns_slave_abort(struct spi_controller *ctlr) static int cdns_target_abort(struct spi_controller *ctlr)
{ {
struct cdns_spi *xspi = spi_controller_get_devdata(ctlr); struct cdns_spi *xspi = spi_controller_get_devdata(ctlr);
u32 intr_status; u32 intr_status;
...@@ -555,13 +555,13 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -555,13 +555,13 @@ static int cdns_spi_probe(struct platform_device *pdev)
struct spi_controller *ctlr; struct spi_controller *ctlr;
struct cdns_spi *xspi; struct cdns_spi *xspi;
u32 num_cs; u32 num_cs;
bool slave; bool target;
slave = of_property_read_bool(pdev->dev.of_node, "spi-slave"); target = of_property_read_bool(pdev->dev.of_node, "spi-slave");
if (slave) if (target)
ctlr = spi_alloc_slave(&pdev->dev, sizeof(*xspi)); ctlr = spi_alloc_target(&pdev->dev, sizeof(*xspi));
else else
ctlr = spi_alloc_master(&pdev->dev, sizeof(*xspi)); ctlr = spi_alloc_host(&pdev->dev, sizeof(*xspi));
if (!ctlr) if (!ctlr)
return -ENOMEM; return -ENOMEM;
...@@ -589,7 +589,7 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -589,7 +589,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
goto remove_ctlr; goto remove_ctlr;
} }
if (!spi_controller_is_slave(ctlr)) { if (!spi_controller_is_target(ctlr)) {
xspi->ref_clk = devm_clk_get(&pdev->dev, "ref_clk"); xspi->ref_clk = devm_clk_get(&pdev->dev, "ref_clk");
if (IS_ERR(xspi->ref_clk)) { if (IS_ERR(xspi->ref_clk)) {
dev_err(&pdev->dev, "ref_clk clock not found.\n"); dev_err(&pdev->dev, "ref_clk clock not found.\n");
...@@ -624,7 +624,7 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -624,7 +624,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
cdns_spi_detect_fifo_depth(xspi); cdns_spi_detect_fifo_depth(xspi);
/* SPI controller initializations */ /* SPI controller initializations */
cdns_spi_init_hw(xspi, spi_controller_is_slave(ctlr)); cdns_spi_init_hw(xspi, spi_controller_is_target(ctlr));
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
...@@ -648,7 +648,7 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -648,7 +648,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
ctlr->mode_bits = SPI_CPOL | SPI_CPHA; ctlr->mode_bits = SPI_CPOL | SPI_CPHA;
ctlr->bits_per_word_mask = SPI_BPW_MASK(8); ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
if (!spi_controller_is_slave(ctlr)) { if (!spi_controller_is_target(ctlr)) {
ctlr->mode_bits |= SPI_CS_HIGH; ctlr->mode_bits |= SPI_CS_HIGH;
ctlr->set_cs = cdns_spi_chipselect; ctlr->set_cs = cdns_spi_chipselect;
ctlr->auto_runtime_pm = true; ctlr->auto_runtime_pm = true;
...@@ -660,7 +660,7 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -660,7 +660,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
pm_runtime_put_autosuspend(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev);
} else { } else {
ctlr->mode_bits |= SPI_NO_CS; ctlr->mode_bits |= SPI_NO_CS;
ctlr->slave_abort = cdns_slave_abort; ctlr->target_abort = cdns_target_abort;
} }
ret = spi_register_controller(ctlr); ret = spi_register_controller(ctlr);
if (ret) { if (ret) {
...@@ -671,7 +671,7 @@ static int cdns_spi_probe(struct platform_device *pdev) ...@@ -671,7 +671,7 @@ static int cdns_spi_probe(struct platform_device *pdev)
return ret; return ret;
clk_dis_all: clk_dis_all:
if (!spi_controller_is_slave(ctlr)) { if (!spi_controller_is_target(ctlr)) {
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(xspi->ref_clk); clk_disable_unprepare(xspi->ref_clk);
...@@ -735,7 +735,7 @@ static int __maybe_unused cdns_spi_resume(struct device *dev) ...@@ -735,7 +735,7 @@ static int __maybe_unused cdns_spi_resume(struct device *dev)
struct spi_controller *ctlr = dev_get_drvdata(dev); struct spi_controller *ctlr = dev_get_drvdata(dev);
struct cdns_spi *xspi = spi_controller_get_devdata(ctlr); struct cdns_spi *xspi = spi_controller_get_devdata(ctlr);
cdns_spi_init_hw(xspi, spi_controller_is_slave(ctlr)); cdns_spi_init_hw(xspi, spi_controller_is_target(ctlr));
return spi_controller_resume(ctlr); return spi_controller_resume(ctlr);
} }
......
...@@ -19,15 +19,15 @@ ...@@ -19,15 +19,15 @@
static int octeon_spi_probe(struct platform_device *pdev) static int octeon_spi_probe(struct platform_device *pdev)
{ {
void __iomem *reg_base; void __iomem *reg_base;
struct spi_master *master; struct spi_controller *host;
struct octeon_spi *p; struct octeon_spi *p;
int err = -ENOENT; int err = -ENOENT;
master = spi_alloc_master(&pdev->dev, sizeof(struct octeon_spi)); host = spi_alloc_host(&pdev->dev, sizeof(struct octeon_spi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
p = spi_master_get_devdata(master); p = spi_controller_get_devdata(host);
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
reg_base = devm_platform_ioremap_resource(pdev, 0); reg_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(reg_base)) { if (IS_ERR(reg_base)) {
...@@ -43,21 +43,21 @@ static int octeon_spi_probe(struct platform_device *pdev) ...@@ -43,21 +43,21 @@ static int octeon_spi_probe(struct platform_device *pdev)
p->regs.tx = 0x10; p->regs.tx = 0x10;
p->regs.data = 0x80; p->regs.data = 0x80;
master->num_chipselect = 4; host->num_chipselect = 4;
master->mode_bits = SPI_CPHA | host->mode_bits = SPI_CPHA |
SPI_CPOL | SPI_CPOL |
SPI_CS_HIGH | SPI_CS_HIGH |
SPI_LSB_FIRST | SPI_LSB_FIRST |
SPI_3WIRE; SPI_3WIRE;
master->transfer_one_message = octeon_spi_transfer_one_message; host->transfer_one_message = octeon_spi_transfer_one_message;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->max_speed_hz = OCTEON_SPI_MAX_CLOCK_HZ; host->max_speed_hz = OCTEON_SPI_MAX_CLOCK_HZ;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
err = devm_spi_register_master(&pdev->dev, master); err = devm_spi_register_controller(&pdev->dev, host);
if (err) { if (err) {
dev_err(&pdev->dev, "register master failed: %d\n", err); dev_err(&pdev->dev, "register host failed: %d\n", err);
goto fail; goto fail;
} }
...@@ -65,14 +65,14 @@ static int octeon_spi_probe(struct platform_device *pdev) ...@@ -65,14 +65,14 @@ static int octeon_spi_probe(struct platform_device *pdev)
return 0; return 0;
fail: fail:
spi_master_put(master); spi_controller_put(host);
return err; return err;
} }
static void octeon_spi_remove(struct platform_device *pdev) static void octeon_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct octeon_spi *p = spi_master_get_devdata(master); struct octeon_spi *p = spi_controller_get_devdata(host);
/* Clear the CSENA* and put everything in a known state. */ /* Clear the CSENA* and put everything in a known state. */
writeq(0, p->register_base + OCTEON_SPI_CFG(p)); writeq(0, p->register_base + OCTEON_SPI_CFG(p));
......
...@@ -20,15 +20,15 @@ static int thunderx_spi_probe(struct pci_dev *pdev, ...@@ -20,15 +20,15 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_master *master; struct spi_controller *host;
struct octeon_spi *p; struct octeon_spi *p;
int ret; int ret;
master = spi_alloc_master(dev, sizeof(struct octeon_spi)); host = spi_alloc_host(dev, sizeof(struct octeon_spi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
p = spi_master_get_devdata(master); p = spi_controller_get_devdata(host);
ret = pcim_enable_device(pdev); ret = pcim_enable_device(pdev);
if (ret) if (ret)
...@@ -64,18 +64,18 @@ static int thunderx_spi_probe(struct pci_dev *pdev, ...@@ -64,18 +64,18 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
p->sys_freq = SYS_FREQ_DEFAULT; p->sys_freq = SYS_FREQ_DEFAULT;
dev_info(dev, "Set system clock to %u\n", p->sys_freq); dev_info(dev, "Set system clock to %u\n", p->sys_freq);
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->num_chipselect = 4; host->num_chipselect = 4;
master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH | host->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH |
SPI_LSB_FIRST | SPI_3WIRE; SPI_LSB_FIRST | SPI_3WIRE;
master->transfer_one_message = octeon_spi_transfer_one_message; host->transfer_one_message = octeon_spi_transfer_one_message;
master->bits_per_word_mask = SPI_BPW_MASK(8); host->bits_per_word_mask = SPI_BPW_MASK(8);
master->max_speed_hz = OCTEON_SPI_MAX_CLOCK_HZ; host->max_speed_hz = OCTEON_SPI_MAX_CLOCK_HZ;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
pci_set_drvdata(pdev, master); pci_set_drvdata(pdev, host);
ret = devm_spi_register_master(dev, master); ret = devm_spi_register_controller(dev, host);
if (ret) if (ret)
goto error; goto error;
...@@ -84,16 +84,16 @@ static int thunderx_spi_probe(struct pci_dev *pdev, ...@@ -84,16 +84,16 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
error: error:
clk_disable_unprepare(p->clk); clk_disable_unprepare(p->clk);
pci_release_regions(pdev); pci_release_regions(pdev);
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void thunderx_spi_remove(struct pci_dev *pdev) static void thunderx_spi_remove(struct pci_dev *pdev)
{ {
struct spi_master *master = pci_get_drvdata(pdev); struct spi_controller *host = pci_get_drvdata(pdev);
struct octeon_spi *p; struct octeon_spi *p;
p = spi_master_get_devdata(master); p = spi_controller_get_devdata(host);
if (!p) if (!p)
return; return;
......
...@@ -33,10 +33,10 @@ struct spi_clps711x_data { ...@@ -33,10 +33,10 @@ struct spi_clps711x_data {
int len; int len;
}; };
static int spi_clps711x_prepare_message(struct spi_master *master, static int spi_clps711x_prepare_message(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct spi_clps711x_data *hw = spi_master_get_devdata(master); struct spi_clps711x_data *hw = spi_controller_get_devdata(host);
struct spi_device *spi = msg->spi; struct spi_device *spi = msg->spi;
/* Setup mode for transfer */ /* Setup mode for transfer */
...@@ -45,11 +45,11 @@ static int spi_clps711x_prepare_message(struct spi_master *master, ...@@ -45,11 +45,11 @@ static int spi_clps711x_prepare_message(struct spi_master *master,
SYSCON3_ADCCKNSEN : 0); SYSCON3_ADCCKNSEN : 0);
} }
static int spi_clps711x_transfer_one(struct spi_master *master, static int spi_clps711x_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct spi_clps711x_data *hw = spi_master_get_devdata(master); struct spi_clps711x_data *hw = spi_controller_get_devdata(host);
u8 data; u8 data;
clk_set_rate(hw->spi_clk, xfer->speed_hz ? : spi->max_speed_hz); clk_set_rate(hw->spi_clk, xfer->speed_hz ? : spi->max_speed_hz);
...@@ -68,8 +68,8 @@ static int spi_clps711x_transfer_one(struct spi_master *master, ...@@ -68,8 +68,8 @@ static int spi_clps711x_transfer_one(struct spi_master *master,
static irqreturn_t spi_clps711x_isr(int irq, void *dev_id) static irqreturn_t spi_clps711x_isr(int irq, void *dev_id)
{ {
struct spi_master *master = dev_id; struct spi_controller *host = dev_id;
struct spi_clps711x_data *hw = spi_master_get_devdata(master); struct spi_clps711x_data *hw = spi_controller_get_devdata(host);
u8 data; u8 data;
/* Handle RX */ /* Handle RX */
...@@ -83,7 +83,7 @@ static irqreturn_t spi_clps711x_isr(int irq, void *dev_id) ...@@ -83,7 +83,7 @@ static irqreturn_t spi_clps711x_isr(int irq, void *dev_id)
writel(data | SYNCIO_FRMLEN(hw->bpw) | SYNCIO_TXFRMEN, writel(data | SYNCIO_FRMLEN(hw->bpw) | SYNCIO_TXFRMEN,
hw->syncio); hw->syncio);
} else } else
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -92,26 +92,26 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -92,26 +92,26 @@ static int spi_clps711x_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct spi_clps711x_data *hw; struct spi_clps711x_data *hw;
struct spi_master *master; struct spi_controller *host;
int irq, ret; int irq, ret;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) if (irq < 0)
return irq; return irq;
master = spi_alloc_master(&pdev->dev, sizeof(*hw)); host = spi_alloc_host(&pdev->dev, sizeof(*hw));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->bus_num = -1; host->bus_num = -1;
master->mode_bits = SPI_CPHA | SPI_CS_HIGH; host->mode_bits = SPI_CPHA | SPI_CS_HIGH;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 8); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 8);
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->prepare_message = spi_clps711x_prepare_message; host->prepare_message = spi_clps711x_prepare_message;
master->transfer_one = spi_clps711x_transfer_one; host->transfer_one = spi_clps711x_transfer_one;
hw = spi_master_get_devdata(master); hw = spi_controller_get_devdata(host);
hw->spi_clk = devm_clk_get(&pdev->dev, NULL); hw->spi_clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(hw->spi_clk)) { if (IS_ERR(hw->spi_clk)) {
...@@ -138,16 +138,16 @@ static int spi_clps711x_probe(struct platform_device *pdev) ...@@ -138,16 +138,16 @@ static int spi_clps711x_probe(struct platform_device *pdev)
readl(hw->syncio); readl(hw->syncio);
ret = devm_request_irq(&pdev->dev, irq, spi_clps711x_isr, 0, ret = devm_request_irq(&pdev->dev, irq, spi_clps711x_isr, 0,
dev_name(&pdev->dev), master); dev_name(&pdev->dev), host);
if (ret) if (ret)
goto err_out; goto err_out;
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (!ret) if (!ret)
return 0; return 0;
err_out: err_out:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
......
...@@ -286,7 +286,7 @@ static void mcfqspi_transfer_msg16(struct mcfqspi *mcfqspi, unsigned count, ...@@ -286,7 +286,7 @@ static void mcfqspi_transfer_msg16(struct mcfqspi *mcfqspi, unsigned count,
static void mcfqspi_set_cs(struct spi_device *spi, bool enable) static void mcfqspi_set_cs(struct spi_device *spi, bool enable)
{ {
struct mcfqspi *mcfqspi = spi_master_get_devdata(spi->master); struct mcfqspi *mcfqspi = spi_controller_get_devdata(spi->controller);
bool cs_high = spi->mode & SPI_CS_HIGH; bool cs_high = spi->mode & SPI_CS_HIGH;
if (enable) if (enable)
...@@ -295,11 +295,11 @@ static void mcfqspi_set_cs(struct spi_device *spi, bool enable) ...@@ -295,11 +295,11 @@ static void mcfqspi_set_cs(struct spi_device *spi, bool enable)
mcfqspi_cs_deselect(mcfqspi, spi_get_chipselect(spi, 0), cs_high); mcfqspi_cs_deselect(mcfqspi, spi_get_chipselect(spi, 0), cs_high);
} }
static int mcfqspi_transfer_one(struct spi_master *master, static int mcfqspi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
struct mcfqspi *mcfqspi = spi_master_get_devdata(master); struct mcfqspi *mcfqspi = spi_controller_get_devdata(host);
u16 qmr = MCFQSPI_QMR_MSTR; u16 qmr = MCFQSPI_QMR_MSTR;
qmr |= t->bits_per_word << 10; qmr |= t->bits_per_word << 10;
...@@ -323,7 +323,7 @@ static int mcfqspi_transfer_one(struct spi_master *master, ...@@ -323,7 +323,7 @@ static int mcfqspi_transfer_one(struct spi_master *master,
static int mcfqspi_setup(struct spi_device *spi) static int mcfqspi_setup(struct spi_device *spi)
{ {
mcfqspi_cs_deselect(spi_master_get_devdata(spi->master), mcfqspi_cs_deselect(spi_controller_get_devdata(spi->controller),
spi_get_chipselect(spi, 0), spi->mode & SPI_CS_HIGH); spi_get_chipselect(spi, 0), spi->mode & SPI_CS_HIGH);
dev_dbg(&spi->dev, dev_dbg(&spi->dev,
...@@ -337,7 +337,7 @@ static int mcfqspi_setup(struct spi_device *spi) ...@@ -337,7 +337,7 @@ static int mcfqspi_setup(struct spi_device *spi)
static int mcfqspi_probe(struct platform_device *pdev) static int mcfqspi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct mcfqspi *mcfqspi; struct mcfqspi *mcfqspi;
struct mcfqspi_platform_data *pdata; struct mcfqspi_platform_data *pdata;
int status; int status;
...@@ -353,13 +353,13 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -353,13 +353,13 @@ static int mcfqspi_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
master = spi_alloc_master(&pdev->dev, sizeof(*mcfqspi)); host = spi_alloc_host(&pdev->dev, sizeof(*mcfqspi));
if (master == NULL) { if (host == NULL) {
dev_dbg(&pdev->dev, "spi_alloc_master failed\n"); dev_dbg(&pdev->dev, "spi_alloc_host failed\n");
return -ENOMEM; return -ENOMEM;
} }
mcfqspi = spi_master_get_devdata(master); mcfqspi = spi_controller_get_devdata(host);
mcfqspi->iobase = devm_platform_ioremap_resource(pdev, 0); mcfqspi->iobase = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(mcfqspi->iobase)) { if (IS_ERR(mcfqspi->iobase)) {
...@@ -388,8 +388,8 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -388,8 +388,8 @@ static int mcfqspi_probe(struct platform_device *pdev)
goto fail0; goto fail0;
} }
master->bus_num = pdata->bus_num; host->bus_num = pdata->bus_num;
master->num_chipselect = pdata->num_chipselect; host->num_chipselect = pdata->num_chipselect;
mcfqspi->cs_control = pdata->cs_control; mcfqspi->cs_control = pdata->cs_control;
status = mcfqspi_cs_setup(mcfqspi); status = mcfqspi_cs_setup(mcfqspi);
...@@ -400,19 +400,19 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -400,19 +400,19 @@ static int mcfqspi_probe(struct platform_device *pdev)
init_waitqueue_head(&mcfqspi->waitq); init_waitqueue_head(&mcfqspi->waitq);
master->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA; host->mode_bits = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16);
master->setup = mcfqspi_setup; host->setup = mcfqspi_setup;
master->set_cs = mcfqspi_set_cs; host->set_cs = mcfqspi_set_cs;
master->transfer_one = mcfqspi_transfer_one; host->transfer_one = mcfqspi_transfer_one;
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
status = devm_spi_register_master(&pdev->dev, master); status = devm_spi_register_controller(&pdev->dev, host);
if (status) { if (status) {
dev_dbg(&pdev->dev, "spi_register_master failed\n"); dev_dbg(&pdev->dev, "devm_spi_register_controller failed\n");
goto fail1; goto fail1;
} }
...@@ -424,7 +424,7 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -424,7 +424,7 @@ static int mcfqspi_probe(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
mcfqspi_cs_teardown(mcfqspi); mcfqspi_cs_teardown(mcfqspi);
fail0: fail0:
spi_master_put(master); spi_controller_put(host);
dev_dbg(&pdev->dev, "Coldfire QSPI probe failed\n"); dev_dbg(&pdev->dev, "Coldfire QSPI probe failed\n");
...@@ -433,8 +433,8 @@ static int mcfqspi_probe(struct platform_device *pdev) ...@@ -433,8 +433,8 @@ static int mcfqspi_probe(struct platform_device *pdev)
static void mcfqspi_remove(struct platform_device *pdev) static void mcfqspi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct mcfqspi *mcfqspi = spi_master_get_devdata(master); struct mcfqspi *mcfqspi = spi_controller_get_devdata(host);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
/* disable the hardware (set the baud rate to 0) */ /* disable the hardware (set the baud rate to 0) */
...@@ -447,11 +447,11 @@ static void mcfqspi_remove(struct platform_device *pdev) ...@@ -447,11 +447,11 @@ static void mcfqspi_remove(struct platform_device *pdev)
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int mcfqspi_suspend(struct device *dev) static int mcfqspi_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mcfqspi *mcfqspi = spi_master_get_devdata(master); struct mcfqspi *mcfqspi = 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;
...@@ -462,20 +462,20 @@ static int mcfqspi_suspend(struct device *dev) ...@@ -462,20 +462,20 @@ static int mcfqspi_suspend(struct device *dev)
static int mcfqspi_resume(struct device *dev) static int mcfqspi_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mcfqspi *mcfqspi = spi_master_get_devdata(master); struct mcfqspi *mcfqspi = spi_controller_get_devdata(host);
clk_enable(mcfqspi->clk); clk_enable(mcfqspi->clk);
return spi_master_resume(master); return spi_controller_resume(host);
} }
#endif #endif
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int mcfqspi_runtime_suspend(struct device *dev) static int mcfqspi_runtime_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mcfqspi *mcfqspi = spi_master_get_devdata(master); struct mcfqspi *mcfqspi = spi_controller_get_devdata(host);
clk_disable(mcfqspi->clk); clk_disable(mcfqspi->clk);
...@@ -484,8 +484,8 @@ static int mcfqspi_runtime_suspend(struct device *dev) ...@@ -484,8 +484,8 @@ static int mcfqspi_runtime_suspend(struct device *dev)
static int mcfqspi_runtime_resume(struct device *dev) static int mcfqspi_runtime_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct mcfqspi *mcfqspi = spi_master_get_devdata(master); struct mcfqspi *mcfqspi = spi_controller_get_devdata(host);
clk_enable(mcfqspi->clk); clk_enable(mcfqspi->clk);
......
...@@ -201,7 +201,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value) ...@@ -201,7 +201,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
u8 chip_sel = spi_get_chipselect(spi, 0); u8 chip_sel = spi_get_chipselect(spi, 0);
u16 spidat1 = CS_DEFAULT; u16 spidat1 = CS_DEFAULT;
dspi = spi_master_get_devdata(spi->master); dspi = spi_controller_get_devdata(spi->controller);
/* program delay transfers if tx_delay is non zero */ /* program delay transfers if tx_delay is non zero */
if (spicfg && spicfg->wdelay) if (spicfg && spicfg->wdelay)
...@@ -271,7 +271,7 @@ static int davinci_spi_setup_transfer(struct spi_device *spi, ...@@ -271,7 +271,7 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
u32 hz = 0, spifmt = 0; u32 hz = 0, spifmt = 0;
int prescale; int prescale;
dspi = spi_master_get_devdata(spi->master); dspi = spi_controller_get_devdata(spi->controller);
spicfg = spi->controller_data; spicfg = spi->controller_data;
if (!spicfg) if (!spicfg)
spicfg = &davinci_spi_default_cfg; spicfg = &davinci_spi_default_cfg;
...@@ -379,7 +379,7 @@ static int davinci_spi_of_setup(struct spi_device *spi) ...@@ -379,7 +379,7 @@ static int davinci_spi_of_setup(struct spi_device *spi)
{ {
struct davinci_spi_config *spicfg = spi->controller_data; struct davinci_spi_config *spicfg = spi->controller_data;
struct device_node *np = spi->dev.of_node; struct device_node *np = spi->dev.of_node;
struct davinci_spi *dspi = spi_master_get_devdata(spi->master); struct davinci_spi *dspi = spi_controller_get_devdata(spi->controller);
u32 prop; u32 prop;
if (spicfg == NULL && np) { if (spicfg == NULL && np) {
...@@ -411,7 +411,7 @@ static int davinci_spi_setup(struct spi_device *spi) ...@@ -411,7 +411,7 @@ static int davinci_spi_setup(struct spi_device *spi)
struct device_node *np = spi->dev.of_node; struct device_node *np = spi->dev.of_node;
bool internal_cs = true; bool internal_cs = true;
dspi = spi_master_get_devdata(spi->master); dspi = spi_controller_get_devdata(spi->controller);
if (!(spi->mode & SPI_NO_CS)) { if (!(spi->mode & SPI_NO_CS)) {
if (np && spi_get_csgpiod(spi, 0)) if (np && spi_get_csgpiod(spi, 0))
...@@ -441,7 +441,7 @@ static void davinci_spi_cleanup(struct spi_device *spi) ...@@ -441,7 +441,7 @@ static void davinci_spi_cleanup(struct spi_device *spi)
kfree(spicfg); kfree(spicfg);
} }
static bool davinci_spi_can_dma(struct spi_master *master, static bool davinci_spi_can_dma(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
...@@ -571,7 +571,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -571,7 +571,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
struct davinci_spi_config *spicfg; struct davinci_spi_config *spicfg;
struct davinci_spi_platform_data *pdata; struct davinci_spi_platform_data *pdata;
dspi = spi_master_get_devdata(spi->master); dspi = spi_controller_get_devdata(spi->controller);
pdata = &dspi->pdata; pdata = &dspi->pdata;
spicfg = (struct davinci_spi_config *)spi->controller_data; spicfg = (struct davinci_spi_config *)spi->controller_data;
if (!spicfg) if (!spicfg)
...@@ -592,7 +592,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -592,7 +592,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
reinit_completion(&dspi->done); reinit_completion(&dspi->done);
if (!davinci_spi_can_dma(spi->master, spi, t)) { if (!davinci_spi_can_dma(spi->controller, spi, t)) {
if (spicfg->io_type != SPI_IO_TYPE_POLL) if (spicfg->io_type != SPI_IO_TYPE_POLL)
set_io_bits(dspi->base + SPIINT, SPIINT_MASKINT); set_io_bits(dspi->base + SPIINT, SPIINT_MASKINT);
/* start the transfer */ /* start the transfer */
...@@ -673,7 +673,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) ...@@ -673,7 +673,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
} }
clear_io_bits(dspi->base + SPIINT, SPIINT_MASKALL); clear_io_bits(dspi->base + SPIINT, SPIINT_MASKALL);
if (davinci_spi_can_dma(spi->master, spi, t)) if (davinci_spi_can_dma(spi->controller, spi, t))
clear_io_bits(dspi->base + SPIINT, SPIINT_DMA_REQ_EN); clear_io_bits(dspi->base + SPIINT, SPIINT_DMA_REQ_EN);
clear_io_bits(dspi->base + SPIGCR1, SPIGCR1_SPIENA_MASK); clear_io_bits(dspi->base + SPIGCR1, SPIGCR1_SPIENA_MASK);
...@@ -855,22 +855,22 @@ static int spi_davinci_get_pdata(struct platform_device *pdev, ...@@ -855,22 +855,22 @@ static int spi_davinci_get_pdata(struct platform_device *pdev,
*/ */
static int davinci_spi_probe(struct platform_device *pdev) static int davinci_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct davinci_spi *dspi; struct davinci_spi *dspi;
struct davinci_spi_platform_data *pdata; struct davinci_spi_platform_data *pdata;
struct resource *r; struct resource *r;
int ret = 0; int ret = 0;
u32 spipc0; u32 spipc0;
master = spi_alloc_master(&pdev->dev, sizeof(struct davinci_spi)); host = spi_alloc_host(&pdev->dev, sizeof(struct davinci_spi));
if (master == NULL) { if (host == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
dspi = spi_master_get_devdata(master); dspi = spi_controller_get_devdata(host);
if (dev_get_platdata(&pdev->dev)) { if (dev_get_platdata(&pdev->dev)) {
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
...@@ -879,7 +879,7 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -879,7 +879,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
/* update dspi pdata with that from the DT */ /* update dspi pdata with that from the DT */
ret = spi_davinci_get_pdata(pdev, dspi); ret = spi_davinci_get_pdata(pdev, dspi);
if (ret < 0) if (ret < 0)
goto free_master; goto free_host;
} }
/* pdata in dspi is now updated and point pdata to that */ /* pdata in dspi is now updated and point pdata to that */
...@@ -891,13 +891,13 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -891,13 +891,13 @@ static int davinci_spi_probe(struct platform_device *pdev)
GFP_KERNEL); GFP_KERNEL);
if (dspi->bytes_per_word == NULL) { if (dspi->bytes_per_word == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto free_master; goto free_host;
} }
dspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r); dspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
if (IS_ERR(dspi->base)) { if (IS_ERR(dspi->base)) {
ret = PTR_ERR(dspi->base); ret = PTR_ERR(dspi->base);
goto free_master; goto free_host;
} }
dspi->pbase = r->start; dspi->pbase = r->start;
...@@ -905,34 +905,34 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -905,34 +905,34 @@ static int davinci_spi_probe(struct platform_device *pdev)
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) if (ret < 0)
goto free_master; goto free_host;
dspi->irq = ret; dspi->irq = ret;
ret = devm_request_threaded_irq(&pdev->dev, dspi->irq, davinci_spi_irq, ret = devm_request_threaded_irq(&pdev->dev, dspi->irq, davinci_spi_irq,
dummy_thread_fn, 0, dev_name(&pdev->dev), dspi); dummy_thread_fn, 0, dev_name(&pdev->dev), dspi);
if (ret) if (ret)
goto free_master; goto free_host;
dspi->bitbang.master = master; dspi->bitbang.master = host;
dspi->clk = devm_clk_get(&pdev->dev, NULL); dspi->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dspi->clk)) { if (IS_ERR(dspi->clk)) {
ret = -ENODEV; ret = -ENODEV;
goto free_master; goto free_host;
} }
ret = clk_prepare_enable(dspi->clk); ret = clk_prepare_enable(dspi->clk);
if (ret) if (ret)
goto free_master; goto free_host;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->num_chipselect = pdata->num_chipselect; host->num_chipselect = pdata->num_chipselect;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16);
master->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_GPIO_SS; host->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_GPIO_SS;
master->setup = davinci_spi_setup; host->setup = davinci_spi_setup;
master->cleanup = davinci_spi_cleanup; host->cleanup = davinci_spi_cleanup;
master->can_dma = davinci_spi_can_dma; host->can_dma = davinci_spi_can_dma;
dspi->bitbang.chipselect = davinci_spi_chipselect; dspi->bitbang.chipselect = davinci_spi_chipselect;
dspi->bitbang.setup_transfer = davinci_spi_setup_transfer; dspi->bitbang.setup_transfer = davinci_spi_setup_transfer;
...@@ -973,7 +973,7 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -973,7 +973,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
iowrite32(CS_DEFAULT, dspi->base + SPIDEF); iowrite32(CS_DEFAULT, dspi->base + SPIDEF);
/* master mode default */ /* host mode default */
set_io_bits(dspi->base + SPIGCR1, SPIGCR1_CLKMOD_MASK); set_io_bits(dspi->base + SPIGCR1, SPIGCR1_CLKMOD_MASK);
set_io_bits(dspi->base + SPIGCR1, SPIGCR1_MASTER_MASK); set_io_bits(dspi->base + SPIGCR1, SPIGCR1_MASTER_MASK);
set_io_bits(dspi->base + SPIGCR1, SPIGCR1_POWERDOWN_MASK); set_io_bits(dspi->base + SPIGCR1, SPIGCR1_POWERDOWN_MASK);
...@@ -993,8 +993,8 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -993,8 +993,8 @@ static int davinci_spi_probe(struct platform_device *pdev)
} }
free_clk: free_clk:
clk_disable_unprepare(dspi->clk); clk_disable_unprepare(dspi->clk);
free_master: free_host:
spi_master_put(master); spi_controller_put(host);
err: err:
return ret; return ret;
} }
...@@ -1011,10 +1011,10 @@ static int davinci_spi_probe(struct platform_device *pdev) ...@@ -1011,10 +1011,10 @@ static int davinci_spi_probe(struct platform_device *pdev)
static void davinci_spi_remove(struct platform_device *pdev) static void davinci_spi_remove(struct platform_device *pdev)
{ {
struct davinci_spi *dspi; struct davinci_spi *dspi;
struct spi_master *master; struct spi_controller *host;
master = platform_get_drvdata(pdev); host = platform_get_drvdata(pdev);
dspi = spi_master_get_devdata(master); dspi = spi_controller_get_devdata(host);
spi_bitbang_stop(&dspi->bitbang); spi_bitbang_stop(&dspi->bitbang);
...@@ -1025,7 +1025,7 @@ static void davinci_spi_remove(struct platform_device *pdev) ...@@ -1025,7 +1025,7 @@ static void davinci_spi_remove(struct platform_device *pdev)
dma_release_channel(dspi->dma_tx); dma_release_channel(dspi->dma_tx);
} }
spi_master_put(master); spi_controller_put(host);
} }
static struct platform_driver davinci_spi_driver = { static struct platform_driver davinci_spi_driver = {
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
struct dln2_spi { struct dln2_spi {
struct platform_device *pdev; struct platform_device *pdev;
struct spi_master *master; struct spi_controller *host;
u8 port; u8 port;
/* /*
...@@ -176,7 +176,7 @@ static int dln2_spi_cs_enable(struct dln2_spi *dln2, u8 cs_mask, bool enable) ...@@ -176,7 +176,7 @@ static int dln2_spi_cs_enable(struct dln2_spi *dln2, u8 cs_mask, bool enable)
static int dln2_spi_cs_enable_all(struct dln2_spi *dln2, bool enable) static int dln2_spi_cs_enable_all(struct dln2_spi *dln2, bool enable)
{ {
u8 cs_mask = GENMASK(dln2->master->num_chipselect - 1, 0); u8 cs_mask = GENMASK(dln2->host->num_chipselect - 1, 0);
return dln2_spi_cs_enable(dln2, cs_mask, enable); return dln2_spi_cs_enable(dln2, cs_mask, enable);
} }
...@@ -589,11 +589,11 @@ static int dln2_spi_rdwr(struct dln2_spi *dln2, const u8 *tx_data, ...@@ -589,11 +589,11 @@ static int dln2_spi_rdwr(struct dln2_spi *dln2, const u8 *tx_data,
return 0; return 0;
} }
static int dln2_spi_prepare_message(struct spi_master *master, static int dln2_spi_prepare_message(struct spi_controller *host,
struct spi_message *message) struct spi_message *message)
{ {
int ret; int ret;
struct dln2_spi *dln2 = spi_master_get_devdata(master); struct dln2_spi *dln2 = spi_controller_get_devdata(host);
struct spi_device *spi = message->spi; struct spi_device *spi = message->spi;
if (dln2->cs != spi_get_chipselect(spi, 0)) { if (dln2->cs != spi_get_chipselect(spi, 0)) {
...@@ -650,11 +650,11 @@ static int dln2_spi_transfer_setup(struct dln2_spi *dln2, u32 speed, ...@@ -650,11 +650,11 @@ static int dln2_spi_transfer_setup(struct dln2_spi *dln2, u32 speed,
return dln2_spi_enable(dln2, true); return dln2_spi_enable(dln2, true);
} }
static int dln2_spi_transfer_one(struct spi_master *master, static int dln2_spi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *xfer) struct spi_transfer *xfer)
{ {
struct dln2_spi *dln2 = spi_master_get_devdata(master); struct dln2_spi *dln2 = spi_controller_get_devdata(host);
int status; int status;
u8 attr = 0; u8 attr = 0;
...@@ -666,7 +666,7 @@ static int dln2_spi_transfer_one(struct spi_master *master, ...@@ -666,7 +666,7 @@ static int dln2_spi_transfer_one(struct spi_master *master,
return status; return status;
} }
if (!xfer->cs_change && !spi_transfer_is_last(master, xfer)) if (!xfer->cs_change && !spi_transfer_is_last(host, xfer))
attr = DLN2_SPI_ATTR_LEAVE_SS_LOW; attr = DLN2_SPI_ATTR_LEAVE_SS_LOW;
status = dln2_spi_rdwr(dln2, xfer->tx_buf, xfer->rx_buf, status = dln2_spi_rdwr(dln2, xfer->tx_buf, xfer->rx_buf,
...@@ -679,29 +679,29 @@ static int dln2_spi_transfer_one(struct spi_master *master, ...@@ -679,29 +679,29 @@ static int dln2_spi_transfer_one(struct spi_master *master,
static int dln2_spi_probe(struct platform_device *pdev) static int dln2_spi_probe(struct platform_device *pdev)
{ {
struct spi_master *master; struct spi_controller *host;
struct dln2_spi *dln2; struct dln2_spi *dln2;
struct dln2_platform_data *pdata = dev_get_platdata(&pdev->dev); struct dln2_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret; int ret;
master = spi_alloc_master(&pdev->dev, sizeof(*dln2)); host = spi_alloc_host(&pdev->dev, sizeof(*dln2));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
device_set_node(&master->dev, dev_fwnode(dev)); device_set_node(&host->dev, dev_fwnode(dev));
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
dln2 = spi_master_get_devdata(master); dln2 = spi_controller_get_devdata(host);
dln2->buf = devm_kmalloc(&pdev->dev, DLN2_SPI_BUF_SIZE, GFP_KERNEL); dln2->buf = devm_kmalloc(&pdev->dev, DLN2_SPI_BUF_SIZE, GFP_KERNEL);
if (!dln2->buf) { if (!dln2->buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit_free_master; goto exit_free_host;
} }
dln2->master = master; dln2->host = host;
dln2->pdev = pdev; dln2->pdev = pdev;
dln2->port = pdata->port; dln2->port = pdata->port;
/* cs/mode can never be 0xff, so the first transfer will set them */ /* cs/mode can never be 0xff, so the first transfer will set them */
...@@ -712,47 +712,47 @@ static int dln2_spi_probe(struct platform_device *pdev) ...@@ -712,47 +712,47 @@ static int dln2_spi_probe(struct platform_device *pdev)
ret = dln2_spi_enable(dln2, false); ret = dln2_spi_enable(dln2, false);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to disable SPI module\n"); dev_err(&pdev->dev, "Failed to disable SPI module\n");
goto exit_free_master; goto exit_free_host;
} }
ret = dln2_spi_get_cs_num(dln2, &master->num_chipselect); ret = dln2_spi_get_cs_num(dln2, &host->num_chipselect);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to get number of CS pins\n"); dev_err(&pdev->dev, "Failed to get number of CS pins\n");
goto exit_free_master; goto exit_free_host;
} }
ret = dln2_spi_get_speed_range(dln2, ret = dln2_spi_get_speed_range(dln2,
&master->min_speed_hz, &host->min_speed_hz,
&master->max_speed_hz); &host->max_speed_hz);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to read bus min/max freqs\n"); dev_err(&pdev->dev, "Failed to read bus min/max freqs\n");
goto exit_free_master; goto exit_free_host;
} }
ret = dln2_spi_get_supported_frame_sizes(dln2, ret = dln2_spi_get_supported_frame_sizes(dln2,
&master->bits_per_word_mask); &host->bits_per_word_mask);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to read supported frame sizes\n"); dev_err(&pdev->dev, "Failed to read supported frame sizes\n");
goto exit_free_master; goto exit_free_host;
} }
ret = dln2_spi_cs_enable_all(dln2, true); ret = dln2_spi_cs_enable_all(dln2, true);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to enable CS pins\n"); dev_err(&pdev->dev, "Failed to enable CS pins\n");
goto exit_free_master; goto exit_free_host;
} }
master->bus_num = -1; host->bus_num = -1;
master->mode_bits = SPI_CPOL | SPI_CPHA; host->mode_bits = SPI_CPOL | SPI_CPHA;
master->prepare_message = dln2_spi_prepare_message; host->prepare_message = dln2_spi_prepare_message;
master->transfer_one = dln2_spi_transfer_one; host->transfer_one = dln2_spi_transfer_one;
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
/* enable SPI module, we're good to go */ /* enable SPI module, we're good to go */
ret = dln2_spi_enable(dln2, true); ret = dln2_spi_enable(dln2, true);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to enable SPI module\n"); dev_err(&pdev->dev, "Failed to enable SPI module\n");
goto exit_free_master; goto exit_free_host;
} }
pm_runtime_set_autosuspend_delay(&pdev->dev, pm_runtime_set_autosuspend_delay(&pdev->dev,
...@@ -761,9 +761,9 @@ static int dln2_spi_probe(struct platform_device *pdev) ...@@ -761,9 +761,9 @@ static int dln2_spi_probe(struct platform_device *pdev)
pm_runtime_set_active(&pdev->dev); pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "Failed to register master\n"); dev_err(&pdev->dev, "Failed to register host\n");
goto exit_register; goto exit_register;
} }
...@@ -775,16 +775,16 @@ static int dln2_spi_probe(struct platform_device *pdev) ...@@ -775,16 +775,16 @@ static int dln2_spi_probe(struct platform_device *pdev)
if (dln2_spi_enable(dln2, false) < 0) if (dln2_spi_enable(dln2, false) < 0)
dev_err(&pdev->dev, "Failed to disable SPI module\n"); dev_err(&pdev->dev, "Failed to disable SPI module\n");
exit_free_master: exit_free_host:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
static void dln2_spi_remove(struct platform_device *pdev) static void dln2_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct dln2_spi *dln2 = spi_master_get_devdata(master); struct dln2_spi *dln2 = spi_controller_get_devdata(host);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
...@@ -796,10 +796,10 @@ static void dln2_spi_remove(struct platform_device *pdev) ...@@ -796,10 +796,10 @@ static void dln2_spi_remove(struct platform_device *pdev)
static int dln2_spi_suspend(struct device *dev) static int dln2_spi_suspend(struct device *dev)
{ {
int ret; int ret;
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct dln2_spi *dln2 = spi_master_get_devdata(master); struct dln2_spi *dln2 = spi_controller_get_devdata(host);
ret = spi_master_suspend(master); ret = spi_controller_suspend(host);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -824,8 +824,8 @@ static int dln2_spi_suspend(struct device *dev) ...@@ -824,8 +824,8 @@ static int dln2_spi_suspend(struct device *dev)
static int dln2_spi_resume(struct device *dev) static int dln2_spi_resume(struct device *dev)
{ {
int ret; int ret;
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct dln2_spi *dln2 = spi_master_get_devdata(master); struct dln2_spi *dln2 = spi_controller_get_devdata(host);
if (!pm_runtime_suspended(dev)) { if (!pm_runtime_suspended(dev)) {
ret = dln2_spi_cs_enable_all(dln2, true); ret = dln2_spi_cs_enable_all(dln2, true);
...@@ -837,23 +837,23 @@ static int dln2_spi_resume(struct device *dev) ...@@ -837,23 +837,23 @@ static int dln2_spi_resume(struct device *dev)
return ret; return ret;
} }
return spi_master_resume(master); return spi_controller_resume(host);
} }
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int dln2_spi_runtime_suspend(struct device *dev) static int dln2_spi_runtime_suspend(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct dln2_spi *dln2 = spi_master_get_devdata(master); struct dln2_spi *dln2 = spi_controller_get_devdata(host);
return dln2_spi_enable(dln2, false); return dln2_spi_enable(dln2, false);
} }
static int dln2_spi_runtime_resume(struct device *dev) static int dln2_spi_runtime_resume(struct device *dev)
{ {
struct spi_master *master = dev_get_drvdata(dev); struct spi_controller *host = dev_get_drvdata(dev);
struct dln2_spi *dln2 = spi_master_get_devdata(master); struct dln2_spi *dln2 = spi_controller_get_devdata(host);
return dln2_spi_enable(dln2, true); return dln2_spi_enable(dln2, true);
} }
...@@ -875,7 +875,7 @@ static struct platform_driver spi_dln2_driver = { ...@@ -875,7 +875,7 @@ static struct platform_driver spi_dln2_driver = {
}; };
module_platform_driver(spi_dln2_driver); module_platform_driver(spi_dln2_driver);
MODULE_DESCRIPTION("Driver for the Diolan DLN2 SPI master interface"); MODULE_DESCRIPTION("Driver for the Diolan DLN2 SPI host interface");
MODULE_AUTHOR("Laurentiu Palcu <laurentiu.palcu@intel.com>"); MODULE_AUTHOR("Laurentiu Palcu <laurentiu.palcu@intel.com>");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:dln2-spi"); MODULE_ALIAS("platform:dln2-spi");
...@@ -61,7 +61,7 @@ static void dw_spi_debugfs_init(struct dw_spi *dws) ...@@ -61,7 +61,7 @@ static void dw_spi_debugfs_init(struct dw_spi *dws)
{ {
char name[32]; char name[32];
snprintf(name, 32, "dw_spi%d", dws->master->bus_num); snprintf(name, 32, "dw_spi%d", dws->host->bus_num);
dws->debugfs = debugfs_create_dir(name, NULL); dws->debugfs = debugfs_create_dir(name, NULL);
dws->regset.regs = dw_spi_dbgfs_regs; dws->regset.regs = dw_spi_dbgfs_regs;
...@@ -183,25 +183,25 @@ int dw_spi_check_status(struct dw_spi *dws, bool raw) ...@@ -183,25 +183,25 @@ int dw_spi_check_status(struct dw_spi *dws, bool raw)
irq_status = dw_readl(dws, DW_SPI_ISR); irq_status = dw_readl(dws, DW_SPI_ISR);
if (irq_status & DW_SPI_INT_RXOI) { if (irq_status & DW_SPI_INT_RXOI) {
dev_err(&dws->master->dev, "RX FIFO overflow detected\n"); dev_err(&dws->host->dev, "RX FIFO overflow detected\n");
ret = -EIO; ret = -EIO;
} }
if (irq_status & DW_SPI_INT_RXUI) { if (irq_status & DW_SPI_INT_RXUI) {
dev_err(&dws->master->dev, "RX FIFO underflow detected\n"); dev_err(&dws->host->dev, "RX FIFO underflow detected\n");
ret = -EIO; ret = -EIO;
} }
if (irq_status & DW_SPI_INT_TXOI) { if (irq_status & DW_SPI_INT_TXOI) {
dev_err(&dws->master->dev, "TX FIFO overflow detected\n"); dev_err(&dws->host->dev, "TX FIFO overflow detected\n");
ret = -EIO; ret = -EIO;
} }
/* Generically handle the erroneous situation */ /* Generically handle the erroneous situation */
if (ret) { if (ret) {
dw_spi_reset_chip(dws); dw_spi_reset_chip(dws);
if (dws->master->cur_msg) if (dws->host->cur_msg)
dws->master->cur_msg->status = ret; dws->host->cur_msg->status = ret;
} }
return ret; return ret;
...@@ -213,7 +213,7 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws) ...@@ -213,7 +213,7 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
u16 irq_status = dw_readl(dws, DW_SPI_ISR); u16 irq_status = dw_readl(dws, DW_SPI_ISR);
if (dw_spi_check_status(dws, false)) { if (dw_spi_check_status(dws, false)) {
spi_finalize_current_transfer(dws->master); spi_finalize_current_transfer(dws->host);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -227,7 +227,7 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws) ...@@ -227,7 +227,7 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
dw_reader(dws); dw_reader(dws);
if (!dws->rx_len) { if (!dws->rx_len) {
dw_spi_mask_intr(dws, 0xff); dw_spi_mask_intr(dws, 0xff);
spi_finalize_current_transfer(dws->master); spi_finalize_current_transfer(dws->host);
} else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) { } else if (dws->rx_len <= dw_readl(dws, DW_SPI_RXFTLR)) {
dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1); dw_writel(dws, DW_SPI_RXFTLR, dws->rx_len - 1);
} }
...@@ -248,14 +248,14 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws) ...@@ -248,14 +248,14 @@ static irqreturn_t dw_spi_transfer_handler(struct dw_spi *dws)
static irqreturn_t dw_spi_irq(int irq, void *dev_id) static irqreturn_t dw_spi_irq(int irq, void *dev_id)
{ {
struct spi_controller *master = dev_id; struct spi_controller *host = dev_id;
struct dw_spi *dws = spi_controller_get_devdata(master); struct dw_spi *dws = spi_controller_get_devdata(host);
u16 irq_status = dw_readl(dws, DW_SPI_ISR) & DW_SPI_INT_MASK; u16 irq_status = dw_readl(dws, DW_SPI_ISR) & DW_SPI_INT_MASK;
if (!irq_status) if (!irq_status)
return IRQ_NONE; return IRQ_NONE;
if (!master->cur_msg) { if (!host->cur_msg) {
dw_spi_mask_intr(dws, 0xff); dw_spi_mask_intr(dws, 0xff);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -408,11 +408,11 @@ static int dw_spi_poll_transfer(struct dw_spi *dws, ...@@ -408,11 +408,11 @@ static int dw_spi_poll_transfer(struct dw_spi *dws,
return 0; return 0;
} }
static int dw_spi_transfer_one(struct spi_controller *master, static int dw_spi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_device *spi,
struct spi_transfer *transfer) struct spi_transfer *transfer)
{ {
struct dw_spi *dws = spi_controller_get_devdata(master); struct dw_spi *dws = spi_controller_get_devdata(host);
struct dw_spi_cfg cfg = { struct dw_spi_cfg cfg = {
.tmode = DW_SPI_CTRLR0_TMOD_TR, .tmode = DW_SPI_CTRLR0_TMOD_TR,
.dfs = transfer->bits_per_word, .dfs = transfer->bits_per_word,
...@@ -440,8 +440,8 @@ static int dw_spi_transfer_one(struct spi_controller *master, ...@@ -440,8 +440,8 @@ static int dw_spi_transfer_one(struct spi_controller *master,
transfer->effective_speed_hz = dws->current_freq; transfer->effective_speed_hz = dws->current_freq;
/* Check if current transfer is a DMA transaction */ /* Check if current transfer is a DMA transaction */
if (master->can_dma && master->can_dma(master, spi, transfer)) if (host->can_dma && host->can_dma(host, spi, transfer))
dws->dma_mapped = master->cur_msg_mapped; dws->dma_mapped = host->cur_msg_mapped;
/* For poll mode just disable all interrupts */ /* For poll mode just disable all interrupts */
dw_spi_mask_intr(dws, 0xff); dw_spi_mask_intr(dws, 0xff);
...@@ -464,10 +464,10 @@ static int dw_spi_transfer_one(struct spi_controller *master, ...@@ -464,10 +464,10 @@ static int dw_spi_transfer_one(struct spi_controller *master,
return 1; return 1;
} }
static void dw_spi_handle_err(struct spi_controller *master, static void dw_spi_handle_err(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct dw_spi *dws = spi_controller_get_devdata(master); struct dw_spi *dws = spi_controller_get_devdata(host);
if (dws->dma_mapped) if (dws->dma_mapped)
dws->dma_ops->dma_stop(dws); dws->dma_ops->dma_stop(dws);
...@@ -576,7 +576,7 @@ static int dw_spi_write_then_read(struct dw_spi *dws, struct spi_device *spi) ...@@ -576,7 +576,7 @@ static int dw_spi_write_then_read(struct dw_spi *dws, struct spi_device *spi)
while (len) { while (len) {
entries = readl_relaxed(dws->regs + DW_SPI_TXFLR); entries = readl_relaxed(dws->regs + DW_SPI_TXFLR);
if (!entries) { if (!entries) {
dev_err(&dws->master->dev, "CS de-assertion on Tx\n"); dev_err(&dws->host->dev, "CS de-assertion on Tx\n");
return -EIO; return -EIO;
} }
room = min(dws->fifo_len - entries, len); room = min(dws->fifo_len - entries, len);
...@@ -596,7 +596,7 @@ static int dw_spi_write_then_read(struct dw_spi *dws, struct spi_device *spi) ...@@ -596,7 +596,7 @@ static int dw_spi_write_then_read(struct dw_spi *dws, struct spi_device *spi)
if (!entries) { if (!entries) {
sts = readl_relaxed(dws->regs + DW_SPI_RISR); sts = readl_relaxed(dws->regs + DW_SPI_RISR);
if (sts & DW_SPI_INT_RXOI) { if (sts & DW_SPI_INT_RXOI) {
dev_err(&dws->master->dev, "FIFO overflow on Rx\n"); dev_err(&dws->host->dev, "FIFO overflow on Rx\n");
return -EIO; return -EIO;
} }
continue; continue;
...@@ -637,7 +637,7 @@ static int dw_spi_wait_mem_op_done(struct dw_spi *dws) ...@@ -637,7 +637,7 @@ static int dw_spi_wait_mem_op_done(struct dw_spi *dws)
spi_delay_exec(&delay, NULL); spi_delay_exec(&delay, NULL);
if (retry < 0) { if (retry < 0) {
dev_err(&dws->master->dev, "Mem op hanged up\n"); dev_err(&dws->host->dev, "Mem op hanged up\n");
return -EIO; return -EIO;
} }
...@@ -884,56 +884,56 @@ static void dw_spi_hw_init(struct device *dev, struct dw_spi *dws) ...@@ -884,56 +884,56 @@ static void dw_spi_hw_init(struct device *dev, struct dw_spi *dws)
int dw_spi_add_host(struct device *dev, struct dw_spi *dws) int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
{ {
struct spi_controller *master; struct spi_controller *host;
int ret; int ret;
if (!dws) if (!dws)
return -EINVAL; return -EINVAL;
master = spi_alloc_master(dev, 0); host = spi_alloc_host(dev, 0);
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
device_set_node(&master->dev, dev_fwnode(dev)); device_set_node(&host->dev, dev_fwnode(dev));
dws->master = master; dws->host = host;
dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR); dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR);
spi_controller_set_devdata(master, dws); spi_controller_set_devdata(host, dws);
/* Basic HW init */ /* Basic HW init */
dw_spi_hw_init(dev, dws); dw_spi_hw_init(dev, dws);
ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dev_name(dev), ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dev_name(dev),
master); host);
if (ret < 0 && ret != -ENOTCONN) { if (ret < 0 && ret != -ENOTCONN) {
dev_err(dev, "can not get IRQ\n"); dev_err(dev, "can not get IRQ\n");
goto err_free_master; goto err_free_host;
} }
dw_spi_init_mem_ops(dws); dw_spi_init_mem_ops(dws);
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP;
if (dws->caps & DW_SPI_CAP_DFS32) if (dws->caps & DW_SPI_CAP_DFS32)
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
else else
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
master->bus_num = dws->bus_num; host->bus_num = dws->bus_num;
master->num_chipselect = dws->num_cs; host->num_chipselect = dws->num_cs;
master->setup = dw_spi_setup; host->setup = dw_spi_setup;
master->cleanup = dw_spi_cleanup; host->cleanup = dw_spi_cleanup;
if (dws->set_cs) if (dws->set_cs)
master->set_cs = dws->set_cs; host->set_cs = dws->set_cs;
else else
master->set_cs = dw_spi_set_cs; host->set_cs = dw_spi_set_cs;
master->transfer_one = dw_spi_transfer_one; host->transfer_one = dw_spi_transfer_one;
master->handle_err = dw_spi_handle_err; host->handle_err = dw_spi_handle_err;
if (dws->mem_ops.exec_op) if (dws->mem_ops.exec_op)
master->mem_ops = &dws->mem_ops; host->mem_ops = &dws->mem_ops;
master->max_speed_hz = dws->max_freq; host->max_speed_hz = dws->max_freq;
master->flags = SPI_CONTROLLER_GPIO_SS; host->flags = SPI_CONTROLLER_GPIO_SS;
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
/* Get default rx sample delay */ /* Get default rx sample delay */
device_property_read_u32(dev, "rx-sample-delay-ns", device_property_read_u32(dev, "rx-sample-delay-ns",
...@@ -946,14 +946,14 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) ...@@ -946,14 +946,14 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
} else if (ret) { } else if (ret) {
dev_warn(dev, "DMA init failed\n"); dev_warn(dev, "DMA init failed\n");
} else { } else {
master->can_dma = dws->dma_ops->can_dma; host->can_dma = dws->dma_ops->can_dma;
master->flags |= SPI_CONTROLLER_MUST_TX; host->flags |= SPI_CONTROLLER_MUST_TX;
} }
} }
ret = spi_register_controller(master); ret = spi_register_controller(host);
if (ret) { if (ret) {
dev_err_probe(dev, ret, "problem registering spi master\n"); dev_err_probe(dev, ret, "problem registering spi host\n");
goto err_dma_exit; goto err_dma_exit;
} }
...@@ -965,9 +965,9 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) ...@@ -965,9 +965,9 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
dws->dma_ops->dma_exit(dws); dws->dma_ops->dma_exit(dws);
dw_spi_enable_chip(dws, 0); dw_spi_enable_chip(dws, 0);
err_free_irq: err_free_irq:
free_irq(dws->irq, master); free_irq(dws->irq, host);
err_free_master: err_free_host:
spi_controller_put(master); spi_controller_put(host);
return ret; return ret;
} }
EXPORT_SYMBOL_NS_GPL(dw_spi_add_host, SPI_DW_CORE); EXPORT_SYMBOL_NS_GPL(dw_spi_add_host, SPI_DW_CORE);
...@@ -976,14 +976,14 @@ void dw_spi_remove_host(struct dw_spi *dws) ...@@ -976,14 +976,14 @@ void dw_spi_remove_host(struct dw_spi *dws)
{ {
dw_spi_debugfs_remove(dws); dw_spi_debugfs_remove(dws);
spi_unregister_controller(dws->master); spi_unregister_controller(dws->host);
if (dws->dma_ops && dws->dma_ops->dma_exit) if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws); dws->dma_ops->dma_exit(dws);
dw_spi_shutdown_chip(dws); dw_spi_shutdown_chip(dws);
free_irq(dws->irq, dws->master); free_irq(dws->irq, dws->host);
} }
EXPORT_SYMBOL_NS_GPL(dw_spi_remove_host, SPI_DW_CORE); EXPORT_SYMBOL_NS_GPL(dw_spi_remove_host, SPI_DW_CORE);
...@@ -991,7 +991,7 @@ int dw_spi_suspend_host(struct dw_spi *dws) ...@@ -991,7 +991,7 @@ int dw_spi_suspend_host(struct dw_spi *dws)
{ {
int ret; int ret;
ret = spi_controller_suspend(dws->master); ret = spi_controller_suspend(dws->host);
if (ret) if (ret)
return ret; return ret;
...@@ -1002,8 +1002,8 @@ EXPORT_SYMBOL_NS_GPL(dw_spi_suspend_host, SPI_DW_CORE); ...@@ -1002,8 +1002,8 @@ EXPORT_SYMBOL_NS_GPL(dw_spi_suspend_host, SPI_DW_CORE);
int dw_spi_resume_host(struct dw_spi *dws) int dw_spi_resume_host(struct dw_spi *dws)
{ {
dw_spi_hw_init(&dws->master->dev, dws); dw_spi_hw_init(&dws->host->dev, dws);
return spi_controller_resume(dws->master); return spi_controller_resume(dws->host);
} }
EXPORT_SYMBOL_NS_GPL(dw_spi_resume_host, SPI_DW_CORE); EXPORT_SYMBOL_NS_GPL(dw_spi_resume_host, SPI_DW_CORE);
......
...@@ -139,8 +139,8 @@ static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws) ...@@ -139,8 +139,8 @@ static int dw_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
if (!dws->txchan) if (!dws->txchan)
goto free_rxchan; goto free_rxchan;
dws->master->dma_rx = dws->rxchan; dws->host->dma_rx = dws->rxchan;
dws->master->dma_tx = dws->txchan; dws->host->dma_tx = dws->txchan;
init_completion(&dws->dma_completion); init_completion(&dws->dma_completion);
...@@ -183,8 +183,8 @@ static int dw_spi_dma_init_generic(struct device *dev, struct dw_spi *dws) ...@@ -183,8 +183,8 @@ static int dw_spi_dma_init_generic(struct device *dev, struct dw_spi *dws)
goto free_rxchan; goto free_rxchan;
} }
dws->master->dma_rx = dws->rxchan; dws->host->dma_rx = dws->rxchan;
dws->master->dma_tx = dws->txchan; dws->host->dma_tx = dws->txchan;
init_completion(&dws->dma_completion); init_completion(&dws->dma_completion);
...@@ -242,10 +242,10 @@ static enum dma_slave_buswidth dw_spi_dma_convert_width(u8 n_bytes) ...@@ -242,10 +242,10 @@ static enum dma_slave_buswidth dw_spi_dma_convert_width(u8 n_bytes)
} }
} }
static bool dw_spi_can_dma(struct spi_controller *master, static bool dw_spi_can_dma(struct spi_controller *host,
struct spi_device *spi, struct spi_transfer *xfer) struct spi_device *spi, struct spi_transfer *xfer)
{ {
struct dw_spi *dws = spi_controller_get_devdata(master); struct dw_spi *dws = spi_controller_get_devdata(host);
enum dma_slave_buswidth dma_bus_width; enum dma_slave_buswidth dma_bus_width;
if (xfer->len <= dws->fifo_len) if (xfer->len <= dws->fifo_len)
...@@ -271,7 +271,7 @@ static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed) ...@@ -271,7 +271,7 @@ static int dw_spi_dma_wait(struct dw_spi *dws, unsigned int len, u32 speed)
msecs_to_jiffies(ms)); msecs_to_jiffies(ms));
if (ms == 0) { if (ms == 0) {
dev_err(&dws->master->cur_msg->spi->dev, dev_err(&dws->host->cur_msg->spi->dev,
"DMA transaction timed out\n"); "DMA transaction timed out\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -299,7 +299,7 @@ static int dw_spi_dma_wait_tx_done(struct dw_spi *dws, ...@@ -299,7 +299,7 @@ static int dw_spi_dma_wait_tx_done(struct dw_spi *dws,
spi_delay_exec(&delay, xfer); spi_delay_exec(&delay, xfer);
if (retry < 0) { if (retry < 0) {
dev_err(&dws->master->dev, "Tx hanged up\n"); dev_err(&dws->host->dev, "Tx hanged up\n");
return -EIO; return -EIO;
} }
...@@ -400,7 +400,7 @@ static int dw_spi_dma_wait_rx_done(struct dw_spi *dws) ...@@ -400,7 +400,7 @@ static int dw_spi_dma_wait_rx_done(struct dw_spi *dws)
spi_delay_exec(&delay, NULL); spi_delay_exec(&delay, NULL);
if (retry < 0) { if (retry < 0) {
dev_err(&dws->master->dev, "Rx hanged up\n"); dev_err(&dws->host->dev, "Rx hanged up\n");
return -EIO; return -EIO;
} }
...@@ -656,13 +656,13 @@ static int dw_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer) ...@@ -656,13 +656,13 @@ static int dw_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer)
if (ret) if (ret)
return ret; return ret;
if (dws->master->cur_msg->status == -EINPROGRESS) { if (dws->host->cur_msg->status == -EINPROGRESS) {
ret = dw_spi_dma_wait_tx_done(dws, xfer); ret = dw_spi_dma_wait_tx_done(dws, xfer);
if (ret) if (ret)
return ret; return ret;
} }
if (xfer->rx_buf && dws->master->cur_msg->status == -EINPROGRESS) if (xfer->rx_buf && dws->host->cur_msg->status == -EINPROGRESS)
ret = dw_spi_dma_wait_rx_done(dws); ret = dw_spi_dma_wait_rx_done(dws);
return ret; return ret;
......
...@@ -68,7 +68,7 @@ struct dw_spi_mscc { ...@@ -68,7 +68,7 @@ struct dw_spi_mscc {
((((val) << 1) | BIT(0)) << ELBA_SPICS_OFFSET(cs)) ((((val) << 1) | BIT(0)) << ELBA_SPICS_OFFSET(cs))
/* /*
* The Designware SPI controller (referred to as master in the documentation) * The Designware SPI controller (referred to as host in the documentation)
* automatically deasserts chip select when the tx fifo is empty. The chip * automatically deasserts chip select when the tx fifo is empty. The chip
* selects then needs to be either driven as GPIOs or, for the first 4 using * selects then needs to be either driven as GPIOs or, for the first 4 using
* the SPI boot controller registers. the final chip select is an OR gate * the SPI boot controller registers. the final chip select is an OR gate
...@@ -76,7 +76,7 @@ struct dw_spi_mscc { ...@@ -76,7 +76,7 @@ struct dw_spi_mscc {
*/ */
static void dw_spi_mscc_set_cs(struct spi_device *spi, bool enable) static void dw_spi_mscc_set_cs(struct spi_device *spi, bool enable)
{ {
struct dw_spi *dws = spi_master_get_devdata(spi->master); struct dw_spi *dws = spi_controller_get_devdata(spi->controller);
struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws); struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws);
struct dw_spi_mscc *dwsmscc = dwsmmio->priv; struct dw_spi_mscc *dwsmscc = dwsmmio->priv;
u32 cs = spi_get_chipselect(spi, 0); u32 cs = spi_get_chipselect(spi, 0);
...@@ -142,14 +142,14 @@ static int dw_spi_mscc_jaguar2_init(struct platform_device *pdev, ...@@ -142,14 +142,14 @@ static int dw_spi_mscc_jaguar2_init(struct platform_device *pdev,
} }
/* /*
* The Designware SPI controller (referred to as master in the * The Designware SPI controller (referred to as host in the
* documentation) automatically deasserts chip select when the tx fifo * documentation) automatically deasserts chip select when the tx fifo
* is empty. The chip selects then needs to be driven by a CS override * is empty. The chip selects then needs to be driven by a CS override
* register. enable is an active low signal. * register. enable is an active low signal.
*/ */
static void dw_spi_sparx5_set_cs(struct spi_device *spi, bool enable) static void dw_spi_sparx5_set_cs(struct spi_device *spi, bool enable)
{ {
struct dw_spi *dws = spi_master_get_devdata(spi->master); struct dw_spi *dws = spi_controller_get_devdata(spi->controller);
struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws); struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws);
struct dw_spi_mscc *dwsmscc = dwsmmio->priv; struct dw_spi_mscc *dwsmscc = dwsmmio->priv;
u8 cs = spi_get_chipselect(spi, 0); u8 cs = spi_get_chipselect(spi, 0);
...@@ -277,7 +277,7 @@ static void dw_spi_elba_override_cs(struct regmap *syscon, int cs, int enable) ...@@ -277,7 +277,7 @@ static void dw_spi_elba_override_cs(struct regmap *syscon, int cs, int enable)
static void dw_spi_elba_set_cs(struct spi_device *spi, bool enable) static void dw_spi_elba_set_cs(struct spi_device *spi, bool enable)
{ {
struct dw_spi *dws = spi_master_get_devdata(spi->master); struct dw_spi *dws = spi_controller_get_devdata(spi->controller);
struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws); struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws);
struct regmap *syscon = dwsmmio->priv; struct regmap *syscon = dwsmmio->priv;
u8 cs; u8 cs;
......
...@@ -142,14 +142,14 @@ struct dw_spi_dma_ops { ...@@ -142,14 +142,14 @@ struct dw_spi_dma_ops {
int (*dma_init)(struct device *dev, struct dw_spi *dws); int (*dma_init)(struct device *dev, struct dw_spi *dws);
void (*dma_exit)(struct dw_spi *dws); void (*dma_exit)(struct dw_spi *dws);
int (*dma_setup)(struct dw_spi *dws, struct spi_transfer *xfer); int (*dma_setup)(struct dw_spi *dws, struct spi_transfer *xfer);
bool (*can_dma)(struct spi_controller *master, struct spi_device *spi, bool (*can_dma)(struct spi_controller *host, struct spi_device *spi,
struct spi_transfer *xfer); struct spi_transfer *xfer);
int (*dma_transfer)(struct dw_spi *dws, struct spi_transfer *xfer); int (*dma_transfer)(struct dw_spi *dws, struct spi_transfer *xfer);
void (*dma_stop)(struct dw_spi *dws); void (*dma_stop)(struct dw_spi *dws);
}; };
struct dw_spi { struct dw_spi {
struct spi_controller *master; struct spi_controller *host;
u32 ip; /* Synopsys DW SSI IP-core ID */ u32 ip; /* Synopsys DW SSI IP-core ID */
u32 ver; /* Synopsys component version */ u32 ver; /* Synopsys component version */
......
...@@ -164,10 +164,10 @@ static int hisi_spi_debugfs_init(struct hisi_spi *hs) ...@@ -164,10 +164,10 @@ static int hisi_spi_debugfs_init(struct hisi_spi *hs)
{ {
char name[32]; char name[32];
struct spi_controller *master; struct spi_controller *host;
master = container_of(hs->dev, struct spi_controller, dev); host = container_of(hs->dev, struct spi_controller, dev);
snprintf(name, 32, "hisi_spi%d", master->bus_num); snprintf(name, 32, "hisi_spi%d", host->bus_num);
hs->debugfs = debugfs_create_dir(name, NULL); hs->debugfs = debugfs_create_dir(name, NULL);
if (IS_ERR(hs->debugfs)) if (IS_ERR(hs->debugfs))
return -ENOMEM; return -ENOMEM;
...@@ -291,18 +291,18 @@ static void __hisi_calc_div_reg(struct hisi_chip_data *chip) ...@@ -291,18 +291,18 @@ static void __hisi_calc_div_reg(struct hisi_chip_data *chip)
chip->div_post = (chip->clk_div / chip->div_pre) - 1; chip->div_post = (chip->clk_div / chip->div_pre) - 1;
} }
static u32 hisi_calc_effective_speed(struct spi_controller *master, static u32 hisi_calc_effective_speed(struct spi_controller *host,
struct hisi_chip_data *chip, u32 speed_hz) struct hisi_chip_data *chip, u32 speed_hz)
{ {
u32 effective_speed; u32 effective_speed;
/* Note clock divider doesn't support odd numbers */ /* Note clock divider doesn't support odd numbers */
chip->clk_div = DIV_ROUND_UP(master->max_speed_hz, speed_hz) + 1; chip->clk_div = DIV_ROUND_UP(host->max_speed_hz, speed_hz) + 1;
chip->clk_div &= 0xfffe; chip->clk_div &= 0xfffe;
if (chip->clk_div > CLK_DIV_MAX) if (chip->clk_div > CLK_DIV_MAX)
chip->clk_div = CLK_DIV_MAX; chip->clk_div = CLK_DIV_MAX;
effective_speed = master->max_speed_hz / chip->clk_div; effective_speed = host->max_speed_hz / chip->clk_div;
if (chip->speed_hz != effective_speed) { if (chip->speed_hz != effective_speed) {
__hisi_calc_div_reg(chip); __hisi_calc_div_reg(chip);
chip->speed_hz = effective_speed; chip->speed_hz = effective_speed;
...@@ -336,20 +336,20 @@ static void hisi_spi_hw_init(struct hisi_spi *hs) ...@@ -336,20 +336,20 @@ static void hisi_spi_hw_init(struct hisi_spi *hs)
static irqreturn_t hisi_spi_irq(int irq, void *dev_id) static irqreturn_t hisi_spi_irq(int irq, void *dev_id)
{ {
struct spi_controller *master = dev_id; struct spi_controller *host = dev_id;
struct hisi_spi *hs = spi_controller_get_devdata(master); struct hisi_spi *hs = spi_controller_get_devdata(host);
u32 irq_status = readl(hs->regs + HISI_SPI_ISR) & ISR_MASK; u32 irq_status = readl(hs->regs + HISI_SPI_ISR) & ISR_MASK;
if (!irq_status) if (!irq_status)
return IRQ_NONE; return IRQ_NONE;
if (!master->cur_msg) if (!host->cur_msg)
return IRQ_HANDLED; return IRQ_HANDLED;
/* Error handling */ /* Error handling */
if (irq_status & ISR_RXOF) { if (irq_status & ISR_RXOF) {
dev_err(hs->dev, "interrupt_transfer: fifo overflow\n"); dev_err(hs->dev, "interrupt_transfer: fifo overflow\n");
master->cur_msg->status = -EIO; host->cur_msg->status = -EIO;
goto finalize_transfer; goto finalize_transfer;
} }
...@@ -369,20 +369,20 @@ static irqreturn_t hisi_spi_irq(int irq, void *dev_id) ...@@ -369,20 +369,20 @@ static irqreturn_t hisi_spi_irq(int irq, void *dev_id)
finalize_transfer: finalize_transfer:
hisi_spi_disable(hs); hisi_spi_disable(hs);
spi_finalize_current_transfer(master); spi_finalize_current_transfer(host);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int hisi_spi_transfer_one(struct spi_controller *master, static int hisi_spi_transfer_one(struct spi_controller *host,
struct spi_device *spi, struct spi_transfer *transfer) struct spi_device *spi, struct spi_transfer *transfer)
{ {
struct hisi_spi *hs = spi_controller_get_devdata(master); struct hisi_spi *hs = spi_controller_get_devdata(host);
struct hisi_chip_data *chip = spi_get_ctldata(spi); struct hisi_chip_data *chip = spi_get_ctldata(spi);
u32 cr = chip->cr; u32 cr = chip->cr;
/* Update per transfer options for speed and bpw */ /* Update per transfer options for speed and bpw */
transfer->effective_speed_hz = transfer->effective_speed_hz =
hisi_calc_effective_speed(master, chip, transfer->speed_hz); hisi_calc_effective_speed(host, chip, transfer->speed_hz);
cr |= FIELD_PREP(CR_DIV_PRE_MASK, chip->div_pre); cr |= FIELD_PREP(CR_DIV_PRE_MASK, chip->div_pre);
cr |= FIELD_PREP(CR_DIV_POST_MASK, chip->div_post); cr |= FIELD_PREP(CR_DIV_POST_MASK, chip->div_post);
cr |= FIELD_PREP(CR_BPW_MASK, transfer->bits_per_word - 1); cr |= FIELD_PREP(CR_BPW_MASK, transfer->bits_per_word - 1);
...@@ -409,10 +409,10 @@ static int hisi_spi_transfer_one(struct spi_controller *master, ...@@ -409,10 +409,10 @@ static int hisi_spi_transfer_one(struct spi_controller *master,
return 1; return 1;
} }
static void hisi_spi_handle_err(struct spi_controller *master, static void hisi_spi_handle_err(struct spi_controller *host,
struct spi_message *msg) struct spi_message *msg)
{ {
struct hisi_spi *hs = spi_controller_get_devdata(master); struct hisi_spi *hs = spi_controller_get_devdata(host);
hisi_spi_disable(hs); hisi_spi_disable(hs);
...@@ -452,7 +452,7 @@ static void hisi_spi_cleanup(struct spi_device *spi) ...@@ -452,7 +452,7 @@ static void hisi_spi_cleanup(struct spi_device *spi)
static int hisi_spi_probe(struct platform_device *pdev) static int hisi_spi_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_controller *master; struct spi_controller *host;
struct hisi_spi *hs; struct hisi_spi *hs;
int ret, irq; int ret, irq;
...@@ -460,13 +460,13 @@ static int hisi_spi_probe(struct platform_device *pdev) ...@@ -460,13 +460,13 @@ static int hisi_spi_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
master = devm_spi_alloc_master(dev, sizeof(*hs)); host = devm_spi_alloc_host(dev, sizeof(*hs));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, host);
hs = spi_controller_get_devdata(master); hs = spi_controller_get_devdata(host);
hs->dev = dev; hs->dev = dev;
hs->irq = irq; hs->irq = irq;
...@@ -474,9 +474,9 @@ static int hisi_spi_probe(struct platform_device *pdev) ...@@ -474,9 +474,9 @@ static int hisi_spi_probe(struct platform_device *pdev)
if (IS_ERR(hs->regs)) if (IS_ERR(hs->regs))
return PTR_ERR(hs->regs); return PTR_ERR(hs->regs);
/* Specify maximum SPI clocking speed (master only) by firmware */ /* Specify maximum SPI clocking speed (host only) by firmware */
ret = device_property_read_u32(dev, "spi-max-frequency", ret = device_property_read_u32(dev, "spi-max-frequency",
&master->max_speed_hz); &host->max_speed_hz);
if (ret) { if (ret) {
dev_err(dev, "failed to get max SPI clocking speed, ret=%d\n", dev_err(dev, "failed to get max SPI clocking speed, ret=%d\n",
ret); ret);
...@@ -484,32 +484,32 @@ static int hisi_spi_probe(struct platform_device *pdev) ...@@ -484,32 +484,32 @@ static int hisi_spi_probe(struct platform_device *pdev)
} }
ret = device_property_read_u16(dev, "num-cs", ret = device_property_read_u16(dev, "num-cs",
&master->num_chipselect); &host->num_chipselect);
if (ret) if (ret)
master->num_chipselect = DEFAULT_NUM_CS; host->num_chipselect = DEFAULT_NUM_CS;
master->use_gpio_descriptors = true; host->use_gpio_descriptors = true;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
master->bus_num = pdev->id; host->bus_num = pdev->id;
master->setup = hisi_spi_setup; host->setup = hisi_spi_setup;
master->cleanup = hisi_spi_cleanup; host->cleanup = hisi_spi_cleanup;
master->transfer_one = hisi_spi_transfer_one; host->transfer_one = hisi_spi_transfer_one;
master->handle_err = hisi_spi_handle_err; host->handle_err = hisi_spi_handle_err;
master->dev.fwnode = dev->fwnode; host->dev.fwnode = dev->fwnode;
hisi_spi_hw_init(hs); hisi_spi_hw_init(hs);
ret = devm_request_irq(dev, hs->irq, hisi_spi_irq, 0, dev_name(dev), ret = devm_request_irq(dev, hs->irq, hisi_spi_irq, 0, dev_name(dev),
master); host);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to get IRQ=%d, ret=%d\n", hs->irq, ret); dev_err(dev, "failed to get IRQ=%d, ret=%d\n", hs->irq, ret);
return ret; return ret;
} }
ret = spi_register_controller(master); ret = spi_register_controller(host);
if (ret) { if (ret) {
dev_err(dev, "failed to register spi master, ret=%d\n", ret); dev_err(dev, "failed to register spi host, ret=%d\n", ret);
return ret; return ret;
} }
...@@ -518,18 +518,18 @@ static int hisi_spi_probe(struct platform_device *pdev) ...@@ -518,18 +518,18 @@ static int hisi_spi_probe(struct platform_device *pdev)
dev_info(dev, "hw version:0x%x max-freq:%u kHz\n", dev_info(dev, "hw version:0x%x max-freq:%u kHz\n",
readl(hs->regs + HISI_SPI_VERSION), readl(hs->regs + HISI_SPI_VERSION),
master->max_speed_hz / 1000); host->max_speed_hz / 1000);
return 0; return 0;
} }
static void hisi_spi_remove(struct platform_device *pdev) static void hisi_spi_remove(struct platform_device *pdev)
{ {
struct spi_controller *master = platform_get_drvdata(pdev); struct spi_controller *host = platform_get_drvdata(pdev);
struct hisi_spi *hs = spi_controller_get_devdata(master); struct hisi_spi *hs = spi_controller_get_devdata(host);
debugfs_remove_recursive(hs->debugfs); debugfs_remove_recursive(hs->debugfs);
spi_unregister_controller(master); spi_unregister_controller(host);
} }
static const struct acpi_device_id hisi_spi_acpi_match[] = { static const struct acpi_device_id hisi_spi_acpi_match[] = {
......
...@@ -287,7 +287,7 @@ static ssize_t npcm_fiu_direct_read(struct spi_mem_dirmap_desc *desc, ...@@ -287,7 +287,7 @@ static ssize_t npcm_fiu_direct_read(struct spi_mem_dirmap_desc *desc,
u64 offs, size_t len, void *buf) u64 offs, size_t len, void *buf)
{ {
struct npcm_fiu_spi *fiu = struct npcm_fiu_spi *fiu =
spi_controller_get_devdata(desc->mem->spi->master); spi_controller_get_devdata(desc->mem->spi->controller);
struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)]; struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)];
void __iomem *src = (void __iomem *)(chip->flash_region_mapped_ptr + void __iomem *src = (void __iomem *)(chip->flash_region_mapped_ptr +
offs); offs);
...@@ -314,7 +314,7 @@ static ssize_t npcm_fiu_direct_write(struct spi_mem_dirmap_desc *desc, ...@@ -314,7 +314,7 @@ static ssize_t npcm_fiu_direct_write(struct spi_mem_dirmap_desc *desc,
u64 offs, size_t len, const void *buf) u64 offs, size_t len, const void *buf)
{ {
struct npcm_fiu_spi *fiu = struct npcm_fiu_spi *fiu =
spi_controller_get_devdata(desc->mem->spi->master); spi_controller_get_devdata(desc->mem->spi->controller);
struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)]; struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)];
void __iomem *dst = (void __iomem *)(chip->flash_region_mapped_ptr + void __iomem *dst = (void __iomem *)(chip->flash_region_mapped_ptr +
offs); offs);
...@@ -335,7 +335,7 @@ static int npcm_fiu_uma_read(struct spi_mem *mem, ...@@ -335,7 +335,7 @@ static int npcm_fiu_uma_read(struct spi_mem *mem,
bool is_address_size, u8 *data, u32 data_size) bool is_address_size, u8 *data, u32 data_size)
{ {
struct npcm_fiu_spi *fiu = struct npcm_fiu_spi *fiu =
spi_controller_get_devdata(mem->spi->master); spi_controller_get_devdata(mem->spi->controller);
u32 uma_cfg = BIT(10); u32 uma_cfg = BIT(10);
u32 data_reg[4]; u32 data_reg[4];
int ret; int ret;
...@@ -390,7 +390,7 @@ static int npcm_fiu_uma_write(struct spi_mem *mem, ...@@ -390,7 +390,7 @@ static int npcm_fiu_uma_write(struct spi_mem *mem,
bool is_address_size, u8 *data, u32 data_size) bool is_address_size, u8 *data, u32 data_size)
{ {
struct npcm_fiu_spi *fiu = struct npcm_fiu_spi *fiu =
spi_controller_get_devdata(mem->spi->master); spi_controller_get_devdata(mem->spi->controller);
u32 uma_cfg = BIT(10); u32 uma_cfg = BIT(10);
u32 data_reg[4] = {0}; u32 data_reg[4] = {0};
u32 val; u32 val;
...@@ -439,7 +439,7 @@ static int npcm_fiu_manualwrite(struct spi_mem *mem, ...@@ -439,7 +439,7 @@ static int npcm_fiu_manualwrite(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct npcm_fiu_spi *fiu = struct npcm_fiu_spi *fiu =
spi_controller_get_devdata(mem->spi->master); spi_controller_get_devdata(mem->spi->controller);
u8 *data = (u8 *)op->data.buf.out; u8 *data = (u8 *)op->data.buf.out;
u32 num_data_chunks; u32 num_data_chunks;
u32 remain_data; u32 remain_data;
...@@ -544,7 +544,7 @@ static void npcm_fiux_set_direct_rd(struct npcm_fiu_spi *fiu) ...@@ -544,7 +544,7 @@ static void npcm_fiux_set_direct_rd(struct npcm_fiu_spi *fiu)
static int npcm_fiu_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) static int npcm_fiu_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
{ {
struct npcm_fiu_spi *fiu = struct npcm_fiu_spi *fiu =
spi_controller_get_devdata(mem->spi->master); spi_controller_get_devdata(mem->spi->controller);
struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(mem->spi, 0)]; struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(mem->spi, 0)];
int ret = 0; int ret = 0;
u8 *buf; u8 *buf;
...@@ -604,7 +604,7 @@ static int npcm_fiu_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) ...@@ -604,7 +604,7 @@ static int npcm_fiu_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
static int npcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc) static int npcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc)
{ {
struct npcm_fiu_spi *fiu = struct npcm_fiu_spi *fiu =
spi_controller_get_devdata(desc->mem->spi->master); spi_controller_get_devdata(desc->mem->spi->controller);
struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)]; struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)];
struct regmap *gcr_regmap; struct regmap *gcr_regmap;
...@@ -665,7 +665,7 @@ static int npcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc) ...@@ -665,7 +665,7 @@ static int npcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc)
static int npcm_fiu_setup(struct spi_device *spi) static int npcm_fiu_setup(struct spi_device *spi)
{ {
struct spi_controller *ctrl = spi->master; struct spi_controller *ctrl = spi->controller;
struct npcm_fiu_spi *fiu = spi_controller_get_devdata(ctrl); struct npcm_fiu_spi *fiu = spi_controller_get_devdata(ctrl);
struct npcm_fiu_chip *chip; struct npcm_fiu_chip *chip;
...@@ -701,7 +701,7 @@ static int npcm_fiu_probe(struct platform_device *pdev) ...@@ -701,7 +701,7 @@ static int npcm_fiu_probe(struct platform_device *pdev)
void __iomem *regbase; void __iomem *regbase;
int id, ret; int id, ret;
ctrl = devm_spi_alloc_master(dev, sizeof(*fiu)); ctrl = devm_spi_alloc_host(dev, sizeof(*fiu));
if (!ctrl) if (!ctrl)
return -ENOMEM; return -ENOMEM;
...@@ -755,7 +755,7 @@ static int npcm_fiu_probe(struct platform_device *pdev) ...@@ -755,7 +755,7 @@ static int npcm_fiu_probe(struct platform_device *pdev)
ctrl->num_chipselect = fiu->info->max_cs; ctrl->num_chipselect = fiu->info->max_cs;
ctrl->dev.of_node = dev->of_node; ctrl->dev.of_node = dev->of_node;
ret = devm_spi_register_master(dev, ctrl); ret = devm_spi_register_controller(dev, ctrl);
if (ret) if (ret)
clk_disable_unprepare(fiu->clk); clk_disable_unprepare(fiu->clk);
......
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