Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp302025rdb; Fri, 6 Oct 2023 04:11:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjaSLv31xbTpiAwnB6vT7uYDoKDdMRpbogBJ/vgugKWCGzS0aCvjtbHXIefoKHKRJpy11f X-Received: by 2002:a05:6a00:198a:b0:693:3fa4:9c56 with SMTP id d10-20020a056a00198a00b006933fa49c56mr8267431pfl.25.1696590687105; Fri, 06 Oct 2023 04:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696590687; cv=none; d=google.com; s=arc-20160816; b=TKqRPbAkzQWGr0JYNO4pHfoia9DffdcNudfVDohhH4WdcqGe2UlqYjR0qTQM9eQThV 6vjP1g4KAa1D2xZYDi9xZObDBroYS8km4iPGDFvbJv7+j+gESWPKWfs4zPjcBZs4nbWh O1X+MGmtl+tO6vFam/voMc+shmtJwgn2BvPvXbvAtBqTouu9QSmkySEH7zsKCm3foRYQ /1V54AR+bUDcLyldeif8/XGzCjVvvxr9l2X42aFuSRqSDmkIMWs04vLdErFi0GyRyGjX 4ZIJSIqqAW7376D4LVgvd0KOJ/Pwd7bAUI9U9fyOO4Vb1GemgKWxG5sk7dknaHUQgf2N okGw== 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=RlyXKyITjmeNbb6voK2kiPtwUMgBnTpkOA+RxMPoLIg=; fh=Rl1wQ59/j6+8vTsmPNZ5QU5HcfLJ8GHCArwj1jVIO9Y=; b=TmQzgBLS3RCIOCEIbw2f7Y3EA5LijnE/N6yGr/MTk0h3oDwxhdLv2Cl7R9H9vXl2hD ZxBzH84qq1R407gaAgcv0TuBwPc4KSRt1eBatuk3VIoXLiqCM/+2PJoPONXx6kWIQ2iO 1CLn+qqxAu1JWZWaL9qdN0qcfKNEqTy83BtGO8LfBIQvSWT+27MXMpby7IxqZe+WlLj4 YvC3WFDvzwHUTl1wR77fMtf6sueLEkgsultvryHSsyht+A48HDXkf2ohiDV8Eav3S7k8 m6ahdOhCan8HvQ1juHlo/RtNlS/lQ3yOFkDMAQG7NTHYtciZmj2V8QtLX0OCWvuAdoJI qwAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=QPOi9KeQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id v8-20020a655c48000000b005789f94cd34si3273465pgr.636.2023.10.06.04.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 04:11:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=QPOi9KeQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9A32683D8D68; Fri, 6 Oct 2023 04:11:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbjJFLK5 (ORCPT + 99 others); Fri, 6 Oct 2023 07:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231889AbjJFLK4 (ORCPT ); Fri, 6 Oct 2023 07:10:56 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2850DB for ; Fri, 6 Oct 2023 04:10:52 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 3965fxce025983; Fri, 6 Oct 2023 06:10:45 -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=RlyXKyITjmeNbb6voK2kiPtwUMgBnTpkOA+RxMPoLIg=; b= QPOi9KeQqQpZRQU+r2xbZi+XuvNxhBp7qpe46+J1LFQhcf0/TUgjngZ5WnC1dnW2 gYhQ9YcSo4/Lj6Y2CNNPiLvyLgp9tksCwUT7n2UHjSwcCk7B8jvZQvOrN+jAuAmB mkDOMtxjmgHBp1/gPqjLCDucE+6LtoPA4bRyVzLcU1map4KgGMGOQe6x5UZ+XUq9 b5hk5qlUyPjs1Xrp5MRUW8y8yMEZCiPLlGJLrCSdMm30r0ftzWsDAO/Si20qGmW1 +JbzZHVcbOTPWMfXfIjlqOud9ngfcf2ITJdHQgORXlHAR60lE26Rc8JiLgtpPzFn JDNBkwUumvXylA4ki2IZLQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3th2dtbmxb-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Oct 2023 06:10:45 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Fri, 6 Oct 2023 12:10:42 +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.2.1118.37 via Frontend Transport; Fri, 6 Oct 2023 12:10:42 +0100 Received: from work-debian.ad.cirrus.com (unknown [198.61.64.45]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id A1CEA11AA; Fri, 6 Oct 2023 11:10:42 +0000 (UTC) From: Richard Fitzgerald To: CC: , , , Simon Trimmer , Richard Fitzgerald Subject: [PATCH 2/4] ASoC: cs35l56: Wake transactions need to be issued twice Date: Fri, 6 Oct 2023 12:10:37 +0100 Message-ID: <20231006111039.101914-3-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231006111039.101914-1-rf@opensource.cirrus.com> References: <20231006111039.101914-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: vfrFDBZ8iX4B25Cg-1VZgT8UXHnE1qt4 X-Proofpoint-GUID: vfrFDBZ8iX4B25Cg-1VZgT8UXHnE1qt4 X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 04:11:18 -0700 (PDT) X-Spam-Level: ** From: Simon Trimmer As the dummy wake is a toggling signal (either I2C or SPI activity) it is not guaranteed to meet the minimum asserted hold time for a wake signal. In this case the wake must guarantee rising edges separated by at least the minimum hold time. Signed-off-by: Simon Trimmer Signed-off-by: Richard Fitzgerald --- include/sound/cs35l56.h | 1 + sound/soc/codecs/cs35l56-shared.c | 51 +++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h index 762b96b29211..8c18e8b6d27d 100644 --- a/include/sound/cs35l56.h +++ b/include/sound/cs35l56.h @@ -243,6 +243,7 @@ #define CS35L56_HALO_STATE_POLL_US 1000 #define CS35L56_HALO_STATE_TIMEOUT_US 50000 #define CS35L56_RESET_PULSE_MIN_US 1100 +#define CS35L56_WAKE_HOLD_TIME_US 1000 #define CS35L56_SDW1_PLAYBACK_PORT 1 #define CS35L56_SDW1_CAPTURE_PORT 3 diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c index 68dc93b82789..953ba066bab1 100644 --- a/sound/soc/codecs/cs35l56-shared.c +++ b/sound/soc/codecs/cs35l56-shared.c @@ -446,6 +446,32 @@ static const struct reg_sequence cs35l56_hibernate_wake_seq[] = { REG_SEQ0(CS35L56_DSP_VIRTUAL1_MBOX_1, CS35L56_MBOX_CMD_WAKEUP), }; +static void cs35l56_issue_wake_event(struct cs35l56_base *cs35l56_base) +{ + /* + * Dummy transactions to trigger I2C/SPI auto-wake. Issue two + * transactions to meet the minimum required time from the rising edge + * to the last falling edge of wake. + * + * It uses bypassed write because we must wake the chip before + * disabling regmap cache-only. + * + * This can NAK on I2C which will terminate the write sequence so the + * single-write sequence is issued twice. + */ + regmap_multi_reg_write_bypassed(cs35l56_base->regmap, + cs35l56_hibernate_wake_seq, + ARRAY_SIZE(cs35l56_hibernate_wake_seq)); + + usleep_range(CS35L56_WAKE_HOLD_TIME_US, 2 * CS35L56_WAKE_HOLD_TIME_US); + + regmap_multi_reg_write_bypassed(cs35l56_base->regmap, + cs35l56_hibernate_wake_seq, + ARRAY_SIZE(cs35l56_hibernate_wake_seq)); + + cs35l56_wait_control_port_ready(); +} + int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base) { unsigned int val; @@ -500,17 +526,9 @@ int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_sou if (!cs35l56_base->can_hibernate) goto out_sync; - if (!is_soundwire) { - /* - * Dummy transaction to trigger I2C/SPI auto-wake. This will NAK on I2C. - * Must be done before releasing cache-only. - */ - regmap_multi_reg_write_bypassed(cs35l56_base->regmap, - cs35l56_hibernate_wake_seq, - ARRAY_SIZE(cs35l56_hibernate_wake_seq)); - - cs35l56_wait_control_port_ready(); - } + /* Must be done before releasing cache-only */ + if (!is_soundwire) + cs35l56_issue_wake_event(cs35l56_base); out_sync: regcache_cache_only(cs35l56_base->regmap, false); @@ -578,13 +596,14 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base) unsigned int devid, revid, otpid, secured; /* - * If the system is not using a reset_gpio then issue a - * dummy read to force a wakeup. + * When the system is not using a reset_gpio ensure the device is + * awake, otherwise the device has just been released from reset and + * the driver must wait for the control port to become usable. */ if (!cs35l56_base->reset_gpio) - regmap_read(cs35l56_base->regmap, CS35L56_DSP_VIRTUAL1_MBOX_1, &devid); - - cs35l56_wait_control_port_ready(); + cs35l56_issue_wake_event(cs35l56_base); + else + cs35l56_wait_control_port_ready(); /* * The HALO_STATE register is in different locations on Ax and B0 -- 2.30.2