Skip to content

Commit 7caae11

Browse files
committed
ASoC: add Renesas MSIOF sound driver
Merge series from Kuninori Morimoto <[email protected]>: Renesas MSIOF can work as both SPI and I2S. Current Linux supports MSIOF-SPI. This patch-set adds new MSIOF-I2S. Because it is using same HW-IP, we want to share same compatible for both MSIOF-SPI/I2S case. MSIOF-I2S (Sound) will use Audio-Graph-Card/Card2 which uses Of-Graph, but MSIOF-SPI is not use Of-Graph. So, this patch-set assumes it was used as MSIOF-I2S if DT is using Of-Graph, otherwise, it is MSIOF-SPI (This assumption will works if SPI *never* use Of-Graph in the future). One note so far is that it is using "spi@xxx" node name for both MSIOF-SPI/I2S. DTC will automatically checks "spi@xxx" node as SPI device which requests #address-cells/#size-cells. But is not needed for I2S. So we will get warning about it on Sparrow Hawk which uses MSIOF-I2S. We have no solution about it, so far. Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected]
2 parents 64c05a1 + cf06681 commit 7caae11

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/kernel.h>
2121
#include <linux/module.h>
2222
#include <linux/of.h>
23+
#include <linux/of_graph.h>
2324
#include <linux/platform_device.h>
2425
#include <linux/pm_runtime.h>
2526
#include <linux/sh_dma.h>
@@ -1276,32 +1277,36 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
12761277
const struct sh_msiof_chipdata *chipdata;
12771278
struct sh_msiof_spi_info *info;
12781279
struct sh_msiof_spi_priv *p;
1280+
struct device *dev = &pdev->dev;
12791281
unsigned long clksrc;
12801282
int i;
12811283
int ret;
12821284

1283-
chipdata = of_device_get_match_data(&pdev->dev);
1285+
/* Check whether MSIOF is used as I2S mode or SPI mode by checking "port" node */
1286+
struct device_node *port __free(device_node) = of_graph_get_next_port(dev->of_node, NULL);
1287+
if (port) /* It was MSIOF-I2S */
1288+
return -ENODEV;
1289+
1290+
chipdata = of_device_get_match_data(dev);
12841291
if (chipdata) {
1285-
info = sh_msiof_spi_parse_dt(&pdev->dev);
1292+
info = sh_msiof_spi_parse_dt(dev);
12861293
} else {
12871294
chipdata = (const void *)pdev->id_entry->driver_data;
1288-
info = dev_get_platdata(&pdev->dev);
1295+
info = dev_get_platdata(dev);
12891296
}
12901297

12911298
if (!info) {
1292-
dev_err(&pdev->dev, "failed to obtain device info\n");
1299+
dev_err(dev, "failed to obtain device info\n");
12931300
return -ENXIO;
12941301
}
12951302

12961303
if (chipdata->flags & SH_MSIOF_FLAG_FIXED_DTDL_200)
12971304
info->dtdl = 200;
12981305

12991306
if (info->mode == MSIOF_SPI_TARGET)
1300-
ctlr = spi_alloc_target(&pdev->dev,
1301-
sizeof(struct sh_msiof_spi_priv));
1307+
ctlr = spi_alloc_target(dev, sizeof(struct sh_msiof_spi_priv));
13021308
else
1303-
ctlr = spi_alloc_host(&pdev->dev,
1304-
sizeof(struct sh_msiof_spi_priv));
1309+
ctlr = spi_alloc_host(dev, sizeof(struct sh_msiof_spi_priv));
13051310
if (ctlr == NULL)
13061311
return -ENOMEM;
13071312

@@ -1315,9 +1320,9 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13151320
init_completion(&p->done);
13161321
init_completion(&p->done_txdma);
13171322

1318-
p->clk = devm_clk_get(&pdev->dev, NULL);
1323+
p->clk = devm_clk_get(dev, NULL);
13191324
if (IS_ERR(p->clk)) {
1320-
dev_err(&pdev->dev, "cannot get clock\n");
1325+
dev_err(dev, "cannot get clock\n");
13211326
ret = PTR_ERR(p->clk);
13221327
goto err1;
13231328
}
@@ -1334,15 +1339,14 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13341339
goto err1;
13351340
}
13361341

1337-
ret = devm_request_irq(&pdev->dev, i, sh_msiof_spi_irq, 0,
1338-
dev_name(&pdev->dev), p);
1342+
ret = devm_request_irq(dev, i, sh_msiof_spi_irq, 0, dev_name(&pdev->dev), p);
13391343
if (ret) {
1340-
dev_err(&pdev->dev, "unable to request irq\n");
1344+
dev_err(dev, "unable to request irq\n");
13411345
goto err1;
13421346
}
13431347

13441348
p->pdev = pdev;
1345-
pm_runtime_enable(&pdev->dev);
1349+
pm_runtime_enable(dev);
13461350

13471351
/* Platform data may override FIFO sizes */
13481352
p->tx_fifo_size = chipdata->tx_fifo_size;
@@ -1361,7 +1365,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13611365
ctlr->flags = chipdata->ctlr_flags;
13621366
ctlr->bus_num = pdev->id;
13631367
ctlr->num_chipselect = p->info->num_chipselect;
1364-
ctlr->dev.of_node = pdev->dev.of_node;
1368+
ctlr->dev.of_node = dev->of_node;
13651369
ctlr->setup = sh_msiof_spi_setup;
13661370
ctlr->prepare_message = sh_msiof_prepare_message;
13671371
ctlr->target_abort = sh_msiof_target_abort;
@@ -1373,19 +1377,19 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
13731377

13741378
ret = sh_msiof_request_dma(p);
13751379
if (ret < 0)
1376-
dev_warn(&pdev->dev, "DMA not available, using PIO\n");
1380+
dev_warn(dev, "DMA not available, using PIO\n");
13771381

1378-
ret = devm_spi_register_controller(&pdev->dev, ctlr);
1382+
ret = devm_spi_register_controller(dev, ctlr);
13791383
if (ret < 0) {
1380-
dev_err(&pdev->dev, "devm_spi_register_controller error.\n");
1384+
dev_err(dev, "devm_spi_register_controller error.\n");
13811385
goto err2;
13821386
}
13831387

13841388
return 0;
13851389

13861390
err2:
13871391
sh_msiof_release_dma(p);
1388-
pm_runtime_disable(&pdev->dev);
1392+
pm_runtime_disable(dev);
13891393
err1:
13901394
spi_controller_put(ctlr);
13911395
return ret;

0 commit comments

Comments
 (0)