this patch add the support of spi-mem for ipm design.
Signed-off-by: Leilk Liu <leilk.liu@xxxxxxxxxxxx>
---
drivers/spi/spi-mt65xx.c | 349 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 348 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 1a0b3208dfca..8958c3fa4fea 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
+
+static void of_mtk_spi_parse_dt(struct spi_master *master, struct device_node *nc)
+{
+ struct mtk_spi *mdata = spi_master_get_devdata(master);
+ u32 value;
+
+ if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
+ switch (value) {
+ case 1:
+ break;
+ case 2:
+ master->mode_bits |= SPI_TX_DUAL;
+ break;
+ case 4:
+ master->mode_bits |= SPI_TX_QUAD;
+ break;
+ default:
+ dev_warn(mdata->dev,
+ "spi-tx-bus-width %d not supported\n",
+ value);
+ break;
+ }
+ }
+
+ if (!of_property_read_u32(nc, "spi-rx-bus-width", &value)) {
+ switch (value) {
+ case 1:
+ break;
+ case 2:
+ master->mode_bits |= SPI_RX_DUAL;
+ break;
+ case 4:
+ master->mode_bits |= SPI_RX_QUAD;
+ break;
+ case 8:
+ master->mode_bits |= SPI_RX_OCTAL;
+ break;
+ default:
+ dev_warn(mdata->dev,
+ "spi-rx-bus-width %d not supported\n",
+ value);
+ break;
+ }
+ }
+}
+
static int mtk_spi_probe(struct platform_device *pdev)
{
struct spi_master *master;
@@ -830,6 +1170,13 @@ static int mtk_spi_probe(struct platform_device *pdev)
if (mdata->dev_comp->ipm_design)
master->mode_bits |= SPI_LOOP;
+ if (mdata->dev_comp->ipm_design) {
+ mdata->dev = &pdev->dev;
+ master->mem_ops = &mtk_spi_mem_ops;
+ of_mtk_spi_parse_dt(master, pdev->dev.of_node);
+ init_completion(&mdata->spimem_done);
+ }
+
if (mdata->dev_comp->need_pad_sel) {
mdata->pad_num = of_property_count_u32_elems(
pdev->dev.of_node,