Commit 9d93c8d9 authored by Yang Yingliang's avatar Yang Yingliang Committed by Mark Brown

spi: spi-ti-qspi: switch to use modern name

Change legacy name master to modern name host or controller.

No functional changed.
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://msgid.link/r/20231128093031.3707034-16-yangyingliang@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 767e4532
...@@ -40,7 +40,7 @@ struct ti_qspi { ...@@ -40,7 +40,7 @@ struct ti_qspi {
/* list synchronization */ /* list synchronization */
struct mutex list_lock; struct mutex list_lock;
struct spi_master *master; struct spi_controller *host;
void __iomem *base; void __iomem *base;
void __iomem *mmap_base; void __iomem *mmap_base;
size_t mmap_size; size_t mmap_size;
...@@ -137,20 +137,20 @@ static inline void ti_qspi_write(struct ti_qspi *qspi, ...@@ -137,20 +137,20 @@ static inline void ti_qspi_write(struct ti_qspi *qspi,
static int ti_qspi_setup(struct spi_device *spi) static int ti_qspi_setup(struct spi_device *spi)
{ {
struct ti_qspi *qspi = spi_master_get_devdata(spi->master); struct ti_qspi *qspi = spi_controller_get_devdata(spi->controller);
int ret; int ret;
if (spi->master->busy) { if (spi->controller->busy) {
dev_dbg(qspi->dev, "master busy doing other transfers\n"); dev_dbg(qspi->dev, "host busy doing other transfers\n");
return -EBUSY; return -EBUSY;
} }
if (!qspi->master->max_speed_hz) { if (!qspi->host->max_speed_hz) {
dev_err(qspi->dev, "spi max frequency not defined\n"); dev_err(qspi->dev, "spi max frequency not defined\n");
return -EINVAL; return -EINVAL;
} }
spi->max_speed_hz = min(spi->max_speed_hz, qspi->master->max_speed_hz); spi->max_speed_hz = min(spi->max_speed_hz, qspi->host->max_speed_hz);
ret = pm_runtime_resume_and_get(qspi->dev); ret = pm_runtime_resume_and_get(qspi->dev);
if (ret < 0) { if (ret < 0) {
...@@ -526,7 +526,7 @@ static int ti_qspi_dma_xfer_sg(struct ti_qspi *qspi, struct sg_table rx_sg, ...@@ -526,7 +526,7 @@ static int ti_qspi_dma_xfer_sg(struct ti_qspi *qspi, struct sg_table rx_sg,
static void ti_qspi_enable_memory_map(struct spi_device *spi) static void ti_qspi_enable_memory_map(struct spi_device *spi)
{ {
struct ti_qspi *qspi = spi_master_get_devdata(spi->master); struct ti_qspi *qspi = spi_controller_get_devdata(spi->controller);
ti_qspi_write(qspi, MM_SWITCH, QSPI_SPI_SWITCH_REG); ti_qspi_write(qspi, MM_SWITCH, QSPI_SPI_SWITCH_REG);
if (qspi->ctrl_base) { if (qspi->ctrl_base) {
...@@ -540,7 +540,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi) ...@@ -540,7 +540,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
static void ti_qspi_disable_memory_map(struct spi_device *spi) static void ti_qspi_disable_memory_map(struct spi_device *spi)
{ {
struct ti_qspi *qspi = spi_master_get_devdata(spi->master); struct ti_qspi *qspi = spi_controller_get_devdata(spi->controller);
ti_qspi_write(qspi, 0, QSPI_SPI_SWITCH_REG); ti_qspi_write(qspi, 0, QSPI_SPI_SWITCH_REG);
if (qspi->ctrl_base) if (qspi->ctrl_base)
...@@ -554,7 +554,7 @@ static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode, ...@@ -554,7 +554,7 @@ static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode,
u8 data_nbits, u8 addr_width, u8 data_nbits, u8 addr_width,
u8 dummy_bytes) u8 dummy_bytes)
{ {
struct ti_qspi *qspi = spi_master_get_devdata(spi->master); struct ti_qspi *qspi = spi_controller_get_devdata(spi->controller);
u32 memval = opcode; u32 memval = opcode;
switch (data_nbits) { switch (data_nbits) {
...@@ -576,7 +576,7 @@ static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode, ...@@ -576,7 +576,7 @@ static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode,
static int ti_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) static int ti_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
{ {
struct ti_qspi *qspi = spi_controller_get_devdata(mem->spi->master); struct ti_qspi *qspi = spi_controller_get_devdata(mem->spi->controller);
size_t max_len; size_t max_len;
if (op->data.dir == SPI_MEM_DATA_IN) { if (op->data.dir == SPI_MEM_DATA_IN) {
...@@ -606,7 +606,7 @@ static int ti_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) ...@@ -606,7 +606,7 @@ static int ti_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
static int ti_qspi_exec_mem_op(struct spi_mem *mem, static int ti_qspi_exec_mem_op(struct spi_mem *mem,
const struct spi_mem_op *op) const struct spi_mem_op *op)
{ {
struct ti_qspi *qspi = spi_master_get_devdata(mem->spi->master); struct ti_qspi *qspi = spi_controller_get_devdata(mem->spi->controller);
u32 from = 0; u32 from = 0;
int ret = 0; int ret = 0;
...@@ -633,10 +633,10 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem, ...@@ -633,10 +633,10 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem,
struct sg_table sgt; struct sg_table sgt;
if (virt_addr_valid(op->data.buf.in) && if (virt_addr_valid(op->data.buf.in) &&
!spi_controller_dma_map_mem_op_data(mem->spi->master, op, !spi_controller_dma_map_mem_op_data(mem->spi->controller, op,
&sgt)) { &sgt)) {
ret = ti_qspi_dma_xfer_sg(qspi, sgt, from); ret = ti_qspi_dma_xfer_sg(qspi, sgt, from);
spi_controller_dma_unmap_mem_op_data(mem->spi->master, spi_controller_dma_unmap_mem_op_data(mem->spi->controller,
op, &sgt); op, &sgt);
} else { } else {
ret = ti_qspi_dma_bounce_buffer(qspi, from, ret = ti_qspi_dma_bounce_buffer(qspi, from,
...@@ -658,10 +658,10 @@ static const struct spi_controller_mem_ops ti_qspi_mem_ops = { ...@@ -658,10 +658,10 @@ static const struct spi_controller_mem_ops ti_qspi_mem_ops = {
.adjust_op_size = ti_qspi_adjust_op_size, .adjust_op_size = ti_qspi_adjust_op_size,
}; };
static int ti_qspi_start_transfer_one(struct spi_master *master, static int ti_qspi_start_transfer_one(struct spi_controller *host,
struct spi_message *m) struct spi_message *m)
{ {
struct ti_qspi *qspi = spi_master_get_devdata(master); struct ti_qspi *qspi = spi_controller_get_devdata(host);
struct spi_device *spi = m->spi; struct spi_device *spi = m->spi;
struct spi_transfer *t; struct spi_transfer *t;
int status = 0, ret; int status = 0, ret;
...@@ -720,7 +720,7 @@ static int ti_qspi_start_transfer_one(struct spi_master *master, ...@@ -720,7 +720,7 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,
ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG); ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG);
m->status = status; m->status = status;
spi_finalize_current_message(master); spi_finalize_current_message(host);
return status; return status;
} }
...@@ -756,33 +756,33 @@ MODULE_DEVICE_TABLE(of, ti_qspi_match); ...@@ -756,33 +756,33 @@ MODULE_DEVICE_TABLE(of, ti_qspi_match);
static int ti_qspi_probe(struct platform_device *pdev) static int ti_qspi_probe(struct platform_device *pdev)
{ {
struct ti_qspi *qspi; struct ti_qspi *qspi;
struct spi_master *master; struct spi_controller *host;
struct resource *r, *res_mmap; struct resource *r, *res_mmap;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
u32 max_freq; u32 max_freq;
int ret = 0, num_cs, irq; int ret = 0, num_cs, irq;
dma_cap_mask_t mask; dma_cap_mask_t mask;
master = spi_alloc_master(&pdev->dev, sizeof(*qspi)); host = spi_alloc_host(&pdev->dev, sizeof(*qspi));
if (!master) if (!host)
return -ENOMEM; return -ENOMEM;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD;
master->flags = SPI_CONTROLLER_HALF_DUPLEX; host->flags = SPI_CONTROLLER_HALF_DUPLEX;
master->setup = ti_qspi_setup; host->setup = ti_qspi_setup;
master->auto_runtime_pm = true; host->auto_runtime_pm = true;
master->transfer_one_message = ti_qspi_start_transfer_one; host->transfer_one_message = ti_qspi_start_transfer_one;
master->dev.of_node = pdev->dev.of_node; host->dev.of_node = pdev->dev.of_node;
master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) | host->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) |
SPI_BPW_MASK(8); SPI_BPW_MASK(8);
master->mem_ops = &ti_qspi_mem_ops; host->mem_ops = &ti_qspi_mem_ops;
if (!of_property_read_u32(np, "num-cs", &num_cs)) if (!of_property_read_u32(np, "num-cs", &num_cs))
master->num_chipselect = num_cs; host->num_chipselect = num_cs;
qspi = spi_master_get_devdata(master); qspi = spi_controller_get_devdata(host);
qspi->master = master; qspi->host = host;
qspi->dev = &pdev->dev; qspi->dev = &pdev->dev;
platform_set_drvdata(pdev, qspi); platform_set_drvdata(pdev, qspi);
...@@ -792,7 +792,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -792,7 +792,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
if (r == NULL) { if (r == NULL) {
dev_err(&pdev->dev, "missing platform data\n"); dev_err(&pdev->dev, "missing platform data\n");
ret = -ENODEV; ret = -ENODEV;
goto free_master; goto free_host;
} }
} }
...@@ -812,7 +812,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -812,7 +812,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
ret = irq; ret = irq;
goto free_master; goto free_host;
} }
mutex_init(&qspi->list_lock); mutex_init(&qspi->list_lock);
...@@ -820,7 +820,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -820,7 +820,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
qspi->base = devm_ioremap_resource(&pdev->dev, r); qspi->base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(qspi->base)) { if (IS_ERR(qspi->base)) {
ret = PTR_ERR(qspi->base); ret = PTR_ERR(qspi->base);
goto free_master; goto free_host;
} }
...@@ -830,7 +830,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -830,7 +830,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
"syscon-chipselects"); "syscon-chipselects");
if (IS_ERR(qspi->ctrl_base)) { if (IS_ERR(qspi->ctrl_base)) {
ret = PTR_ERR(qspi->ctrl_base); ret = PTR_ERR(qspi->ctrl_base);
goto free_master; goto free_host;
} }
ret = of_property_read_u32_index(np, ret = of_property_read_u32_index(np,
"syscon-chipselects", "syscon-chipselects",
...@@ -838,7 +838,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -838,7 +838,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"couldn't get ctrl_mod reg index\n"); "couldn't get ctrl_mod reg index\n");
goto free_master; goto free_host;
} }
} }
...@@ -853,7 +853,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -853,7 +853,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
if (!of_property_read_u32(np, "spi-max-frequency", &max_freq)) if (!of_property_read_u32(np, "spi-max-frequency", &max_freq))
master->max_speed_hz = max_freq; host->max_speed_hz = max_freq;
dma_cap_zero(mask); dma_cap_zero(mask);
dma_cap_set(DMA_MEMCPY, mask); dma_cap_set(DMA_MEMCPY, mask);
...@@ -876,7 +876,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -876,7 +876,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
dma_release_channel(qspi->rx_chan); dma_release_channel(qspi->rx_chan);
goto no_dma; goto no_dma;
} }
master->dma_rx = qspi->rx_chan; host->dma_rx = qspi->rx_chan;
init_completion(&qspi->transfer_complete); init_completion(&qspi->transfer_complete);
if (res_mmap) if (res_mmap)
qspi->mmap_phys_base = (dma_addr_t)res_mmap->start; qspi->mmap_phys_base = (dma_addr_t)res_mmap->start;
...@@ -889,21 +889,21 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -889,21 +889,21 @@ static int ti_qspi_probe(struct platform_device *pdev)
"mmap failed with error %ld using PIO mode\n", "mmap failed with error %ld using PIO mode\n",
PTR_ERR(qspi->mmap_base)); PTR_ERR(qspi->mmap_base));
qspi->mmap_base = NULL; qspi->mmap_base = NULL;
master->mem_ops = NULL; host->mem_ops = NULL;
} }
} }
qspi->mmap_enabled = false; qspi->mmap_enabled = false;
qspi->current_cs = -1; qspi->current_cs = -1;
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_controller(&pdev->dev, host);
if (!ret) if (!ret)
return 0; return 0;
ti_qspi_dma_cleanup(qspi); ti_qspi_dma_cleanup(qspi);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
free_master: free_host:
spi_master_put(master); spi_controller_put(host);
return ret; return ret;
} }
...@@ -912,9 +912,9 @@ static void ti_qspi_remove(struct platform_device *pdev) ...@@ -912,9 +912,9 @@ static void ti_qspi_remove(struct platform_device *pdev)
struct ti_qspi *qspi = platform_get_drvdata(pdev); struct ti_qspi *qspi = platform_get_drvdata(pdev);
int rc; int rc;
rc = spi_master_suspend(qspi->master); rc = spi_controller_suspend(qspi->host);
if (rc) { if (rc) {
dev_alert(&pdev->dev, "spi_master_suspend() failed (%pe)\n", dev_alert(&pdev->dev, "spi_controller_suspend() failed (%pe)\n",
ERR_PTR(rc)); ERR_PTR(rc));
return; return;
} }
......
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