Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3635783pxb; Mon, 24 Jan 2022 14:04:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDzlFVnmKgoxD3Xa4PDiuUeMTFXosB400VjtHyRSFP6liBKwPlVM/+hcvJ0wVIlzCX5JWc X-Received: by 2002:a63:5d7:: with SMTP id 206mr234294pgf.500.1643061880323; Mon, 24 Jan 2022 14:04:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061880; cv=none; d=google.com; s=arc-20160816; b=0vjm6O0jUzX6JM2NwQBTsCAVFkKC9xFHtySnc3HXSXZCr3A1bYNju/C4hpLReLxMmr wV6kcAROLYp2v7ZUnFk5hG2UUvG8iBGJ8WoZdHeibs2Fuvb//JVu1/2l6aCeGdU5vi9r 0ViiPk2Vv8WkoCu2yhl/F3Z58AVtrGFdNzymGWcP8C6bU1XxCmx25rRAivR4znRBLYBq KQCwSUh+ZNl7sPPUZLx2OjySJUC4ZYNVVeJqb21Nu69fMf/EhJNadqfXx43c8G+xrHcs Fr7yWYc7Sog7PjLMO+aZxMLIrG3JRiq5oapooF5mG1gxj+V/g0oatrDow6kG2xfesOHM +aoA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UCOEU0pIVzwIPompsqu1WTSXRP2YPBw/5V+fs8FKx1Q=; b=nchvUEwAXo1v4uVM8TvVQb7tpzy/1Kew2LdNDr232PMnyPZ9ho+QdcDCxIjb1qOh2E 7zCtQ9GAEtt1B0quT+rlkj4RHIK1mHXyDrzDEUnOc4/rBZmTntY7Kqecv27871HVKF8W 5fLGdetu7xDWqc7Sr21i771pJ7L1VRxTxQrL23g1M73SXOYIuA114wzi6BKB7rwMZ3kp KzgU1t/2OBAhl+or4RsD051/1bWO+GNEDUR84IIPa7oVIKvluBHyVCVkznWAqC3x9j4Q XTbegfLpuGKXNIfA9xfua6pw+/d+f1zFfbpurYi88qytdTuM9skaa6v2eUusjbhviszi AkkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QvVRPgn4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z6si10416577pfz.284.2022.01.24.14.04.27; Mon, 24 Jan 2022 14:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QvVRPgn4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1576085AbiAXVxA (ORCPT + 99 others); Mon, 24 Jan 2022 16:53:00 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:37822 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1447065AbiAXVSo (ORCPT ); Mon, 24 Jan 2022 16:18:44 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 36925B8105C; Mon, 24 Jan 2022 21:18:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68541C340E4; Mon, 24 Jan 2022 21:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059119; bh=pieXjopHJClA3R5Ukxgru4qNpdVk33ngFDmFKm50a+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QvVRPgn4Xt1ZTAJDSOxyQevyqvoCTx2Bcd4W7dalyLuuloDTGXdGYeDFPmQ0ybph7 h5cT8moIDqbqzW5Pa/Ixnzo6YKLw6D/PLaFBXs91In4gKC6yMAWdHkgcYYjYpfLCEA YN4NQjBDZUQyps12KMQRoudivMVswLUbcs1kUSJs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Swapnil Jakhade , Aswath Govindraju , Vinod Koul , Sasha Levin Subject: [PATCH 5.16 0509/1039] phy: cadence: Sierra: Fix to get correct parent for mux clocks Date: Mon, 24 Jan 2022 19:38:18 +0100 Message-Id: <20220124184142.400075607@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Swapnil Jakhade [ Upstream commit da08aab940092a050a4fb2857ed9479d2b0e03c4 ] Fix get_parent() callback to return the correct index of the parent for PLL_CMNLC1 clock. Add a separate table of register values corresponding to the parent index for PLL_CMNLC1. Update set_parent() callback accordingly. Fixes: 28081b72859f ("phy: cadence: Sierra: Model PLL_CMNLC and PLL_CMNLC1 as clocks (mux clocks)") Signed-off-by: Swapnil Jakhade Reviewed-by: Aswath Govindraju Link: https://lore.kernel.org/r/20211223060137.9252-12-sjakhade@cadence.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/cadence/phy-cadence-sierra.c | 31 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c index e93818e3991fd..3e2d096d54fd7 100644 --- a/drivers/phy/cadence/phy-cadence-sierra.c +++ b/drivers/phy/cadence/phy-cadence-sierra.c @@ -215,7 +215,10 @@ static const int pll_mux_parent_index[][SIERRA_NUM_CMN_PLLC_PARENTS] = { [CMN_PLLLC1] = { PLL1_REFCLK, PLL0_REFCLK }, }; -static u32 cdns_sierra_pll_mux_table[] = { 0, 1 }; +static u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = { + [CMN_PLLLC] = { 0, 1 }, + [CMN_PLLLC1] = { 1, 0 }, +}; struct cdns_sierra_inst { struct phy *phy; @@ -436,11 +439,25 @@ static const struct phy_ops ops = { static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw) { struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw); + struct regmap_field *plllc1en_field = mux->plllc1en_field; + struct regmap_field *termen_field = mux->termen_field; struct regmap_field *field = mux->pfdclk_sel_preg; unsigned int val; + int index; regmap_field_read(field, &val); - return clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table, 0, val); + + if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) { + index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val); + if (index == 1) { + regmap_field_write(plllc1en_field, 1); + regmap_field_write(termen_field, 1); + } + } else { + index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val); + } + + return index; } static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index) @@ -458,7 +475,11 @@ static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index) ret |= regmap_field_write(termen_field, 1); } - val = cdns_sierra_pll_mux_table[index]; + if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) + val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index]; + else + val = cdns_sierra_pll_mux_table[CMN_PLLLC][index]; + ret |= regmap_field_write(field, val); return ret; @@ -496,8 +517,8 @@ static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp, for (i = 0; i < num_parents; i++) { clk = sp->input_clks[pll_mux_parent_index[clk_index][i]]; if (IS_ERR_OR_NULL(clk)) { - dev_err(dev, "No parent clock for derived_refclk\n"); - return PTR_ERR(clk); + dev_err(dev, "No parent clock for PLL mux clocks\n"); + return IS_ERR(clk) ? PTR_ERR(clk) : -ENOENT; } parent_names[i] = __clk_get_name(clk); } -- 2.34.1