Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 1 | /* sound/soc/s3c24xx/s3c-i2c-v2.c |
| 2 | * |
| 3 | * ALSA Soc Audio Layer - I2S core for newer Samsung SoCs. |
| 4 | * |
| 5 | * Copyright (c) 2006 Wolfson Microelectronics PLC. |
| 6 | * Graeme Gregory graeme.gregory@wolfsonmicro.com |
| 7 | * linux@wolfsonmicro.com |
| 8 | * |
| 9 | * Copyright (c) 2008, 2007, 2004-2005 Simtec Electronics |
| 10 | * http://armlinux.simtec.co.uk/ |
| 11 | * Ben Dooks <ben@simtec.co.uk> |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify it |
| 14 | * under the terms of the GNU General Public License as published by the |
| 15 | * Free Software Foundation; either version 2 of the License, or (at your |
| 16 | * option) any later version. |
| 17 | */ |
| 18 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 19 | #include <linux/delay.h> |
| 20 | #include <linux/clk.h> |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 21 | #include <linux/io.h> |
| 22 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 23 | #include <sound/pcm.h> |
| 24 | #include <sound/pcm_params.h> |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 25 | #include <sound/soc.h> |
| 26 | |
| 27 | #include <plat/regs-s3c2412-iis.h> |
| 28 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 29 | #include <mach/dma.h> |
| 30 | |
| 31 | #include "s3c-i2s-v2.h" |
Jassi Brar | d3ff5a3 | 2009-11-17 16:53:31 +0900 | [diff] [blame] | 32 | #include "s3c-dma.h" |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 33 | |
Mark Brown | 8a0f62b | 2009-04-29 20:28:47 +0100 | [diff] [blame] | 34 | #undef S3C_IIS_V2_SUPPORTED |
| 35 | |
| 36 | #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) |
| 37 | #define S3C_IIS_V2_SUPPORTED |
| 38 | #endif |
| 39 | |
| 40 | #ifdef CONFIG_PLAT_S3C64XX |
| 41 | #define S3C_IIS_V2_SUPPORTED |
| 42 | #endif |
| 43 | |
| 44 | #ifndef S3C_IIS_V2_SUPPORTED |
| 45 | #error Unsupported CPU model |
| 46 | #endif |
| 47 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 48 | #define S3C2412_I2S_DEBUG_CON 0 |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 49 | |
| 50 | static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) |
| 51 | { |
| 52 | return cpu_dai->private_data; |
| 53 | } |
| 54 | |
| 55 | #define bit_set(v, b) (((v) & (b)) ? 1 : 0) |
| 56 | |
| 57 | #if S3C2412_I2S_DEBUG_CON |
| 58 | static void dbg_showcon(const char *fn, u32 con) |
| 59 | { |
| 60 | printk(KERN_DEBUG "%s: LRI=%d, TXFEMPT=%d, RXFEMPT=%d, TXFFULL=%d, RXFFULL=%d\n", fn, |
| 61 | bit_set(con, S3C2412_IISCON_LRINDEX), |
| 62 | bit_set(con, S3C2412_IISCON_TXFIFO_EMPTY), |
| 63 | bit_set(con, S3C2412_IISCON_RXFIFO_EMPTY), |
| 64 | bit_set(con, S3C2412_IISCON_TXFIFO_FULL), |
| 65 | bit_set(con, S3C2412_IISCON_RXFIFO_FULL)); |
| 66 | |
| 67 | printk(KERN_DEBUG "%s: PAUSE: TXDMA=%d, RXDMA=%d, TXCH=%d, RXCH=%d\n", |
| 68 | fn, |
| 69 | bit_set(con, S3C2412_IISCON_TXDMA_PAUSE), |
| 70 | bit_set(con, S3C2412_IISCON_RXDMA_PAUSE), |
| 71 | bit_set(con, S3C2412_IISCON_TXCH_PAUSE), |
| 72 | bit_set(con, S3C2412_IISCON_RXCH_PAUSE)); |
| 73 | printk(KERN_DEBUG "%s: ACTIVE: TXDMA=%d, RXDMA=%d, IIS=%d\n", fn, |
| 74 | bit_set(con, S3C2412_IISCON_TXDMA_ACTIVE), |
| 75 | bit_set(con, S3C2412_IISCON_RXDMA_ACTIVE), |
| 76 | bit_set(con, S3C2412_IISCON_IIS_ACTIVE)); |
| 77 | } |
| 78 | #else |
| 79 | static inline void dbg_showcon(const char *fn, u32 con) |
| 80 | { |
| 81 | } |
| 82 | #endif |
| 83 | |
| 84 | |
| 85 | /* Turn on or off the transmission path. */ |
Mark Brown | abbc8246 | 2009-04-30 13:21:52 +0100 | [diff] [blame] | 86 | static void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 87 | { |
| 88 | void __iomem *regs = i2s->regs; |
| 89 | u32 fic, con, mod; |
| 90 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 91 | pr_debug("%s(%d)\n", __func__, on); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 92 | |
| 93 | fic = readl(regs + S3C2412_IISFIC); |
| 94 | con = readl(regs + S3C2412_IISCON); |
| 95 | mod = readl(regs + S3C2412_IISMOD); |
| 96 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 97 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 98 | |
| 99 | if (on) { |
| 100 | con |= S3C2412_IISCON_TXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; |
| 101 | con &= ~S3C2412_IISCON_TXDMA_PAUSE; |
| 102 | con &= ~S3C2412_IISCON_TXCH_PAUSE; |
| 103 | |
| 104 | switch (mod & S3C2412_IISMOD_MODE_MASK) { |
| 105 | case S3C2412_IISMOD_MODE_TXONLY: |
| 106 | case S3C2412_IISMOD_MODE_TXRX: |
| 107 | /* do nothing, we are in the right mode */ |
| 108 | break; |
| 109 | |
| 110 | case S3C2412_IISMOD_MODE_RXONLY: |
| 111 | mod &= ~S3C2412_IISMOD_MODE_MASK; |
| 112 | mod |= S3C2412_IISMOD_MODE_TXRX; |
| 113 | break; |
| 114 | |
| 115 | default: |
Mark Brown | abbc8246 | 2009-04-30 13:21:52 +0100 | [diff] [blame] | 116 | dev_err(i2s->dev, "TXEN: Invalid MODE %x in IISMOD\n", |
| 117 | mod & S3C2412_IISMOD_MODE_MASK); |
| 118 | break; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | writel(con, regs + S3C2412_IISCON); |
| 122 | writel(mod, regs + S3C2412_IISMOD); |
| 123 | } else { |
| 124 | /* Note, we do not have any indication that the FIFO problems |
| 125 | * tha the S3C2410/2440 had apply here, so we should be able |
| 126 | * to disable the DMA and TX without resetting the FIFOS. |
| 127 | */ |
| 128 | |
| 129 | con |= S3C2412_IISCON_TXDMA_PAUSE; |
| 130 | con |= S3C2412_IISCON_TXCH_PAUSE; |
| 131 | con &= ~S3C2412_IISCON_TXDMA_ACTIVE; |
| 132 | |
| 133 | switch (mod & S3C2412_IISMOD_MODE_MASK) { |
| 134 | case S3C2412_IISMOD_MODE_TXRX: |
| 135 | mod &= ~S3C2412_IISMOD_MODE_MASK; |
| 136 | mod |= S3C2412_IISMOD_MODE_RXONLY; |
| 137 | break; |
| 138 | |
| 139 | case S3C2412_IISMOD_MODE_TXONLY: |
| 140 | mod &= ~S3C2412_IISMOD_MODE_MASK; |
| 141 | con &= ~S3C2412_IISCON_IIS_ACTIVE; |
| 142 | break; |
| 143 | |
| 144 | default: |
Mark Brown | abbc8246 | 2009-04-30 13:21:52 +0100 | [diff] [blame] | 145 | dev_err(i2s->dev, "TXDIS: Invalid MODE %x in IISMOD\n", |
| 146 | mod & S3C2412_IISMOD_MODE_MASK); |
| 147 | break; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | writel(mod, regs + S3C2412_IISMOD); |
| 151 | writel(con, regs + S3C2412_IISCON); |
| 152 | } |
| 153 | |
| 154 | fic = readl(regs + S3C2412_IISFIC); |
| 155 | dbg_showcon(__func__, con); |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 156 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 157 | } |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 158 | |
Mark Brown | abbc8246 | 2009-04-30 13:21:52 +0100 | [diff] [blame] | 159 | static void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 160 | { |
| 161 | void __iomem *regs = i2s->regs; |
| 162 | u32 fic, con, mod; |
| 163 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 164 | pr_debug("%s(%d)\n", __func__, on); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 165 | |
| 166 | fic = readl(regs + S3C2412_IISFIC); |
| 167 | con = readl(regs + S3C2412_IISCON); |
| 168 | mod = readl(regs + S3C2412_IISMOD); |
| 169 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 170 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 171 | |
| 172 | if (on) { |
| 173 | con |= S3C2412_IISCON_RXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; |
| 174 | con &= ~S3C2412_IISCON_RXDMA_PAUSE; |
| 175 | con &= ~S3C2412_IISCON_RXCH_PAUSE; |
| 176 | |
| 177 | switch (mod & S3C2412_IISMOD_MODE_MASK) { |
| 178 | case S3C2412_IISMOD_MODE_TXRX: |
| 179 | case S3C2412_IISMOD_MODE_RXONLY: |
| 180 | /* do nothing, we are in the right mode */ |
| 181 | break; |
| 182 | |
| 183 | case S3C2412_IISMOD_MODE_TXONLY: |
| 184 | mod &= ~S3C2412_IISMOD_MODE_MASK; |
| 185 | mod |= S3C2412_IISMOD_MODE_TXRX; |
| 186 | break; |
| 187 | |
| 188 | default: |
Mark Brown | abbc8246 | 2009-04-30 13:21:52 +0100 | [diff] [blame] | 189 | dev_err(i2s->dev, "RXEN: Invalid MODE %x in IISMOD\n", |
| 190 | mod & S3C2412_IISMOD_MODE_MASK); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | writel(mod, regs + S3C2412_IISMOD); |
| 194 | writel(con, regs + S3C2412_IISCON); |
| 195 | } else { |
| 196 | /* See txctrl notes on FIFOs. */ |
| 197 | |
| 198 | con &= ~S3C2412_IISCON_RXDMA_ACTIVE; |
| 199 | con |= S3C2412_IISCON_RXDMA_PAUSE; |
| 200 | con |= S3C2412_IISCON_RXCH_PAUSE; |
| 201 | |
| 202 | switch (mod & S3C2412_IISMOD_MODE_MASK) { |
| 203 | case S3C2412_IISMOD_MODE_RXONLY: |
| 204 | con &= ~S3C2412_IISCON_IIS_ACTIVE; |
| 205 | mod &= ~S3C2412_IISMOD_MODE_MASK; |
| 206 | break; |
| 207 | |
| 208 | case S3C2412_IISMOD_MODE_TXRX: |
| 209 | mod &= ~S3C2412_IISMOD_MODE_MASK; |
| 210 | mod |= S3C2412_IISMOD_MODE_TXONLY; |
| 211 | break; |
| 212 | |
| 213 | default: |
Mark Brown | abbc8246 | 2009-04-30 13:21:52 +0100 | [diff] [blame] | 214 | dev_err(i2s->dev, "RXDIS: Invalid MODE %x in IISMOD\n", |
| 215 | mod & S3C2412_IISMOD_MODE_MASK); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | writel(con, regs + S3C2412_IISCON); |
| 219 | writel(mod, regs + S3C2412_IISMOD); |
| 220 | } |
| 221 | |
| 222 | fic = readl(regs + S3C2412_IISFIC); |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 223 | pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 224 | } |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 225 | |
Jassi | fa68e00 | 2009-09-15 19:02:37 +0900 | [diff] [blame] | 226 | #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) |
| 227 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 228 | /* |
| 229 | * Wait for the LR signal to allow synchronisation to the L/R clock |
| 230 | * from the codec. May only be needed for slave mode. |
| 231 | */ |
| 232 | static int s3c2412_snd_lrsync(struct s3c_i2sv2_info *i2s) |
| 233 | { |
| 234 | u32 iiscon; |
Jassi | fa68e00 | 2009-09-15 19:02:37 +0900 | [diff] [blame] | 235 | unsigned long loops = msecs_to_loops(5); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 236 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 237 | pr_debug("Entered %s\n", __func__); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 238 | |
Jassi | fa68e00 | 2009-09-15 19:02:37 +0900 | [diff] [blame] | 239 | while (--loops) { |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 240 | iiscon = readl(i2s->regs + S3C2412_IISCON); |
| 241 | if (iiscon & S3C2412_IISCON_LRINDEX) |
| 242 | break; |
| 243 | |
Jassi | fa68e00 | 2009-09-15 19:02:37 +0900 | [diff] [blame] | 244 | cpu_relax(); |
| 245 | } |
| 246 | |
| 247 | if (!loops) { |
| 248 | printk(KERN_ERR "%s: timeout\n", __func__); |
| 249 | return -ETIMEDOUT; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | * Set S3C2412 I2S DAI format |
| 257 | */ |
| 258 | static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, |
| 259 | unsigned int fmt) |
| 260 | { |
| 261 | struct s3c_i2sv2_info *i2s = to_info(cpu_dai); |
| 262 | u32 iismod; |
| 263 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 264 | pr_debug("Entered %s\n", __func__); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 265 | |
| 266 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 267 | pr_debug("hw_params r: IISMOD: %x \n", iismod); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 268 | |
| 269 | #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) |
| 270 | #define IISMOD_MASTER_MASK S3C2412_IISMOD_MASTER_MASK |
| 271 | #define IISMOD_SLAVE S3C2412_IISMOD_SLAVE |
| 272 | #define IISMOD_MASTER S3C2412_IISMOD_MASTER_INTERNAL |
| 273 | #endif |
| 274 | |
| 275 | #if defined(CONFIG_PLAT_S3C64XX) |
| 276 | /* From Rev1.1 datasheet, we have two master and two slave modes: |
| 277 | * IMS[11:10]: |
| 278 | * 00 = master mode, fed from PCLK |
| 279 | * 01 = master mode, fed from CLKAUDIO |
| 280 | * 10 = slave mode, using PCLK |
| 281 | * 11 = slave mode, using I2SCLK |
| 282 | */ |
| 283 | #define IISMOD_MASTER_MASK (1 << 11) |
| 284 | #define IISMOD_SLAVE (1 << 11) |
Mark Brown | 553b1dd | 2009-04-29 20:29:25 +0100 | [diff] [blame] | 285 | #define IISMOD_MASTER (0 << 11) |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 286 | #endif |
| 287 | |
| 288 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 289 | case SND_SOC_DAIFMT_CBM_CFM: |
| 290 | i2s->master = 0; |
| 291 | iismod &= ~IISMOD_MASTER_MASK; |
| 292 | iismod |= IISMOD_SLAVE; |
| 293 | break; |
| 294 | case SND_SOC_DAIFMT_CBS_CFS: |
| 295 | i2s->master = 1; |
| 296 | iismod &= ~IISMOD_MASTER_MASK; |
| 297 | iismod |= IISMOD_MASTER; |
| 298 | break; |
| 299 | default: |
Mark Brown | 38e43c8 | 2009-04-30 13:14:38 +0100 | [diff] [blame] | 300 | pr_err("unknwon master/slave format\n"); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 301 | return -EINVAL; |
| 302 | } |
| 303 | |
| 304 | iismod &= ~S3C2412_IISMOD_SDF_MASK; |
| 305 | |
| 306 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 307 | case SND_SOC_DAIFMT_RIGHT_J: |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 308 | iismod |= S3C2412_IISMOD_LR_RLOW; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 309 | iismod |= S3C2412_IISMOD_SDF_MSB; |
| 310 | break; |
| 311 | case SND_SOC_DAIFMT_LEFT_J: |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 312 | iismod |= S3C2412_IISMOD_LR_RLOW; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 313 | iismod |= S3C2412_IISMOD_SDF_LSB; |
| 314 | break; |
| 315 | case SND_SOC_DAIFMT_I2S: |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 316 | iismod &= ~S3C2412_IISMOD_LR_RLOW; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 317 | iismod |= S3C2412_IISMOD_SDF_IIS; |
| 318 | break; |
| 319 | default: |
Mark Brown | 38e43c8 | 2009-04-30 13:14:38 +0100 | [diff] [blame] | 320 | pr_err("Unknown data format\n"); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 321 | return -EINVAL; |
| 322 | } |
| 323 | |
| 324 | writel(iismod, i2s->regs + S3C2412_IISMOD); |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 325 | pr_debug("hw_params w: IISMOD: %x \n", iismod); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
Jassi Brar | 9c9b125 | 2010-03-10 16:48:58 +0900 | [diff] [blame] | 329 | static int s3c_i2sv2_hw_params(struct snd_pcm_substream *substream, |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 330 | struct snd_pcm_hw_params *params, |
| 331 | struct snd_soc_dai *socdai) |
| 332 | { |
| 333 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 334 | struct snd_soc_dai_link *dai = rtd->dai; |
| 335 | struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai); |
Daniel Mack | fd23b7d | 2010-03-19 14:52:55 +0000 | [diff] [blame^] | 336 | struct s3c_dma_params *dma_data; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 337 | u32 iismod; |
| 338 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 339 | pr_debug("Entered %s\n", __func__); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 340 | |
| 341 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
Daniel Mack | fd23b7d | 2010-03-19 14:52:55 +0000 | [diff] [blame^] | 342 | dma_data = i2s->dma_playback; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 343 | else |
Daniel Mack | fd23b7d | 2010-03-19 14:52:55 +0000 | [diff] [blame^] | 344 | dma_data = i2s->dma_capture; |
| 345 | |
| 346 | snd_soc_dai_set_dma_data(dai->cpu_dai, substream, dma_data); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 347 | |
| 348 | /* Working copies of register */ |
| 349 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 350 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 351 | |
Jassi Brar | bf32882 | 2010-03-10 16:48:52 +0900 | [diff] [blame] | 352 | iismod &= ~S3C64XX_IISMOD_BLC_MASK; |
Mark Brown | 553b1dd | 2009-04-29 20:29:25 +0100 | [diff] [blame] | 353 | /* Sample size */ |
| 354 | switch (params_format(params)) { |
| 355 | case SNDRV_PCM_FORMAT_S8: |
Jassi Brar | bf32882 | 2010-03-10 16:48:52 +0900 | [diff] [blame] | 356 | iismod |= S3C64XX_IISMOD_BLC_8BIT; |
Mark Brown | 553b1dd | 2009-04-29 20:29:25 +0100 | [diff] [blame] | 357 | break; |
| 358 | case SNDRV_PCM_FORMAT_S16_LE: |
Mark Brown | 553b1dd | 2009-04-29 20:29:25 +0100 | [diff] [blame] | 359 | break; |
| 360 | case SNDRV_PCM_FORMAT_S24_LE: |
Jassi Brar | bf32882 | 2010-03-10 16:48:52 +0900 | [diff] [blame] | 361 | iismod |= S3C64XX_IISMOD_BLC_24BIT; |
Mark Brown | 553b1dd | 2009-04-29 20:29:25 +0100 | [diff] [blame] | 362 | break; |
| 363 | } |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 364 | |
| 365 | writel(iismod, i2s->regs + S3C2412_IISMOD); |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 366 | pr_debug("%s: w: IISMOD: %x\n", __func__, iismod); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, |
| 371 | struct snd_soc_dai *dai) |
| 372 | { |
| 373 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 374 | struct s3c_i2sv2_info *i2s = to_info(rtd->dai->cpu_dai); |
| 375 | int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); |
| 376 | unsigned long irqs; |
| 377 | int ret = 0; |
Daniel Mack | fd23b7d | 2010-03-19 14:52:55 +0000 | [diff] [blame^] | 378 | struct s3c_dma_params *dma_data = |
| 379 | snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 380 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 381 | pr_debug("Entered %s\n", __func__); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 382 | |
| 383 | switch (cmd) { |
| 384 | case SNDRV_PCM_TRIGGER_START: |
| 385 | /* On start, ensure that the FIFOs are cleared and reset. */ |
| 386 | |
| 387 | writel(capture ? S3C2412_IISFIC_RXFLUSH : S3C2412_IISFIC_TXFLUSH, |
| 388 | i2s->regs + S3C2412_IISFIC); |
| 389 | |
| 390 | /* clear again, just in case */ |
| 391 | writel(0x0, i2s->regs + S3C2412_IISFIC); |
| 392 | |
| 393 | case SNDRV_PCM_TRIGGER_RESUME: |
| 394 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 395 | if (!i2s->master) { |
| 396 | ret = s3c2412_snd_lrsync(i2s); |
| 397 | if (ret) |
| 398 | goto exit_err; |
| 399 | } |
| 400 | |
| 401 | local_irq_save(irqs); |
| 402 | |
| 403 | if (capture) |
| 404 | s3c2412_snd_rxctrl(i2s, 1); |
| 405 | else |
| 406 | s3c2412_snd_txctrl(i2s, 1); |
| 407 | |
| 408 | local_irq_restore(irqs); |
Shine Liu | faf907c | 2009-08-25 20:05:50 +0800 | [diff] [blame] | 409 | |
| 410 | /* |
| 411 | * Load the next buffer to DMA to meet the reqirement |
| 412 | * of the auto reload mechanism of S3C24XX. |
| 413 | * This call won't bother S3C64XX. |
| 414 | */ |
Daniel Mack | fd23b7d | 2010-03-19 14:52:55 +0000 | [diff] [blame^] | 415 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); |
Shine Liu | faf907c | 2009-08-25 20:05:50 +0800 | [diff] [blame] | 416 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 417 | break; |
| 418 | |
| 419 | case SNDRV_PCM_TRIGGER_STOP: |
| 420 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 421 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
| 422 | local_irq_save(irqs); |
| 423 | |
| 424 | if (capture) |
| 425 | s3c2412_snd_rxctrl(i2s, 0); |
| 426 | else |
| 427 | s3c2412_snd_txctrl(i2s, 0); |
| 428 | |
| 429 | local_irq_restore(irqs); |
| 430 | break; |
| 431 | default: |
| 432 | ret = -EINVAL; |
| 433 | break; |
| 434 | } |
| 435 | |
| 436 | exit_err: |
| 437 | return ret; |
| 438 | } |
| 439 | |
| 440 | /* |
| 441 | * Set S3C2412 Clock dividers |
| 442 | */ |
| 443 | static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, |
| 444 | int div_id, int div) |
| 445 | { |
| 446 | struct s3c_i2sv2_info *i2s = to_info(cpu_dai); |
| 447 | u32 reg; |
| 448 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 449 | pr_debug("%s(%p, %d, %d)\n", __func__, cpu_dai, div_id, div); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 450 | |
| 451 | switch (div_id) { |
| 452 | case S3C_I2SV2_DIV_BCLK: |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 453 | switch (div) { |
| 454 | case 16: |
| 455 | div = S3C2412_IISMOD_BCLK_16FS; |
| 456 | break; |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 457 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 458 | case 32: |
| 459 | div = S3C2412_IISMOD_BCLK_32FS; |
| 460 | break; |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 461 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 462 | case 24: |
| 463 | div = S3C2412_IISMOD_BCLK_24FS; |
| 464 | break; |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 465 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 466 | case 48: |
| 467 | div = S3C2412_IISMOD_BCLK_48FS; |
| 468 | break; |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 469 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 470 | default: |
| 471 | return -EINVAL; |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 472 | } |
| 473 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 474 | reg = readl(i2s->regs + S3C2412_IISMOD); |
| 475 | reg &= ~S3C2412_IISMOD_BCLK_MASK; |
| 476 | writel(reg | div, i2s->regs + S3C2412_IISMOD); |
| 477 | |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 478 | pr_debug("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 479 | break; |
| 480 | |
| 481 | case S3C_I2SV2_DIV_RCLK: |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 482 | switch (div) { |
| 483 | case 256: |
| 484 | div = S3C2412_IISMOD_RCLK_256FS; |
| 485 | break; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 486 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 487 | case 384: |
| 488 | div = S3C2412_IISMOD_RCLK_384FS; |
| 489 | break; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 490 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 491 | case 512: |
| 492 | div = S3C2412_IISMOD_RCLK_512FS; |
| 493 | break; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 494 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 495 | case 768: |
| 496 | div = S3C2412_IISMOD_RCLK_768FS; |
| 497 | break; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 498 | |
Jassi Brar | 51c6ab1 | 2010-03-10 16:48:51 +0900 | [diff] [blame] | 499 | default: |
| 500 | return -EINVAL; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | reg = readl(i2s->regs + S3C2412_IISMOD); |
| 504 | reg &= ~S3C2412_IISMOD_RCLK_MASK; |
| 505 | writel(reg | div, i2s->regs + S3C2412_IISMOD); |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 506 | pr_debug("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 507 | break; |
| 508 | |
| 509 | case S3C_I2SV2_DIV_PRESCALER: |
| 510 | if (div >= 0) { |
| 511 | writel((div << 8) | S3C2412_IISPSR_PSREN, |
| 512 | i2s->regs + S3C2412_IISPSR); |
| 513 | } else { |
| 514 | writel(0x0, i2s->regs + S3C2412_IISPSR); |
| 515 | } |
Mark Brown | ee7d476 | 2009-03-06 18:04:34 +0000 | [diff] [blame] | 516 | pr_debug("%s: PSR=%08x\n", __func__, readl(i2s->regs + S3C2412_IISPSR)); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 517 | break; |
| 518 | |
| 519 | default: |
| 520 | return -EINVAL; |
| 521 | } |
| 522 | |
| 523 | return 0; |
| 524 | } |
| 525 | |
Mark Brown | 1ca7578 | 2010-03-04 14:54:40 +0000 | [diff] [blame] | 526 | static snd_pcm_sframes_t s3c2412_i2s_delay(struct snd_pcm_substream *substream, |
| 527 | struct snd_soc_dai *dai) |
| 528 | { |
| 529 | struct s3c_i2sv2_info *i2s = to_info(dai); |
| 530 | u32 reg = readl(i2s->regs + S3C2412_IISFIC); |
| 531 | snd_pcm_sframes_t delay; |
| 532 | |
| 533 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 534 | delay = S3C2412_IISFIC_TXCOUNT(reg); |
| 535 | else |
| 536 | delay = S3C2412_IISFIC_RXCOUNT(reg); |
| 537 | |
| 538 | return delay; |
| 539 | } |
| 540 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 541 | /* default table of all avaialable root fs divisors */ |
| 542 | static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 }; |
| 543 | |
Ben Dooks | 1d2b7ae | 2009-04-16 10:32:23 +0100 | [diff] [blame] | 544 | int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, |
| 545 | unsigned int *fstab, |
| 546 | unsigned int rate, struct clk *clk) |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 547 | { |
| 548 | unsigned long clkrate = clk_get_rate(clk); |
| 549 | unsigned int div; |
| 550 | unsigned int fsclk; |
| 551 | unsigned int actual; |
| 552 | unsigned int fs; |
| 553 | unsigned int fsdiv; |
| 554 | signed int deviation = 0; |
| 555 | unsigned int best_fs = 0; |
| 556 | unsigned int best_div = 0; |
| 557 | unsigned int best_rate = 0; |
| 558 | unsigned int best_deviation = INT_MAX; |
| 559 | |
Mark Brown | af3ea7b | 2009-04-30 13:13:55 +0100 | [diff] [blame] | 560 | pr_debug("Input clock rate %ldHz\n", clkrate); |
| 561 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 562 | if (fstab == NULL) |
| 563 | fstab = iis_fs_tab; |
| 564 | |
| 565 | for (fs = 0; fs < ARRAY_SIZE(iis_fs_tab); fs++) { |
| 566 | fsdiv = iis_fs_tab[fs]; |
| 567 | |
| 568 | fsclk = clkrate / fsdiv; |
| 569 | div = fsclk / rate; |
| 570 | |
| 571 | if ((fsclk % rate) > (rate / 2)) |
| 572 | div++; |
| 573 | |
| 574 | if (div <= 1) |
| 575 | continue; |
| 576 | |
| 577 | actual = clkrate / (fsdiv * div); |
| 578 | deviation = actual - rate; |
| 579 | |
Roel Kluin | 449bd54 | 2009-05-27 17:08:39 -0700 | [diff] [blame] | 580 | printk(KERN_DEBUG "%ufs: div %u => result %u, deviation %d\n", |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 581 | fsdiv, div, actual, deviation); |
| 582 | |
| 583 | deviation = abs(deviation); |
| 584 | |
| 585 | if (deviation < best_deviation) { |
| 586 | best_fs = fsdiv; |
| 587 | best_div = div; |
| 588 | best_rate = actual; |
| 589 | best_deviation = deviation; |
| 590 | } |
| 591 | |
| 592 | if (deviation == 0) |
| 593 | break; |
| 594 | } |
| 595 | |
Roel Kluin | 449bd54 | 2009-05-27 17:08:39 -0700 | [diff] [blame] | 596 | printk(KERN_DEBUG "best: fs=%u, div=%u, rate=%u\n", |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 597 | best_fs, best_div, best_rate); |
| 598 | |
| 599 | info->fs_div = best_fs; |
| 600 | info->clk_div = best_div; |
| 601 | |
| 602 | return 0; |
| 603 | } |
Ben Dooks | 1d2b7ae | 2009-04-16 10:32:23 +0100 | [diff] [blame] | 604 | EXPORT_SYMBOL_GPL(s3c_i2sv2_iis_calc_rate); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 605 | |
| 606 | int s3c_i2sv2_probe(struct platform_device *pdev, |
| 607 | struct snd_soc_dai *dai, |
| 608 | struct s3c_i2sv2_info *i2s, |
| 609 | unsigned long base) |
| 610 | { |
| 611 | struct device *dev = &pdev->dev; |
Mark Brown | 07736d4 | 2009-04-30 13:13:14 +0100 | [diff] [blame] | 612 | unsigned int iismod; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 613 | |
| 614 | i2s->dev = dev; |
| 615 | |
| 616 | /* record our i2s structure for later use in the callbacks */ |
| 617 | dai->private_data = i2s; |
| 618 | |
Mark Brown | c86bde5 | 2009-04-30 13:09:33 +0100 | [diff] [blame] | 619 | if (!base) { |
| 620 | struct resource *res = platform_get_resource(pdev, |
| 621 | IORESOURCE_MEM, |
| 622 | 0); |
| 623 | if (!res) { |
| 624 | dev_err(dev, "Unable to get register resource\n"); |
| 625 | return -ENXIO; |
| 626 | } |
| 627 | |
| 628 | if (!request_mem_region(res->start, resource_size(res), |
| 629 | "s3c64xx-i2s-v4")) { |
| 630 | dev_err(dev, "Unable to request register region\n"); |
| 631 | return -EBUSY; |
| 632 | } |
| 633 | |
| 634 | base = res->start; |
| 635 | } |
| 636 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 637 | i2s->regs = ioremap(base, 0x100); |
| 638 | if (i2s->regs == NULL) { |
| 639 | dev_err(dev, "cannot ioremap registers\n"); |
| 640 | return -ENXIO; |
| 641 | } |
| 642 | |
| 643 | i2s->iis_pclk = clk_get(dev, "iis"); |
Jassi | fd5ad65 | 2009-09-15 19:02:38 +0900 | [diff] [blame] | 644 | if (IS_ERR(i2s->iis_pclk)) { |
Mark Brown | b52a519 | 2009-03-06 18:13:43 +0000 | [diff] [blame] | 645 | dev_err(dev, "failed to get iis_clock\n"); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 646 | iounmap(i2s->regs); |
| 647 | return -ENOENT; |
| 648 | } |
| 649 | |
| 650 | clk_enable(i2s->iis_pclk); |
| 651 | |
Mark Brown | 07736d4 | 2009-04-30 13:13:14 +0100 | [diff] [blame] | 652 | /* Mark ourselves as in TXRX mode so we can run through our cleanup |
| 653 | * process without warnings. */ |
| 654 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
| 655 | iismod |= S3C2412_IISMOD_MODE_TXRX; |
| 656 | writel(iismod, i2s->regs + S3C2412_IISMOD); |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 657 | s3c2412_snd_txctrl(i2s, 0); |
| 658 | s3c2412_snd_rxctrl(i2s, 0); |
| 659 | |
| 660 | return 0; |
| 661 | } |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 662 | EXPORT_SYMBOL_GPL(s3c_i2sv2_probe); |
| 663 | |
| 664 | #ifdef CONFIG_PM |
| 665 | static int s3c2412_i2s_suspend(struct snd_soc_dai *dai) |
| 666 | { |
| 667 | struct s3c_i2sv2_info *i2s = to_info(dai); |
| 668 | u32 iismod; |
| 669 | |
| 670 | if (dai->active) { |
| 671 | i2s->suspend_iismod = readl(i2s->regs + S3C2412_IISMOD); |
| 672 | i2s->suspend_iiscon = readl(i2s->regs + S3C2412_IISCON); |
| 673 | i2s->suspend_iispsr = readl(i2s->regs + S3C2412_IISPSR); |
| 674 | |
| 675 | /* some basic suspend checks */ |
| 676 | |
| 677 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
| 678 | |
| 679 | if (iismod & S3C2412_IISCON_RXDMA_ACTIVE) |
| 680 | pr_warning("%s: RXDMA active?\n", __func__); |
| 681 | |
| 682 | if (iismod & S3C2412_IISCON_TXDMA_ACTIVE) |
| 683 | pr_warning("%s: TXDMA active?\n", __func__); |
| 684 | |
| 685 | if (iismod & S3C2412_IISCON_IIS_ACTIVE) |
| 686 | pr_warning("%s: IIS active\n", __func__); |
| 687 | } |
| 688 | |
| 689 | return 0; |
| 690 | } |
| 691 | |
| 692 | static int s3c2412_i2s_resume(struct snd_soc_dai *dai) |
| 693 | { |
| 694 | struct s3c_i2sv2_info *i2s = to_info(dai); |
| 695 | |
| 696 | pr_info("dai_active %d, IISMOD %08x, IISCON %08x\n", |
| 697 | dai->active, i2s->suspend_iismod, i2s->suspend_iiscon); |
| 698 | |
| 699 | if (dai->active) { |
| 700 | writel(i2s->suspend_iiscon, i2s->regs + S3C2412_IISCON); |
| 701 | writel(i2s->suspend_iismod, i2s->regs + S3C2412_IISMOD); |
| 702 | writel(i2s->suspend_iispsr, i2s->regs + S3C2412_IISPSR); |
| 703 | |
| 704 | writel(S3C2412_IISFIC_RXFLUSH | S3C2412_IISFIC_TXFLUSH, |
| 705 | i2s->regs + S3C2412_IISFIC); |
| 706 | |
| 707 | ndelay(250); |
| 708 | writel(0x0, i2s->regs + S3C2412_IISFIC); |
| 709 | } |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | #else |
| 714 | #define s3c2412_i2s_suspend NULL |
| 715 | #define s3c2412_i2s_resume NULL |
| 716 | #endif |
| 717 | |
| 718 | int s3c_i2sv2_register_dai(struct snd_soc_dai *dai) |
| 719 | { |
Ben Dooks | 3715c6a | 2009-04-16 10:32:22 +0100 | [diff] [blame] | 720 | struct snd_soc_dai_ops *ops = dai->ops; |
| 721 | |
| 722 | ops->trigger = s3c2412_i2s_trigger; |
Jassi Brar | 9c9b125 | 2010-03-10 16:48:58 +0900 | [diff] [blame] | 723 | if (!ops->hw_params) |
| 724 | ops->hw_params = s3c_i2sv2_hw_params; |
Ben Dooks | 3715c6a | 2009-04-16 10:32:22 +0100 | [diff] [blame] | 725 | ops->set_fmt = s3c2412_i2s_set_fmt; |
| 726 | ops->set_clkdiv = s3c2412_i2s_set_clkdiv; |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 727 | |
Mark Brown | 1ca7578 | 2010-03-04 14:54:40 +0000 | [diff] [blame] | 728 | /* Allow overriding by (for example) IISv4 */ |
| 729 | if (!ops->delay) |
Jassi Brar | 08226614 | 2010-03-10 16:48:50 +0900 | [diff] [blame] | 730 | ops->delay = s3c2412_i2s_delay; |
Mark Brown | 1ca7578 | 2010-03-04 14:54:40 +0000 | [diff] [blame] | 731 | |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 732 | dai->suspend = s3c2412_i2s_suspend; |
| 733 | dai->resume = s3c2412_i2s_resume; |
| 734 | |
| 735 | return snd_soc_register_dai(dai); |
| 736 | } |
Ben Dooks | dc85447 | 2009-03-04 00:49:30 +0000 | [diff] [blame] | 737 | EXPORT_SYMBOL_GPL(s3c_i2sv2_register_dai); |
Mark Brown | a396e32 | 2009-04-23 15:43:45 +0100 | [diff] [blame] | 738 | |
| 739 | MODULE_LICENSE("GPL"); |