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