Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7116496rwl; Wed, 22 Mar 2023 22:34:17 -0700 (PDT) X-Google-Smtp-Source: AK7set/lcjH9s+y+2/rLrcSm0hM1tdnJF/uEZ6VFAW/t0WSryAtlh/2BqRwqe6FBqggZlwD0CU1J X-Received: by 2002:a17:90b:1d07:b0:23d:1bf6:5c74 with SMTP id on7-20020a17090b1d0700b0023d1bf65c74mr5908976pjb.41.1679549657232; Wed, 22 Mar 2023 22:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679549657; cv=none; d=google.com; s=arc-20160816; b=vNcFNLb6qRxc4lv7wbfIY7yEZieVf7skwn8PkAHl8m3BaZHt9a9OZgM459IKRED9cA QbgYkKpk944GZQptdRmdGmNkVclz2wIZGuloVFYr/Q7Ccc09r1ugN4C/BUisUZDB9DHJ 7CE4NZgeB4GnJ0Gw8u7wS+2TjLEcNfbzeNgFpGvp2froFWT7AGVe0fLyzIEohsHvi88l EKerAGJSRFDZd/29j1ty9Wwaep9Iqswx24WLlWnuXjYqR2kaZztTyyBwnXtdL24gadYO 8OFMAPuVuz4kXDOiK1XM7OF66Lj0ZmdfGYzu++mLvb9Kh1FtliJodEiPZqw1MmHTd2Hp KHzQ== 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=rTwsq9F14ZOdztyFU3HhyI+LoRxLvbV7olCF/ItTltg=; b=OmKxpaTUb7SmnESjfuZESebet7oycmbPl1rHiw2pcAZ5Q+SLFyIvb+0T6iNKq7Wsaz UHqT1hwe2DE376GxanxKcma1bF8wzYm16N5um0DcPk0hKGArLFnh3WIp+RXfBq0Lq8tW aV/LboPu4UM2KfS1uq5QDXayRumWiueFZX1LSR7FRkpLRnebxztaursPZod4Rsv5bwa2 UQy85JjR7YxtTeTZZL2GecJH60mBga0Qi7yVAzqfViLIoT3WxAwiU+fpj+zZKrfg1X0M 67rTe73o8RvoML7EsYxX7DYTi7j+Erkn2Dkevelc2b7DnLGa+cqB2e5m9bWzUz4WP0+1 Qc0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="VMZ3Wyb/"; 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 nl6-20020a17090b384600b0023082ccac58si1008224pjb.7.2023.03.22.22.34.06; Wed, 22 Mar 2023 22:34:17 -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="VMZ3Wyb/"; 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 S231214AbjCWFdK (ORCPT + 99 others); Thu, 23 Mar 2023 01:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230406AbjCWFcd (ORCPT ); Thu, 23 Mar 2023 01:32:33 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C848632E69 for ; Wed, 22 Mar 2023 22:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679549501; x=1711085501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R3GyCN8p+cJBxO9BTibcqpeTRWzFQliw1LPEGnZdocY=; b=VMZ3Wyb/VSSzKrOPiOwT7pc5BwcZQuDv0PoaGz9TZsUpT59uXeQd1sbv +7O/tB9b03s6Ss62knNnx4jGubyLTMoUC0WSLFoJvoNpMYWAdN4PPjlgY BMN+rAvA44Bqj3K788wDANuL0qKElPpSf+Ezcf8IikZfEb+h3aKEOhI82 3qisOA14Y/SLxfrl8rIv8ZnRndMeDFZa3j3k7M98I2BFG5Fhe0Cl3Od+8 ODznk2zSdkrpS5wkgN8RCas8Khhln0ZC3kE+UzjPUlWoJcxWT48GmNY84 0QXcsUCs1go7QadRFT04IeFFbYS2fPdFmj3BsnzCjwomXfMf8s9LgTiXQ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327779513" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="327779513" 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:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="675567305" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="675567305" 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:39 -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 20/20] soundwire: intel_ace2x: add new_peripheral_assigned callback Date: Thu, 23 Mar 2023 13:44:52 +0800 Message-Id: <20230323054452.1543233-21-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 Add the abstraction needed to only program the LSDIID registers for the HDaudio extended links. It's perfectly fine to program this register multiple times in case devices lose sync and reattach. 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 | 12 ++++++++++++ drivers/soundwire/intel_auxdevice.c | 16 ++++++++++++++++ include/linux/soundwire/sdw_intel.h | 3 +++ 3 files changed, 31 insertions(+) diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index a12fee8a5bfa..65deb4345354 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -350,6 +350,16 @@ static int intel_register_dai(struct sdw_intel *sdw) dais, num_dai); } +static void intel_program_sdi(struct sdw_intel *sdw, int dev_num) +{ + int ret; + + ret = hdac_bus_eml_sdw_set_lsdiid(sdw->link_res->hbus, sdw->instance, dev_num); + if (ret < 0) + dev_err(sdw->cdns.dev, "%s: could not set lsdiid for link %d %d\n", + __func__, sdw->instance, dev_num); +} + const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = { .debugfs_init = intel_ace2x_debugfs_init, .debugfs_exit = intel_ace2x_debugfs_exit, @@ -372,6 +382,8 @@ const struct sdw_intel_hw_ops sdw_intel_lnl_hw_ops = { .sync_go_unlocked = intel_sync_go_unlocked, .sync_go = intel_sync_go, .sync_check_cmdsync_unlocked = intel_check_cmdsync_unlocked, + + .program_sdi = intel_program_sdi, }; EXPORT_SYMBOL_NS(sdw_intel_lnl_hw_ops, SOUNDWIRE_INTEL); diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index b02cef4f4b66..6e02782ef211 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -60,6 +60,21 @@ static int generic_post_bank_switch(struct sdw_bus *bus) return sdw->link_res->hw_ops->post_bank_switch(sdw); } +static void generic_new_peripheral_assigned(struct sdw_bus *bus, int dev_num) +{ + struct sdw_cdns *cdns = bus_to_cdns(bus); + struct sdw_intel *sdw = cdns_to_intel(cdns); + + /* paranoia check, this should never happen */ + if (dev_num < INTEL_DEV_NUM_IDA_MIN || dev_num > SDW_MAX_DEVICES) { + dev_err(bus->dev, "%s: invalid dev_num %d\n", __func__, dev_num); + return; + } + + if (sdw->link_res->hw_ops->program_sdi) + sdw->link_res->hw_ops->program_sdi(sdw, dev_num); +} + static int sdw_master_read_intel_prop(struct sdw_bus *bus) { struct sdw_master_prop *prop = &bus->prop; @@ -117,6 +132,7 @@ static struct sdw_master_ops sdw_intel_ops = { .pre_bank_switch = generic_pre_bank_switch, .post_bank_switch = generic_post_bank_switch, .read_ping_status = cdns_read_ping_status, + .new_peripheral_assigned = generic_new_peripheral_assigned, }; /* diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index bafc6f2554b0..1a8f32059cd8 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -399,6 +399,7 @@ struct sdw_intel; * @sync_go: helper for multi-link synchronization * @sync_check_cmdsync_unlocked: helper for multi-link synchronization * and bank switch - shim_lock is assumed to be locked at higher level + * @program_sdi: helper for codec command/control based on dev_num */ struct sdw_intel_hw_ops { void (*debugfs_init)(struct sdw_intel *sdw); @@ -425,6 +426,8 @@ struct sdw_intel_hw_ops { int (*sync_go_unlocked)(struct sdw_intel *sdw); int (*sync_go)(struct sdw_intel *sdw); bool (*sync_check_cmdsync_unlocked)(struct sdw_intel *sdw); + + void (*program_sdi)(struct sdw_intel *sdw, int dev_num); }; extern const struct sdw_intel_hw_ops sdw_intel_cnl_hw_ops; -- 2.25.1