Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * tegra_i2s.c - Tegra I2S driver |
| 3 | * |
| 4 | * Author: Stephen Warren <swarren@nvidia.com> |
| 5 | * Copyright (C) 2010 - NVIDIA, Inc. |
| 6 | * |
| 7 | * Based on code copyright/by: |
| 8 | * |
| 9 | * Copyright (c) 2009-2010, NVIDIA Corporation. |
| 10 | * Scott Peterson <speterson@nvidia.com> |
| 11 | * |
| 12 | * Copyright (C) 2010 Google, Inc. |
| 13 | * Iliyan Malchev <malchev@google.com> |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License |
| 17 | * version 2 as published by the Free Software Foundation. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, but |
| 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | * General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 27 | * 02110-1301 USA |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <linux/clk.h> |
| 32 | #include <linux/module.h> |
| 33 | #include <linux/debugfs.h> |
| 34 | #include <linux/device.h> |
| 35 | #include <linux/platform_device.h> |
| 36 | #include <linux/seq_file.h> |
| 37 | #include <linux/slab.h> |
| 38 | #include <linux/io.h> |
| 39 | #include <mach/iomap.h> |
| 40 | #include <sound/core.h> |
| 41 | #include <sound/pcm.h> |
| 42 | #include <sound/pcm_params.h> |
| 43 | #include <sound/soc.h> |
| 44 | |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 45 | #include "tegra_i2s.h" |
| 46 | |
| 47 | #define DRV_NAME "tegra-i2s" |
| 48 | |
| 49 | static inline void tegra_i2s_write(struct tegra_i2s *i2s, u32 reg, u32 val) |
| 50 | { |
| 51 | __raw_writel(val, i2s->regs + reg); |
| 52 | } |
| 53 | |
| 54 | static inline u32 tegra_i2s_read(struct tegra_i2s *i2s, u32 reg) |
| 55 | { |
| 56 | return __raw_readl(i2s->regs + reg); |
| 57 | } |
| 58 | |
| 59 | #ifdef CONFIG_DEBUG_FS |
| 60 | static int tegra_i2s_show(struct seq_file *s, void *unused) |
| 61 | { |
| 62 | #define REG(r) { r, #r } |
| 63 | static const struct { |
| 64 | int offset; |
| 65 | const char *name; |
| 66 | } regs[] = { |
| 67 | REG(TEGRA_I2S_CTRL), |
| 68 | REG(TEGRA_I2S_STATUS), |
| 69 | REG(TEGRA_I2S_TIMING), |
| 70 | REG(TEGRA_I2S_FIFO_SCR), |
| 71 | REG(TEGRA_I2S_PCM_CTRL), |
| 72 | REG(TEGRA_I2S_NW_CTRL), |
| 73 | REG(TEGRA_I2S_TDM_CTRL), |
| 74 | REG(TEGRA_I2S_TDM_TX_RX_CTRL), |
| 75 | }; |
| 76 | #undef REG |
| 77 | |
| 78 | struct tegra_i2s *i2s = s->private; |
| 79 | int i; |
| 80 | |
| 81 | for (i = 0; i < ARRAY_SIZE(regs); i++) { |
| 82 | u32 val = tegra_i2s_read(i2s, regs[i].offset); |
| 83 | seq_printf(s, "%s = %08x\n", regs[i].name, val); |
| 84 | } |
| 85 | |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | static int tegra_i2s_debug_open(struct inode *inode, struct file *file) |
| 90 | { |
| 91 | return single_open(file, tegra_i2s_show, inode->i_private); |
| 92 | } |
| 93 | |
| 94 | static const struct file_operations tegra_i2s_debug_fops = { |
| 95 | .open = tegra_i2s_debug_open, |
| 96 | .read = seq_read, |
| 97 | .llseek = seq_lseek, |
| 98 | .release = single_release, |
| 99 | }; |
| 100 | |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 101 | static void tegra_i2s_debug_add(struct tegra_i2s *i2s) |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 102 | { |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 103 | i2s->debug = debugfs_create_file(i2s->dai.name, S_IRUGO, |
| 104 | snd_soc_debugfs_root, i2s, |
| 105 | &tegra_i2s_debug_fops); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static void tegra_i2s_debug_remove(struct tegra_i2s *i2s) |
| 109 | { |
| 110 | if (i2s->debug) |
| 111 | debugfs_remove(i2s->debug); |
| 112 | } |
| 113 | #else |
Stephen Warren | 0dfe8da | 2011-05-16 14:19:27 -0600 | [diff] [blame] | 114 | static inline void tegra_i2s_debug_add(struct tegra_i2s *i2s, int id) |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 115 | { |
| 116 | } |
| 117 | |
| 118 | static inline void tegra_i2s_debug_remove(struct tegra_i2s *i2s) |
| 119 | { |
| 120 | } |
| 121 | #endif |
| 122 | |
| 123 | static int tegra_i2s_set_fmt(struct snd_soc_dai *dai, |
| 124 | unsigned int fmt) |
| 125 | { |
| 126 | struct tegra_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
| 127 | |
| 128 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
| 129 | case SND_SOC_DAIFMT_NB_NF: |
| 130 | break; |
| 131 | default: |
| 132 | return -EINVAL; |
| 133 | } |
| 134 | |
| 135 | i2s->reg_ctrl &= ~TEGRA_I2S_CTRL_MASTER_ENABLE; |
| 136 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 137 | case SND_SOC_DAIFMT_CBS_CFS: |
| 138 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_MASTER_ENABLE; |
| 139 | break; |
| 140 | case SND_SOC_DAIFMT_CBM_CFM: |
| 141 | break; |
| 142 | default: |
| 143 | return -EINVAL; |
| 144 | } |
| 145 | |
| 146 | i2s->reg_ctrl &= ~(TEGRA_I2S_CTRL_BIT_FORMAT_MASK | |
| 147 | TEGRA_I2S_CTRL_LRCK_MASK); |
| 148 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 149 | case SND_SOC_DAIFMT_DSP_A: |
| 150 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_FORMAT_DSP; |
| 151 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_LRCK_L_LOW; |
| 152 | break; |
| 153 | case SND_SOC_DAIFMT_DSP_B: |
| 154 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_FORMAT_DSP; |
| 155 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_LRCK_R_LOW; |
| 156 | break; |
| 157 | case SND_SOC_DAIFMT_I2S: |
| 158 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_FORMAT_I2S; |
| 159 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_LRCK_L_LOW; |
| 160 | break; |
| 161 | case SND_SOC_DAIFMT_RIGHT_J: |
| 162 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_FORMAT_RJM; |
| 163 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_LRCK_L_LOW; |
| 164 | break; |
| 165 | case SND_SOC_DAIFMT_LEFT_J: |
| 166 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_FORMAT_LJM; |
| 167 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_LRCK_L_LOW; |
| 168 | break; |
| 169 | default: |
| 170 | return -EINVAL; |
| 171 | } |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | static int tegra_i2s_hw_params(struct snd_pcm_substream *substream, |
| 177 | struct snd_pcm_hw_params *params, |
| 178 | struct snd_soc_dai *dai) |
| 179 | { |
| 180 | struct device *dev = substream->pcm->card->dev; |
| 181 | struct tegra_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
| 182 | u32 reg; |
| 183 | int ret, sample_size, srate, i2sclock, bitcnt; |
| 184 | |
| 185 | i2s->reg_ctrl &= ~TEGRA_I2S_CTRL_BIT_SIZE_MASK; |
| 186 | switch (params_format(params)) { |
| 187 | case SNDRV_PCM_FORMAT_S16_LE: |
| 188 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_SIZE_16; |
| 189 | sample_size = 16; |
| 190 | break; |
| 191 | case SNDRV_PCM_FORMAT_S24_LE: |
| 192 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_SIZE_24; |
| 193 | sample_size = 24; |
| 194 | break; |
| 195 | case SNDRV_PCM_FORMAT_S32_LE: |
| 196 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_BIT_SIZE_32; |
| 197 | sample_size = 32; |
| 198 | break; |
| 199 | default: |
| 200 | return -EINVAL; |
| 201 | } |
| 202 | |
| 203 | srate = params_rate(params); |
| 204 | |
| 205 | /* Final "* 2" required by Tegra hardware */ |
| 206 | i2sclock = srate * params_channels(params) * sample_size * 2; |
| 207 | |
| 208 | ret = clk_set_rate(i2s->clk_i2s, i2sclock); |
| 209 | if (ret) { |
| 210 | dev_err(dev, "Can't set I2S clock rate: %d\n", ret); |
| 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | bitcnt = (i2sclock / (2 * srate)) - 1; |
| 215 | if (bitcnt < 0 || bitcnt > TEGRA_I2S_TIMING_CHANNEL_BIT_COUNT_MASK_US) |
| 216 | return -EINVAL; |
| 217 | reg = bitcnt << TEGRA_I2S_TIMING_CHANNEL_BIT_COUNT_SHIFT; |
| 218 | |
| 219 | if (i2sclock % (2 * srate)) |
| 220 | reg |= TEGRA_I2S_TIMING_NON_SYM_ENABLE; |
| 221 | |
Stephen Warren | 713d136 | 2011-07-01 13:56:13 -0600 | [diff] [blame] | 222 | if (!i2s->clk_refs) |
| 223 | clk_enable(i2s->clk_i2s); |
| 224 | |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 225 | tegra_i2s_write(i2s, TEGRA_I2S_TIMING, reg); |
| 226 | |
| 227 | tegra_i2s_write(i2s, TEGRA_I2S_FIFO_SCR, |
| 228 | TEGRA_I2S_FIFO_SCR_FIFO2_ATN_LVL_FOUR_SLOTS | |
| 229 | TEGRA_I2S_FIFO_SCR_FIFO1_ATN_LVL_FOUR_SLOTS); |
| 230 | |
Stephen Warren | 713d136 | 2011-07-01 13:56:13 -0600 | [diff] [blame] | 231 | if (!i2s->clk_refs) |
| 232 | clk_disable(i2s->clk_i2s); |
| 233 | |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | static void tegra_i2s_start_playback(struct tegra_i2s *i2s) |
| 238 | { |
| 239 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_FIFO1_ENABLE; |
| 240 | tegra_i2s_write(i2s, TEGRA_I2S_CTRL, i2s->reg_ctrl); |
| 241 | } |
| 242 | |
| 243 | static void tegra_i2s_stop_playback(struct tegra_i2s *i2s) |
| 244 | { |
| 245 | i2s->reg_ctrl &= ~TEGRA_I2S_CTRL_FIFO1_ENABLE; |
| 246 | tegra_i2s_write(i2s, TEGRA_I2S_CTRL, i2s->reg_ctrl); |
| 247 | } |
| 248 | |
| 249 | static void tegra_i2s_start_capture(struct tegra_i2s *i2s) |
| 250 | { |
| 251 | i2s->reg_ctrl |= TEGRA_I2S_CTRL_FIFO2_ENABLE; |
| 252 | tegra_i2s_write(i2s, TEGRA_I2S_CTRL, i2s->reg_ctrl); |
| 253 | } |
| 254 | |
| 255 | static void tegra_i2s_stop_capture(struct tegra_i2s *i2s) |
| 256 | { |
| 257 | i2s->reg_ctrl &= ~TEGRA_I2S_CTRL_FIFO2_ENABLE; |
| 258 | tegra_i2s_write(i2s, TEGRA_I2S_CTRL, i2s->reg_ctrl); |
| 259 | } |
| 260 | |
| 261 | static int tegra_i2s_trigger(struct snd_pcm_substream *substream, int cmd, |
| 262 | struct snd_soc_dai *dai) |
| 263 | { |
| 264 | struct tegra_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
| 265 | |
| 266 | switch (cmd) { |
| 267 | case SNDRV_PCM_TRIGGER_START: |
| 268 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 269 | case SNDRV_PCM_TRIGGER_RESUME: |
| 270 | if (!i2s->clk_refs) |
| 271 | clk_enable(i2s->clk_i2s); |
| 272 | i2s->clk_refs++; |
| 273 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 274 | tegra_i2s_start_playback(i2s); |
| 275 | else |
| 276 | tegra_i2s_start_capture(i2s); |
| 277 | break; |
| 278 | case SNDRV_PCM_TRIGGER_STOP: |
| 279 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
| 280 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 281 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 282 | tegra_i2s_stop_playback(i2s); |
| 283 | else |
| 284 | tegra_i2s_stop_capture(i2s); |
| 285 | i2s->clk_refs--; |
| 286 | if (!i2s->clk_refs) |
| 287 | clk_disable(i2s->clk_i2s); |
| 288 | break; |
| 289 | default: |
| 290 | return -EINVAL; |
| 291 | } |
| 292 | |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | static int tegra_i2s_probe(struct snd_soc_dai *dai) |
| 297 | { |
| 298 | struct tegra_i2s * i2s = snd_soc_dai_get_drvdata(dai); |
| 299 | |
| 300 | dai->capture_dma_data = &i2s->capture_dma_data; |
| 301 | dai->playback_dma_data = &i2s->playback_dma_data; |
| 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
Lars-Peter Clausen | 85e7652 | 2011-11-23 11:40:40 +0100 | [diff] [blame] | 306 | static const struct snd_soc_dai_ops tegra_i2s_dai_ops = { |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 307 | .set_fmt = tegra_i2s_set_fmt, |
| 308 | .hw_params = tegra_i2s_hw_params, |
| 309 | .trigger = tegra_i2s_trigger, |
| 310 | }; |
| 311 | |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 312 | static const struct snd_soc_dai_driver tegra_i2s_dai_template = { |
| 313 | .probe = tegra_i2s_probe, |
| 314 | .playback = { |
| 315 | .channels_min = 2, |
| 316 | .channels_max = 2, |
| 317 | .rates = SNDRV_PCM_RATE_8000_96000, |
| 318 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 319 | }, |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 320 | .capture = { |
| 321 | .channels_min = 2, |
| 322 | .channels_max = 2, |
| 323 | .rates = SNDRV_PCM_RATE_8000_96000, |
| 324 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 325 | }, |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 326 | .ops = &tegra_i2s_dai_ops, |
| 327 | .symmetric_rates = 1, |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 328 | }; |
| 329 | |
| 330 | static __devinit int tegra_i2s_platform_probe(struct platform_device *pdev) |
| 331 | { |
| 332 | struct tegra_i2s * i2s; |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 333 | struct resource *mem, *memregion, *dmareq; |
| 334 | int ret; |
| 335 | |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 336 | i2s = devm_kzalloc(&pdev->dev, sizeof(struct tegra_i2s), GFP_KERNEL); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 337 | if (!i2s) { |
| 338 | dev_err(&pdev->dev, "Can't allocate tegra_i2s\n"); |
| 339 | ret = -ENOMEM; |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 340 | goto err; |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 341 | } |
| 342 | dev_set_drvdata(&pdev->dev, i2s); |
| 343 | |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 344 | i2s->dai = tegra_i2s_dai_template; |
| 345 | i2s->dai.name = dev_name(&pdev->dev); |
| 346 | |
Stephen Warren | b5f9cfe | 2011-07-01 13:56:14 -0600 | [diff] [blame] | 347 | i2s->clk_i2s = clk_get(&pdev->dev, NULL); |
Stephen Warren | 422650e | 2011-01-11 12:48:53 -0700 | [diff] [blame] | 348 | if (IS_ERR(i2s->clk_i2s)) { |
Stephen Warren | 713dce4 | 2011-01-28 14:26:41 -0700 | [diff] [blame] | 349 | dev_err(&pdev->dev, "Can't retrieve i2s clock\n"); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 350 | ret = PTR_ERR(i2s->clk_i2s); |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 351 | goto err; |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 355 | if (!mem) { |
| 356 | dev_err(&pdev->dev, "No memory resource\n"); |
| 357 | ret = -ENODEV; |
| 358 | goto err_clk_put; |
| 359 | } |
| 360 | |
| 361 | dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
| 362 | if (!dmareq) { |
| 363 | dev_err(&pdev->dev, "No DMA resource\n"); |
| 364 | ret = -ENODEV; |
| 365 | goto err_clk_put; |
| 366 | } |
| 367 | |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 368 | memregion = devm_request_mem_region(&pdev->dev, mem->start, |
| 369 | resource_size(mem), DRV_NAME); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 370 | if (!memregion) { |
| 371 | dev_err(&pdev->dev, "Memory region already claimed\n"); |
| 372 | ret = -EBUSY; |
| 373 | goto err_clk_put; |
| 374 | } |
| 375 | |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 376 | i2s->regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 377 | if (!i2s->regs) { |
| 378 | dev_err(&pdev->dev, "ioremap failed\n"); |
| 379 | ret = -ENOMEM; |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 380 | goto err_clk_put; |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | i2s->capture_dma_data.addr = mem->start + TEGRA_I2S_FIFO2; |
| 384 | i2s->capture_dma_data.wrap = 4; |
| 385 | i2s->capture_dma_data.width = 32; |
| 386 | i2s->capture_dma_data.req_sel = dmareq->start; |
| 387 | |
| 388 | i2s->playback_dma_data.addr = mem->start + TEGRA_I2S_FIFO1; |
| 389 | i2s->playback_dma_data.wrap = 4; |
| 390 | i2s->playback_dma_data.width = 32; |
| 391 | i2s->playback_dma_data.req_sel = dmareq->start; |
| 392 | |
| 393 | i2s->reg_ctrl = TEGRA_I2S_CTRL_FIFO_FORMAT_PACKED; |
| 394 | |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 395 | ret = snd_soc_register_dai(&pdev->dev, &i2s->dai); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 396 | if (ret) { |
| 397 | dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); |
| 398 | ret = -ENOMEM; |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 399 | goto err_clk_put; |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 400 | } |
| 401 | |
Stephen Warren | d4a2eca | 2011-11-23 13:33:25 -0700 | [diff] [blame] | 402 | tegra_i2s_debug_add(i2s); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 403 | |
| 404 | return 0; |
| 405 | |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 406 | err_clk_put: |
| 407 | clk_put(i2s->clk_i2s); |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 408 | err: |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 409 | return ret; |
| 410 | } |
| 411 | |
| 412 | static int __devexit tegra_i2s_platform_remove(struct platform_device *pdev) |
| 413 | { |
| 414 | struct tegra_i2s *i2s = dev_get_drvdata(&pdev->dev); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 415 | |
| 416 | snd_soc_unregister_dai(&pdev->dev); |
| 417 | |
| 418 | tegra_i2s_debug_remove(i2s); |
| 419 | |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 420 | clk_put(i2s->clk_i2s); |
| 421 | |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | static struct platform_driver tegra_i2s_driver = { |
| 426 | .driver = { |
| 427 | .name = DRV_NAME, |
| 428 | .owner = THIS_MODULE, |
| 429 | }, |
| 430 | .probe = tegra_i2s_platform_probe, |
| 431 | .remove = __devexit_p(tegra_i2s_platform_remove), |
| 432 | }; |
Stephen Warren | bea0ed0 | 2011-11-22 18:21:16 -0700 | [diff] [blame] | 433 | module_platform_driver(tegra_i2s_driver); |
Stephen Warren | 71f78e2 | 2011-01-07 22:36:14 -0700 | [diff] [blame] | 434 | |
| 435 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); |
| 436 | MODULE_DESCRIPTION("Tegra I2S ASoC driver"); |
| 437 | MODULE_LICENSE("GPL"); |
Stephen Warren | 8eb3420 | 2011-02-10 15:37:19 -0700 | [diff] [blame] | 438 | MODULE_ALIAS("platform:" DRV_NAME); |