Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp7028849pxv; Fri, 30 Jul 2021 08:21:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEqd3HHAu5cxvKeGoc2vJ6G099V6APKtD0epaNUMxegykUYiDDsbJFG70c5d3SVmabb6ZS X-Received: by 2002:a05:6402:22b0:: with SMTP id cx16mr3574208edb.185.1627658505912; Fri, 30 Jul 2021 08:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627658505; cv=none; d=google.com; s=arc-20160816; b=tDRSVwPJbGLhUEls2mexZEqyqMNt5lrV4elOI4dflazZvE9WfW4QO12A/DjXh1YPU7 Vj98G30JeIuX9d3qZLv4wB104Y3Ohf8ZbGgrWkD5Ms2Itiu/GHSWnAUwtXEKJfkesnKm 7Rgxhnl8NZNY4sn+jbHMc6PbLCWQUYORdrCG5tW0r6us/0FTXT8+/8O74nv/xNw6APcb vlttlpYkjOC7BtZs+lLwhEBIR5MW7wd0ZmFzTiSXdNtSwEHK/02t9Y/B5tpOlzXR+0VY +1GtEPTafxi851spYBhq8KBzfaYOgG0acekTRkRV4TrwCuG+KY/X7BZ5kFUjKogIu+ji bMyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u/raanWu8QxKw7hxEaMYUQ8wjoKB+rgkVuf1kEvYiUU=; b=gluywmNhRCMWDIoqX0hKvrT5OSeVr6WXACeW31icA8eq1cHr+vETHxqzV9b6t0SdYu hPERmTaWyG1cegWxq4FSBgJkuRcPrugtaaKlOy/hD5SgPo4C29MneIKJbMa/+LkXnV2A JRNu3yGC4P05sr6/L8TWm1xWqbB/rq9d1wa28Rg+TwPGlSWvymhrbibM4UKJF75eM01a F3ttGJ/2RZUozHinMOkUZgaCTWLdPKeqMgDP2ekGNa3oIA8o+kUDbGOK086YsnOGZcl0 ZNH1DiYON9Rv5kPvehzqG4JuYuKIn52ZGSZhxCinkFxylHZTPRFgbMmIuzjO/gl6mJma pxFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=YUcTjmrZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q1si1954278ejr.43.2021.07.30.08.21.22; Fri, 30 Jul 2021 08:21:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=YUcTjmrZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239802AbhG3PTs (ORCPT + 99 others); Fri, 30 Jul 2021 11:19:48 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:59752 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239655AbhG3PTe (ORCPT ); Fri, 30 Jul 2021 11:19:34 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 16UEL0df003614; Fri, 30 Jul 2021 10:19:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=u/raanWu8QxKw7hxEaMYUQ8wjoKB+rgkVuf1kEvYiUU=; b=YUcTjmrZSHI2cDqTVPeK6rvlz7mcdzI+oPkmMRAfYk3iLCpzo4o5OPtOrUxM9Fz0vnyD BUMd2yWIfHCoa5WOPhTrHbV4o7BLO2sndqzeLv/pPxaskkWl8DGNd+k4ywoOocM+lnNa 1DJhg0NOcPuuE4CWpMr5NfCozXGwwrcSNgcaSNj0nYPRzdIQBR2RRYXz/uGrV0JxjEus 7mLS+I8H6cR/IxhjGCLoXC7J3zETveA7+diwPyfeXoEwOpVT9WhCflGk9TeCWbBbxnQ5 NVbs4lARN64wsD/hbUc8C6O1Y5rBI7qfZfH4RaVniht1a0GrUaLejcbvukskUmasaEDG vA== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 3a41wd181n-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 30 Jul 2021 10:19:17 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Fri, 30 Jul 2021 16:19:09 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Fri, 30 Jul 2021 16:19:09 +0100 Received: from vitaly-Inspiron-5415.ad.cirrus.com (unknown [198.90.238.32]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 22DEB45D; Fri, 30 Jul 2021 15:19:09 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai CC: , , , Lucas Tanure Subject: [PATCH v3 11/27] ALSA: hda/cs8409: Prevent I2C access during suspend time Date: Fri, 30 Jul 2021 16:18:28 +0100 Message-ID: <20210730151844.7873-12-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210730151844.7873-1-vitalyr@opensource.cirrus.com> References: <20210730151844.7873-1-vitalyr@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: GVslHpCjrnPGDDMmvazMJ7M8BKSt3lkv X-Proofpoint-ORIG-GUID: GVslHpCjrnPGDDMmvazMJ7M8BKSt3lkv X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 impostorscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107300102 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lucas Tanure Signed-off-by: Lucas Tanure Signed-off-by: Vitaly Rodionov --- Changes in v2: - No changes Changes in v3: - No changes sound/pci/hda/patch_cs8409.c | 14 ++++++++++++++ sound/pci/hda/patch_cs8409.h | 1 + 2 files changed, 15 insertions(+) diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index 4ad832f5c4ba..0b13bcecd778 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -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); diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index 1d3ce28415fa..0f2084b6ec8e 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -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]; -- 2.25.1