From patchwork Thu Aug 19 06:14:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1518446 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GqvfB6dklz9t0p; Thu, 19 Aug 2021 16:16:02 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mGbLL-0000lG-Q3; Thu, 19 Aug 2021 06:15:59 +0000 Received: from mail-pj1-f42.google.com ([209.85.216.42]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mGbKl-0000Ez-Qg for kernel-team@lists.ubuntu.com; Thu, 19 Aug 2021 06:15:24 +0000 Received: by mail-pj1-f42.google.com with SMTP id fa24-20020a17090af0d8b0290178bfa69d97so4108079pjb.0 for ; Wed, 18 Aug 2021 23:15:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AfQBdC0acLcheWxi/7W5Er5KQ5ZhhivXyjS0iJwekJw=; b=cBmLtq3R65661gPAneg6FetTutKnkiTihy2VAuky+sFGz47J3/5YPCKyu9pdRW0skV bCc2d7oQRZgjNoeiNoVlrJznw2moBkLkyKwuyzJszToFzoS0yGoQhW1pFMRfs8GW+8BB zIGeyMEZ2/0h6+0FXNWZwG1pcyWDp1vgy4yg/8Iv2SqjgEJfXDt0HEEERvilxMmmD9zr n/Kn4dXlFDnCPCP65Fv572zL6hGk1faU8B5zSshqXJvZNgJfRFuHJ5vsBu1OqIhMLGf9 U2sFGshSHwdvYwk3UBOU4sl5faV4sxr7qnDdYerNXiVyex+wae+yhYIRbpk6vGARIKj4 CYUQ== X-Gm-Message-State: AOAM5329CHo9/iAfbrYJA8MsP0HKT6e93gDs/bYQFOxKce3XYpIfshPy KGp/+qtGOsMn7UM8VBQ8KTK9DXwvmkkbdw== X-Google-Smtp-Source: ABdhPJwnGDhX/N45JdHyNcp0of/6t0u8fqBkilfZHJ1Jl0A5mpZcmUgdVgpTkR4YDBYnA0u/n+NiAQ== X-Received: by 2002:a17:90a:bd87:: with SMTP id z7mr13268259pjr.163.1629353716284; Wed, 18 Aug 2021 23:15:16 -0700 (PDT) Received: from localhost (114-47-140-65.dynamic-ip.hinet.net. [114.47.140.65]) by smtp.gmail.com with ESMTPSA id x19sm2208786pgk.37.2021.08.18.23.15.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 23:15:16 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 26/30][SRU][OEM-5.13][I][U] ALSA: hda/cs8409: Follow correct CS42L42 power down sequence for suspend Date: Thu, 19 Aug 2021 14:14:22 +0800 Message-Id: <20210819061427.900601-27-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210819061427.900601-1-vicamo.yang@canonical.com> References: <20210819061427.900601-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.42; envelope-from=vicamo@gmail.com; helo=mail-pj1-f42.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Stefan Binding BugLink: https://bugs.launchpad.net/bugs/1939541 Signed-off-by: Stefan Binding Signed-off-by: Vitaly Rodionov Link: https://lore.kernel.org/r/20210811185654.6837-27-vitalyr@opensource.cirrus.com Signed-off-by: Takashi Iwai (cherry picked from commit 4ff2ae3a135ffe3f849492fd59ebeda3c7d1100f) Signed-off-by: You-Sheng Yang --- sound/pci/hda/patch_cs8409.c | 23 ++++++++++++++++++++++- sound/pci/hda/patch_cs8409.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index b528c8353b3c..928972b4315d 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "patch_cs8409.h" @@ -219,6 +220,7 @@ static int cs8409_i2c_read(struct sub_codec *scodec, unsigned int addr) read_data = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD); mutex_unlock(&spec->i2c_mux); + return read_data & 0x0ff; error: @@ -675,9 +677,28 @@ static void cs42l42_suspend(struct sub_codec *cs42l42) { struct hda_codec *codec = cs42l42->codec; unsigned int gpio_data; + int reg_cdc_status = 0; + const struct cs8409_i2c_param cs42l42_pwr_down_seq[] = { + { 0x2301, 0x3F }, + { 0x2302, 0x3F }, + { 0x2303, 0x3F }, + { 0x2001, 0x0F }, + { 0x2A01, 0x00 }, + { 0x1207, 0x00 }, + { 0x1101, 0xFE }, + { 0x1102, 0x8C }, + { 0x1101, 0xFF }, + }; + + cs8409_i2c_bulk_write(cs42l42, cs42l42_pwr_down_seq, ARRAY_SIZE(cs42l42_pwr_down_seq)); + + if (read_poll_timeout(cs8409_i2c_read, reg_cdc_status, + (reg_cdc_status & 0x1), CS42L42_PDN_SLEEP_US, CS42L42_PDN_TIMEOUT_US, + true, cs42l42, 0x1308) < 0) + codec_warn(codec, "Timeout waiting for PDN_DONE for CS42L42\n"); /* Power down CS42L42 ASP/EQ/MIX/HP */ - cs8409_i2c_write(cs42l42, 0x1101, 0xfe); + cs8409_i2c_write(cs42l42, 0x1102, 0x9C); cs42l42->suspended = 1; cs42l42->last_page = 0; diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index 71dbbd8e2f3b..09987daa9cbf 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -233,6 +233,8 @@ enum cs8409_coefficient_index_registers { #define CS42L42_JACK_REMOVED (0x00) #define CS42L42_I2C_TIMEOUT_US (20000) #define CS42L42_I2C_SLEEP_US (2000) +#define CS42L42_PDN_TIMEOUT_US (250000) +#define CS42L42_PDN_SLEEP_US (2000) /* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */