Skip to contentSkip to conversation

Add Mediatek MT8195 SPI driver support

PATCH In review Leilk Liu 2 participants 6 messages Mar 22, 2021 – Mar 23, 2021

Subsystems (3)
lore
Share & tools
lore

Leilk Liu

author
#0 lore raw

cover Add Mediatek MT8195 SPI driver support

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(-)
Signature · 6 lines
2.25.1

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
author
#1 lore raw

PATCH 1/4 spi: update spi master bindings for MT8195 SoC

Add a DT binding documentation for the MT8195 soc.

---
 Documentation/devicetree/bindings/spi/spi-mt65xx.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/spi/spi-mt65xx.txt +1 -0
index 7bae7eef26c7..4d0e4c15c4ea 100644
@@ -12,6 +12,7 @@ Required properties:
     - mediatek,mt8173-spi: for mt8173 platforms
     - mediatek,mt8183-spi: for mt8183 platforms
     - "mediatek,mt8192-spi", "mediatek,mt6765-spi": for mt8192 platforms
+    - "mediatek,mt8195-spi", "mediatek,mt6765-spi": for mt8195 platforms
     - "mediatek,mt8516-spi", "mediatek,mt2712-spi": for mt8516 platforms
     - "mediatek,mt6779-spi", "mediatek,mt6765-spi": for mt6779 platforms
 
Signature · 1 line
2.18.0
author
#2 lore raw

PATCH 2/4 spi: update spi slave bindings for MT8195 SoC

In reply to Leilk Liu

Add a DT binding documentation for the MT8195 soc.

---
 Documentation/devicetree/bindings/spi/spi-slave-mt27xx.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/spi/spi-slave-mt27xx.txt +1 -0
index c37e5a179b21..9192724540fd 100644
@@ -3,6 +3,7 @@ Binding for MTK SPI Slave controller
 Required properties:
 - compatible: should be one of the following.
     - mediatek,mt2712-spi-slave: for mt2712 platforms
+    - mediatek,mt8195-spi-slave: for mt8195 platforms
 - reg: Address and length of the register set for the device.
 - interrupts: Should contain spi interrupt.
 - clocks: phandles to input clocks.
Signature · 1 line
2.18.0
author
#3 lore raw

PATCH 3/4 spi: mediatek: add mtk_spi_compatible support

In reply to Leilk Liu

this patch adds max_fifo_size and must_rx compat support.

---
 drivers/spi/spi-slave-mt27xx.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/spi/spi-slave-mt27xx.c +24 -4
index 44edaa360405..7e6fadc88cef 100644
@@ -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);
 
Signature · 5 lines
2.18.0
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
author
#4 lore raw

PATCH 4/4 spi: mediatek: add mt8195 spi slave support

In reply to Leilk Liu

this patch adds mt8195 spi slave compatible support.

---
 drivers/spi/spi-slave-mt27xx.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/spi/spi-slave-mt27xx.c +8 -0
index 7e6fadc88cef..f199a6c4738a 100644
@@ -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);
Signature · 1 line
2.18.0
maintainer
#5 lore raw
In reply to Leilk Liu
Quoted 9 lines · Leilk Liu

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

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek