Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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)  * tosa.c  --  SoC audio for Tosa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright 2005 Wolfson Microelectronics PLC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright 2005 Openedhand Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Authors: Liam Girdwood <lrg@slimlogic.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *          Richard Purdie <richard@openedhand.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * GPIO's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  1 - Jack Insertion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  5 - Hookswitch (headset answer/hang up switch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <mach/tosa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <mach/audio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define TOSA_HP        0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define TOSA_MIC_INT   1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define TOSA_HEADSET   2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define TOSA_HP_OFF    3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define TOSA_SPK_ON    0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define TOSA_SPK_OFF   1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static int tosa_jack_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) static int tosa_spk_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static void tosa_ext_control(struct snd_soc_dapm_context *dapm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	snd_soc_dapm_mutex_lock(dapm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	/* set up jack connection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	switch (tosa_jack_func) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	case TOSA_HP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		snd_soc_dapm_disable_pin_unlocked(dapm, "Mic (Internal)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	case TOSA_MIC_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		snd_soc_dapm_enable_pin_unlocked(dapm, "Mic (Internal)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	case TOSA_HEADSET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		snd_soc_dapm_disable_pin_unlocked(dapm, "Mic (Internal)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Jack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	if (tosa_spk_func == TOSA_SPK_ON)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		snd_soc_dapm_enable_pin_unlocked(dapm, "Speaker");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		snd_soc_dapm_disable_pin_unlocked(dapm, "Speaker");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	snd_soc_dapm_sync_unlocked(dapm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	snd_soc_dapm_mutex_unlock(dapm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static int tosa_startup(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	/* check the jack status at stream startup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	tosa_ext_control(&rtd->card->dapm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	return 0;
^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_ops tosa_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	.startup = tosa_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static int tosa_get_jack(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	ucontrol->value.enumerated.item[0] = tosa_jack_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return 0;
^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) static int tosa_set_jack(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	if (tosa_jack_func == ucontrol->value.enumerated.item[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	tosa_jack_func = ucontrol->value.enumerated.item[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	tosa_ext_control(&card->dapm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static int tosa_get_spk(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	ucontrol->value.enumerated.item[0] = tosa_spk_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static int tosa_set_spk(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	if (tosa_spk_func == ucontrol->value.enumerated.item[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	tosa_spk_func = ucontrol->value.enumerated.item[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	tosa_ext_control(&card->dapm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* tosa dapm event handlers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) static int tosa_hp_event(struct snd_soc_dapm_widget *w,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct snd_kcontrol *k, int event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	gpio_set_value(TOSA_GPIO_L_MUTE, SND_SOC_DAPM_EVENT_ON(event) ? 1 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* tosa machine dapm widgets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static const struct snd_soc_dapm_widget tosa_dapm_widgets[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) SND_SOC_DAPM_HP("Headphone Jack", tosa_hp_event),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) SND_SOC_DAPM_HP("Headset Jack", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) SND_SOC_DAPM_MIC("Mic (Internal)", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) SND_SOC_DAPM_SPK("Speaker", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* tosa audio map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static const struct snd_soc_dapm_route audio_map[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	/* headphone connected to HPOUTL, HPOUTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	{"Headphone Jack", NULL, "HPOUTL"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	{"Headphone Jack", NULL, "HPOUTR"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	/* ext speaker connected to LOUT2, ROUT2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	{"Speaker", NULL, "LOUT2"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	{"Speaker", NULL, "ROUT2"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	/* internal mic is connected to mic1, mic2 differential - with bias */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	{"MIC1", NULL, "Mic Bias"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	{"MIC2", NULL, "Mic Bias"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	{"Mic Bias", NULL, "Mic (Internal)"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	/* headset is connected to HPOUTR, and LINEINR with bias */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	{"Headset Jack", NULL, "HPOUTR"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	{"LINEINR", NULL, "Mic Bias"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	{"Mic Bias", NULL, "Headset Jack"},
^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) static const char * const jack_function[] = {"Headphone", "Mic", "Line",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	"Headset", "Off"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static const char * const spk_function[] = {"On", "Off"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static const struct soc_enum tosa_enum[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	SOC_ENUM_SINGLE_EXT(5, jack_function),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	SOC_ENUM_SINGLE_EXT(2, spk_function),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) static const struct snd_kcontrol_new tosa_controls[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	SOC_ENUM_EXT("Jack Function", tosa_enum[0], tosa_get_jack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		tosa_set_jack),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	SOC_ENUM_EXT("Speaker Function", tosa_enum[1], tosa_get_spk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		tosa_set_spk),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) SND_SOC_DAILINK_DEFS(ac97,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-hifi")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) SND_SOC_DAILINK_DEFS(ac97_aux,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97-aux")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-aux")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static struct snd_soc_dai_link tosa_dai[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	.name = "AC97",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	.stream_name = "AC97 HiFi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	.ops = &tosa_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	SND_SOC_DAILINK_REG(ac97),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	.name = "AC97 Aux",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	.stream_name = "AC97 Aux",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	.ops = &tosa_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	SND_SOC_DAILINK_REG(ac97_aux),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static struct snd_soc_card tosa = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	.name = "Tosa",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	.dai_link = tosa_dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	.num_links = ARRAY_SIZE(tosa_dai),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	.controls = tosa_controls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	.num_controls = ARRAY_SIZE(tosa_controls),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	.dapm_widgets = tosa_dapm_widgets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	.num_dapm_widgets = ARRAY_SIZE(tosa_dapm_widgets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	.dapm_routes = audio_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	.num_dapm_routes = ARRAY_SIZE(audio_map),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.fully_routed = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static int tosa_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	struct snd_soc_card *card = &tosa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	ret = gpio_request_one(TOSA_GPIO_L_MUTE, GPIOF_OUT_INIT_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 			       "Headphone Jack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	card->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	ret = devm_snd_soc_register_card(&pdev->dev, card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		gpio_free(TOSA_GPIO_L_MUTE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	}
^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 tosa_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) 	gpio_free(TOSA_GPIO_L_MUTE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static struct platform_driver tosa_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		.name	= "tosa-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		.pm     = &snd_soc_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	.probe		= tosa_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	.remove		= tosa_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) module_platform_driver(tosa_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* Module information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) MODULE_AUTHOR("Richard Purdie");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) MODULE_DESCRIPTION("ALSA SoC Tosa");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) MODULE_ALIAS("platform:tosa-audio");