ASoC: mxs: add device tree support for mxs-saif
Add device tree probe for mxs-saif driver. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
36
Documentation/devicetree/bindings/sound/mxs-saif.txt
Normal file
36
Documentation/devicetree/bindings/sound/mxs-saif.txt
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
* Freescale MXS Serial Audio Interface (SAIF)
|
||||||
|
|
||||||
|
Required properties:
|
||||||
|
- compatible: Should be "fsl,<chip>-saif"
|
||||||
|
- reg: Should contain registers location and length
|
||||||
|
- interrupts: Should contain ERROR and DMA interrupts
|
||||||
|
- fsl,saif-dma-channel: APBX DMA channel for the SAIF
|
||||||
|
|
||||||
|
Optional properties:
|
||||||
|
- fsl,saif-master: phandle to the master SAIF. It's only required for
|
||||||
|
the slave SAIF.
|
||||||
|
|
||||||
|
Note: Each SAIF controller should have an alias correctly numbered
|
||||||
|
in "aliases" node.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
aliases {
|
||||||
|
saif0 = &saif0;
|
||||||
|
saif1 = &saif1;
|
||||||
|
};
|
||||||
|
|
||||||
|
saif0: saif@80042000 {
|
||||||
|
compatible = "fsl,imx28-saif";
|
||||||
|
reg = <0x80042000 2000>;
|
||||||
|
interrupts = <59 80>;
|
||||||
|
fsl,saif-dma-channel = <4>;
|
||||||
|
};
|
||||||
|
|
||||||
|
saif1: saif@80046000 {
|
||||||
|
compatible = "fsl,imx28-saif";
|
||||||
|
reg = <0x80046000 2000>;
|
||||||
|
interrupts = <58 81>;
|
||||||
|
fsl,saif-dma-channel = <5>;
|
||||||
|
fsl,saif-master = <&saif0>;
|
||||||
|
};
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/dma-mapping.h>
|
#include <linux/dma-mapping.h>
|
||||||
@ -622,34 +624,54 @@ static irqreturn_t mxs_saif_irq(int irq, void *dev_id)
|
|||||||
|
|
||||||
static int __devinit mxs_saif_probe(struct platform_device *pdev)
|
static int __devinit mxs_saif_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
struct device_node *np = pdev->dev.of_node;
|
||||||
struct resource *iores, *dmares;
|
struct resource *iores, *dmares;
|
||||||
struct mxs_saif *saif;
|
struct mxs_saif *saif;
|
||||||
struct mxs_saif_platform_data *pdata;
|
struct mxs_saif_platform_data *pdata;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (pdev->id >= ARRAY_SIZE(mxs_saif))
|
|
||||||
|
if (!np && pdev->id >= ARRAY_SIZE(mxs_saif))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
saif = devm_kzalloc(&pdev->dev, sizeof(*saif), GFP_KERNEL);
|
saif = devm_kzalloc(&pdev->dev, sizeof(*saif), GFP_KERNEL);
|
||||||
if (!saif)
|
if (!saif)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mxs_saif[pdev->id] = saif;
|
if (np) {
|
||||||
saif->id = pdev->id;
|
struct device_node *master;
|
||||||
|
saif->id = of_alias_get_id(np, "saif");
|
||||||
pdata = pdev->dev.platform_data;
|
if (saif->id < 0)
|
||||||
if (pdata && !pdata->master_mode) {
|
return saif->id;
|
||||||
saif->master_id = pdata->master_id;
|
/*
|
||||||
if (saif->master_id < 0 ||
|
* If there is no "fsl,saif-master" phandle, it's a saif
|
||||||
saif->master_id >= ARRAY_SIZE(mxs_saif) ||
|
* master. Otherwise, it's a slave and its phandle points
|
||||||
saif->master_id == saif->id) {
|
* to the master.
|
||||||
dev_err(&pdev->dev, "get wrong master id\n");
|
*/
|
||||||
return -EINVAL;
|
master = of_parse_phandle(np, "fsl,saif-master", 0);
|
||||||
|
if (!master) {
|
||||||
|
saif->master_id = saif->id;
|
||||||
|
} else {
|
||||||
|
saif->master_id = of_alias_get_id(master, "saif");
|
||||||
|
if (saif->master_id < 0)
|
||||||
|
return saif->master_id;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
saif->master_id = saif->id;
|
saif->id = pdev->id;
|
||||||
|
pdata = pdev->dev.platform_data;
|
||||||
|
if (pdata && !pdata->master_mode)
|
||||||
|
saif->master_id = pdata->master_id;
|
||||||
|
else
|
||||||
|
saif->master_id = saif->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saif->master_id < 0 || saif->master_id >= ARRAY_SIZE(mxs_saif)) {
|
||||||
|
dev_err(&pdev->dev, "get wrong master id\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mxs_saif[saif->id] = saif;
|
||||||
|
|
||||||
saif->clk = clk_get(&pdev->dev, NULL);
|
saif->clk = clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(saif->clk)) {
|
if (IS_ERR(saif->clk)) {
|
||||||
ret = PTR_ERR(saif->clk);
|
ret = PTR_ERR(saif->clk);
|
||||||
@ -669,12 +691,19 @@ static int __devinit mxs_saif_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
|
dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
|
||||||
if (!dmares) {
|
if (!dmares) {
|
||||||
ret = -ENODEV;
|
/*
|
||||||
dev_err(&pdev->dev, "failed to get dma resource: %d\n",
|
* TODO: This is a temporary solution and should be changed
|
||||||
ret);
|
* to use generic DMA binding later when the helplers get in.
|
||||||
goto failed_get_resource;
|
*/
|
||||||
|
ret = of_property_read_u32(np, "fsl,saif-dma-channel",
|
||||||
|
&saif->dma_param.chan_num);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(&pdev->dev, "failed to get dma channel\n");
|
||||||
|
goto failed_get_resource;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
saif->dma_param.chan_num = dmares->start;
|
||||||
}
|
}
|
||||||
saif->dma_param.chan_num = dmares->start;
|
|
||||||
|
|
||||||
saif->irq = platform_get_irq(pdev, 0);
|
saif->irq = platform_get_irq(pdev, 0);
|
||||||
if (saif->irq < 0) {
|
if (saif->irq < 0) {
|
||||||
@ -735,6 +764,12 @@ static int __devexit mxs_saif_remove(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct of_device_id mxs_saif_dt_ids[] = {
|
||||||
|
{ .compatible = "fsl,imx28-saif", },
|
||||||
|
{ /* sentinel */ }
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, mxs_saif_dt_ids);
|
||||||
|
|
||||||
static struct platform_driver mxs_saif_driver = {
|
static struct platform_driver mxs_saif_driver = {
|
||||||
.probe = mxs_saif_probe,
|
.probe = mxs_saif_probe,
|
||||||
.remove = __devexit_p(mxs_saif_remove),
|
.remove = __devexit_p(mxs_saif_remove),
|
||||||
@ -742,6 +777,7 @@ static struct platform_driver mxs_saif_driver = {
|
|||||||
.driver = {
|
.driver = {
|
||||||
.name = "mxs-saif",
|
.name = "mxs-saif",
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
.of_match_table = mxs_saif_dt_ids,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user