Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp6109375pxb; Thu, 27 Jan 2022 06:45:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFVO6UWbF8k3TjxWoBJfg0wMTp/TOEXAL9L6aPOSldj0VY8CeH/0Us7BaYbPMRcK8ncHaO X-Received: by 2002:a17:907:3f8d:: with SMTP id hr13mr3114457ejc.608.1643294707301; Thu, 27 Jan 2022 06:45:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643294707; cv=none; d=google.com; s=arc-20160816; b=lTalRS9dFrtH+38l/VSFklrg4JFDmvKRGkdLTbjB2CNU1a/yOl03NeODTgHzL2Th8l WUkmRGW8CJwJosgXBakukzAZv5NeTc9cn6S1yid4ckNazzu2/nD5EcpBwUntaNwZL5c+ 6m+h6a4HRcRlvi3Rhaiwx/gatZFZ90qKDDVzbBQo7rMAs7AVt49RDm0AyDhAWCSR4r0p iXRJccQCQJgJN2nDkNqTg3b8GrETOiqVjBaG/rjvHP/vM4S5tYvB2WUOv6RfFr/Q5sPK 1F4nuF4ud3Z70lwaXlkuFfrPL0nUiDRpOcNpTQaA6/fGGfF+4ydjcKkY2fu9s9PNFsrz T5DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:mime-version:message-id:date:subject:cc:from :dkim-signature; bh=7UGkZLlsCbU6/7eRk2sQKQKDQzdA+OHIOBNXAlW3FuQ=; b=lT4ubmPR/GPYXhsqO4N1zY71BNGUgnJWQCmFa+5I2NUEDr1FeM68kARmNpmJoghSyu vsS+2r6iJcjMEMwXn9FXq26yQ3iJx2arP8a40pZd3ZcOr2GlPgt/D6mU79XzJEKIqo5X NzTiGGWyFwQh3l/rYwWgJalgKrnbiqepHweHWfeUViVfDQG9/RNgOcD/NGmrMxGN/Qb+ n0TsEc57cy6tYWchUckCPEUoD0ElzesjVaG3Zl/KEPMmeHcp/DspSTeZwm0LG0JjeI8F 7yoe/3dc/cDkvb8TolBeaEgKfgOPFiSYggvmM9YeHL6/klda1eT6gNZKc0/X5k6yVMZX m9Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=E+HN7iuv; 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=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq37si1523880ejc.582.2022.01.27.06.44.41; Thu, 27 Jan 2022 06:45:07 -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=fail header.i=@ti.com header.s=ti-com-17Q1 header.b=E+HN7iuv; 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=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238077AbiA0I5c (ORCPT + 99 others); Thu, 27 Jan 2022 03:57:32 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:58166 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238063AbiA0I5b (ORCPT ); Thu, 27 Jan 2022 03:57:31 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 20R8v6tA067443; Thu, 27 Jan 2022 02:57:06 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1643273826; bh=7UGkZLlsCbU6/7eRk2sQKQKDQzdA+OHIOBNXAlW3FuQ=; h=From:To:CC:Subject:Date; b=E+HN7iuvG7KJHSntdZBahrsZQ4h/eUofRe5g3dwqCFl+B8s+WJjdkAaPXeBJdLUFy S2cgQoz1bA3q5K5wuqrdxpIWapAnrEcRTg5Je9pMlBEeknL7oo9V02DM5czsf2OgfQ Q+SZajr/kC/C/8RxZVh20FEOWrlgm2YqGMw8ygCI= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 20R8v6Nv047367 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Jan 2022 02:57:06 -0600 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 27 Jan 2022 02:57:05 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 27 Jan 2022 02:57:05 -0600 Received: from gsaswath-HP-ProBook-640-G5.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 20R8v2OO014712; Thu, 27 Jan 2022 02:57:03 -0600 From: Aswath Govindraju CC: Aswath Govindraju , Kishon Vijay Abraham I , Vinod Koul , Philipp Zabel , Swapnil Jakhade , Dan Carpenter , , Subject: [PATCH] phy: cadence: Sierra: Add support for skipping configuration Date: Thu, 27 Jan 2022 14:26:58 +0530 Message-ID: <20220127085700.10333-1-a-govindraju@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Skip the phy configuration if the required configurations were done in an earlier boot stage. Signed-off-by: Aswath Govindraju --- drivers/phy/cadence/phy-cadence-sierra.c | 73 +++++++++++++++++------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c index e265647e29a2..d4197524ee8d 100644 --- a/drivers/phy/cadence/phy-cadence-sierra.c +++ b/drivers/phy/cadence/phy-cadence-sierra.c @@ -370,6 +370,7 @@ struct cdns_sierra_phy { int nsubnodes; u32 num_lanes; bool autoconf; + int already_configured; struct clk_onecell_data clk_data; struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS]; }; @@ -517,7 +518,7 @@ static int cdns_sierra_phy_init(struct phy *gphy) int i, j; /* Initialise the PHY registers, unless auto configured */ - if (phy->autoconf || phy->nsubnodes > 1) + if (phy->autoconf || phy->already_configured || phy->nsubnodes > 1) return 0; clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000); @@ -646,6 +647,18 @@ static const struct phy_ops ops = { .owner = THIS_MODULE, }; +static int cdns_sierra_noop_phy_on(struct phy *gphy) +{ + usleep_range(5000, 10000); + + return 0; +} + +static const struct phy_ops noop_ops = { + .power_on = cdns_sierra_noop_phy_on, + .owner = THIS_MODULE, +}; + static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw) { struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw); @@ -1118,13 +1131,6 @@ static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, struct clk *clk; int ret; - clk = devm_clk_get_optional(dev, "phy_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get clock phy_clk\n"); - return PTR_ERR(clk); - } - sp->input_clks[PHY_CLK] = clk; - clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div"); if (IS_ERR(clk)) { dev_err(dev, "cmn_refclk_dig_div clock not found\n"); @@ -1160,17 +1166,33 @@ static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, return 0; } -static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp) +static int cdns_sierra_phy_clk(struct cdns_sierra_phy *sp) { + struct device *dev = sp->dev; + struct clk *clk; int ret; + clk = devm_clk_get_optional(dev, "phy_clk"); + if (IS_ERR(clk)) { + dev_err(dev, "failed to get clock phy_clk\n"); + return PTR_ERR(clk); + } + sp->input_clks[PHY_CLK] = clk; + ret = clk_prepare_enable(sp->input_clks[PHY_CLK]); if (ret) return ret; + return 0; +} + +static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp) +{ + int ret; + ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); if (ret) - goto err_pll_cmnlc; + return ret; ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]); if (ret) @@ -1181,9 +1203,6 @@ static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp) err_pll_cmnlc1: clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]); -err_pll_cmnlc: - clk_disable_unprepare(sp->input_clks[PHY_CLK]); - return ret; } @@ -1382,16 +1401,24 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev) if (ret) return ret; - ret = cdns_sierra_phy_get_resets(sp, dev); - if (ret) - goto unregister_clk; - ret = cdns_sierra_phy_enable_clocks(sp); if (ret) goto unregister_clk; - /* Enable APB */ - reset_control_deassert(sp->apb_rst); + regmap_field_read(sp->pma_cmn_ready, &sp->already_configured); + + if (!(sp->already_configured)) { + ret = cdns_sierra_phy_clk(sp); + if (ret) + goto unregister_clk; + + ret = cdns_sierra_phy_get_resets(sp, dev); + if (ret) + goto unregister_clk; + + /* Enable APB */ + reset_control_deassert(sp->apb_rst); + } /* Check that PHY is present */ regmap_field_read(sp->macro_id_type, &id_value); @@ -1433,8 +1460,10 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev) sp->num_lanes += sp->phys[node].num_lanes; - gphy = devm_phy_create(dev, child, &ops); - + if (!(sp->already_configured)) + gphy = devm_phy_create(dev, child, &ops); + else + gphy = devm_phy_create(dev, child, &noop_ops); if (IS_ERR(gphy)) { ret = PTR_ERR(gphy); of_node_put(child); @@ -1455,7 +1484,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev) } /* If more than one subnode, configure the PHY as multilink */ - if (!sp->autoconf && sp->nsubnodes > 1) { + if (!(sp->already_configured && sp->autoconf) && sp->nsubnodes > 1) { ret = cdns_sierra_phy_configure_multilink(sp); if (ret) goto put_control; -- 2.17.1