Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 1 | /* |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 2 | * Copyright 2012 Freescale Semiconductor, Inc. |
| 3 | * Copyright 2012 Linaro Ltd. |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 4 | * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de> |
| 5 | * |
| 6 | * Initial development of this code was funded by |
| 7 | * Phytec Messtechnik GmbH, http://www.phytec.de |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 18 | */ |
| 19 | |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 20 | #include <linux/clk.h> |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 21 | #include <linux/debugfs.h> |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 22 | #include <linux/err.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/module.h> |
Richard Zhao | 9d5ef26 | 2012-03-05 22:31:04 +0800 | [diff] [blame] | 25 | #include <linux/of.h> |
| 26 | #include <linux/of_device.h> |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 27 | #include <linux/platform_device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 28 | #include <linux/slab.h> |
Shawn Guo | 3c77c29 | 2012-03-05 22:30:53 +0800 | [diff] [blame] | 29 | |
| 30 | #include "imx-audmux.h" |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 31 | |
| 32 | #define DRIVER_NAME "imx-audmux" |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 33 | |
| 34 | static struct clk *audmux_clk; |
| 35 | static void __iomem *audmux_base; |
| 36 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 37 | #define IMX_AUDMUX_V2_PTCR(x) ((x) * 8) |
| 38 | #define IMX_AUDMUX_V2_PDCR(x) ((x) * 8 + 4) |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 39 | |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 40 | #ifdef CONFIG_DEBUG_FS |
| 41 | static struct dentry *audmux_debugfs_root; |
| 42 | |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 43 | /* There is an annoying discontinuity in the SSI numbering with regard |
| 44 | * to the Linux number of the devices */ |
| 45 | static const char *audmux_port_string(int port) |
| 46 | { |
| 47 | switch (port) { |
| 48 | case MX31_AUDMUX_PORT1_SSI0: |
| 49 | return "imx-ssi.0"; |
| 50 | case MX31_AUDMUX_PORT2_SSI1: |
| 51 | return "imx-ssi.1"; |
| 52 | case MX31_AUDMUX_PORT3_SSI_PINS_3: |
| 53 | return "SSI3"; |
| 54 | case MX31_AUDMUX_PORT4_SSI_PINS_4: |
| 55 | return "SSI4"; |
| 56 | case MX31_AUDMUX_PORT5_SSI_PINS_5: |
| 57 | return "SSI5"; |
| 58 | case MX31_AUDMUX_PORT6_SSI_PINS_6: |
| 59 | return "SSI6"; |
| 60 | default: |
| 61 | return "UNKNOWN"; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | static ssize_t audmux_read_file(struct file *file, char __user *user_buf, |
| 66 | size_t count, loff_t *ppos) |
| 67 | { |
| 68 | ssize_t ret; |
Felipe Pena | 1b3ed70 | 2013-10-12 19:35:06 -0300 | [diff] [blame] | 69 | char *buf; |
Mark Brown | e5f8976 | 2014-08-01 17:55:55 +0100 | [diff] [blame] | 70 | uintptr_t port = (uintptr_t)file->private_data; |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 71 | u32 pdcr, ptcr; |
| 72 | |
Fabio Estevam | 7219236 | 2013-07-21 13:39:08 -0300 | [diff] [blame] | 73 | if (audmux_clk) { |
| 74 | ret = clk_prepare_enable(audmux_clk); |
| 75 | if (ret) |
| 76 | return ret; |
| 77 | } |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 78 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 79 | ptcr = readl(audmux_base + IMX_AUDMUX_V2_PTCR(port)); |
| 80 | pdcr = readl(audmux_base + IMX_AUDMUX_V2_PDCR(port)); |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 81 | |
| 82 | if (audmux_clk) |
Linus Torvalds | 3480059 | 2012-03-27 16:41:24 -0700 | [diff] [blame] | 83 | clk_disable_unprepare(audmux_clk); |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 84 | |
Felipe Pena | 1b3ed70 | 2013-10-12 19:35:06 -0300 | [diff] [blame] | 85 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 86 | if (!buf) |
| 87 | return -ENOMEM; |
| 88 | |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 89 | ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n", |
| 90 | pdcr, ptcr); |
| 91 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 92 | if (ptcr & IMX_AUDMUX_V2_PTCR_TFSDIR) |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 93 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 94 | "TxFS output from %s, ", |
| 95 | audmux_port_string((ptcr >> 27) & 0x7)); |
| 96 | else |
| 97 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 98 | "TxFS input, "); |
| 99 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 100 | if (ptcr & IMX_AUDMUX_V2_PTCR_TCLKDIR) |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 101 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 102 | "TxClk output from %s", |
| 103 | audmux_port_string((ptcr >> 22) & 0x7)); |
| 104 | else |
| 105 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 106 | "TxClk input"); |
| 107 | |
| 108 | ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n"); |
| 109 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 110 | if (ptcr & IMX_AUDMUX_V2_PTCR_SYN) { |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 111 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 112 | "Port is symmetric"); |
| 113 | } else { |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 114 | if (ptcr & IMX_AUDMUX_V2_PTCR_RFSDIR) |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 115 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 116 | "RxFS output from %s, ", |
| 117 | audmux_port_string((ptcr >> 17) & 0x7)); |
| 118 | else |
| 119 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 120 | "RxFS input, "); |
| 121 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 122 | if (ptcr & IMX_AUDMUX_V2_PTCR_RCLKDIR) |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 123 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 124 | "RxClk output from %s", |
| 125 | audmux_port_string((ptcr >> 12) & 0x7)); |
| 126 | else |
| 127 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 128 | "RxClk input"); |
| 129 | } |
| 130 | |
| 131 | ret += snprintf(buf + ret, PAGE_SIZE - ret, |
| 132 | "\nData received from %s\n", |
| 133 | audmux_port_string((pdcr >> 13) & 0x7)); |
| 134 | |
| 135 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); |
| 136 | |
| 137 | kfree(buf); |
| 138 | |
| 139 | return ret; |
| 140 | } |
| 141 | |
| 142 | static const struct file_operations audmux_debugfs_fops = { |
Stephen Boyd | 234e340 | 2012-04-05 14:25:11 -0700 | [diff] [blame] | 143 | .open = simple_open, |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 144 | .read = audmux_read_file, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 145 | .llseek = default_llseek, |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
Lars-Peter Clausen | b890978 | 2014-04-24 08:25:56 +0200 | [diff] [blame] | 148 | static void audmux_debugfs_init(void) |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 149 | { |
Mark Brown | e5f8976 | 2014-08-01 17:55:55 +0100 | [diff] [blame] | 150 | uintptr_t i; |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 151 | char buf[20]; |
| 152 | |
| 153 | audmux_debugfs_root = debugfs_create_dir("audmux", NULL); |
| 154 | if (!audmux_debugfs_root) { |
| 155 | pr_warning("Failed to create AUDMUX debugfs root\n"); |
| 156 | return; |
| 157 | } |
| 158 | |
Torben Hohn | 409b78c | 2012-07-18 15:01:17 +0200 | [diff] [blame] | 159 | for (i = 0; i < MX31_AUDMUX_PORT7_SSI_PINS_7 + 1; i++) { |
Mark Brown | e5f8976 | 2014-08-01 17:55:55 +0100 | [diff] [blame] | 160 | snprintf(buf, sizeof(buf), "ssi%lu", i); |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 161 | if (!debugfs_create_file(buf, 0444, audmux_debugfs_root, |
| 162 | (void *)i, &audmux_debugfs_fops)) |
Mark Brown | e5f8976 | 2014-08-01 17:55:55 +0100 | [diff] [blame] | 163 | pr_warning("Failed to create AUDMUX port %lu debugfs file\n", |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 164 | i); |
| 165 | } |
| 166 | } |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 167 | |
Bill Pemberton | a0a3d51 | 2012-12-07 09:26:16 -0500 | [diff] [blame] | 168 | static void audmux_debugfs_remove(void) |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 169 | { |
| 170 | debugfs_remove_recursive(audmux_debugfs_root); |
| 171 | } |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 172 | #else |
| 173 | static inline void audmux_debugfs_init(void) |
| 174 | { |
| 175 | } |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 176 | |
| 177 | static inline void audmux_debugfs_remove(void) |
| 178 | { |
| 179 | } |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 180 | #endif |
| 181 | |
Fabio Estevam | a10807a | 2013-02-11 13:39:08 -0200 | [diff] [blame] | 182 | static enum imx_audmux_type { |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 183 | IMX21_AUDMUX, |
| 184 | IMX31_AUDMUX, |
| 185 | } audmux_type; |
| 186 | |
Krzysztof Kozlowski | e51cebf | 2015-05-02 01:00:13 +0900 | [diff] [blame] | 187 | static const struct platform_device_id imx_audmux_ids[] = { |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 188 | { |
| 189 | .name = "imx21-audmux", |
| 190 | .driver_data = IMX21_AUDMUX, |
| 191 | }, { |
| 192 | .name = "imx31-audmux", |
| 193 | .driver_data = IMX31_AUDMUX, |
| 194 | }, { |
| 195 | /* sentinel */ |
| 196 | } |
| 197 | }; |
| 198 | MODULE_DEVICE_TABLE(platform, imx_audmux_ids); |
| 199 | |
Richard Zhao | 9d5ef26 | 2012-03-05 22:31:04 +0800 | [diff] [blame] | 200 | static const struct of_device_id imx_audmux_dt_ids[] = { |
| 201 | { .compatible = "fsl,imx21-audmux", .data = &imx_audmux_ids[0], }, |
| 202 | { .compatible = "fsl,imx31-audmux", .data = &imx_audmux_ids[1], }, |
| 203 | { /* sentinel */ } |
| 204 | }; |
| 205 | MODULE_DEVICE_TABLE(of, imx_audmux_dt_ids); |
| 206 | |
Shawn Guo | 2405fc9 | 2012-03-05 22:30:51 +0800 | [diff] [blame] | 207 | static const uint8_t port_mapping[] = { |
| 208 | 0x0, 0x4, 0x8, 0x10, 0x14, 0x1c, |
| 209 | }; |
| 210 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 211 | int imx_audmux_v1_configure_port(unsigned int port, unsigned int pcr) |
Shawn Guo | 2405fc9 | 2012-03-05 22:30:51 +0800 | [diff] [blame] | 212 | { |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 213 | if (audmux_type != IMX21_AUDMUX) |
| 214 | return -EINVAL; |
| 215 | |
Shawn Guo | 2405fc9 | 2012-03-05 22:30:51 +0800 | [diff] [blame] | 216 | if (!audmux_base) |
| 217 | return -ENOSYS; |
| 218 | |
| 219 | if (port >= ARRAY_SIZE(port_mapping)) |
| 220 | return -EINVAL; |
| 221 | |
| 222 | writel(pcr, audmux_base + port_mapping[port]); |
| 223 | |
| 224 | return 0; |
| 225 | } |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 226 | EXPORT_SYMBOL_GPL(imx_audmux_v1_configure_port); |
Shawn Guo | 2405fc9 | 2012-03-05 22:30:51 +0800 | [diff] [blame] | 227 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 228 | int imx_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 229 | unsigned int pdcr) |
| 230 | { |
Fabio Estevam | 7219236 | 2013-07-21 13:39:08 -0300 | [diff] [blame] | 231 | int ret; |
| 232 | |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 233 | if (audmux_type != IMX31_AUDMUX) |
| 234 | return -EINVAL; |
| 235 | |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 236 | if (!audmux_base) |
| 237 | return -ENOSYS; |
| 238 | |
Fabio Estevam | 7219236 | 2013-07-21 13:39:08 -0300 | [diff] [blame] | 239 | if (audmux_clk) { |
| 240 | ret = clk_prepare_enable(audmux_clk); |
| 241 | if (ret) |
| 242 | return ret; |
| 243 | } |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 244 | |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 245 | writel(ptcr, audmux_base + IMX_AUDMUX_V2_PTCR(port)); |
| 246 | writel(pdcr, audmux_base + IMX_AUDMUX_V2_PDCR(port)); |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 247 | |
| 248 | if (audmux_clk) |
Linus Torvalds | 3480059 | 2012-03-27 16:41:24 -0700 | [diff] [blame] | 249 | clk_disable_unprepare(audmux_clk); |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 250 | |
| 251 | return 0; |
| 252 | } |
Shawn Guo | af4872f | 2012-03-05 22:30:54 +0800 | [diff] [blame] | 253 | EXPORT_SYMBOL_GPL(imx_audmux_v2_configure_port); |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 254 | |
Markus Pargmann | 8548a46 | 2013-07-27 13:31:52 +0200 | [diff] [blame] | 255 | static int imx_audmux_parse_dt_defaults(struct platform_device *pdev, |
| 256 | struct device_node *of_node) |
| 257 | { |
| 258 | struct device_node *child; |
| 259 | |
| 260 | for_each_available_child_of_node(of_node, child) { |
| 261 | unsigned int port; |
| 262 | unsigned int ptcr = 0; |
| 263 | unsigned int pdcr = 0; |
| 264 | unsigned int pcr = 0; |
| 265 | unsigned int val; |
| 266 | int ret; |
| 267 | int i = 0; |
| 268 | |
| 269 | ret = of_property_read_u32(child, "fsl,audmux-port", &port); |
| 270 | if (ret) { |
| 271 | dev_warn(&pdev->dev, "Failed to get fsl,audmux-port of child node \"%s\"\n", |
| 272 | child->full_name); |
| 273 | continue; |
| 274 | } |
| 275 | if (!of_property_read_bool(child, "fsl,port-config")) { |
| 276 | dev_warn(&pdev->dev, "child node \"%s\" does not have property fsl,port-config\n", |
| 277 | child->full_name); |
| 278 | continue; |
| 279 | } |
| 280 | |
| 281 | for (i = 0; (ret = of_property_read_u32_index(child, |
Markus Pargmann | 9c0aeaa | 2013-08-10 14:55:57 +0200 | [diff] [blame] | 282 | "fsl,port-config", i, &val)) == 0; |
Markus Pargmann | 8548a46 | 2013-07-27 13:31:52 +0200 | [diff] [blame] | 283 | ++i) { |
| 284 | if (audmux_type == IMX31_AUDMUX) { |
| 285 | if (i % 2) |
| 286 | pdcr |= val; |
| 287 | else |
| 288 | ptcr |= val; |
| 289 | } else { |
| 290 | pcr |= val; |
| 291 | } |
| 292 | } |
| 293 | |
Markus Pargmann | 9c0aeaa | 2013-08-10 14:55:57 +0200 | [diff] [blame] | 294 | if (ret != -EOVERFLOW) { |
Markus Pargmann | 8548a46 | 2013-07-27 13:31:52 +0200 | [diff] [blame] | 295 | dev_err(&pdev->dev, "Failed to read u32 at index %d of child %s\n", |
| 296 | i, child->full_name); |
| 297 | continue; |
| 298 | } |
| 299 | |
| 300 | if (audmux_type == IMX31_AUDMUX) { |
| 301 | if (i % 2) { |
| 302 | dev_err(&pdev->dev, "One pdcr value is missing in child node %s\n", |
| 303 | child->full_name); |
| 304 | continue; |
| 305 | } |
| 306 | imx_audmux_v2_configure_port(port, ptcr, pdcr); |
| 307 | } else { |
| 308 | imx_audmux_v1_configure_port(port, pcr); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | return 0; |
| 313 | } |
| 314 | |
Bill Pemberton | a0a3d51 | 2012-12-07 09:26:16 -0500 | [diff] [blame] | 315 | static int imx_audmux_probe(struct platform_device *pdev) |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 316 | { |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 317 | struct resource *res; |
Richard Zhao | 9d5ef26 | 2012-03-05 22:31:04 +0800 | [diff] [blame] | 318 | const struct of_device_id *of_id = |
| 319 | of_match_device(imx_audmux_dt_ids, &pdev->dev); |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 320 | |
| 321 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Thierry Reding | b25b5aa | 2013-01-21 11:09:26 +0100 | [diff] [blame] | 322 | audmux_base = devm_ioremap_resource(&pdev->dev, res); |
| 323 | if (IS_ERR(audmux_base)) |
| 324 | return PTR_ERR(audmux_base); |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 325 | |
Fabio Estevam | 127c5ca | 2013-03-12 20:51:28 -0300 | [diff] [blame] | 326 | audmux_clk = devm_clk_get(&pdev->dev, "audmux"); |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 327 | if (IS_ERR(audmux_clk)) { |
| 328 | dev_dbg(&pdev->dev, "cannot get clock: %ld\n", |
| 329 | PTR_ERR(audmux_clk)); |
| 330 | audmux_clk = NULL; |
Eric BĂ©nard | 8402ed3 | 2010-06-08 11:03:00 +0200 | [diff] [blame] | 331 | } |
Sascha Hauer | 56c6b87 | 2011-08-23 21:24:57 +0200 | [diff] [blame] | 332 | |
Richard Zhao | 9d5ef26 | 2012-03-05 22:31:04 +0800 | [diff] [blame] | 333 | if (of_id) |
| 334 | pdev->id_entry = of_id->data; |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 335 | audmux_type = pdev->id_entry->driver_data; |
| 336 | if (audmux_type == IMX31_AUDMUX) |
Shawn Guo | 2405fc9 | 2012-03-05 22:30:51 +0800 | [diff] [blame] | 337 | audmux_debugfs_init(); |
Mark Brown | 7b4e08a | 2010-01-11 16:33:18 +0000 | [diff] [blame] | 338 | |
Fabio Estevam | bae3599 | 2013-09-03 15:14:12 -0300 | [diff] [blame] | 339 | if (of_id) |
| 340 | imx_audmux_parse_dt_defaults(pdev, pdev->dev.of_node); |
Markus Pargmann | 8548a46 | 2013-07-27 13:31:52 +0200 | [diff] [blame] | 341 | |
Sascha Hauer | 9eedbdf | 2009-10-29 17:12:39 +0100 | [diff] [blame] | 342 | return 0; |
| 343 | } |
| 344 | |
Bill Pemberton | a0a3d51 | 2012-12-07 09:26:16 -0500 | [diff] [blame] | 345 | static int imx_audmux_remove(struct platform_device *pdev) |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 346 | { |
| 347 | if (audmux_type == IMX31_AUDMUX) |
| 348 | audmux_debugfs_remove(); |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | static struct platform_driver imx_audmux_driver = { |
| 354 | .probe = imx_audmux_probe, |
Bill Pemberton | a0a3d51 | 2012-12-07 09:26:16 -0500 | [diff] [blame] | 355 | .remove = imx_audmux_remove, |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 356 | .id_table = imx_audmux_ids, |
| 357 | .driver = { |
| 358 | .name = DRIVER_NAME, |
Richard Zhao | 9d5ef26 | 2012-03-05 22:31:04 +0800 | [diff] [blame] | 359 | .of_match_table = imx_audmux_dt_ids, |
Richard Zhao | 3bc34a6 | 2012-03-05 22:30:52 +0800 | [diff] [blame] | 360 | } |
| 361 | }; |
| 362 | |
| 363 | static int __init imx_audmux_init(void) |
| 364 | { |
| 365 | return platform_driver_register(&imx_audmux_driver); |
| 366 | } |
| 367 | subsys_initcall(imx_audmux_init); |
| 368 | |
| 369 | static void __exit imx_audmux_exit(void) |
| 370 | { |
| 371 | platform_driver_unregister(&imx_audmux_driver); |
| 372 | } |
| 373 | module_exit(imx_audmux_exit); |
| 374 | |
| 375 | MODULE_DESCRIPTION("Freescale i.MX AUDMUX driver"); |
| 376 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
| 377 | MODULE_LICENSE("GPL v2"); |
| 378 | MODULE_ALIAS("platform:" DRIVER_NAME); |