Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4280652pxf; Tue, 30 Mar 2021 04:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8N7E9d/gKeIgv/q4ODgoGhRu0XDDNQ3ywY8JbCH3mtYiNVNTGwhn8pb6K2s/9aGkdBQke X-Received: by 2002:a17:907:62a7:: with SMTP id nd39mr33016005ejc.510.1617102231004; Tue, 30 Mar 2021 04:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617102230; cv=none; d=google.com; s=arc-20160816; b=VUTy9ZVvqZn9AzRaT20RGuiiW3N74V5r8/QQP5rt9Tx0BMYLfK8PnauBpRUacx0PI+ CBHefw9QuiDfv9/hlEsaxDsi0eVibzonsEATuvyQRXSpnR1ecBC2ScKWq3xsFzd3xWBd sTUaa2WsWuVR5PaKXNM4EYroxY2ZPNebYvSrcYaiQPgagy2tQHZRgpoa3WeMjxTcxq8M kqUJgDdqC0zgZ6Y/uwZkhOFoK9heWe7uHnQyT8TbNxuMSdXxCZRMDjGKtAfHo8xSMYwI xWtjv4enI1vguI7COT5PXfI/YgVNBTjwPMepl0gkY6QHgIt0TDdESiWgoia3SvN4jPtI Biqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ujbp6egUdE2P1HPKmF5jsMpxvgPGHhYG2h+v76R89vw=; b=Eu0dYkvPtmNAxhoqSIROmYlbLhgegn1ARVXSm82BMeqm5LV8H7f/4uphO7xFsvXaM4 0PFXH06FNh3WinM7IaIpciujACxgufyCmuuApqZw2lSC3pJ2mFfV5cDSODPV8vxTqfMQ NXwvLCahubRdp8d5+m1ZuFII5XsD1bK6OJcEx21u2l9K7FIKxUBncERnZIXIIx8dgriO PqNjpOfGYJUCVazOpyhXlgm5ha222K1Dpzs/6Rtt3ofGz0CQq8E72LkvjMIEy/lNt+Mx XZ96PbToxtjUaA+KIKX2wjVBFo21FeVKAtFxA72kB8Grlxa+SfrJlaFVmizCtoP2Bqzl G2Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SqR1uDiY; 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=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 y1si14536962eds.133.2021.03.30.04.03.28; Tue, 30 Mar 2021 04:03:50 -0700 (PDT) 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=@ti.com header.s=ti-com-17Q1 header.b=SqR1uDiY; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231829AbhC3LCf (ORCPT + 99 others); Tue, 30 Mar 2021 07:02:35 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:44552 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231772AbhC3LCL (ORCPT ); Tue, 30 Mar 2021 07:02:11 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12UB1nTb058287; Tue, 30 Mar 2021 06:01:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1617102109; bh=ujbp6egUdE2P1HPKmF5jsMpxvgPGHhYG2h+v76R89vw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=SqR1uDiYNlUozHJpBKSayiwpWTLkGDPM0oHh9dDtjAwbCtYPelvtH8BaYuube1/sQ lbjRIr0gu4zpWNfefavVNtuy+vl9rg546VNw3/2/F12KgFZBu+yBgWLlojbgSlo1CW P2v4y1I3Zw0pX8nj16p+H8yr7ICAGvKb7Q0qntIo= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12UB1nOr007473 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Mar 2021 06:01:49 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 30 Mar 2021 06:01:49 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 30 Mar 2021 06:01:49 -0500 Received: from a0393678-ssd.dhcp.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 12UB1dck094447; Tue, 30 Mar 2021 06:01:46 -0500 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Vinod Koul , Philipp Zabel CC: Swapnil Jakhade , , , Lokesh Vutla Subject: [PATCH v2 2/5] phy: cadence-torrent: Group reset APIs and clock APIs Date: Tue, 30 Mar 2021 16:31:35 +0530 Message-ID: <20210330110138.24356-3-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210330110138.24356-1-kishon@ti.com> References: <20210330110138.24356-1-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No functional change intended. Group reset APIs and clock APIs in preparation for adding support to skip configuration if the SERDES is already configured by bootloader. Signed-off-by: Kishon Vijay Abraham I Reviewed-by: Swapnil Jakhade --- drivers/phy/cadence/phy-cadence-torrent.c | 84 ++++++++++++++--------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 3fdab0d288c4..ab51c4bf7b30 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -2249,6 +2249,54 @@ static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy) return 0; } +static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) +{ + struct device *dev = cdns_phy->dev; + + cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); + if (IS_ERR(cdns_phy->phy_rst)) { + dev_err(dev, "%s: failed to get reset\n", + dev->of_node->full_name); + return PTR_ERR(cdns_phy->phy_rst); + } + + cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb"); + if (IS_ERR(cdns_phy->apb_rst)) { + dev_err(dev, "%s: failed to get apb reset\n", + dev->of_node->full_name); + return PTR_ERR(cdns_phy->apb_rst); + } + + return 0; +} + +static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy) +{ + struct device *dev = cdns_phy->dev; + int ret; + + cdns_phy->clk = devm_clk_get(dev, "refclk"); + if (IS_ERR(cdns_phy->clk)) { + dev_err(dev, "phy ref clock not found\n"); + return PTR_ERR(cdns_phy->clk); + } + + ret = clk_prepare_enable(cdns_phy->clk); + if (ret) { + dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); + return ret; + } + + cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk); + if (!(cdns_phy->ref_clk_rate)) { + dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); + clk_disable_unprepare(cdns_phy->clk); + return -EINVAL; + } + + return 0; +} + static int cdns_torrent_phy_probe(struct platform_device *pdev) { struct cdns_torrent_phy *cdns_phy; @@ -2274,26 +2322,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) cdns_phy->dev = dev; cdns_phy->init_data = data; - cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); - if (IS_ERR(cdns_phy->phy_rst)) { - dev_err(dev, "%s: failed to get reset\n", - dev->of_node->full_name); - return PTR_ERR(cdns_phy->phy_rst); - } - - cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb"); - if (IS_ERR(cdns_phy->apb_rst)) { - dev_err(dev, "%s: failed to get apb reset\n", - dev->of_node->full_name); - return PTR_ERR(cdns_phy->apb_rst); - } - - cdns_phy->clk = devm_clk_get(dev, "refclk"); - if (IS_ERR(cdns_phy->clk)) { - dev_err(dev, "phy ref clock not found\n"); - return PTR_ERR(cdns_phy->clk); - } - cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(cdns_phy->sd_base)) return PTR_ERR(cdns_phy->sd_base); @@ -2316,18 +2344,13 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) if (ret) return ret; - ret = clk_prepare_enable(cdns_phy->clk); - if (ret) { - dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); + ret = cdns_torrent_reset(cdns_phy); + if (ret) goto clk_cleanup; - } - cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk); - if (!(cdns_phy->ref_clk_rate)) { - dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); - ret = -EINVAL; - goto clk_disable; - } + ret = cdns_torrent_clk(cdns_phy); + if (ret) + goto clk_cleanup; /* Enable APB */ reset_control_deassert(cdns_phy->apb_rst); @@ -2505,7 +2528,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) reset_control_put(cdns_phy->phys[i].lnk_rst); of_node_put(child); reset_control_assert(cdns_phy->apb_rst); -clk_disable: clk_disable_unprepare(cdns_phy->clk); clk_cleanup: cdns_torrent_clk_cleanup(cdns_phy); -- 2.17.1