aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/sound/mxs-saif.txt36
-rw-r--r--sound/soc/mxs/mxs-saif.c72
2 files changed, 90 insertions, 18 deletions
diff --git a/Documentation/devicetree/bindings/sound/mxs-saif.txt b/Documentation/devicetree/bindings/sound/mxs-saif.txt
new file mode 100644
index 000000000000..c37ba6143d9b
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/mxs-saif.txt
@@ -0,0 +1,36 @@
1* Freescale MXS Serial Audio Interface (SAIF)
2
3Required properties:
4- compatible: Should be "fsl,<chip>-saif"
5- reg: Should contain registers location and length
6- interrupts: Should contain ERROR and DMA interrupts
7- fsl,saif-dma-channel: APBX DMA channel for the SAIF
8
9Optional properties:
10- fsl,saif-master: phandle to the master SAIF. It's only required for
11 the slave SAIF.
12
13Note: Each SAIF controller should have an alias correctly numbered
14in "aliases" node.
15
16Example:
17
18aliases {
19 saif0 = &saif0;
20 saif1 = &saif1;
21};
22
23saif0: saif@80042000 {
24 compatible = "fsl,imx28-saif";
25 reg = <0x80042000 2000>;
26 interrupts = <59 80>;
27 fsl,saif-dma-channel = <4>;
28};
29
30saif1: saif@80046000 {
31 compatible = "fsl,imx28-saif";
32 reg = <0x80046000 2000>;
33 interrupts = <58 81>;
34 fsl,saif-dma-channel = <5>;
35 fsl,saif-master = <&saif0>;
36};
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index 356aad83c1fe..064274880673 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -18,6 +18,8 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/of.h>
22#include <linux/of_device.h>
21#include <linux/platform_device.h> 23#include <linux/platform_device.h>
22#include <linux/slab.h> 24#include <linux/slab.h>
23#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
@@ -622,34 +624,54 @@ static irqreturn_t mxs_saif_irq(int irq, void *dev_id)
622 624
623static int __devinit mxs_saif_probe(struct platform_device *pdev) 625static int __devinit mxs_saif_probe(struct platform_device *pdev)
624{ 626{
627 struct device_node *np = pdev->dev.of_node;
625 struct resource *iores, *dmares; 628 struct resource *iores, *dmares;
626 struct mxs_saif *saif; 629 struct mxs_saif *saif;
627 struct mxs_saif_platform_data *pdata; 630 struct mxs_saif_platform_data *pdata;
628 int ret = 0; 631 int ret = 0;
629 632
630 if (pdev->id >= ARRAY_SIZE(mxs_saif)) 633
634 if (!np && pdev->id >= ARRAY_SIZE(mxs_saif))
631 return -EINVAL; 635 return -EINVAL;
632 636
633 saif = devm_kzalloc(&pdev->dev, sizeof(*saif), GFP_KERNEL); 637 saif = devm_kzalloc(&pdev->dev, sizeof(*saif), GFP_KERNEL);
634 if (!saif) 638 if (!saif)
635 return -ENOMEM; 639 return -ENOMEM;
636 640
637 mxs_saif[pdev->id] = saif; 641 if (np) {
638 saif->id = pdev->id; 642 struct device_node *master;
639 643 saif->id = of_alias_get_id(np, "saif");
640 pdata = pdev->dev.platform_data; 644 if (saif->id < 0)
641 if (pdata && !pdata->master_mode) { 645 return saif->id;
642 saif->master_id = pdata->master_id; 646 /*
643 if (saif->master_id < 0 || 647 * If there is no "fsl,saif-master" phandle, it's a saif
644 saif->master_id >= ARRAY_SIZE(mxs_saif) || 648 * master. Otherwise, it's a slave and its phandle points
645 saif->master_id == saif->id) { 649 * to the master.
646 dev_err(&pdev->dev, "get wrong master id\n"); 650 */
647 return -EINVAL; 651 master = of_parse_phandle(np, "fsl,saif-master", 0);
652 if (!master) {
653 saif->master_id = saif->id;
654 } else {
655 saif->master_id = of_alias_get_id(master, "saif");
656 if (saif->master_id < 0)
657 return saif->master_id;
648 } 658 }
649 } else { 659 } else {
650 saif->master_id = saif->id; 660 saif->id = pdev->id;
661 pdata = pdev->dev.platform_data;
662 if (pdata && !pdata->master_mode)
663 saif->master_id = pdata->master_id;
664 else
665 saif->master_id = saif->id;
666 }
667
668 if (saif->master_id < 0 || saif->master_id >= ARRAY_SIZE(mxs_saif)) {
669 dev_err(&pdev->dev, "get wrong master id\n");
670 return -EINVAL;
651 } 671 }
652 672
673 mxs_saif[saif->id] = saif;
674
653 saif->clk = clk_get(&pdev->dev, NULL); 675 saif->clk = clk_get(&pdev->dev, NULL);
654 if (IS_ERR(saif->clk)) { 676 if (IS_ERR(saif->clk)) {
655 ret = PTR_ERR(saif->clk); 677 ret = PTR_ERR(saif->clk);
@@ -669,12 +691,19 @@ static int __devinit mxs_saif_probe(struct platform_device *pdev)
669 691
670 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); 692 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
671 if (!dmares) { 693 if (!dmares) {
672 ret = -ENODEV; 694 /*
673 dev_err(&pdev->dev, "failed to get dma resource: %d\n", 695 * TODO: This is a temporary solution and should be changed
674 ret); 696 * to use generic DMA binding later when the helplers get in.
675 goto failed_get_resource; 697 */
698 ret = of_property_read_u32(np, "fsl,saif-dma-channel",
699 &saif->dma_param.chan_num);
700 if (ret) {
701 dev_err(&pdev->dev, "failed to get dma channel\n");
702 goto failed_get_resource;
703 }
704 } else {
705 saif->dma_param.chan_num = dmares->start;
676 } 706 }
677 saif->dma_param.chan_num = dmares->start;
678 707
679 saif->irq = platform_get_irq(pdev, 0); 708 saif->irq = platform_get_irq(pdev, 0);
680 if (saif->irq < 0) { 709 if (saif->irq < 0) {
@@ -735,6 +764,12 @@ static int __devexit mxs_saif_remove(struct platform_device *pdev)
735 return 0; 764 return 0;
736} 765}
737 766
767static const struct of_device_id mxs_saif_dt_ids[] = {
768 { .compatible = "fsl,imx28-saif", },
769 { /* sentinel */ }
770};
771MODULE_DEVICE_TABLE(of, mxs_saif_dt_ids);
772
738static struct platform_driver mxs_saif_driver = { 773static struct platform_driver mxs_saif_driver = {
739 .probe = mxs_saif_probe, 774 .probe = mxs_saif_probe,
740 .remove = __devexit_p(mxs_saif_remove), 775 .remove = __devexit_p(mxs_saif_remove),
@@ -742,6 +777,7 @@ static struct platform_driver mxs_saif_driver = {
742 .driver = { 777 .driver = {
743 .name = "mxs-saif", 778 .name = "mxs-saif",
744 .owner = THIS_MODULE, 779 .owner = THIS_MODULE,
780 .of_match_table = mxs_saif_dt_ids,
745 }, 781 },
746}; 782};
747 783