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