^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * sam9g20_wm8731 -- SoC audio for AT91SAM9G20-based
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * ATMEL AT91SAM9G20ek board.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2005 SAN People
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2008 Atmel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Based on ati_b1_wm8731.c by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Frank Mandarino <fmandarino@endrelia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Copyright 2006 Endrelia Technologies Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Based on corgi.c by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Copyright 2005 Wolfson Microelectronics PLC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Copyright 2005 Openedhand Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/clk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/atmel-ssc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <sound/pcm_params.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include "../codecs/wm8731.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include "atmel-pcm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include "atmel_ssc_dai.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define MCLK_RATE 12000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * As shipped the board does not have inputs. However, it is relatively
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * straightforward to modify the board to hook them up so support is left
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * in the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #undef ENABLE_MIC_INPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static struct clk *mclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct snd_soc_dapm_context *dapm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) enum snd_soc_bias_level level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static int mclk_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) switch (level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) case SND_SOC_BIAS_ON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) case SND_SOC_BIAS_PREPARE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (!mclk_on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ret = clk_enable(mclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) mclk_on = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) case SND_SOC_BIAS_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) case SND_SOC_BIAS_STANDBY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) if (mclk_on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) clk_disable(mclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) mclk_on = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static const struct snd_soc_dapm_widget at91sam9g20ek_dapm_widgets[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) SND_SOC_DAPM_MIC("Int Mic", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) SND_SOC_DAPM_SPK("Ext Spk", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static const struct snd_soc_dapm_route intercon[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /* speaker connected to LHPOUT/RHPOUT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {"Ext Spk", NULL, "LHPOUT"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {"Ext Spk", NULL, "RHPOUT"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* mic is connected to Mic Jack, with WM8731 Mic Bias */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {"MICIN", NULL, "Mic Bias"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {"Mic Bias", NULL, "Int Mic"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * Logic for a wm8731 as connected on a at91sam9g20ek board.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static int at91sam9g20ek_wm8731_init(struct snd_soc_pcm_runtime *rtd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct device *dev = rtd->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) dev_dbg(dev, "%s called\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_MCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) MCLK_RATE, SND_SOC_CLOCK_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) dev_err(dev, "Failed to set WM8731 SYSCLK: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #ifndef ENABLE_MIC_INPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) snd_soc_dapm_nc_pin(&rtd->card->dapm, "Int Mic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) SND_SOC_DAILINK_DEFS(pcm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) DAILINK_COMP_ARRAY(COMP_CPU("at91rm9200_ssc.0")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) DAILINK_COMP_ARRAY(COMP_PLATFORM("at91rm9200_ssc.0")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static struct snd_soc_dai_link at91sam9g20ek_dai = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) .name = "WM8731",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) .stream_name = "WM8731 PCM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) .init = at91sam9g20ek_wm8731_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) SND_SOC_DAIFMT_CBM_CFM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) SND_SOC_DAILINK_REG(pcm),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static struct snd_soc_card snd_soc_at91sam9g20ek = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) .name = "AT91SAMG20-EK",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) .dai_link = &at91sam9g20ek_dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) .num_links = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) .set_bias_level = at91sam9g20ek_set_bias_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) .dapm_widgets = at91sam9g20ek_dapm_widgets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .num_dapm_widgets = ARRAY_SIZE(at91sam9g20ek_dapm_widgets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) .dapm_routes = intercon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) .num_dapm_routes = ARRAY_SIZE(intercon),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) .fully_routed = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static int at91sam9g20ek_audio_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct device_node *np = pdev->dev.of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct device_node *codec_np, *cpu_np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct clk *pllb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct snd_soc_card *card = &snd_soc_at91sam9g20ek;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!np) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) ret = atmel_ssc_set_audio(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) dev_err(&pdev->dev, "ssc channel is not valid\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * Codec MCLK is supplied by PCK0 - set it up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) mclk = clk_get(NULL, "pck0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (IS_ERR(mclk)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) dev_err(&pdev->dev, "Failed to get MCLK\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) ret = PTR_ERR(mclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) pllb = clk_get(NULL, "pllb");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (IS_ERR(pllb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) dev_err(&pdev->dev, "Failed to get PLLB\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ret = PTR_ERR(pllb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) goto err_mclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) ret = clk_set_parent(mclk, pllb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) clk_put(pllb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) if (ret != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) dev_err(&pdev->dev, "Failed to set MCLK parent\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) goto err_mclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) clk_set_rate(mclk, MCLK_RATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) card->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /* Parse device node info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ret = snd_soc_of_parse_card_name(card, "atmel,model");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ret = snd_soc_of_parse_audio_routing(card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) "atmel,audio-routing");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /* Parse codec info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) at91sam9g20ek_dai.codecs->name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) codec_np = of_parse_phandle(np, "atmel,audio-codec", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!codec_np) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) dev_err(&pdev->dev, "codec info missing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) at91sam9g20ek_dai.codecs->of_node = codec_np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* Parse dai and platform info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) at91sam9g20ek_dai.cpus->dai_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) at91sam9g20ek_dai.platforms->name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (!cpu_np) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) dev_err(&pdev->dev, "dai and pcm info missing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) of_node_put(codec_np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) at91sam9g20ek_dai.cpus->of_node = cpu_np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) at91sam9g20ek_dai.platforms->of_node = cpu_np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) of_node_put(codec_np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) of_node_put(cpu_np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) ret = snd_soc_register_card(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) dev_err(&pdev->dev, "snd_soc_register_card() failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) err_mclk:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) clk_put(mclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) mclk = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) atmel_ssc_put_audio(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static int at91sam9g20ek_audio_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) struct snd_soc_card *card = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) clk_disable(mclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) mclk = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) snd_soc_unregister_card(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) atmel_ssc_put_audio(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static const struct of_device_id at91sam9g20ek_wm8731_dt_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) { .compatible = "atmel,at91sam9g20ek-wm8731-audio", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) MODULE_DEVICE_TABLE(of, at91sam9g20ek_wm8731_dt_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static struct platform_driver at91sam9g20ek_audio_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) .name = "at91sam9g20ek-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) .of_match_table = of_match_ptr(at91sam9g20ek_wm8731_dt_ids),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) .probe = at91sam9g20ek_audio_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) .remove = at91sam9g20ek_audio_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) module_platform_driver(at91sam9g20ek_audio_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /* Module information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) MODULE_ALIAS("platform:at91sam9g20ek-audio");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) MODULE_LICENSE("GPL");