From patchwork Tue Jan 7 01:58:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13927947 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 092A586321; Tue, 7 Jan 2025 01:58:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736215116; cv=none; b=jLwy0MD4N1j5hcfIKn23Iu/lPFFf4OmvzUs88ec8md9Um+i4nDL5PVUXnxuygWuXeMxQnZrKu8srSb2rZm62XlmbJ90ORORqBfxRXcciZo4cAXfaoFY20Fg3Qw1RX813vczWkKXYiJzsH/zzS8Y2rq/NR9Rzymn7sVv8Xra2yb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736215116; c=relaxed/simple; bh=fyTuj6Hj+uJBQJeo9L3cZ4RIREVWX9F3lkW8b7FC+ik=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lWxmHcxpcjs9pzLh6GEWxDfcQsFs5ff777dqm7qHAnJTO2gQ4Ts4zJ4uCc97kq/St7F04/x9EF4LBREOtnBPQCtldcdfJWjshDP2MGU0+IO/5CLu1DPJmoZNrNlr1e3UBHJe8vRX5Pstfrqc94KwG87ku00eKkp/aohLPYnEZ30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fLmYePxY; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fLmYePxY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736215115; x=1767751115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fyTuj6Hj+uJBQJeo9L3cZ4RIREVWX9F3lkW8b7FC+ik=; b=fLmYePxYqoNNGOX6m4rCERxAPrWZWU322OBZeJwuuwdxW/o4lNZqhO18 txB5xCGP6R8WGujqy3OCdzN17yKHkljpHfHVe33g7KcQ5StxMpblkywoW ZSiihNR+7g/1yZIVzTcmNrpz+qXpPUWgJxHBOHZsbCLVLAo4I7JLG6KiY GChZ+1X/164nOMnOVBdHMFmrU54qunCx+FG023ltH/4NDmrxNbHIhuopD 4njEC4Z627z5kRYEko+pVkY8uBbeXNTFc7RFHF/OqhBdKXtQCWJFSp4G8 VyTWD/AYL+BrI7BaWq/BI5lZau9cOGpbgvKkuSSsceKa+58QDWwyUpHP8 w==; X-CSE-ConnectionGUID: XNG++eucT5uGM653FwBI7w== X-CSE-MsgGUID: EEOBjYrXSJS1oyrsAa1hOA== X-IronPort-AV: E=McAfee;i="6700,10204,11307"; a="36396897" X-IronPort-AV: E=Sophos;i="6.12,294,1728975600"; d="scan'208";a="36396897" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2025 17:58:34 -0800 X-CSE-ConnectionGUID: 3prc3bTHTXSm734mjiK7vA== X-CSE-MsgGUID: cz3RkN1UTT26YSiOt39u5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,294,1728975600"; d="scan'208";a="102798808" Received: from daliomra-mobl3.amr.corp.intel.com (HELO yungchua-desk.intel.com) ([10.124.221.46]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2025 17:58:32 -0800 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 1/2] soundwire: cadence_master: set frame shape and divider based on actual clk freq Date: Tue, 7 Jan 2025 09:58:23 +0800 Message-ID: <20250107015824.5046-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250107015824.5046-1-yung-chuan.liao@linux.intel.com> References: <20250107015824.5046-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Frame shape and curr_dr_freq could be updated by sdw_compute_bus_params(). Peripherals will set curr_dr_freq as their frequency. Managers should do the same. Then update frame shape according to the actual bus frequency. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi --- drivers/soundwire/cadence_master.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index f367670ea991..a49d4e521a8f 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -1341,13 +1341,14 @@ static u32 cdns_set_initial_frame_shape(int n_rows, int n_cols) return val; } -static void cdns_init_clock_ctrl(struct sdw_cdns *cdns) +static int cdns_init_clock_ctrl(struct sdw_cdns *cdns) { struct sdw_bus *bus = &cdns->bus; struct sdw_master_prop *prop = &bus->prop; u32 val; u32 ssp_interval; int divider; + int freq; dev_dbg(cdns->dev, "mclk %d max %d row %d col %d\n", prop->mclk_freq, @@ -1356,13 +1357,25 @@ static void cdns_init_clock_ctrl(struct sdw_cdns *cdns) prop->default_col); /* Set clock divider */ - divider = (prop->mclk_freq / prop->max_clk_freq) - 1; + divider = (prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR / + bus->params.curr_dr_freq) - 1; + freq = bus->params.curr_dr_freq >> 1; cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0, CDNS_MCP_CLK_MCLKD_MASK, divider); cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1, CDNS_MCP_CLK_MCLKD_MASK, divider); + /* Set frame shape base on the actual bus frequency. */ + if (!prop->default_frame_rate || !prop->default_row) { + dev_err(cdns->dev, "Default frame_rate %d or row %d is invalid\n", + prop->default_frame_rate, prop->default_row); + return -EINVAL; + } + + prop->default_col = freq * SDW_DOUBLE_RATE_FACTOR / + prop->default_frame_rate / prop->default_row; + /* * Frame shape changes after initialization have to be done * with the bank switch mechanism @@ -1375,6 +1388,8 @@ static void cdns_init_clock_ctrl(struct sdw_cdns *cdns) ssp_interval = prop->default_frame_rate / SDW_CADENCE_GSYNC_HZ; cdns_writel(cdns, CDNS_MCP_SSP_CTRL0, ssp_interval); cdns_writel(cdns, CDNS_MCP_SSP_CTRL1, ssp_interval); + + return 0; } /** @@ -1408,9 +1423,12 @@ EXPORT_SYMBOL(sdw_cdns_soft_reset); */ int sdw_cdns_init(struct sdw_cdns *cdns) { + int ret; u32 val; - cdns_init_clock_ctrl(cdns); + ret = cdns_init_clock_ctrl(cdns); + if (ret) + return ret; sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0); From patchwork Tue Jan 7 01:58:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 13927946 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E816082890; Tue, 7 Jan 2025 01:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736215116; cv=none; b=XoafzPNwE51VgANgHRSsryEfD+U+HmClx7xh3lWKH+X0ySJe5Ana5zGvD5QaR9tGRhhcYiWQbPh6lDAF+5Poe/66eqgChyB+BFLrxEIh1xqhxsgtgUdvc7+hkloXsX3c6uh1x74SgY1QBlROvzATjA5ZIXmMfa4BKn6JsYq/d8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736215116; c=relaxed/simple; bh=6D3qu2jFcm9JJdol9jZ39EiknhJ1ytniof8hwSRzgWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DyKxm1lMZlutc1e/SGfWmi7tLdn7Ux/i9k88dOtv0NynEUkt1XEGQrRqOSImZ3VjAv8t8LCEC6HCi2sWaVTdW5ZQlrjf96bDbhXvsopN8nUIvuaPvuhZypXnBGHiRmZcsinrpQ+/8zGme1dFhy1PR9k05iTTtOJ5nBB0wa1DljQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Xy2FxxMs; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Xy2FxxMs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736215115; x=1767751115; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6D3qu2jFcm9JJdol9jZ39EiknhJ1ytniof8hwSRzgWg=; b=Xy2FxxMs4QwPA8Lte4uRztK0emK33KgHU4MkDma7xjGArta3rWooHCGZ Pq1EhgRXAm4i+n8jQzNBTu4d0gTrI1AjVOLHLlq5ZNOPYV0EHbFXIVcNl S82f4SMZAI1DYL/w7VO+TX7PKxe9N2OjcwxrBLBNwSjQ1qOGz+e3uQE2c 7bPE/O9zO5mDL4VjjmXs1T6RzmIfUy2ax9HxYPYEPN9ck/SHlpy8K9SJH KM8bA2heQ6BhC3wJ65/lGBEHtCkUwK6OIXT9bJXEMksAHZliVFLlE1KN2 9wEiUhFsaY15/4D55lyJZW3HosVgdXF4Lv5wbri4+kiJ7TZlOBLr7UjZ+ g==; X-CSE-ConnectionGUID: Er/eaqyxR+Kb0ouawq4jFw== X-CSE-MsgGUID: qChqadonQoeM/BxVQf7S6Q== X-IronPort-AV: E=McAfee;i="6700,10204,11307"; a="36396904" X-IronPort-AV: E=Sophos;i="6.12,294,1728975600"; d="scan'208";a="36396904" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2025 17:58:35 -0800 X-CSE-ConnectionGUID: oDfx9cOiQkCim5VZ1ILTew== X-CSE-MsgGUID: tu3L2eQAQhu/b+K7nw7g1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,294,1728975600"; d="scan'208";a="102798818" Received: from daliomra-mobl3.amr.corp.intel.com (HELO yungchua-desk.intel.com) ([10.124.221.46]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2025 17:58:34 -0800 From: Bard Liao To: linux-sound@vger.kernel.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.dev, bard.liao@intel.com Subject: [PATCH 2/2] Revert "soundwire: intel_auxdevice: start the bus at default frequency" Date: Tue, 7 Jan 2025 09:58:24 +0800 Message-ID: <20250107015824.5046-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250107015824.5046-1-yung-chuan.liao@linux.intel.com> References: <20250107015824.5046-1-yung-chuan.liao@linux.intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now, we can support more than 1 soundwire bus clock frequency. This reverts commit c326356188f1dc2d7a2c55b30dac6a8b76087bc6. Signed-off-by: Bard Liao Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi --- drivers/soundwire/intel_auxdevice.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 599954d92752..dee126f6d9d5 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -222,30 +222,9 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus) static int intel_prop_read(struct sdw_bus *bus) { - struct sdw_master_prop *prop; - /* Initialize with default handler to read all DisCo properties */ sdw_master_read_prop(bus); - /* - * Only one bus frequency is supported so far, filter - * frequencies reported in the DSDT - */ - prop = &bus->prop; - if (prop->clk_freq && prop->num_clk_freq > 1) { - unsigned int default_bus_frequency; - - default_bus_frequency = - prop->default_frame_rate * - prop->default_row * - prop->default_col / - SDW_DOUBLE_RATE_FACTOR; - - prop->num_clk_freq = 1; - prop->clk_freq[0] = default_bus_frequency; - prop->max_clk_freq = default_bus_frequency; - } - /* read Intel-specific properties */ sdw_master_read_intel_prop(bus);