Andra Danciu | 1af301d | 2019-04-05 14:50:02 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | // |
| 3 | // linux/sound/mpc5200-ac97.c -- AC97 support for the Freescale MPC52xx chip. |
| 4 | // |
| 5 | // Copyright (C) 2009 Jon Smirl, Digispeaker |
| 6 | // Author: Jon Smirl <jonsmirl@gmail.com> |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 7 | |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/of_device.h> |
| 10 | #include <linux/of_platform.h> |
John Bonesio | ed0f19b | 2009-07-21 13:15:40 -0700 | [diff] [blame] | 11 | #include <linux/delay.h> |
Xiubo Li | 0d55ad4 | 2016-01-15 19:35:25 +0800 | [diff] [blame] | 12 | #include <linux/time.h> |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 13 | |
| 14 | #include <sound/pcm.h> |
| 15 | #include <sound/pcm_params.h> |
| 16 | #include <sound/soc.h> |
| 17 | |
| 18 | #include <asm/time.h> |
| 19 | #include <asm/delay.h> |
Eric Millbrandt | 949ad0a | 2010-08-06 20:49:19 -0600 | [diff] [blame] | 20 | #include <asm/mpc52xx.h> |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 21 | #include <asm/mpc52xx_psc.h> |
| 22 | |
| 23 | #include "mpc5200_dma.h" |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 24 | |
| 25 | #define DRV_NAME "mpc5200-psc-ac97" |
| 26 | |
| 27 | /* ALSA only supports a single AC97 device so static is recommend here */ |
| 28 | static struct psc_dma *psc_dma; |
| 29 | |
| 30 | static unsigned short psc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) |
| 31 | { |
Jon Smirl | ea8b27a | 2009-05-27 01:06:19 -0400 | [diff] [blame] | 32 | int status; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 33 | unsigned int val; |
| 34 | |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 35 | mutex_lock(&psc_dma->mutex); |
| 36 | |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 37 | /* Wait for command send status zero = ready */ |
Jon Smirl | ea8b27a | 2009-05-27 01:06:19 -0400 | [diff] [blame] | 38 | status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) & |
| 39 | MPC52xx_PSC_SR_CMDSEND), 100, 0); |
| 40 | if (status == 0) { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 41 | pr_err("timeout on ac97 bus (rdy)\n"); |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 42 | mutex_unlock(&psc_dma->mutex); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 43 | return -ENODEV; |
| 44 | } |
Grant Likely | 0757353 | 2009-07-02 11:57:19 -0600 | [diff] [blame] | 45 | |
| 46 | /* Force clear the data valid bit */ |
| 47 | in_be32(&psc_dma->psc_regs->ac97_data); |
| 48 | |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 49 | /* Send the read */ |
| 50 | out_be32(&psc_dma->psc_regs->ac97_cmd, (1<<31) | ((reg & 0x7f) << 24)); |
| 51 | |
| 52 | /* Wait for the answer */ |
Jon Smirl | ea8b27a | 2009-05-27 01:06:19 -0400 | [diff] [blame] | 53 | status = spin_event_timeout((in_be16(&psc_dma->psc_regs->sr_csr.status) & |
| 54 | MPC52xx_PSC_SR_DATA_VAL), 100, 0); |
| 55 | if (status == 0) { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 56 | pr_err("timeout on ac97 read (val) %x\n", |
| 57 | in_be16(&psc_dma->psc_regs->sr_csr.status)); |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 58 | mutex_unlock(&psc_dma->mutex); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 59 | return -ENODEV; |
| 60 | } |
| 61 | /* Get the data */ |
| 62 | val = in_be32(&psc_dma->psc_regs->ac97_data); |
| 63 | if (((val >> 24) & 0x7f) != reg) { |
| 64 | pr_err("reg echo error on ac97 read\n"); |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 65 | mutex_unlock(&psc_dma->mutex); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 66 | return -ENODEV; |
| 67 | } |
| 68 | val = (val >> 8) & 0xffff; |
| 69 | |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 70 | mutex_unlock(&psc_dma->mutex); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 71 | return (unsigned short) val; |
| 72 | } |
| 73 | |
| 74 | static void psc_ac97_write(struct snd_ac97 *ac97, |
| 75 | unsigned short reg, unsigned short val) |
| 76 | { |
Jon Smirl | ea8b27a | 2009-05-27 01:06:19 -0400 | [diff] [blame] | 77 | int status; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 78 | |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 79 | mutex_lock(&psc_dma->mutex); |
| 80 | |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 81 | /* Wait for command status zero = ready */ |
Jon Smirl | ea8b27a | 2009-05-27 01:06:19 -0400 | [diff] [blame] | 82 | status = spin_event_timeout(!(in_be16(&psc_dma->psc_regs->sr_csr.status) & |
| 83 | MPC52xx_PSC_SR_CMDSEND), 100, 0); |
| 84 | if (status == 0) { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 85 | pr_err("timeout on ac97 bus (write)\n"); |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 86 | goto out; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 87 | } |
| 88 | /* Write data */ |
| 89 | out_be32(&psc_dma->psc_regs->ac97_cmd, |
| 90 | ((reg & 0x7f) << 24) | (val << 8)); |
Grant Likely | 0827d6b | 2009-07-02 11:57:25 -0600 | [diff] [blame] | 91 | |
| 92 | out: |
| 93 | mutex_unlock(&psc_dma->mutex); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | static void psc_ac97_warm_reset(struct snd_ac97 *ac97) |
| 97 | { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 98 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; |
| 99 | |
Eric Millbrandt | 949ad0a | 2010-08-06 20:49:19 -0600 | [diff] [blame] | 100 | mutex_lock(&psc_dma->mutex); |
| 101 | |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 102 | out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_AWR); |
Jon Smirl | ea8b27a | 2009-05-27 01:06:19 -0400 | [diff] [blame] | 103 | udelay(3); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 104 | out_be32(®s->sicr, psc_dma->sicr); |
Eric Millbrandt | 949ad0a | 2010-08-06 20:49:19 -0600 | [diff] [blame] | 105 | |
| 106 | mutex_unlock(&psc_dma->mutex); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | static void psc_ac97_cold_reset(struct snd_ac97 *ac97) |
| 110 | { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 111 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; |
| 112 | |
Eric Millbrandt | 949ad0a | 2010-08-06 20:49:19 -0600 | [diff] [blame] | 113 | mutex_lock(&psc_dma->mutex); |
| 114 | dev_dbg(psc_dma->dev, "cold reset\n"); |
| 115 | |
| 116 | mpc5200_psc_ac97_gpio_reset(psc_dma->id); |
| 117 | |
| 118 | /* Notify the PSC that a reset has occurred */ |
| 119 | out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_ACRB); |
| 120 | |
| 121 | /* Re-enable RX and TX */ |
| 122 | out_8(®s->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); |
| 123 | |
| 124 | mutex_unlock(&psc_dma->mutex); |
| 125 | |
Xiubo Li | 0d55ad4 | 2016-01-15 19:35:25 +0800 | [diff] [blame] | 126 | usleep_range(1000, 2000); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 127 | psc_ac97_warm_reset(ac97); |
| 128 | } |
| 129 | |
Mark Brown | b047e1c | 2013-06-26 12:45:59 +0100 | [diff] [blame] | 130 | static struct snd_ac97_bus_ops psc_ac97_ops = { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 131 | .read = psc_ac97_read, |
| 132 | .write = psc_ac97_write, |
| 133 | .reset = psc_ac97_cold_reset, |
| 134 | .warm_reset = psc_ac97_warm_reset, |
| 135 | }; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 136 | |
| 137 | static int psc_ac97_hw_analog_params(struct snd_pcm_substream *substream, |
| 138 | struct snd_pcm_hw_params *params, |
| 139 | struct snd_soc_dai *cpu_dai) |
| 140 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 141 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai); |
Grant Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 142 | struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 143 | |
| 144 | dev_dbg(psc_dma->dev, "%s(substream=%p) p_size=%i p_bytes=%i" |
| 145 | " periods=%i buffer_size=%i buffer_bytes=%i channels=%i" |
| 146 | " rate=%i format=%i\n", |
| 147 | __func__, substream, params_period_size(params), |
| 148 | params_period_bytes(params), params_periods(params), |
| 149 | params_buffer_size(params), params_buffer_bytes(params), |
| 150 | params_channels(params), params_rate(params), |
| 151 | params_format(params)); |
| 152 | |
Grant Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 153 | /* Determine the set of enable bits to turn on */ |
| 154 | s->ac97_slot_bits = (params_channels(params) == 1) ? 0x100 : 0x300; |
| 155 | if (substream->pstr->stream != SNDRV_PCM_STREAM_CAPTURE) |
| 156 | s->ac97_slot_bits <<= 16; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | static int psc_ac97_hw_digital_params(struct snd_pcm_substream *substream, |
| 161 | struct snd_pcm_hw_params *params, |
| 162 | struct snd_soc_dai *cpu_dai) |
| 163 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 164 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 165 | |
Grant Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 166 | dev_dbg(psc_dma->dev, "%s(substream=%p)\n", __func__, substream); |
| 167 | |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 168 | if (params_channels(params) == 1) |
| 169 | out_be32(&psc_dma->psc_regs->ac97_slots, 0x01000000); |
| 170 | else |
| 171 | out_be32(&psc_dma->psc_regs->ac97_slots, 0x03000000); |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | static int psc_ac97_trigger(struct snd_pcm_substream *substream, int cmd, |
| 177 | struct snd_soc_dai *dai) |
| 178 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 179 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(dai); |
Grant Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 180 | struct psc_dma_stream *s = to_psc_dma_stream(substream, psc_dma); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 181 | |
| 182 | switch (cmd) { |
Grant Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 183 | case SNDRV_PCM_TRIGGER_START: |
| 184 | dev_dbg(psc_dma->dev, "AC97 START: stream=%i\n", |
| 185 | substream->pstr->stream); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 186 | |
Grant Likely | c939e5c | 2009-11-07 01:34:43 -0700 | [diff] [blame] | 187 | /* Set the slot enable bits */ |
| 188 | psc_dma->slots |= s->ac97_slot_bits; |
| 189 | out_be32(&psc_dma->psc_regs->ac97_slots, psc_dma->slots); |
| 190 | break; |
| 191 | |
| 192 | case SNDRV_PCM_TRIGGER_STOP: |
| 193 | dev_dbg(psc_dma->dev, "AC97 STOP: stream=%i\n", |
| 194 | substream->pstr->stream); |
| 195 | |
| 196 | /* Clear the slot enable bits */ |
| 197 | psc_dma->slots &= ~(s->ac97_slot_bits); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 198 | out_be32(&psc_dma->psc_regs->ac97_slots, psc_dma->slots); |
| 199 | break; |
| 200 | } |
| 201 | return 0; |
| 202 | } |
| 203 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 204 | static int psc_ac97_probe(struct snd_soc_dai *cpu_dai) |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 205 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 206 | struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(cpu_dai); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 207 | struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; |
| 208 | |
| 209 | /* Go */ |
| 210 | out_8(®s->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | /* --------------------------------------------------------------------- |
| 215 | * ALSA SoC Bindings |
| 216 | * |
| 217 | * - Digital Audio Interface (DAI) template |
| 218 | * - create/destroy dai hooks |
| 219 | */ |
| 220 | |
| 221 | /** |
| 222 | * psc_ac97_dai_template: template CPU Digital Audio Interface |
| 223 | */ |
Lars-Peter Clausen | 85e7652 | 2011-11-23 11:40:40 +0100 | [diff] [blame] | 224 | static const struct snd_soc_dai_ops psc_ac97_analog_ops = { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 225 | .hw_params = psc_ac97_hw_analog_params, |
| 226 | .trigger = psc_ac97_trigger, |
| 227 | }; |
| 228 | |
Lars-Peter Clausen | 85e7652 | 2011-11-23 11:40:40 +0100 | [diff] [blame] | 229 | static const struct snd_soc_dai_ops psc_ac97_digital_ops = { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 230 | .hw_params = psc_ac97_hw_digital_params, |
| 231 | }; |
| 232 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 233 | static struct snd_soc_dai_driver psc_ac97_dai[] = { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 234 | { |
Eric Millbrandt | a4f7b70 | 2012-09-13 17:43:12 -0400 | [diff] [blame] | 235 | .name = "mpc5200-psc-ac97.0", |
Lars-Peter Clausen | bc26321 | 2014-11-10 22:41:52 +0100 | [diff] [blame] | 236 | .bus_control = true, |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 237 | .probe = psc_ac97_probe, |
| 238 | .playback = { |
Eric Millbrandt | a4f7b70 | 2012-09-13 17:43:12 -0400 | [diff] [blame] | 239 | .stream_name = "AC97 Playback", |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 240 | .channels_min = 1, |
| 241 | .channels_max = 6, |
| 242 | .rates = SNDRV_PCM_RATE_8000_48000, |
| 243 | .formats = SNDRV_PCM_FMTBIT_S32_BE, |
| 244 | }, |
| 245 | .capture = { |
Eric Millbrandt | a4f7b70 | 2012-09-13 17:43:12 -0400 | [diff] [blame] | 246 | .stream_name = "AC97 Capture", |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 247 | .channels_min = 1, |
| 248 | .channels_max = 2, |
| 249 | .rates = SNDRV_PCM_RATE_8000_48000, |
| 250 | .formats = SNDRV_PCM_FMTBIT_S32_BE, |
| 251 | }, |
| 252 | .ops = &psc_ac97_analog_ops, |
| 253 | }, |
| 254 | { |
Eric Millbrandt | a4f7b70 | 2012-09-13 17:43:12 -0400 | [diff] [blame] | 255 | .name = "mpc5200-psc-ac97.1", |
Lars-Peter Clausen | bc26321 | 2014-11-10 22:41:52 +0100 | [diff] [blame] | 256 | .bus_control = true, |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 257 | .playback = { |
Eric Millbrandt | a4f7b70 | 2012-09-13 17:43:12 -0400 | [diff] [blame] | 258 | .stream_name = "AC97 SPDIF", |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 259 | .channels_min = 1, |
| 260 | .channels_max = 2, |
| 261 | .rates = SNDRV_PCM_RATE_32000 | \ |
| 262 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, |
| 263 | .formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE, |
| 264 | }, |
| 265 | .ops = &psc_ac97_digital_ops, |
| 266 | } }; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 267 | |
Kuninori Morimoto | f298a0f | 2013-03-21 03:31:41 -0700 | [diff] [blame] | 268 | static const struct snd_soc_component_driver psc_ac97_component = { |
| 269 | .name = DRV_NAME, |
| 270 | }; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 271 | |
| 272 | |
| 273 | /* --------------------------------------------------------------------- |
| 274 | * OF platform bus binding code: |
| 275 | * - Probe/remove operations |
| 276 | * - OF device match table |
| 277 | */ |
Bill Pemberton | a0a3d51 | 2012-12-07 09:26:16 -0500 | [diff] [blame] | 278 | static int psc_ac97_of_probe(struct platform_device *op) |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 279 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 280 | int rc; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 281 | struct mpc52xx_psc __iomem *regs; |
| 282 | |
Eric Millbrandt | f515b67 | 2012-09-13 17:43:11 -0400 | [diff] [blame] | 283 | rc = mpc5200_audio_dma_create(op); |
| 284 | if (rc != 0) |
| 285 | return rc; |
| 286 | |
Mark Brown | b047e1c | 2013-06-26 12:45:59 +0100 | [diff] [blame] | 287 | rc = snd_soc_set_ac97_ops(&psc_ac97_ops); |
| 288 | if (rc != 0) { |
Rob Herring | 5af5073 | 2013-09-17 14:28:33 -0500 | [diff] [blame] | 289 | dev_err(&op->dev, "Failed to set AC'97 ops: %d\n", rc); |
Mark Brown | b047e1c | 2013-06-26 12:45:59 +0100 | [diff] [blame] | 290 | return rc; |
| 291 | } |
| 292 | |
Kuninori Morimoto | f298a0f | 2013-03-21 03:31:41 -0700 | [diff] [blame] | 293 | rc = snd_soc_register_component(&op->dev, &psc_ac97_component, |
| 294 | psc_ac97_dai, ARRAY_SIZE(psc_ac97_dai)); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 295 | if (rc != 0) { |
| 296 | dev_err(&op->dev, "Failed to register DAI\n"); |
| 297 | return rc; |
| 298 | } |
| 299 | |
| 300 | psc_dma = dev_get_drvdata(&op->dev); |
| 301 | regs = psc_dma->psc_regs; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 302 | |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 303 | psc_dma->imr = 0; |
| 304 | out_be16(&psc_dma->psc_regs->isr_imr.imr, psc_dma->imr); |
| 305 | |
| 306 | /* Configure the serial interface mode to AC97 */ |
| 307 | psc_dma->sicr = MPC52xx_PSC_SICR_SIM_AC97 | MPC52xx_PSC_SICR_ENAC97; |
| 308 | out_be32(®s->sicr, psc_dma->sicr); |
| 309 | |
| 310 | /* No slots active */ |
| 311 | out_be32(®s->ac97_slots, 0x00000000); |
| 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
Bill Pemberton | a0a3d51 | 2012-12-07 09:26:16 -0500 | [diff] [blame] | 316 | static int psc_ac97_of_remove(struct platform_device *op) |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 317 | { |
Eric Millbrandt | f515b67 | 2012-09-13 17:43:11 -0400 | [diff] [blame] | 318 | mpc5200_audio_dma_destroy(op); |
Kuninori Morimoto | f298a0f | 2013-03-21 03:31:41 -0700 | [diff] [blame] | 319 | snd_soc_unregister_component(&op->dev); |
Mark Brown | b047e1c | 2013-06-26 12:45:59 +0100 | [diff] [blame] | 320 | snd_soc_set_ac97_ops(NULL); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 321 | return 0; |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | /* Match table for of_platform binding */ |
Fabian Frederick | 6ffa84d | 2015-03-18 17:48:57 +0100 | [diff] [blame] | 325 | static const struct of_device_id psc_ac97_match[] = { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 326 | { .compatible = "fsl,mpc5200-psc-ac97", }, |
| 327 | { .compatible = "fsl,mpc5200b-psc-ac97", }, |
| 328 | {} |
| 329 | }; |
| 330 | MODULE_DEVICE_TABLE(of, psc_ac97_match); |
| 331 | |
Grant Likely | f07eb22 | 2011-02-22 21:05:04 -0700 | [diff] [blame] | 332 | static struct platform_driver psc_ac97_driver = { |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 333 | .probe = psc_ac97_of_probe, |
Bill Pemberton | a0a3d51 | 2012-12-07 09:26:16 -0500 | [diff] [blame] | 334 | .remove = psc_ac97_of_remove, |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 335 | .driver = { |
| 336 | .name = "mpc5200-psc-ac97", |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 337 | .of_match_table = psc_ac97_match, |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 338 | }, |
| 339 | }; |
| 340 | |
Axel Lin | ba0a7e0 | 2011-11-25 10:10:55 +0800 | [diff] [blame] | 341 | module_platform_driver(psc_ac97_driver); |
Jon Smirl | 20d0e152 | 2009-05-26 08:34:10 -0400 | [diff] [blame] | 342 | |
| 343 | MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); |
| 344 | MODULE_DESCRIPTION("mpc5200 AC97 module"); |
| 345 | MODULE_LICENSE("GPL"); |
| 346 | |