ALSA: hda/cs8409: Prevent I2C access during suspend time

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210811185654.6837-12-vitalyr@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Lucas Tanure 2021-08-11 19:56:38 +01:00 коммит произвёл Takashi Iwai
Родитель db0ae848a9
Коммит a1a6c7df2b
2 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -127,9 +127,13 @@ static int cs8409_i2c_wait_complete(struct hda_codec *codec)
static int cs8409_i2c_read(struct hda_codec *codec, unsigned int i2c_address, unsigned int i2c_reg,
unsigned int paged)
{
struct cs8409_spec *spec = codec->spec;
unsigned int i2c_reg_data;
unsigned int read_data;
if (spec->cs42l42_suspended)
return -EPERM;
cs8409_enable_i2c_clock(codec, 1);
cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, i2c_address);
@ -172,8 +176,12 @@ static int cs8409_i2c_read(struct hda_codec *codec, unsigned int i2c_address, un
static int cs8409_i2c_write(struct hda_codec *codec, unsigned int i2c_address, unsigned int i2c_reg,
unsigned int i2c_data, unsigned int paged)
{
struct cs8409_spec *spec = codec->spec;
unsigned int i2c_reg_data;
if (spec->cs42l42_suspended)
return -EPERM;
cs8409_enable_i2c_clock(codec, 1);
cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, i2c_address);
@ -371,6 +379,8 @@ static void cs8409_cs42l42_reset(struct hda_codec *codec)
/* wait ~10ms */
usleep_range(10000, 15000);
spec->cs42l42_suspended = 0;
mutex_lock(&spec->cs8409_i2c_mux);
/* Clear interrupts, by reading interrupt status registers */
@ -594,6 +604,9 @@ static int cs8409_suspend(struct hda_codec *codec)
/* Power down CS42L42 ASP/EQ/MIX/HP */
cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1101, 0xfe, 1);
mutex_unlock(&spec->cs8409_i2c_mux);
spec->cs42l42_suspended = 1;
/* Assert CS42L42 RTS# line */
snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, 0);
@ -759,6 +772,7 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
spec->cs42l42_hp_jack_in = 0;
spec->cs42l42_mic_jack_in = 0;
spec->cs42l42_suspended = 1;
/* Basic initial sequence for specific hw configuration */
snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs);

Просмотреть файл

@ -269,6 +269,7 @@ struct cs8409_spec {
unsigned int cs42l42_hp_jack_in:1;
unsigned int cs42l42_mic_jack_in:1;
unsigned int cs42l42_volume_init:1;
unsigned int cs42l42_suspended:1;
char cs42l42_hp_volume[CS42L42_HP_CH];
char cs42l42_hs_mic_volume[CS42L42_HS_MIC_CH];