Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp2352453qtg; Wed, 22 Mar 2023 22:32:38 -0700 (PDT) X-Google-Smtp-Source: AK7set8mZvaqLZAq+yuoCQdJh2dMBw4NDUbC1TH0uLD7YPTo0zYyQP3IJ8yYcgcdnUQynZf5vaAe X-Received: by 2002:a05:6a20:4e1a:b0:d9:2827:b65a with SMTP id gk26-20020a056a204e1a00b000d92827b65amr1969721pzb.5.1679549558110; Wed, 22 Mar 2023 22:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679549558; cv=none; d=google.com; s=arc-20160816; b=hyNdZUJwRm8qJc6FShlfMpp/RsjBvETAEgMl0wayp8lOOKEJIVnBY+PDcEOEVmbajK acidKCnAi7B2Yu0TgNOCw7K8qmkQx5m17Dmjb/ZlK8VWVF5uYp1xqd4SZ5TUHwyGYFYk rTGbFN5/luOySX8gc6nvohIZC8DX3p+kqZZG9e0SGH7cZScNu/RzrVdGVQaZlwWfvbCW CCsmapyAtjQ3n0AaAAG4mhPEJUhdaNPiCOZ3d443mD3nP/N7GCIU52yya6zbo8OeXPTZ FWeAGHGuEOA2XzUpAXiHkVtB3m6EdSwByRpL5qsQMniVPYBcdp+AXqRcg419h6iv24r3 fSEA== 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=WGGXlQghPSdmVTg9Bhhj5B+HROJoHvXLSMO0L97gHWQ=; b=FzzbjZFeptz6rl6ITw/MaHdwfla9BA9i4qhn7+bViVQBpJDo1xwBYxQjCICTeukMxT 3F1TkUVj85Hkt2UoLGp4AJb9XNZZ7VE2eQ1jcS6G6S+Nm/JL2XrdMkViK8MHcNYLumgI wbz7vKgmby0vmu0CYMIMINuX7VSmNrJr20lDz99VcD+ZvQs36wBHBZQ0u3VEUyRvEFh4 2X3687xkZJI2p0dHSzbpOfEuOuVSRV3W1Pm3YQrzmzmUXVRHDUmT2PQmKWQNJNnzT6tl R0egGDvGgkfcvtr8OsuHjJA9WjIyunpfTEwM7IydnZUstoA8cymDL/JZW0mKwFIQqcSe UTUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ALhUWyoj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a6566c5000000b0050c10b43533si17137185pgw.60.2023.03.22.22.32.25; Wed, 22 Mar 2023 22:32:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ALhUWyoj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbjCWFbf (ORCPT + 99 others); Thu, 23 Mar 2023 01:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbjCWFbF (ORCPT ); Thu, 23 Mar 2023 01:31:05 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18BC022797 for ; Wed, 22 Mar 2023 22:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679549456; x=1711085456; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aNL2KliVK/W0PGGaQa+13McnVurhskx2OOU+yOO7uSY=; b=ALhUWyojgqzHzE6KZpUEEJgv2r6amjn/APoDkMzpbwHmI2Ev+5f0wGkL GrQ1EeYTsQGiaArk4Se0fDL4P7Xwjp/rABdqYaK6BXjU1Wbgrdlyykfkp BWTijKAFWhhrYc2t8gRwFsp2l3fZDVW4skpvsWXy3bqJ2EnB7YFhRHtA7 XGuGkkRdKRZfXeXpi4ig3/KeLpEr6D1oD8ySB+b8SGQSc3LSZR/y+MisP N+ZC8dkWQB2HegBJfn0Z8cKqLCY+hgwE5r/Wi1kY8pKx67rlYxUhZX5zi St3A+hK6xOt5xJSdroWfcHVUU9UN60TM6J0WWh8WpM441bU3OfwRVwosE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327779422" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="327779422" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 22:30:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="675567132" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="675567132" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 22:30:18 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org, broonie@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, tiwai@suse.de Subject: [PATCH 12/20] soundwire: intel_ace2x: set SYNCPRD before powering-up Date: Thu, 23 Mar 2023 13:44:44 +0800 Message-Id: <20230323054452.1543233-13-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230323054452.1543233-1-yung-chuan.liao@linux.intel.com> References: <20230323054452.1543233-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart The registers used for multi-link synchronization are no longer in the SHIM but in the HDaudio multi-link capability space. Use helpers to configure the SYNCPRD value, and wait for SYNCPU to change after powering-up. Note that the SYNCPRD value is shared between all sublinks, for obvious reasons if those links are supposed to be synchronized. The value of SYNCPRD is programmed only once for all sublinks. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Péter Ujfalusi Reviewed-by: Ranjani Sridharan Signed-off-by: Bard Liao --- drivers/soundwire/intel_ace2x.c | 42 +++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index 5b6a608e63ba..01668246b7ba 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -17,17 +17,51 @@ static int intel_link_power_up(struct sdw_intel *sdw) { + struct sdw_bus *bus = &sdw->cdns.bus; + struct sdw_master_prop *prop = &bus->prop; + u32 *shim_mask = sdw->link_res->shim_mask; + unsigned int link_id = sdw->instance; + u32 syncprd; int ret; mutex_lock(sdw->link_res->shim_lock); - ret = hdac_bus_eml_sdw_power_up_unlocked(sdw->link_res->hbus, sdw->instance); + if (!*shim_mask) { + /* we first need to program the SyncPRD/CPU registers */ + dev_dbg(sdw->cdns.dev, "first link up, programming SYNCPRD\n"); + + if (prop->mclk_freq % 6000000) + syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_38_4; + else + syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_24; + + ret = hdac_bus_eml_sdw_set_syncprd_unlocked(sdw->link_res->hbus, syncprd); + if (ret < 0) { + dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_set_syncprd failed: %d\n", + __func__, ret); + goto out; + } + } + + ret = hdac_bus_eml_sdw_power_up_unlocked(sdw->link_res->hbus, link_id); if (ret < 0) { dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_up failed: %d\n", __func__, ret); goto out; } + if (!*shim_mask) { + /* SYNCPU will change once link is active */ + ret = hdac_bus_eml_sdw_wait_syncpu_unlocked(sdw->link_res->hbus); + if (ret < 0) { + dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_wait_syncpu failed: %d\n", + __func__, ret); + goto out; + } + } + + *shim_mask |= BIT(link_id); + sdw->cdns.link_up = true; out: mutex_unlock(sdw->link_res->shim_lock); @@ -37,13 +71,17 @@ static int intel_link_power_up(struct sdw_intel *sdw) static int intel_link_power_down(struct sdw_intel *sdw) { + u32 *shim_mask = sdw->link_res->shim_mask; + unsigned int link_id = sdw->instance; int ret; mutex_lock(sdw->link_res->shim_lock); sdw->cdns.link_up = false; - ret = hdac_bus_eml_sdw_power_down_unlocked(sdw->link_res->hbus, sdw->instance); + *shim_mask &= ~BIT(link_id); + + ret = hdac_bus_eml_sdw_power_down_unlocked(sdw->link_res->hbus, link_id); if (ret < 0) { dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_down failed: %d\n", __func__, ret); -- 2.25.1