From patchwork Thu Apr 30 07:04:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1134 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 200F23F0D3 for ; Thu, 30 Apr 2020 09:04:37 +0200 (CEST) Received: by mail-pl1-f198.google.com with SMTP id c1sf4155188plz.14 for ; Thu, 30 Apr 2020 00:04:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588230276; cv=pass; d=google.com; s=arc-20160816; b=Fnau68W0xY+n78buhu5cmgdnNtwzHPKvdq+mbPjbHalODJ5mV0zTDaPX4srm44zyeQ TSmwh6d7DOBdRXQ8GAXnc4QchQlcw0IKCgCKUE/h3M+uW2+4SyTikIQKyRHFmboJoLlS LCDO3sxVEIw9Tv6DjbYvgt4eh5jvOZImo6whVO6UjOdweCHxXz4gavBRbviUoPo4B/t2 nmd6tDivs05DNB5wOdDTu//h9HpW4Gz0w5kLFTKHZVPtSULj+sy+DK2l1zHufigBtsvg 95M7YP2PJ/qnthdd11AYEROhhT9F850R2SbScKukhBA/Stg3Vo1xB0DyD2UE1eEHKHAx aWww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=+Fhxijf99W67R9f0+iuN4zGiKF9bzhRfx7/g6NF6lsI=; b=NKD/araKzFsVEzn37E28mapyPpW/+1PFC7jno5tWmFz0pqQRdZ9m6I5DxffMK+Isdn zymPv8el31XDM0s3QXpDmiezGZDsNZOft5ASxmH/i3T6/TrDRmwcUQRCZsMzWbZxDFbN +PAVh8BJQfmGCly/RTwb+U3+OmxEfcxzkVG9Mmlq/CV7y/WLs3kVSFqA+v7ddayEhNFc ax8ko7+KBLmqoDsOeEiD50CiNA2Fdj6OJiyXuTdh+3O3ZBaqixSfoN7V3oPVyUEWb+Cs W1e8yv3H9yHw7jpkycyeZYz2ZwjmoxWg36mOC4YC45t9xOFSP8svrze8QCapzC8i8O9W 4KMQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CIWLUVZ5; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=+Fhxijf99W67R9f0+iuN4zGiKF9bzhRfx7/g6NF6lsI=; b=SrPr/nkLycaHMD2k6uG56It0oRP+x50ekZkDkz1EO2WPgSBY2ZUtyaN3Qj7HAYhU/L cxOICNzsu+2kVGP4ww4rFbf/S4HpcCoRlDQZ+i9jTYD9OB/txXmBdcEs4edDls7SUW4h LYT4OB2JohVNgQKMHAb8D21zjyZ3jPdL76mx4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=+Fhxijf99W67R9f0+iuN4zGiKF9bzhRfx7/g6NF6lsI=; b=YLK0GlAEdr8q2u9cpRrY5EDqtbEvlCMB6chPwjTQCj9g4Bj8fpRvGudpFlh5Ry/L4N ag8bP3CH8D+h5+q6u46j9qcWHWQGJF8Ks7hjFK1M6DAwDu1EllFM1UQlf9I80AZbXa0g jBqh/BNYrP7Vdb8fgF/DP2wS7J/5J/CSnsSC6FqqxmzcpthRPv5APgCY2/uZTsRYptsx 9Z32ij8Kc4L5rribsdW66Y9j6kwBLzZ8fN9pwIlDkoItOT5/oJYrwt8wDHocVvB6isar iVcECCPLgQEtkhH0KbpIqmANgYPA67rUvqbhH1CVb/L3xhHngK/UMPh96S5TdR+28CBg wJXQ== X-Gm-Message-State: AGi0PuZmJC3c+ri2dPSCMBjjwb+w6jThdJUu5SkMDmSMZ5vNtyClxq+u CwYVkQ3uq5umcw4Kvjczok5LjTke X-Google-Smtp-Source: APiQypJprfkz5Nr6OYFaQL2adWtS4YcOSzfBlXjHCQ1vOJpAxixnBPfPVhjTrfurTgK7px1L8QgqgA== X-Received: by 2002:a63:8149:: with SMTP id t70mr1932148pgd.205.1588230275760; Thu, 30 Apr 2020 00:04:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:191c:: with SMTP id z28ls172767pgl.11.gmail; Thu, 30 Apr 2020 00:04:35 -0700 (PDT) X-Received: by 2002:a63:ef04:: with SMTP id u4mr2030093pgh.280.1588230275257; Thu, 30 Apr 2020 00:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588230275; cv=none; d=google.com; s=arc-20160816; b=R+XMjWocw+jtosENVuSw9Tm+2S/SzabNP4OigmFzSsm+32auQb1piYWF++8z7vxhh1 WvyeI45mWpP+WHKB0h9Ovp9EckP517rAN9u8ND1fDkvTeBOMfPaUd609Zk1fje1998mp 7a4opSwr1jRT+1I8xNI1s74X4UNbxUBBRcZ9kheaDEEa3DUFdIbWEzwczlABUreE234o 7hZ0yIcFYEtdVx/lfD0KZW2H08B2rOQJb/85l1Ac9SVPQum2v8VVmff9dwxEmzPRUQ2w locuuysEC2B1k8u5KnAhpKWocmRL4gQJt2o+cay72ea5x/KrCpv3mAabbxAo51ARtcwv 5R6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kx3DvM6u34JnEdDKGfdUYWp2iOjqdjfvFB3xF13lJxo=; b=qzZcNeX3qz0JdZN9n1Xod7eXX6JDlI4tlGthrFcNxfUmto0K7IV8VCjj+r5GxJgO9S ySfNtHXRl7UEdVYkPIeC01SnYWlEfticvVTnF3/lsIvdUqI4plkjO/ZNEc/WdcDmOGKX m8eUxeezm9vGNJININlKFcylDeD8uuGYhngJ8MVVhpV5qeG9HPPw5usDS1q0x+HsXsJC yH0UJuXUHnVGSYCML4ZWx/m3qbPPDLalaLWDfcm+IVv3CDR8fEGvZse7CuhiXkxBNSHe wmf8l0ukz2loy16kprRqPMynzrApmWv94Ke9yNQ2RyDhaX6ZVcJpDU3JruNNPl74JIC4 5Svw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CIWLUVZ5; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z4sor4634126pgn.15.2020.04.30.00.04.35 for (Google Transport Security); Thu, 30 Apr 2020 00:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:d804:: with SMTP id b4mr1938666pgh.127.1588230274920; Thu, 30 Apr 2020 00:04:34 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:6514:3619:d1af:85f6]) by smtp.gmail.com with ESMTPSA id p64sm964143pjp.7.2020.04.30.00.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 00:04:34 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 3/8] clk: rk3399: Add enable/disable clks Date: Thu, 30 Apr 2020 12:34:07 +0530 Message-Id: <20200430070412.12499-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430070412.12499-1-jagan@amarulasolutions.com> References: <20200430070412.12499-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CIWLUVZ5; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Yes, most of the high speed peripheral clocks in rk3399 enabled by default. But it would be better to handle them via clk enable/disable API for handling proper reset conditions like 'usb reset' over command line. So, enable USB, GMAC clock via enable/disable ops. Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/clk/rockchip/clk_rk3399.c | 148 ++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index d822acace1..df70e9fa88 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -1071,12 +1071,160 @@ static int __maybe_unused rk3399_clk_set_parent(struct clk *clk, return -ENOENT; } +static int rk3399_clk_enable(struct clk *clk) +{ + struct rk3399_clk_priv *priv = dev_get_priv(clk->dev); + + switch (clk->id) { + case SCLK_MAC: + rk_clrreg(&priv->cru->clkgate_con[5], BIT(5)); + break; + case SCLK_MAC_RX: + rk_clrreg(&priv->cru->clkgate_con[5], BIT(8)); + break; + case SCLK_MAC_TX: + rk_clrreg(&priv->cru->clkgate_con[5], BIT(9)); + break; + case SCLK_MACREF: + rk_clrreg(&priv->cru->clkgate_con[5], BIT(7)); + break; + case SCLK_MACREF_OUT: + rk_clrreg(&priv->cru->clkgate_con[5], BIT(6)); + break; + case ACLK_GMAC: + rk_clrreg(&priv->cru->clkgate_con[32], BIT(0)); + break; + case PCLK_GMAC: + rk_clrreg(&priv->cru->clkgate_con[32], BIT(2)); + break; + case SCLK_USB3OTG0_REF: + rk_clrreg(&priv->cru->clksel_con[12], BIT(1)); + break; + case SCLK_USB3OTG1_REF: + rk_clrreg(&priv->cru->clksel_con[12], BIT(2)); + break; + case SCLK_USB3OTG0_SUSPEND: + rk_clrreg(&priv->cru->clkgate_con[12], BIT(3)); + break; + case SCLK_USB3OTG1_SUSPEND: + rk_clrreg(&priv->cru->clkgate_con[12], BIT(4)); + break; + case ACLK_USB3OTG0: + rk_clrreg(&priv->cru->clkgate_con[30], BIT(1)); + break; + case ACLK_USB3OTG1: + rk_clrreg(&priv->cru->clkgate_con[30], BIT(2)); + break; + case ACLK_USB3_RKSOC_AXI_PERF: + rk_clrreg(&priv->cru->clkgate_con[30], BIT(3)); + break; + case ACLK_USB3: + rk_clrreg(&priv->cru->clkgate_con[12], BIT(0)); + break; + case ACLK_USB3_GRF: + rk_clrreg(&priv->cru->clkgate_con[30], BIT(4)); + break; + case HCLK_HOST0: + rk_clrreg(&priv->cru->clksel_con[20], BIT(5)); + break; + case HCLK_HOST0_ARB: + rk_clrreg(&priv->cru->clksel_con[20], BIT(6)); + break; + case HCLK_HOST1: + rk_clrreg(&priv->cru->clksel_con[20], BIT(7)); + break; + case HCLK_HOST1_ARB: + rk_clrreg(&priv->cru->clksel_con[20], BIT(8)); + break; + default: + debug("%s: unsupported clk %ld\n", __func__, clk->id); + return -ENOENT; + } + + return 0; +} + +static int rk3399_clk_disable(struct clk *clk) +{ + struct rk3399_clk_priv *priv = dev_get_priv(clk->dev); + + switch (clk->id) { + case SCLK_MAC: + rk_setreg(&priv->cru->clkgate_con[5], BIT(5)); + break; + case SCLK_MAC_RX: + rk_setreg(&priv->cru->clkgate_con[5], BIT(8)); + break; + case SCLK_MAC_TX: + rk_setreg(&priv->cru->clkgate_con[5], BIT(9)); + break; + case SCLK_MACREF: + rk_setreg(&priv->cru->clkgate_con[5], BIT(7)); + break; + case SCLK_MACREF_OUT: + rk_setreg(&priv->cru->clkgate_con[5], BIT(6)); + break; + case ACLK_GMAC: + rk_setreg(&priv->cru->clkgate_con[32], BIT(0)); + break; + case PCLK_GMAC: + rk_setreg(&priv->cru->clkgate_con[32], BIT(2)); + break; + case SCLK_USB3OTG0_REF: + rk_setreg(&priv->cru->clksel_con[12], BIT(1)); + break; + case SCLK_USB3OTG1_REF: + rk_setreg(&priv->cru->clksel_con[12], BIT(2)); + break; + case SCLK_USB3OTG0_SUSPEND: + rk_setreg(&priv->cru->clkgate_con[12], BIT(3)); + break; + case SCLK_USB3OTG1_SUSPEND: + rk_setreg(&priv->cru->clkgate_con[12], BIT(4)); + break; + case ACLK_USB3OTG0: + rk_setreg(&priv->cru->clkgate_con[30], BIT(1)); + break; + case ACLK_USB3OTG1: + rk_setreg(&priv->cru->clkgate_con[30], BIT(2)); + break; + case ACLK_USB3_RKSOC_AXI_PERF: + rk_setreg(&priv->cru->clkgate_con[30], BIT(3)); + break; + case ACLK_USB3: + rk_setreg(&priv->cru->clkgate_con[12], BIT(0)); + break; + case ACLK_USB3_GRF: + rk_setreg(&priv->cru->clkgate_con[30], BIT(4)); + break; + case HCLK_HOST0: + rk_setreg(&priv->cru->clksel_con[20], BIT(5)); + break; + case HCLK_HOST0_ARB: + rk_setreg(&priv->cru->clksel_con[20], BIT(6)); + break; + case HCLK_HOST1: + rk_setreg(&priv->cru->clksel_con[20], BIT(7)); + break; + case HCLK_HOST1_ARB: + rk_setreg(&priv->cru->clksel_con[20], BIT(8)); + break; + default: + debug("%s: unsupported clk %ld\n", __func__, clk->id); + return -ENOENT; + } + + return 0; +} + static struct clk_ops rk3399_clk_ops = { .get_rate = rk3399_clk_get_rate, .set_rate = rk3399_clk_set_rate, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .set_parent = rk3399_clk_set_parent, #endif + .enable = rk3399_clk_enable, + .disable = rk3399_clk_disable, }; #ifdef CONFIG_SPL_BUILD