aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/plat-mxc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-mxc')
-rw-r--r--arch/arm/plat-mxc/audmux-v2.c63
1 files changed, 61 insertions, 2 deletions
diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c
index 8cced35009b..73eb555ecb8 100644
--- a/arch/arm/plat-mxc/audmux-v2.c
+++ b/arch/arm/plat-mxc/audmux-v2.c
@@ -20,7 +20,9 @@
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/debugfs.h>
+#include <linux/platform_device.h>
#include <linux/slab.h>
+#include <linux/of.h>
#include <mach/audmux.h>
#include <mach/hardware.h>
@@ -184,9 +186,66 @@ int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr,
}
EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port);
+#ifdef CONFIG_OF
+
+static int audmux_v2_probe(struct platform_device *pdev)
+{
+ struct resource *res;
+ int ret = 0;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -ENODEV;
+ if (!request_mem_region(res->start, resource_size(res), "audmux_v2")) {
+ dev_err(&pdev->dev, "request_mem_region failed\n");
+ return -EBUSY;
+ }
+
+ audmux_base = ioremap(res->start, resource_size(res));
+ if (!audmux_base) {
+ dev_err(&pdev->dev, "ioremap failed\n");
+ ret = -ENODEV;
+ goto failed_ioremap;
+ }
+
+ audmux_clk = clk_get(NULL, "audmux");
+ if (IS_ERR(audmux_clk)) {
+ dev_warn(&pdev->dev, "%s: cannot get clock: %d\n",
+ __func__, ret);
+ audmux_clk = NULL;
+ }
+
+ audmux_debugfs_init();
+ return 0;
+
+failed_ioremap:
+ release_mem_region(res->start, resource_size(res));
+
+ return ret;
+}
+
+static const struct of_device_id audmux_v2_dt_ids[] = {
+ { .compatible = "fsl,audmux-v2", },
+ { /* sentinel */ }
+};
+
+static struct platform_driver audmux_v2_driver = {
+ .probe = audmux_v2_probe,
+ .driver = {
+ .name = "audmux_v2",
+ .of_match_table = audmux_v2_dt_ids,
+ },
+};
+
+#endif
+
static int mxc_audmux_v2_init(void)
{
+#ifdef CONFIG_OF
+ return platform_driver_register(&audmux_v2_driver);
+#else
int ret;
+
if (cpu_is_mx51()) {
audmux_base = MX51_IO_ADDRESS(MX51_AUDMUX_BASE_ADDR);
} else if (cpu_is_mx31()) {
@@ -194,10 +253,9 @@ static int mxc_audmux_v2_init(void)
} else if (cpu_is_mx35()) {
audmux_clk = clk_get(NULL, "audmux");
if (IS_ERR(audmux_clk)) {
- ret = PTR_ERR(audmux_clk);
printk(KERN_ERR "%s: cannot get clock: %d\n", __func__,
ret);
- return ret;
+ audmux_clk = NULL;
}
audmux_base = MX35_IO_ADDRESS(MX35_AUDMUX_BASE_ADDR);
} else if (cpu_is_mx25()) {
@@ -212,6 +270,7 @@ static int mxc_audmux_v2_init(void)
}
audmux_debugfs_init();
+#endif
return 0;
}