This series are based on spi/for-next, and provide 4 patches to add MT8195 spi support.
Leilk Liu (4):
spi: update spi master bindings for MT8195 SoC
spi: update spi slave bindings for MT8195 SoC
spi: mediatek: add mtk_spi_compatible support
spi: mediatek: add mt8195 spi slave support
.../devicetree/bindings/spi/spi-mt65xx.txt | 1 +
.../bindings/spi/spi-slave-mt27xx.txt | 1 +
drivers/spi/spi-slave-mt27xx.c | 36 ++++++++++++++++---
3 files changed, 34 insertions(+), 4 deletions(-)
--
2.25.1
this patch adds mt8195 spi slave compatible support.
Signed-off-by: Leilk Liu <[email protected]>
---
drivers/spi/spi-slave-mt27xx.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/spi/spi-slave-mt27xx.c b/drivers/spi/spi-slave-mt27xx.c
index 7e6fadc88cef..f199a6c4738a 100644
--- a/drivers/spi/spi-slave-mt27xx.c
+++ b/drivers/spi/spi-slave-mt27xx.c
@@ -77,12 +77,20 @@ 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 mtk_spi_compatible mt8195_compat = {
+ .max_fifo_size = 128,
+ .must_rx = true,
+};
+
static const struct of_device_id mtk_spi_slave_of_match[] = {
{ .compatible = "mediatek,mt2712-spi-slave",
.data = (void *)&mt2712_compat,},
+ { .compatible = "mediatek,mt8195-spi-slave",
+ .data = (void *)&mt8195_compat,},
{}
};
MODULE_DEVICE_TABLE(of, mtk_spi_slave_of_match);
--
2.18.0
this patch adds max_fifo_size and must_rx compat support.
Signed-off-by: Leilk Liu <[email protected]>
---
drivers/spi/spi-slave-mt27xx.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-slave-mt27xx.c b/drivers/spi/spi-slave-mt27xx.c
index 44edaa360405..7e6fadc88cef 100644
--- a/drivers/spi/spi-slave-mt27xx.c
+++ b/drivers/spi/spi-slave-mt27xx.c
@@ -10,6 +10,8 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/spi/spi.h>
+#include <linux/of.h>
+
#define SPIS_IRQ_EN_REG 0x0
#define SPIS_IRQ_CLR_REG 0x4
@@ -61,8 +63,6 @@
#define SPIS_DMA_ADDR_EN BIT(1)
#define SPIS_SOFT_RST BIT(0)
-#define MTK_SPI_SLAVE_MAX_FIFO_SIZE 512U
-
struct mtk_spi_slave {
struct device *dev;
void __iomem *base;
@@ -70,10 +70,19 @@ struct mtk_spi_slave {
struct completion xfer_done;
struct spi_transfer *cur_transfer;
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[] = {
- { .compatible = "mediatek,mt2712-spi-slave", },
+ { .compatible = "mediatek,mt2712-spi-slave",
+ .data = (void *)&mt2712_compat,},
{}
};
MODULE_DEVICE_TABLE(of, mtk_spi_slave_of_match);
@@ -272,7 +281,7 @@ static int mtk_spi_slave_transfer_one(struct spi_controller *ctlr,
mdata->slave_aborted = false;
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);
else
return mtk_spi_slave_fifo_transfer(ctlr, spi, xfer);
@@ -369,6 +378,7 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
struct spi_controller *ctlr;
struct mtk_spi_slave *mdata;
int irq, ret;
+ const struct of_device_id *of_id;
ctlr = spi_alloc_slave(&pdev->dev, sizeof(*mdata));
if (!ctlr) {
@@ -386,7 +396,17 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
ctlr->setup = mtk_spi_slave_setup;
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->dev_comp = of_id->data;
+
+ if (mdata->dev_comp->must_rx)
+ ctlr->flags = SPI_MASTER_MUST_RX;
platform_set_drvdata(pdev, ctlr);
--
2.18.0
On Mon, 22 Mar 2021 13:52:40 +0800, Leilk Liu wrote:
> This series are based on spi/for-next, and provide 4 patches to add MT8195 spi support.
>
> Leilk Liu (4):
> spi: update spi master bindings for MT8195 SoC
> spi: update spi slave bindings for MT8195 SoC
> spi: mediatek: add mtk_spi_compatible support
> spi: mediatek: add mt8195 spi slave support
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/4] spi: update spi master bindings for MT8195 SoC
commit: 08b020d3e9a87fb6d94b02782c42c001a4e084f4
[2/4] spi: update spi slave bindings for MT8195 SoC
commit: f42698a8dc589dc7cc8e36641e86e6a9b3b32f9b
[3/4] spi: mediatek: add mtk_spi_compatible support
commit: d666a833b0b9f5b8e08ecdc002a4cf5d34932b7a
[4/4] spi: mediatek: add mt8195 spi slave support
commit: 1527b09bc80018f02fe0b6d14e97c95f93596221
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark