24 #include <linux/module.h>
28 #include <linux/slab.h>
33 #define DRIVER_NAME "imx-audmux"
35 static struct clk *audmux_clk;
36 static void __iomem *audmux_base;
38 #define IMX_AUDMUX_V2_PTCR(x) ((x) * 8)
39 #define IMX_AUDMUX_V2_PDCR(x) ((x) * 8 + 4)
41 #ifdef CONFIG_DEBUG_FS
42 static struct dentry *audmux_debugfs_root;
46 static const char *audmux_port_string(
int port)
66 static ssize_t audmux_read_file(
struct file *
file,
char __user *user_buf,
67 size_t count, loff_t *ppos)
78 clk_prepare_enable(audmux_clk);
84 clk_disable_unprepare(audmux_clk);
91 "TxFS output from %s, ",
92 audmux_port_string((ptcr >> 27) & 0x7));
99 "TxClk output from %s",
100 audmux_port_string((ptcr >> 22) & 0x7));
109 "Port is symmetric");
113 "RxFS output from %s, ",
114 audmux_port_string((ptcr >> 17) & 0x7));
121 "RxClk output from %s",
122 audmux_port_string((ptcr >> 12) & 0x7));
129 "\nData received from %s\n",
130 audmux_port_string((pdcr >> 13) & 0x7));
141 .read = audmux_read_file,
145 static void __init audmux_debugfs_init(
void)
151 if (!audmux_debugfs_root) {
152 pr_warning(
"Failed to create AUDMUX debugfs root\n");
157 snprintf(buf,
sizeof(buf),
"ssi%d", i);
159 (
void *)i, &audmux_debugfs_fops))
160 pr_warning(
"Failed to create AUDMUX port %d debugfs file\n",
165 static void __devexit audmux_debugfs_remove(
void)
170 static inline void audmux_debugfs_init(
void)
174 static inline void audmux_debugfs_remove(
void)
186 .name =
"imx21-audmux",
189 .name =
"imx31-audmux",
197 static const struct of_device_id imx_audmux_dt_ids[] = {
198 { .compatible =
"fsl,imx21-audmux", .data = &imx_audmux_ids[0], },
199 { .compatible =
"fsl,imx31-audmux", .data = &imx_audmux_ids[1], },
204 static const uint8_t port_mapping[] = {
205 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c,
219 writel(pcr, audmux_base + port_mapping[port]);
235 clk_prepare_enable(audmux_clk);
241 clk_disable_unprepare(audmux_clk);
259 pinctrl = devm_pinctrl_get_select_default(&pdev->
dev);
260 if (IS_ERR(pinctrl)) {
262 return PTR_ERR(pinctrl);
266 if (IS_ERR(audmux_clk)) {
267 dev_dbg(&pdev->
dev,
"cannot get clock: %ld\n",
268 PTR_ERR(audmux_clk));
276 audmux_debugfs_init();
284 audmux_debugfs_remove();
291 .probe = imx_audmux_probe,
293 .id_table = imx_audmux_ids,
297 .of_match_table = imx_audmux_dt_ids,
301 static int __init imx_audmux_init(
void)
307 static void __exit imx_audmux_exit(
void)