Commit d666a833 authored by Leilk Liu's avatar Leilk Liu Committed by Mark Brown

spi: mediatek: add mtk_spi_compatible support

this patch adds max_fifo_size and must_rx compat support.
Signed-off-by: default avatarLeilk Liu <leilk.liu@mediatek.com>
Link: https://lore.kernel.org/r/20210322055244.30179-4-leilk.liu@mediatek.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f42698a8
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/of.h>
#define SPIS_IRQ_EN_REG 0x0 #define SPIS_IRQ_EN_REG 0x0
#define SPIS_IRQ_CLR_REG 0x4 #define SPIS_IRQ_CLR_REG 0x4
...@@ -61,8 +63,6 @@ ...@@ -61,8 +63,6 @@
#define SPIS_DMA_ADDR_EN BIT(1) #define SPIS_DMA_ADDR_EN BIT(1)
#define SPIS_SOFT_RST BIT(0) #define SPIS_SOFT_RST BIT(0)
#define MTK_SPI_SLAVE_MAX_FIFO_SIZE 512U
struct mtk_spi_slave { struct mtk_spi_slave {
struct device *dev; struct device *dev;
void __iomem *base; void __iomem *base;
...@@ -70,10 +70,19 @@ struct mtk_spi_slave { ...@@ -70,10 +70,19 @@ struct mtk_spi_slave {
struct completion xfer_done; struct completion xfer_done;
struct spi_transfer *cur_transfer; struct spi_transfer *cur_transfer;
bool slave_aborted; bool slave_aborted;
const struct mtk_spi_compatible *dev_comp;
}; };
struct mtk_spi_compatible {
const u32 max_fifo_size;
bool must_rx;
};
static const struct mtk_spi_compatible mt2712_compat = {
.max_fifo_size = 512,
};
static const struct of_device_id mtk_spi_slave_of_match[] = { static const struct of_device_id mtk_spi_slave_of_match[] = {
{ .compatible = "mediatek,mt2712-spi-slave", }, { .compatible = "mediatek,mt2712-spi-slave",
.data = (void *)&mt2712_compat,},
{} {}
}; };
MODULE_DEVICE_TABLE(of, mtk_spi_slave_of_match); MODULE_DEVICE_TABLE(of, mtk_spi_slave_of_match);
...@@ -272,7 +281,7 @@ static int mtk_spi_slave_transfer_one(struct spi_controller *ctlr, ...@@ -272,7 +281,7 @@ static int mtk_spi_slave_transfer_one(struct spi_controller *ctlr,
mdata->slave_aborted = false; mdata->slave_aborted = false;
mdata->cur_transfer = xfer; mdata->cur_transfer = xfer;
if (xfer->len > MTK_SPI_SLAVE_MAX_FIFO_SIZE) if (xfer->len > mdata->dev_comp->max_fifo_size)
return mtk_spi_slave_dma_transfer(ctlr, spi, xfer); return mtk_spi_slave_dma_transfer(ctlr, spi, xfer);
else else
return mtk_spi_slave_fifo_transfer(ctlr, spi, xfer); return mtk_spi_slave_fifo_transfer(ctlr, spi, xfer);
...@@ -369,6 +378,7 @@ static int mtk_spi_slave_probe(struct platform_device *pdev) ...@@ -369,6 +378,7 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
struct spi_controller *ctlr; struct spi_controller *ctlr;
struct mtk_spi_slave *mdata; struct mtk_spi_slave *mdata;
int irq, ret; int irq, ret;
const struct of_device_id *of_id;
ctlr = spi_alloc_slave(&pdev->dev, sizeof(*mdata)); ctlr = spi_alloc_slave(&pdev->dev, sizeof(*mdata));
if (!ctlr) { if (!ctlr) {
...@@ -386,7 +396,17 @@ static int mtk_spi_slave_probe(struct platform_device *pdev) ...@@ -386,7 +396,17 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
ctlr->setup = mtk_spi_slave_setup; ctlr->setup = mtk_spi_slave_setup;
ctlr->slave_abort = mtk_slave_abort; ctlr->slave_abort = mtk_slave_abort;
of_id = of_match_node(mtk_spi_slave_of_match, pdev->dev.of_node);
if (!of_id) {
dev_err(&pdev->dev, "failed to probe of_node\n");
ret = -EINVAL;
goto err_put_ctlr;
}
mdata = spi_controller_get_devdata(ctlr); mdata = spi_controller_get_devdata(ctlr);
mdata->dev_comp = of_id->data;
if (mdata->dev_comp->must_rx)
ctlr->flags = SPI_MASTER_MUST_RX;
platform_set_drvdata(pdev, ctlr); platform_set_drvdata(pdev, ctlr);
......
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