Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 1 | /* |
| 2 | * bf5xx-ac97.c -- AC97 support for the ADI blackfin chip. |
| 3 | * |
| 4 | * Author: Roy Huang |
| 5 | * Created: 11th. June 2007 |
| 6 | * Copyright: Analog Device Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/wait.h> |
| 18 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame^] | 19 | #include <linux/slab.h> |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 20 | |
| 21 | #include <sound/core.h> |
| 22 | #include <sound/pcm.h> |
| 23 | #include <sound/ac97_codec.h> |
| 24 | #include <sound/initval.h> |
| 25 | #include <sound/soc.h> |
| 26 | |
| 27 | #include <asm/irq.h> |
| 28 | #include <asm/portmux.h> |
| 29 | #include <linux/mutex.h> |
| 30 | #include <linux/gpio.h> |
| 31 | |
| 32 | #include "bf5xx-sport.h" |
| 33 | #include "bf5xx-ac97.h" |
| 34 | |
Sonic Zhang | cf485da | 2009-06-02 00:18:57 -0400 | [diff] [blame] | 35 | /* Anomaly notes: |
| 36 | * 05000250 - AD1980 is running in TDM mode and RFS/TFS are generated by SPORT |
| 37 | * contrtoller. But, RFSDIV and TFSDIV are always set to 16*16-1, |
| 38 | * while the max AC97 data size is 13*16. The DIV is always larger |
| 39 | * than data size. AD73311 and ad2602 are not running in TDM mode. |
| 40 | * AD1836 and AD73322 depend on external RFS/TFS only. So, this |
| 41 | * anomaly does not affect blackfin sound drivers. |
| 42 | */ |
| 43 | |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 44 | static int *cmd_count; |
| 45 | static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; |
| 46 | |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 47 | #define SPORT_REQ(x) \ |
| 48 | [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \ |
| 49 | P_SPORT##x##_RFS, P_SPORT##x##_DRPRI, P_SPORT##x##_RSCLK, 0} |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 50 | static u16 sport_req[][7] = { |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 51 | #ifdef SPORT0_TCR1 |
| 52 | SPORT_REQ(0), |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 53 | #endif |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 54 | #ifdef SPORT1_TCR1 |
| 55 | SPORT_REQ(1), |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 56 | #endif |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 57 | #ifdef SPORT2_TCR1 |
| 58 | SPORT_REQ(2), |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 59 | #endif |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 60 | #ifdef SPORT3_TCR1 |
| 61 | SPORT_REQ(3), |
| 62 | #endif |
| 63 | }; |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 64 | |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 65 | #define SPORT_PARAMS(x) \ |
| 66 | [x] = { \ |
| 67 | .dma_rx_chan = CH_SPORT##x##_RX, \ |
| 68 | .dma_tx_chan = CH_SPORT##x##_TX, \ |
| 69 | .err_irq = IRQ_SPORT##x##_ERROR, \ |
| 70 | .regs = (struct sport_register *)SPORT##x##_TCR1, \ |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 71 | } |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 72 | static struct sport_param sport_params[4] = { |
| 73 | #ifdef SPORT0_TCR1 |
| 74 | SPORT_PARAMS(0), |
| 75 | #endif |
| 76 | #ifdef SPORT1_TCR1 |
| 77 | SPORT_PARAMS(1), |
| 78 | #endif |
| 79 | #ifdef SPORT2_TCR1 |
| 80 | SPORT_PARAMS(2), |
| 81 | #endif |
| 82 | #ifdef SPORT3_TCR1 |
| 83 | SPORT_PARAMS(3), |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 84 | #endif |
| 85 | }; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 86 | |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 87 | void bf5xx_pcm_to_ac97(struct ac97_frame *dst, const __u16 *src, |
| 88 | size_t count, unsigned int chan_mask) |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 89 | { |
| 90 | while (count--) { |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 91 | dst->ac97_tag = TAG_VALID; |
| 92 | if (chan_mask & SP_FL) { |
| 93 | dst->ac97_pcm_r = *src++; |
| 94 | dst->ac97_tag |= TAG_PCM_RIGHT; |
| 95 | } |
| 96 | if (chan_mask & SP_FR) { |
| 97 | dst->ac97_pcm_l = *src++; |
| 98 | dst->ac97_tag |= TAG_PCM_LEFT; |
| 99 | |
| 100 | } |
| 101 | #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) |
| 102 | if (chan_mask & SP_SR) { |
| 103 | dst->ac97_sl = *src++; |
| 104 | dst->ac97_tag |= TAG_PCM_SL; |
| 105 | } |
| 106 | if (chan_mask & SP_SL) { |
| 107 | dst->ac97_sr = *src++; |
| 108 | dst->ac97_tag |= TAG_PCM_SR; |
| 109 | } |
| 110 | if (chan_mask & SP_LFE) { |
| 111 | dst->ac97_lfe = *src++; |
| 112 | dst->ac97_tag |= TAG_PCM_LFE; |
| 113 | } |
| 114 | if (chan_mask & SP_FC) { |
| 115 | dst->ac97_center = *src++; |
| 116 | dst->ac97_tag |= TAG_PCM_CENTER; |
| 117 | } |
| 118 | #endif |
| 119 | dst++; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | EXPORT_SYMBOL(bf5xx_pcm_to_ac97); |
| 123 | |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 124 | void bf5xx_ac97_to_pcm(const struct ac97_frame *src, __u16 *dst, |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 125 | size_t count) |
| 126 | { |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 127 | while (count--) { |
| 128 | *(dst++) = src->ac97_pcm_l; |
| 129 | *(dst++) = src->ac97_pcm_r; |
| 130 | src++; |
| 131 | } |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 132 | } |
| 133 | EXPORT_SYMBOL(bf5xx_ac97_to_pcm); |
| 134 | |
| 135 | static unsigned int sport_tx_curr_frag(struct sport_device *sport) |
| 136 | { |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 137 | return sport->tx_curr_frag = sport_curr_offset_tx(sport) / |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 138 | sport->tx_fragsize; |
| 139 | } |
| 140 | |
| 141 | static void enqueue_cmd(struct snd_ac97 *ac97, __u16 addr, __u16 data) |
| 142 | { |
| 143 | struct sport_device *sport = sport_handle; |
| 144 | int nextfrag = sport_tx_curr_frag(sport); |
| 145 | struct ac97_frame *nextwrite; |
| 146 | |
| 147 | sport_incfrag(sport, &nextfrag, 1); |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 148 | |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 149 | nextwrite = (struct ac97_frame *)(sport->tx_buf + |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 150 | nextfrag * sport->tx_fragsize); |
| 151 | pr_debug("sport->tx_buf:%p, nextfrag:0x%x nextwrite:%p, cmd_count:%d\n", |
| 152 | sport->tx_buf, nextfrag, nextwrite, cmd_count[nextfrag]); |
| 153 | nextwrite[cmd_count[nextfrag]].ac97_tag |= TAG_CMD; |
| 154 | nextwrite[cmd_count[nextfrag]].ac97_addr = addr; |
| 155 | nextwrite[cmd_count[nextfrag]].ac97_data = data; |
| 156 | ++cmd_count[nextfrag]; |
| 157 | pr_debug("ac97_sport: Inserting %02x/%04x into fragment %d\n", |
| 158 | addr >> 8, data, nextfrag); |
| 159 | } |
| 160 | |
| 161 | static unsigned short bf5xx_ac97_read(struct snd_ac97 *ac97, |
| 162 | unsigned short reg) |
| 163 | { |
| 164 | struct ac97_frame out_frame[2], in_frame[2]; |
| 165 | |
| 166 | pr_debug("%s enter 0x%x\n", __func__, reg); |
| 167 | |
| 168 | /* When dma descriptor is enabled, the register should not be read */ |
| 169 | if (sport_handle->tx_run || sport_handle->rx_run) { |
| 170 | pr_err("Could you send a mail to cliff.cai@analog.com " |
| 171 | "to report this?\n"); |
| 172 | return -EFAULT; |
| 173 | } |
| 174 | |
| 175 | memset(&out_frame, 0, 2 * sizeof(struct ac97_frame)); |
| 176 | memset(&in_frame, 0, 2 * sizeof(struct ac97_frame)); |
| 177 | out_frame[0].ac97_tag = TAG_VALID | TAG_CMD; |
| 178 | out_frame[0].ac97_addr = ((reg << 8) | 0x8000); |
| 179 | sport_send_and_recv(sport_handle, (unsigned char *)&out_frame, |
| 180 | (unsigned char *)&in_frame, |
| 181 | 2 * sizeof(struct ac97_frame)); |
| 182 | return in_frame[1].ac97_data; |
| 183 | } |
| 184 | |
| 185 | void bf5xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, |
| 186 | unsigned short val) |
| 187 | { |
| 188 | pr_debug("%s enter 0x%x:0x%04x\n", __func__, reg, val); |
| 189 | |
| 190 | if (sport_handle->tx_run) { |
| 191 | enqueue_cmd(ac97, (reg << 8), val); /* write */ |
| 192 | enqueue_cmd(ac97, (reg << 8) | 0x8000, 0); /* read back */ |
| 193 | } else { |
| 194 | struct ac97_frame frame; |
| 195 | memset(&frame, 0, sizeof(struct ac97_frame)); |
| 196 | frame.ac97_tag = TAG_VALID | TAG_CMD; |
| 197 | frame.ac97_addr = (reg << 8); |
| 198 | frame.ac97_data = val; |
| 199 | sport_send_and_recv(sport_handle, (unsigned char *)&frame, \ |
| 200 | NULL, sizeof(struct ac97_frame)); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | static void bf5xx_ac97_warm_reset(struct snd_ac97 *ac97) |
| 205 | { |
| 206 | #if defined(CONFIG_BF54x) || defined(CONFIG_BF561) || \ |
| 207 | (defined(BF537_FAMILY) && (CONFIG_SND_BF5XX_SPORT_NUM == 1)) |
| 208 | |
| 209 | #define CONCAT(a, b, c) a ## b ## c |
| 210 | #define BFIN_SPORT_RFS(x) CONCAT(P_SPORT, x, _RFS) |
| 211 | |
| 212 | u16 per = BFIN_SPORT_RFS(CONFIG_SND_BF5XX_SPORT_NUM); |
| 213 | u16 gpio = P_IDENT(BFIN_SPORT_RFS(CONFIG_SND_BF5XX_SPORT_NUM)); |
| 214 | |
| 215 | pr_debug("%s enter\n", __func__); |
| 216 | |
| 217 | peripheral_free(per); |
| 218 | gpio_request(gpio, "bf5xx-ac97"); |
| 219 | gpio_direction_output(gpio, 1); |
| 220 | udelay(2); |
| 221 | gpio_set_value(gpio, 0); |
| 222 | udelay(1); |
| 223 | gpio_free(gpio); |
| 224 | peripheral_request(per, "soc-audio"); |
| 225 | #else |
| 226 | pr_info("%s: Not implemented\n", __func__); |
| 227 | #endif |
| 228 | } |
| 229 | |
| 230 | static void bf5xx_ac97_cold_reset(struct snd_ac97 *ac97) |
| 231 | { |
| 232 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET |
| 233 | pr_debug("%s enter\n", __func__); |
| 234 | |
| 235 | /* It is specified for bf548-ezkit */ |
| 236 | gpio_set_value(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 0); |
| 237 | /* Keep reset pin low for 1 ms */ |
| 238 | mdelay(1); |
| 239 | gpio_set_value(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); |
| 240 | /* Wait for bit clock recover */ |
| 241 | mdelay(1); |
| 242 | #else |
| 243 | pr_info("%s: Not implemented\n", __func__); |
| 244 | #endif |
| 245 | } |
| 246 | |
| 247 | struct snd_ac97_bus_ops soc_ac97_ops = { |
| 248 | .read = bf5xx_ac97_read, |
| 249 | .write = bf5xx_ac97_write, |
| 250 | .warm_reset = bf5xx_ac97_warm_reset, |
| 251 | .reset = bf5xx_ac97_cold_reset, |
| 252 | }; |
| 253 | EXPORT_SYMBOL_GPL(soc_ac97_ops); |
| 254 | |
| 255 | #ifdef CONFIG_PM |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 256 | static int bf5xx_ac97_suspend(struct snd_soc_dai *dai) |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 257 | { |
| 258 | struct sport_device *sport = |
| 259 | (struct sport_device *)dai->private_data; |
| 260 | |
| 261 | pr_debug("%s : sport %d\n", __func__, dai->id); |
| 262 | if (!dai->active) |
| 263 | return 0; |
| 264 | if (dai->capture.active) |
| 265 | sport_rx_stop(sport); |
| 266 | if (dai->playback.active) |
| 267 | sport_tx_stop(sport); |
| 268 | return 0; |
| 269 | } |
| 270 | |
Mark Brown | dc7d7b8 | 2008-12-03 18:21:52 +0000 | [diff] [blame] | 271 | static int bf5xx_ac97_resume(struct snd_soc_dai *dai) |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 272 | { |
| 273 | int ret; |
| 274 | struct sport_device *sport = |
| 275 | (struct sport_device *)dai->private_data; |
| 276 | |
| 277 | pr_debug("%s : sport %d\n", __func__, dai->id); |
| 278 | if (!dai->active) |
| 279 | return 0; |
| 280 | |
Cliff Cai | 79dfc96 | 2009-09-16 20:25:08 -0400 | [diff] [blame] | 281 | #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) |
| 282 | ret = sport_set_multichannel(sport, 16, 0x3FF, 1); |
| 283 | #else |
Cliff Cai | 18d02bc | 2009-07-14 10:01:39 -0400 | [diff] [blame] | 284 | ret = sport_set_multichannel(sport, 16, 0x1F, 1); |
Cliff Cai | 79dfc96 | 2009-09-16 20:25:08 -0400 | [diff] [blame] | 285 | #endif |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 286 | if (ret) { |
| 287 | pr_err("SPORT is busy!\n"); |
| 288 | return -EBUSY; |
| 289 | } |
| 290 | |
Cliff Cai | 18d02bc | 2009-07-14 10:01:39 -0400 | [diff] [blame] | 291 | ret = sport_config_rx(sport, IRFS, 0xF, 0, (16*16-1)); |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 292 | if (ret) { |
| 293 | pr_err("SPORT is busy!\n"); |
| 294 | return -EBUSY; |
| 295 | } |
| 296 | |
Cliff Cai | 18d02bc | 2009-07-14 10:01:39 -0400 | [diff] [blame] | 297 | ret = sport_config_tx(sport, ITFS, 0xF, 0, (16*16-1)); |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 298 | if (ret) { |
| 299 | pr_err("SPORT is busy!\n"); |
| 300 | return -EBUSY; |
| 301 | } |
| 302 | |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | #else |
| 307 | #define bf5xx_ac97_suspend NULL |
| 308 | #define bf5xx_ac97_resume NULL |
| 309 | #endif |
| 310 | |
| 311 | static int bf5xx_ac97_probe(struct platform_device *pdev, |
| 312 | struct snd_soc_dai *dai) |
| 313 | { |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 314 | int ret = 0; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 315 | cmd_count = (int *)get_zeroed_page(GFP_KERNEL); |
| 316 | if (cmd_count == NULL) |
| 317 | return -ENOMEM; |
| 318 | |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 319 | if (peripheral_request_list(sport_req[sport_num], "soc-audio")) { |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 320 | pr_err("Requesting Peripherals failed\n"); |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 321 | ret = -EFAULT; |
| 322 | goto peripheral_err; |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 323 | } |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 324 | |
| 325 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET |
| 326 | /* Request PB3 as reset pin */ |
| 327 | if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) { |
| 328 | pr_err("Failed to request GPIO_%d for reset\n", |
| 329 | CONFIG_SND_BF5XX_RESET_GPIO_NUM); |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 330 | ret = -1; |
| 331 | goto gpio_err; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 332 | } |
| 333 | gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); |
| 334 | #endif |
| 335 | sport_handle = sport_init(&sport_params[sport_num], 2, \ |
| 336 | sizeof(struct ac97_frame), NULL); |
| 337 | if (!sport_handle) { |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 338 | ret = -ENODEV; |
| 339 | goto sport_err; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 340 | } |
| 341 | /*SPORT works in TDM mode to simulate AC97 transfers*/ |
Cliff Cai | 79dfc96 | 2009-09-16 20:25:08 -0400 | [diff] [blame] | 342 | #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) |
| 343 | ret = sport_set_multichannel(sport_handle, 16, 0x3FF, 1); |
| 344 | #else |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 345 | ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1); |
Cliff Cai | 79dfc96 | 2009-09-16 20:25:08 -0400 | [diff] [blame] | 346 | #endif |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 347 | if (ret) { |
| 348 | pr_err("SPORT is busy!\n"); |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 349 | ret = -EBUSY; |
| 350 | goto sport_config_err; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); |
| 354 | if (ret) { |
| 355 | pr_err("SPORT is busy!\n"); |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 356 | ret = -EBUSY; |
| 357 | goto sport_config_err; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); |
| 361 | if (ret) { |
| 362 | pr_err("SPORT is busy!\n"); |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 363 | ret = -EBUSY; |
| 364 | goto sport_config_err; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 365 | } |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 366 | |
Michael Hennerich | 0cade26 | 2008-11-18 16:18:19 +0800 | [diff] [blame] | 367 | return 0; |
| 368 | |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 369 | sport_config_err: |
| 370 | kfree(sport_handle); |
| 371 | sport_err: |
| 372 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET |
| 373 | gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 374 | gpio_err: |
Mike Frysinger | 3465d93 | 2009-03-06 15:53:28 +0800 | [diff] [blame] | 375 | #endif |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 376 | peripheral_free_list(sport_req[sport_num]); |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 377 | peripheral_err: |
| 378 | free_page((unsigned long)cmd_count); |
| 379 | cmd_count = NULL; |
| 380 | |
| 381 | return ret; |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | static void bf5xx_ac97_remove(struct platform_device *pdev, |
| 385 | struct snd_soc_dai *dai) |
| 386 | { |
| 387 | free_page((unsigned long)cmd_count); |
| 388 | cmd_count = NULL; |
Mike Frysinger | 92a950f | 2009-02-06 18:12:34 +0800 | [diff] [blame] | 389 | peripheral_free_list(sport_req[sport_num]); |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 390 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET |
| 391 | gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); |
| 392 | #endif |
| 393 | } |
| 394 | |
| 395 | struct snd_soc_dai bfin_ac97_dai = { |
| 396 | .name = "bf5xx-ac97", |
| 397 | .id = 0, |
Mark Brown | 3ba9e10 | 2008-11-24 18:01:05 +0000 | [diff] [blame] | 398 | .ac97_control = 1, |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 399 | .probe = bf5xx_ac97_probe, |
| 400 | .remove = bf5xx_ac97_remove, |
| 401 | .suspend = bf5xx_ac97_suspend, |
| 402 | .resume = bf5xx_ac97_resume, |
| 403 | .playback = { |
| 404 | .stream_name = "AC97 Playback", |
| 405 | .channels_min = 2, |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 406 | #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) |
| 407 | .channels_max = 6, |
| 408 | #else |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 409 | .channels_max = 2, |
Cliff Cai | 67f854b | 2008-11-18 16:18:17 +0800 | [diff] [blame] | 410 | #endif |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 411 | .rates = SNDRV_PCM_RATE_48000, |
| 412 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, |
| 413 | .capture = { |
| 414 | .stream_name = "AC97 Capture", |
| 415 | .channels_min = 2, |
| 416 | .channels_max = 2, |
| 417 | .rates = SNDRV_PCM_RATE_48000, |
| 418 | .formats = SNDRV_PCM_FMTBIT_S16_LE, }, |
| 419 | }; |
| 420 | EXPORT_SYMBOL_GPL(bfin_ac97_dai); |
| 421 | |
Takashi Iwai | c9b3a40 | 2008-12-10 07:47:22 +0100 | [diff] [blame] | 422 | static int __init bfin_ac97_init(void) |
Mark Brown | 3f4b783 | 2008-12-03 19:26:35 +0000 | [diff] [blame] | 423 | { |
| 424 | return snd_soc_register_dai(&bfin_ac97_dai); |
| 425 | } |
| 426 | module_init(bfin_ac97_init); |
| 427 | |
| 428 | static void __exit bfin_ac97_exit(void) |
| 429 | { |
| 430 | snd_soc_unregister_dai(&bfin_ac97_dai); |
| 431 | } |
| 432 | module_exit(bfin_ac97_exit); |
| 433 | |
Cliff Cai | f202862 | 2008-09-05 18:21:37 +0800 | [diff] [blame] | 434 | MODULE_AUTHOR("Roy Huang"); |
| 435 | MODULE_DESCRIPTION("AC97 driver for ADI Blackfin"); |
| 436 | MODULE_LICENSE("GPL"); |