Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3669445pxb; Mon, 24 Jan 2022 14:57:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkIm+w4RvQOEiaRLd4sJCRYqvGxHpckHoQj9MycV2jSasVEFkaIuFhdyx+hJo8grnWLIcQ X-Received: by 2002:a63:f412:: with SMTP id g18mr13132773pgi.463.1643065057899; Mon, 24 Jan 2022 14:57:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065057; cv=none; d=google.com; s=arc-20160816; b=inExYCFN16TvnaPdlEwYZ9ftt50NiBQfB7dIPNvIng2jJPHXSOH/TY/E1d6RwjiXod z8quH47pS59f7dDLoz3IrZIo6p6JhwqTvYDnjf0ax1ZbfB809pdT3oT41ibzID3ik8cS vFMGMNtJFHfi6GjBbkANWsP8XqsGZvzih3wm0cWHEu6Tlm/q4VuT29suT5eZo9tK3kWf An4nc1wvx2hrMR1kKaNwGBgLn65yFum67hTtOJ/ZP9aFajZaH/PbGoIGr7IzpvVzruQK Th4WVN6hNq6+EtABx42hycz9mhv1Km5UPi32f+y4tv8AHfgUnrmyiloabjmXOxri13QB Q03Q== 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=yj+aoFpt0Pf2Br+N3ube2oabB+j2QfwWrwEmWVbvzeIQ1JwXe2ZPGTc9j/pr7Ra7lC BB3NmoGXs4JDxuNI6s60S+27n/Q+eK/wrVW1qLAzMLEcLD9zgpEHr8TPBZF30Aqwk1Zp /Kd6PXQW6xU1K3BQHHSgG+5WPPgDHR0480Sm6gvOmkcOIENDJB66tJHe3g3429F6n2+V yL8PJGfno8ZPzDT3gm+Re27UYnBvQ2lDjRded9PGT0cz90Jw67xoWhy6NPvZtYuL/fp1 OfoL1BGUla12LxHze0Pv8tN85pvePzthezGTw4vHuqgKaUlfayRdUwVF54aMuAfTlaig za5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PKQaVc33; 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 v4si1202043pfu.184.2022.01.24.14.57.26; Mon, 24 Jan 2022 14:57:37 -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=PKQaVc33; 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 S1840423AbiAXWx1 (ORCPT + 99 others); Mon, 24 Jan 2022 17:53:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573995AbiAXVrF (ORCPT ); Mon, 24 Jan 2022 16:47:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8014EC08118C; Mon, 24 Jan 2022 12:32:50 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 1DD1B614EC; Mon, 24 Jan 2022 20:32:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2EBAC340E5; Mon, 24 Jan 2022 20:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056369; bh=pieXjopHJClA3R5Ukxgru4qNpdVk33ngFDmFKm50a+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PKQaVc3386JFMyljAz3o6uB8+OgGs7MNk4/XcIOFYLt4bakm+se2Gy55SurkC+Iqh ir0XQEGFuIGswaX4vqwge8ajnoNARWtECw6FmTlD2DPjZuKT9uL9MOcnz6s91P1dfL HoNGk9MHe5FYzXvVUEpM9Tw/+TvIJw/kIpVlgJI8= 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.15 434/846] phy: cadence: Sierra: Fix to get correct parent for mux clocks Date: Mon, 24 Jan 2022 19:39:11 +0100 Message-Id: <20220124184115.960604749@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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