aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Zhao <richard.zhao@linaro.org>2012-03-05 09:30:52 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-03-05 19:02:55 -0500
commit3bc34a6143359d2bf19a5e79b9017aeffc6660ad (patch)
tree961e834e2a3fde9c3fe57e634f0a784d703627dc
parent2405fc9728a3ed7dffc36bee68f0c36e4488212d (diff)
ARM: imx: convert audmux to a platform driver
It coverts audmux to a platform driver, so that it can be moved into sound/soc/imx and adopt device tree support later. Signed-off-by: Richard Zhao <richard.zhao@linaro.org> Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--arch/arm/mach-imx/mm-imx21.c6
-rw-r--r--arch/arm/mach-imx/mm-imx25.c7
-rw-r--r--arch/arm/mach-imx/mm-imx27.c7
-rw-r--r--arch/arm/mach-imx/mm-imx3.c13
-rw-r--r--arch/arm/mach-imx/mm-imx5.c22
-rw-r--r--arch/arm/plat-mxc/audmux.c127
6 files changed, 147 insertions, 35 deletions
diff --git a/arch/arm/mach-imx/mm-imx21.c b/arch/arm/mach-imx/mm-imx21.c
index 3f05dfebacc9..14d540edfd1e 100644
--- a/arch/arm/mach-imx/mm-imx21.c
+++ b/arch/arm/mach-imx/mm-imx21.c
@@ -75,6 +75,10 @@ void __init mx21_init_irq(void)
75 mxc_init_irq(MX21_IO_ADDRESS(MX21_AVIC_BASE_ADDR)); 75 mxc_init_irq(MX21_IO_ADDRESS(MX21_AVIC_BASE_ADDR));
76} 76}
77 77
78static const struct resource imx21_audmux_res[] __initconst = {
79 DEFINE_RES_MEM(MX21_AUDMUX_BASE_ADDR, SZ_4K),
80};
81
78void __init imx21_soc_init(void) 82void __init imx21_soc_init(void)
79{ 83{
80 mxc_register_gpio("imx21-gpio", 0, MX21_GPIO1_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); 84 mxc_register_gpio("imx21-gpio", 0, MX21_GPIO1_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0);
@@ -85,4 +89,6 @@ void __init imx21_soc_init(void)
85 mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0); 89 mxc_register_gpio("imx21-gpio", 5, MX21_GPIO6_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0);
86 90
87 imx_add_imx_dma(); 91 imx_add_imx_dma();
92 platform_device_register_simple("imx21-audmux", 0, imx21_audmux_res,
93 ARRAY_SIZE(imx21_audmux_res));
88} 94}
diff --git a/arch/arm/mach-imx/mm-imx25.c b/arch/arm/mach-imx/mm-imx25.c
index cc4d152bd9bd..153b457acdc0 100644
--- a/arch/arm/mach-imx/mm-imx25.c
+++ b/arch/arm/mach-imx/mm-imx25.c
@@ -83,6 +83,10 @@ static struct sdma_platform_data imx25_sdma_pdata __initdata = {
83 .script_addrs = &imx25_sdma_script, 83 .script_addrs = &imx25_sdma_script,
84}; 84};
85 85
86static const struct resource imx25_audmux_res[] __initconst = {
87 DEFINE_RES_MEM(MX25_AUDMUX_BASE_ADDR, SZ_16K),
88};
89
86void __init imx25_soc_init(void) 90void __init imx25_soc_init(void)
87{ 91{
88 /* i.mx25 has the i.mx31 type gpio */ 92 /* i.mx25 has the i.mx31 type gpio */
@@ -93,4 +97,7 @@ void __init imx25_soc_init(void)
93 97
94 /* i.mx25 has the i.mx35 type sdma */ 98 /* i.mx25 has the i.mx35 type sdma */
95 imx_add_imx_sdma("imx35-sdma", MX25_SDMA_BASE_ADDR, MX25_INT_SDMA, &imx25_sdma_pdata); 99 imx_add_imx_sdma("imx35-sdma", MX25_SDMA_BASE_ADDR, MX25_INT_SDMA, &imx25_sdma_pdata);
100 /* i.mx25 has the i.mx31 type audmux */
101 platform_device_register_simple("imx31-audmux", 0, imx25_audmux_res,
102 ARRAY_SIZE(imx25_audmux_res));
96} 103}
diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c
index 96dd1f5ea7bd..8cb3f5e3e569 100644
--- a/arch/arm/mach-imx/mm-imx27.c
+++ b/arch/arm/mach-imx/mm-imx27.c
@@ -75,6 +75,10 @@ void __init mx27_init_irq(void)
75 mxc_init_irq(MX27_IO_ADDRESS(MX27_AVIC_BASE_ADDR)); 75 mxc_init_irq(MX27_IO_ADDRESS(MX27_AVIC_BASE_ADDR));
76} 76}
77 77
78static const struct resource imx27_audmux_res[] __initconst = {
79 DEFINE_RES_MEM(MX27_AUDMUX_BASE_ADDR, SZ_4K),
80};
81
78void __init imx27_soc_init(void) 82void __init imx27_soc_init(void)
79{ 83{
80 /* i.mx27 has the i.mx21 type gpio */ 84 /* i.mx27 has the i.mx21 type gpio */
@@ -86,4 +90,7 @@ void __init imx27_soc_init(void)
86 mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0); 90 mxc_register_gpio("imx21-gpio", 5, MX27_GPIO6_BASE_ADDR, SZ_256, MX27_INT_GPIO, 0);
87 91
88 imx_add_imx_dma(); 92 imx_add_imx_dma();
93 /* imx27 has the imx21 type audmux */
94 platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res,
95 ARRAY_SIZE(imx27_audmux_res));
89} 96}
diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c
index 31807d2a8b7b..2530c151b7b3 100644
--- a/arch/arm/mach-imx/mm-imx3.c
+++ b/arch/arm/mach-imx/mm-imx3.c
@@ -158,6 +158,10 @@ static struct sdma_platform_data imx31_sdma_pdata __initdata = {
158 .script_addrs = &imx31_to2_sdma_script, 158 .script_addrs = &imx31_to2_sdma_script,
159}; 159};
160 160
161static const struct resource imx31_audmux_res[] __initconst = {
162 DEFINE_RES_MEM(MX31_AUDMUX_BASE_ADDR, SZ_16K),
163};
164
161void __init imx31_soc_init(void) 165void __init imx31_soc_init(void)
162{ 166{
163 int to_version = mx31_revision() >> 4; 167 int to_version = mx31_revision() >> 4;
@@ -175,6 +179,8 @@ void __init imx31_soc_init(void)
175 } 179 }
176 180
177 imx_add_imx_sdma("imx31-sdma", MX31_SDMA_BASE_ADDR, MX31_INT_SDMA, &imx31_sdma_pdata); 181 imx_add_imx_sdma("imx31-sdma", MX31_SDMA_BASE_ADDR, MX31_INT_SDMA, &imx31_sdma_pdata);
182 platform_device_register_simple("imx31-audmux", 0, imx31_audmux_res,
183 ARRAY_SIZE(imx31_audmux_res));
178} 184}
179#endif /* ifdef CONFIG_SOC_IMX31 */ 185#endif /* ifdef CONFIG_SOC_IMX31 */
180 186
@@ -241,6 +247,10 @@ static struct sdma_platform_data imx35_sdma_pdata __initdata = {
241 .script_addrs = &imx35_to2_sdma_script, 247 .script_addrs = &imx35_to2_sdma_script,
242}; 248};
243 249
250static const struct resource imx35_audmux_res[] __initconst = {
251 DEFINE_RES_MEM(MX35_AUDMUX_BASE_ADDR, SZ_16K),
252};
253
244void __init imx35_soc_init(void) 254void __init imx35_soc_init(void)
245{ 255{
246 int to_version = mx35_revision() >> 4; 256 int to_version = mx35_revision() >> 4;
@@ -259,5 +269,8 @@ void __init imx35_soc_init(void)
259 } 269 }
260 270
261 imx_add_imx_sdma("imx35-sdma", MX35_SDMA_BASE_ADDR, MX35_INT_SDMA, &imx35_sdma_pdata); 271 imx_add_imx_sdma("imx35-sdma", MX35_SDMA_BASE_ADDR, MX35_INT_SDMA, &imx35_sdma_pdata);
272 /* i.mx35 has the i.mx31 type audmux */
273 platform_device_register_simple("imx31-audmux", 0, imx35_audmux_res,
274 ARRAY_SIZE(imx35_audmux_res));
262} 275}
263#endif /* ifdef CONFIG_SOC_IMX35 */ 276#endif /* ifdef CONFIG_SOC_IMX35 */
diff --git a/arch/arm/mach-imx/mm-imx5.c b/arch/arm/mach-imx/mm-imx5.c
index bc17dfea3817..90d7880bb372 100644
--- a/arch/arm/mach-imx/mm-imx5.c
+++ b/arch/arm/mach-imx/mm-imx5.c
@@ -170,6 +170,18 @@ static struct sdma_platform_data imx53_sdma_pdata __initdata = {
170 .script_addrs = &imx53_sdma_script, 170 .script_addrs = &imx53_sdma_script,
171}; 171};
172 172
173static const struct resource imx50_audmux_res[] __initconst = {
174 DEFINE_RES_MEM(MX50_AUDMUX_BASE_ADDR, SZ_16K),
175};
176
177static const struct resource imx51_audmux_res[] __initconst = {
178 DEFINE_RES_MEM(MX51_AUDMUX_BASE_ADDR, SZ_16K),
179};
180
181static const struct resource imx53_audmux_res[] __initconst = {
182 DEFINE_RES_MEM(MX53_AUDMUX_BASE_ADDR, SZ_16K),
183};
184
173void __init imx50_soc_init(void) 185void __init imx50_soc_init(void)
174{ 186{
175 /* i.mx50 has the i.mx31 type gpio */ 187 /* i.mx50 has the i.mx31 type gpio */
@@ -179,6 +191,10 @@ void __init imx50_soc_init(void)
179 mxc_register_gpio("imx31-gpio", 3, MX50_GPIO4_BASE_ADDR, SZ_16K, MX50_INT_GPIO4_LOW, MX50_INT_GPIO4_HIGH); 191 mxc_register_gpio("imx31-gpio", 3, MX50_GPIO4_BASE_ADDR, SZ_16K, MX50_INT_GPIO4_LOW, MX50_INT_GPIO4_HIGH);
180 mxc_register_gpio("imx31-gpio", 4, MX50_GPIO5_BASE_ADDR, SZ_16K, MX50_INT_GPIO5_LOW, MX50_INT_GPIO5_HIGH); 192 mxc_register_gpio("imx31-gpio", 4, MX50_GPIO5_BASE_ADDR, SZ_16K, MX50_INT_GPIO5_LOW, MX50_INT_GPIO5_HIGH);
181 mxc_register_gpio("imx31-gpio", 5, MX50_GPIO6_BASE_ADDR, SZ_16K, MX50_INT_GPIO6_LOW, MX50_INT_GPIO6_HIGH); 193 mxc_register_gpio("imx31-gpio", 5, MX50_GPIO6_BASE_ADDR, SZ_16K, MX50_INT_GPIO6_LOW, MX50_INT_GPIO6_HIGH);
194
195 /* i.mx50 has the i.mx31 type audmux */
196 platform_device_register_simple("imx31-audmux", 0, imx50_audmux_res,
197 ARRAY_SIZE(imx50_audmux_res));
182} 198}
183 199
184void __init imx51_soc_init(void) 200void __init imx51_soc_init(void)
@@ -191,6 +207,9 @@ void __init imx51_soc_init(void)
191 207
192 /* i.mx51 has the i.mx35 type sdma */ 208 /* i.mx51 has the i.mx35 type sdma */
193 imx_add_imx_sdma("imx35-sdma", MX51_SDMA_BASE_ADDR, MX51_INT_SDMA, &imx51_sdma_pdata); 209 imx_add_imx_sdma("imx35-sdma", MX51_SDMA_BASE_ADDR, MX51_INT_SDMA, &imx51_sdma_pdata);
210 /* i.mx51 has the i.mx31 type audmux */
211 platform_device_register_simple("imx31-audmux", 0, imx51_audmux_res,
212 ARRAY_SIZE(imx51_audmux_res));
194} 213}
195 214
196void __init imx53_soc_init(void) 215void __init imx53_soc_init(void)
@@ -206,4 +225,7 @@ void __init imx53_soc_init(void)
206 225
207 /* i.mx53 has the i.mx35 type sdma */ 226 /* i.mx53 has the i.mx35 type sdma */
208 imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata); 227 imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata);
228 /* i.mx53 has the i.mx31 type audmux */
229 platform_device_register_simple("imx31-audmux", 0, imx53_audmux_res,
230 ARRAY_SIZE(imx53_audmux_res));
209} 231}
diff --git a/arch/arm/plat-mxc/audmux.c b/arch/arm/plat-mxc/audmux.c
index b49a39ff99da..a8c9e04771bf 100644
--- a/arch/arm/plat-mxc/audmux.c
+++ b/arch/arm/plat-mxc/audmux.c
@@ -1,4 +1,6 @@
1/* 1/*
2 * Copyright 2012 Freescale Semiconductor, Inc.
3 * Copyright 2012 Linaro Ltd.
2 * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de> 4 * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
3 * 5 *
4 * Initial development of this code was funded by 6 * Initial development of this code was funded by
@@ -15,14 +17,16 @@
15 * GNU General Public License for more details. 17 * GNU General Public License for more details.
16 */ 18 */
17 19
18#include <linux/module.h>
19#include <linux/err.h>
20#include <linux/io.h>
21#include <linux/clk.h> 20#include <linux/clk.h>
22#include <linux/debugfs.h> 21#include <linux/debugfs.h>
22#include <linux/err.h>
23#include <linux/io.h>
24#include <linux/module.h>
25#include <linux/platform_device.h>
23#include <linux/slab.h> 26#include <linux/slab.h>
24#include <mach/audmux.h> 27#include <mach/audmux.h>
25#include <mach/hardware.h> 28
29#define DRIVER_NAME "imx-audmux"
26 30
27static struct clk *audmux_clk; 31static struct clk *audmux_clk;
28static void __iomem *audmux_base; 32static void __iomem *audmux_base;
@@ -140,7 +144,7 @@ static const struct file_operations audmux_debugfs_fops = {
140 .llseek = default_llseek, 144 .llseek = default_llseek,
141}; 145};
142 146
143static void audmux_debugfs_init(void) 147static void __init audmux_debugfs_init(void)
144{ 148{
145 int i; 149 int i;
146 char buf[20]; 150 char buf[20];
@@ -159,18 +163,48 @@ static void audmux_debugfs_init(void)
159 i); 163 i);
160 } 164 }
161} 165}
166
167static void __exit audmux_debugfs_remove(void)
168{
169 debugfs_remove_recursive(audmux_debugfs_root);
170}
162#else 171#else
163static inline void audmux_debugfs_init(void) 172static inline void audmux_debugfs_init(void)
164{ 173{
165} 174}
175
176static inline void audmux_debugfs_remove(void)
177{
178}
166#endif 179#endif
167 180
181enum imx_audmux_type {
182 IMX21_AUDMUX,
183 IMX31_AUDMUX,
184} audmux_type;
185
186static struct platform_device_id imx_audmux_ids[] = {
187 {
188 .name = "imx21-audmux",
189 .driver_data = IMX21_AUDMUX,
190 }, {
191 .name = "imx31-audmux",
192 .driver_data = IMX31_AUDMUX,
193 }, {
194 /* sentinel */
195 }
196};
197MODULE_DEVICE_TABLE(platform, imx_audmux_ids);
198
168static const uint8_t port_mapping[] = { 199static const uint8_t port_mapping[] = {
169 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c, 200 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c,
170}; 201};
171 202
172int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr) 203int mxc_audmux_v1_configure_port(unsigned int port, unsigned int pcr)
173{ 204{
205 if (audmux_type != IMX21_AUDMUX)
206 return -EINVAL;
207
174 if (!audmux_base) 208 if (!audmux_base)
175 return -ENOSYS; 209 return -ENOSYS;
176 210
@@ -186,6 +220,9 @@ EXPORT_SYMBOL_GPL(mxc_audmux_v1_configure_port);
186int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, 220int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr,
187 unsigned int pdcr) 221 unsigned int pdcr)
188{ 222{
223 if (audmux_type != IMX31_AUDMUX)
224 return -EINVAL;
225
189 if (!audmux_base) 226 if (!audmux_base)
190 return -ENOSYS; 227 return -ENOSYS;
191 228
@@ -202,41 +239,61 @@ int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr,
202} 239}
203EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port); 240EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port);
204 241
205static int mxc_audmux_init(void) 242static int __init imx_audmux_probe(struct platform_device *pdev)
206{ 243{
207 int ret; 244 struct resource *res;
208 if (cpu_is_mx51()) { 245
209 audmux_base = MX51_IO_ADDRESS(MX51_AUDMUX_BASE_ADDR); 246 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
210 } else if (cpu_is_mx31()) { 247 audmux_base = devm_request_and_ioremap(&pdev->dev, res);
211 audmux_base = MX31_IO_ADDRESS(MX31_AUDMUX_BASE_ADDR); 248 if (!audmux_base)
212 } else if (cpu_is_mx35()) { 249 return -EADDRNOTAVAIL;
213 audmux_clk = clk_get(NULL, "audmux"); 250
214 if (IS_ERR(audmux_clk)) { 251 audmux_clk = clk_get(&pdev->dev, "audmux");
215 ret = PTR_ERR(audmux_clk); 252 if (IS_ERR(audmux_clk)) {
216 printk(KERN_ERR "%s: cannot get clock: %d\n", __func__, 253 dev_dbg(&pdev->dev, "cannot get clock: %ld\n",
217 ret); 254 PTR_ERR(audmux_clk));
218 return ret; 255 audmux_clk = NULL;
219 }
220 audmux_base = MX35_IO_ADDRESS(MX35_AUDMUX_BASE_ADDR);
221 } else if (cpu_is_mx25()) {
222 audmux_clk = clk_get(NULL, "audmux");
223 if (IS_ERR(audmux_clk)) {
224 ret = PTR_ERR(audmux_clk);
225 printk(KERN_ERR "%s: cannot get clock: %d\n", __func__,
226 ret);
227 return ret;
228 }
229 audmux_base = MX25_IO_ADDRESS(MX25_AUDMUX_BASE_ADDR);
230 } else if (cpu_is_mx27()) {
231 audmux_base = MX27_IO_ADDRESS(MX27_AUDMUX_BASE_ADDR);
232 } else if (cpu_is_mx21()) {
233 audmux_base = MX21_IO_ADDRESS(MX21_AUDMUX_BASE_ADDR);
234 } 256 }
235 257
236 if (!cpu_is_mx2()) 258 audmux_type = pdev->id_entry->driver_data;
259 if (audmux_type == IMX31_AUDMUX)
237 audmux_debugfs_init(); 260 audmux_debugfs_init();
238 261
239 return 0; 262 return 0;
240} 263}
241 264
242postcore_initcall(mxc_audmux_init); 265static int __exit imx_audmux_remove(struct platform_device *pdev)
266{
267 if (audmux_type == IMX31_AUDMUX)
268 audmux_debugfs_remove();
269 clk_put(audmux_clk);
270
271 return 0;
272}
273
274static struct platform_driver imx_audmux_driver = {
275 .probe = imx_audmux_probe,
276 .remove = __exit_p(imx_audmux_remove),
277 .id_table = imx_audmux_ids,
278 .driver = {
279 .name = DRIVER_NAME,
280 .owner = THIS_MODULE,
281 }
282};
283
284static int __init imx_audmux_init(void)
285{
286 return platform_driver_register(&imx_audmux_driver);
287}
288subsys_initcall(imx_audmux_init);
289
290static void __exit imx_audmux_exit(void)
291{
292 platform_driver_unregister(&imx_audmux_driver);
293}
294module_exit(imx_audmux_exit);
295
296MODULE_DESCRIPTION("Freescale i.MX AUDMUX driver");
297MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
298MODULE_LICENSE("GPL v2");
299MODULE_ALIAS("platform:" DRIVER_NAME);