aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-10-29 12:12:39 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2009-11-14 04:30:39 -0500
commit9eedbdf1b4216e286bd660322ae5a52f79eee243 (patch)
treef68dda745cc87b40aedba9baa84cbb3b7045ffd4 /arch
parentd8d982b1b284370512d5650aadb300d30fd9d4b2 (diff)
MXC: Add a digital audio multiplexer driver
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-mx2/Kconfig2
-rw-r--r--arch/arm/mach-mx3/Kconfig2
-rw-r--r--arch/arm/plat-mxc/Kconfig7
-rw-r--r--arch/arm/plat-mxc/Makefile2
-rw-r--r--arch/arm/plat-mxc/audmux-v1.c53
-rw-r--r--arch/arm/plat-mxc/audmux-v2.c74
-rw-r--r--arch/arm/plat-mxc/include/mach/audmux.h52
7 files changed, 192 insertions, 0 deletions
diff --git a/arch/arm/mach-mx2/Kconfig b/arch/arm/mach-mx2/Kconfig
index c8a2eac4d13c..3e14da3698b5 100644
--- a/arch/arm/mach-mx2/Kconfig
+++ b/arch/arm/mach-mx2/Kconfig
@@ -6,11 +6,13 @@ choice
6 6
7config MACH_MX21 7config MACH_MX21
8 bool "i.MX21 support" 8 bool "i.MX21 support"
9 select ARCH_MXC_AUDMUX_V1
9 help 10 help
10 This enables support for Freescale's MX2 based i.MX21 processor. 11 This enables support for Freescale's MX2 based i.MX21 processor.
11 12
12config MACH_MX27 13config MACH_MX27
13 bool "i.MX27 support" 14 bool "i.MX27 support"
15 select ARCH_MXC_AUDMUX_V1
14 help 16 help
15 This enables support for Freescale's MX2 based i.MX27 processor. 17 This enables support for Freescale's MX2 based i.MX27 processor.
16 18
diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig
index 851f2458bf65..ffdd211e3535 100644
--- a/arch/arm/mach-mx3/Kconfig
+++ b/arch/arm/mach-mx3/Kconfig
@@ -2,11 +2,13 @@ if ARCH_MX3
2 2
3config ARCH_MX31 3config ARCH_MX31
4 select ARCH_HAS_RNGA 4 select ARCH_HAS_RNGA
5 select ARCH_MXC_AUDMUX_V2
5 bool 6 bool
6 7
7config ARCH_MX35 8config ARCH_MX35
8 bool 9 bool
9 select ARCH_MXC_IOMUX_V3 10 select ARCH_MXC_IOMUX_V3
11 select ARCH_MXC_AUDMUX_V2
10 12
11comment "MX3 platforms:" 13comment "MX3 platforms:"
12 14
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index e8e92cbd108c..8b0a1ee039fa 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -78,4 +78,11 @@ config ARCH_HAS_RNGA
78 78
79config ARCH_MXC_IOMUX_V3 79config ARCH_MXC_IOMUX_V3
80 bool 80 bool
81
82config ARCH_MXC_AUDMUX_V1
83 bool
84
85config ARCH_MXC_AUDMUX_V2
86 bool
87
81endif 88endif
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index 545412f81831..4cbca9da1505 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -10,3 +10,5 @@ obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
10obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o 10obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
11obj-$(CONFIG_MXC_PWM) += pwm.o 11obj-$(CONFIG_MXC_PWM) += pwm.o
12obj-$(CONFIG_MXC_ULPI) += ulpi.o 12obj-$(CONFIG_MXC_ULPI) += ulpi.o
13obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o
14obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o
diff --git a/arch/arm/plat-mxc/audmux-v1.c b/arch/arm/plat-mxc/audmux-v1.c
new file mode 100644
index 000000000000..70ab5aff2b9e
--- /dev/null
+++ b/arch/arm/plat-mxc/audmux-v1.c
@@ -0,0 +1,53 @@
1/*
2 * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
3 *
4 * Initial development of this code was funded by
5 * Phytec Messtechnik GmbH, http://www.phytec.de
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/err.h>
24#include <linux/io.h>
25#include <linux/clk.h>
26#include <mach/audmux.h>
27#include <mach/hardware.h>
28
29static void __iomem *audmux_base;
30
31#define MXC_AUDMUX_V1_PCR(x) ((x) * 4)
32
33int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr)
34{
35 if (!audmux_base) {
36 printk("%s: not configured\n", __func__);
37 return -ENOSYS;
38 }
39
40 writel(pcr, audmux_base + MXC_AUDMUX_V1_PCR(port));
41
42 return 0;
43}
44EXPORT_SYMBOL_GPL(mxc_audmux_v1_configure_port);
45
46static int mxc_audmux_v1_init(void)
47{
48 if (cpu_is_mx27() || cpu_is_mx21())
49 audmux_base = IO_ADDRESS(AUDMUX_BASE_ADDR);
50 return 0;
51}
52
53postcore_initcall(mxc_audmux_v1_init);
diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c
new file mode 100644
index 000000000000..6f21096086fd
--- /dev/null
+++ b/arch/arm/plat-mxc/audmux-v2.c
@@ -0,0 +1,74 @@
1/*
2 * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
3 *
4 * Initial development of this code was funded by
5 * Phytec Messtechnik GmbH, http://www.phytec.de
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/err.h>
24#include <linux/io.h>
25#include <linux/clk.h>
26#include <mach/audmux.h>
27#include <mach/hardware.h>
28
29static struct clk *audmux_clk;
30static void __iomem *audmux_base;
31
32#define MXC_AUDMUX_V2_PTCR(x) ((x) * 8)
33#define MXC_AUDMUX_V2_PDCR(x) ((x) * 8 + 4)
34
35int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr,
36 unsigned int pdcr)
37{
38 if (!audmux_base)
39 return -ENOSYS;
40
41 if (audmux_clk)
42 clk_enable(audmux_clk);
43
44 writel(ptcr, audmux_base + MXC_AUDMUX_V2_PTCR(port));
45 writel(pdcr, audmux_base + MXC_AUDMUX_V2_PDCR(port));
46
47 if (audmux_clk)
48 clk_disable(audmux_clk);
49
50 return 0;
51}
52EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port);
53
54static int mxc_audmux_v2_init(void)
55{
56 int ret;
57
58 if (cpu_is_mx35()) {
59 audmux_clk = clk_get(NULL, "audmux");
60 if (IS_ERR(audmux_clk)) {
61 ret = PTR_ERR(audmux_clk);
62 printk(KERN_ERR "%s: cannot get clock: %d\n", __func__,
63 ret);
64 return ret;
65 }
66 }
67
68 if (cpu_is_mx31() || cpu_is_mx35())
69 audmux_base = IO_ADDRESS(AUDMUX_BASE_ADDR);
70
71 return 0;
72}
73
74postcore_initcall(mxc_audmux_v2_init);
diff --git a/arch/arm/plat-mxc/include/mach/audmux.h b/arch/arm/plat-mxc/include/mach/audmux.h
new file mode 100644
index 000000000000..5cd6466964af
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/audmux.h
@@ -0,0 +1,52 @@
1#ifndef __MACH_AUDMUX_H
2#define __MACH_AUDMUX_H
3
4#define MX27_AUDMUX_HPCR1_SSI0 0
5#define MX27_AUDMUX_HPCR2_SSI1 1
6#define MX27_AUDMUX_HPCR3_SSI_PINS_4 2
7#define MX27_AUDMUX_PPCR1_SSI_PINS_1 3
8#define MX27_AUDMUX_PPCR2_SSI_PINS_2 4
9#define MX27_AUDMUX_PPCR3_SSI_PINS_3 5
10
11#define MX31_AUDMUX_PORT1_SSI0 0
12#define MX31_AUDMUX_PORT2_SSI1 1
13#define MX31_AUDMUX_PORT3_SSI_PINS_3 2
14#define MX31_AUDMUX_PORT4_SSI_PINS_4 3
15#define MX31_AUDMUX_PORT5_SSI_PINS_5 4
16#define MX31_AUDMUX_PORT6_SSI_PINS_6 5
17
18/* Register definitions for the i.MX21/27 Digital Audio Multiplexer */
19#define MXC_AUDMUX_V1_PCR_INMMASK(x) ((x) & 0xff)
20#define MXC_AUDMUX_V1_PCR_INMEN (1 << 8)
21#define MXC_AUDMUX_V1_PCR_TXRXEN (1 << 10)
22#define MXC_AUDMUX_V1_PCR_SYN (1 << 12)
23#define MXC_AUDMUX_V1_PCR_RXDSEL(x) (((x) & 0x7) << 13)
24#define MXC_AUDMUX_V1_PCR_RFCSEL(x) (((x) & 0xf) << 20)
25#define MXC_AUDMUX_V1_PCR_RCLKDIR (1 << 24)
26#define MXC_AUDMUX_V1_PCR_RFSDIR (1 << 25)
27#define MXC_AUDMUX_V1_PCR_TFCSEL(x) (((x) & 0xf) << 26)
28#define MXC_AUDMUX_V1_PCR_TCLKDIR (1 << 30)
29#define MXC_AUDMUX_V1_PCR_TFSDIR (1 << 31)
30
31/* Register definitions for the i.MX25/31/35 Digital Audio Multiplexer */
32#define MXC_AUDMUX_V2_PTCR_TFSDIR (1 << 31)
33#define MXC_AUDMUX_V2_PTCR_TFSEL(x) (((x) & 0xf) << 27)
34#define MXC_AUDMUX_V2_PTCR_TCLKDIR (1 << 26)
35#define MXC_AUDMUX_V2_PTCR_TCSEL(x) (((x) & 0xf) << 22)
36#define MXC_AUDMUX_V2_PTCR_RFSDIR (1 << 21)
37#define MXC_AUDMUX_V2_PTCR_RFSEL(x) (((x) & 0xf) << 17)
38#define MXC_AUDMUX_V2_PTCR_RCLKDIR (1 << 16)
39#define MXC_AUDMUX_V2_PTCR_RCSEL(x) (((x) & 0xf) << 12)
40#define MXC_AUDMUX_V2_PTCR_SYN (1 << 11)
41
42#define MXC_AUDMUX_V2_PDCR_RXDSEL(x) (((x) & 0x7) << 13)
43#define MXC_AUDMUX_V2_PDCR_TXRXEN (1 << 12)
44#define MXC_AUDMUX_V2_PDCR_MODE(x) (((x) & 0x3) << 8)
45#define MXC_AUDMUX_V2_PDCR_INMMASK(x) ((x) & 0xff)
46
47int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr);
48
49int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr,
50 unsigned int pdcr);
51
52#endif /* __MACH_AUDMUX_H */