From patchwork Wed Feb 1 13:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 649165 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp301769pva; Wed, 1 Feb 2023 06:03:03 -0800 (PST) X-Google-Smtp-Source: AK7set/6RJjwZc4GkynZM+rRQMNYEMLNjeWu0YPpx8riV/ReMfp43iypO2DHGgqgF5klIm+B4S1w X-Received: by 2002:a05:6871:714:b0:163:49a0:5557 with SMTP id f20-20020a056871071400b0016349a05557mr1080103oap.6.1675260182885; Wed, 01 Feb 2023 06:03:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675260182; cv=none; d=google.com; s=arc-20160816; b=eruTzlhhsxIT8G7SFBGC4zS6zPgEbotf9G9SBl0J1Oqm9z01T7QeKZxDKI4K0Y+x4+ qrPwFSA2t3hqysGeP7TwZOLU/LwJp4eXfKKFU/RE80+W3ubRX7o5OvXAodWbRl6iCwi6 JIf6193sZatQ5YxXZH/M41i1BtiLOUS7qXxU4xuI6Uvdtqu950wU678jcA86N2XhqWFB 2vfJugASeC35K770T4M9yg5HlfPQyN19jcBMkJ8HGXaI2I2yXXvTMRmjAv2aqUR+5j1V Ioc9I0htAT3RFZhfI/3/fF6FBe93q7j719OQ/Cj1Ee5kDD7+0QibcAl3i6fLUOmE5ZAI GBtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wh9FITta3C+uiujkN9yOlTx3uqHPS8M4Fiy7NsSWCpk=; b=bXNve58+jYWXl0Tjs8ruecX4cEU3ftn5f99tL1ELDBYX21rkOesqskioC/KmZ2j+hl dk/Pe6mhNKk/4HYqo5UUsfjFiq7NtB6k6+WyMZTsZ6pOy1PmnBJcPADi06i8IKtnjJSS MHYyYpAUdk2BtIZkjS3di8jxUquUTtS4fJBJJTJQDJLC44daWOgGNVeTXakR+1pNcgeC beXd7kvuE/Nu4a3IvIK5Jm7kSD4xEK3F0OLsPrMUCZwtkIPrs5D7r0WCdoCzHUPOc63p h6YdY2CyOQMLR4H/OPD46rv01yC0Jz16VWzf7tXg2pqlbi3TiG8TpcwtSYRs1fVDPduK p0Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JC7DO1r0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id oi15-20020a0568702e0f00b0013bc222044esi16569612oab.178.2023.02.01.06.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 06:03:02 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JC7DO1r0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E4E4F85C7C; Wed, 1 Feb 2023 15:00:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="JC7DO1r0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D938285C7A; Wed, 1 Feb 2023 14:59:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BL_SPAMCOP_NET, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A826485AA5 for ; Wed, 1 Feb 2023 14:59:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pj1-x1033.google.com with SMTP id ha3-20020a17090af3c300b00230222051a6so2077195pjb.2 for ; Wed, 01 Feb 2023 05:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wh9FITta3C+uiujkN9yOlTx3uqHPS8M4Fiy7NsSWCpk=; b=JC7DO1r0kBc3NmQropa6tG2Lx3PXIZB+zIMrpjMAtkqQ629PZ3HEPx/WGVFPVnOo9I cmpE/ZRnc1zD+gT+oiq3OtwIGZF0ElyHG8AzrI9Jz3JzXTAmepJurAe8HAFDkmhjUr56 ZNTb2zohErBR+3uexT2tegCHbkeaEtKXo5j8fbUYQWwU+f0/gIV+U6cugo8WXW4X31MX +5J4Zkar0rQHvIcxPVtlkDCEP+lrsgPvAnAKZvBwQIzWGE9q4TJPHJYktCoC1IztCbCb zVVIxkYMbXQYTZY2xRzy24HxBOKJFSdVCRIzzrbLPtrLlVwtNSpKWPEDskqQr1fPmlBB X35w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wh9FITta3C+uiujkN9yOlTx3uqHPS8M4Fiy7NsSWCpk=; b=OqYwKjlHuXGhOydw6v3139kmGxAqoFRICuDniANSFJPHX4A3rxyFg9TDlyVUIk4skt toTPx9JgQFTLXMAg6/9bn1kLoq4l0jZ4vKvhelKZiAN/vsiTRunMJMd26O7H19gojG1d nG+RkI05nbZ/GglULmukAm4KSCh9U7qR2vmyz+7ikLAGwLtu2u9k9QixdXwcGYxh11+M /Tj/QOCq9NGBGjx7uajDDS+S/ExOEwp0SSj4swAx5PC+gSc6UAZw434ASqkZVmh25Mee 059T/STLveZW3bNcI0H6sC9ToE+jXCXzy6r5rSTw8tS0QuLGnYOKmxMGnLvt76PsAYra k80Q== X-Gm-Message-State: AO0yUKUZ3unU6vXcZvI3KvTIDVb1GOHbP3rjPB4BdBvTu3R/9DmCcc8m oozXkoS/2AXwpom6z2cp3kezj9oBVLdIECSi X-Received: by 2002:a17:903:22c3:b0:198:a49b:9f53 with SMTP id y3-20020a17090322c300b00198a49b9f53mr3110970plg.10.1675259967021; Wed, 01 Feb 2023 05:59:27 -0800 (PST) Received: from sumit-X1.. ([223.178.209.222]) by smtp.gmail.com with ESMTPSA id i8-20020a17090332c800b001899c2a0ae0sm3636759plr.40.2023.02.01.05.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 05:59:26 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH v2 03/14] clocks: qcs404: Add support for ethernet clocks Date: Wed, 1 Feb 2023 19:28:50 +0530 Message-Id: <20230201135901.482671-4-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201135901.482671-1-sumit.garg@linaro.org> References: <20230201135901.482671-1-sumit.garg@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/clock-qcs404.c | 60 +++++++++++++++++++ .../include/mach/sysmap-qcs404.h | 14 +++++ 2 files changed, 74 insertions(+) diff --git a/arch/arm/mach-snapdragon/clock-qcs404.c b/arch/arm/mach-snapdragon/clock-qcs404.c index 6fe92afe8d..b8f5691aae 100644 --- a/arch/arm/mach-snapdragon/clock-qcs404.c +++ b/arch/arm/mach-snapdragon/clock-qcs404.c @@ -18,6 +18,9 @@ /* GPLL0 clock control registers */ #define GPLL0_STATUS_ACTIVE BIT(31) +#define CFG_CLK_SRC_GPLL1 BIT(8) +#define GPLL1_STATUS_ACTIVE BIT(31) + static struct vote_clk gcc_blsp1_ahb_clk = { .cbcr_reg = BLSP1_AHB_CBCR, .ena_vote = APCS_CLOCK_BRANCH_ENA_VOTE, @@ -47,6 +50,13 @@ static struct pll_vote_clk gpll0_vote_clk = { .vote_bit = BIT(0), }; +static struct pll_vote_clk gpll1_vote_clk = { + .status = GPLL1_STATUS, + .status_bit = GPLL1_STATUS_ACTIVE, + .ena_vote = APCS_GPLL_ENA_VOTE, + .vote_bit = BIT(1), +}; + static const struct bcr_regs usb30_master_regs = { .cfg_rcgr = USB30_MASTER_CFG_RCGR, .cmd_rcgr = USB30_MASTER_CMD_RCGR, @@ -55,6 +65,22 @@ static const struct bcr_regs usb30_master_regs = { .D = USB30_MASTER_D, }; +static const struct bcr_regs emac_regs = { + .cfg_rcgr = EMAC_CFG_RCGR, + .cmd_rcgr = EMAC_CMD_RCGR, + .M = EMAC_M, + .N = EMAC_N, + .D = EMAC_D, +}; + +static const struct bcr_regs emac_ptp_regs = { + .cfg_rcgr = EMAC_PTP_CFG_RCGR, + .cmd_rcgr = EMAC_PTP_CMD_RCGR, + .M = EMAC_M, + .N = EMAC_N, + .D = EMAC_D, +}; + ulong msm_set_rate(struct clk *clk, ulong rate) { struct msm_clk_priv *priv = dev_get_priv(clk->dev); @@ -79,6 +105,20 @@ ulong msm_set_rate(struct clk *clk, ulong rate) case GCC_SDCC1_AHB_CLK: clk_enable_cbc(priv->base + SDCC_AHB_CBCR(1)); break; + case GCC_ETH_RGMII_CLK: + if (rate == 250000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 2, 0, 0, + CFG_CLK_SRC_GPLL1); + else if (rate == 125000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 4, 0, 0, + CFG_CLK_SRC_GPLL1); + else if (rate == 50000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 10, 0, 0, + CFG_CLK_SRC_GPLL1); + else if (rate == 5000000) + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 2, 1, 50, + CFG_CLK_SRC_GPLL1); + break; default: return 0; } @@ -111,6 +151,26 @@ int msm_enable(struct clk *clk) case GCC_USB2A_PHY_SLEEP_CLK: clk_enable_cbc(priv->base + USB_HS_PHY_CFG_AHB_CBCR); break; + case GCC_ETH_PTP_CLK: + /* SPEED_1000: freq -> 250MHz */ + clk_enable_cbc(priv->base + ETH_PTP_CBCR); + clk_enable_gpll0(priv->base, &gpll1_vote_clk); + clk_rcg_set_rate_mnd(priv->base, &emac_ptp_regs, 2, 0, 0, + CFG_CLK_SRC_GPLL1); + break; + case GCC_ETH_RGMII_CLK: + /* SPEED_1000: freq -> 250MHz */ + clk_enable_cbc(priv->base + ETH_RGMII_CBCR); + clk_enable_gpll0(priv->base, &gpll1_vote_clk); + clk_rcg_set_rate_mnd(priv->base, &emac_regs, 2, 0, 0, + CFG_CLK_SRC_GPLL1); + break; + case GCC_ETH_SLAVE_AHB_CLK: + clk_enable_cbc(priv->base + ETH_SLAVE_AHB_CBCR); + break; + case GCC_ETH_AXI_CLK: + clk_enable_cbc(priv->base + ETH_AXI_CBCR); + break; default: return 0; } diff --git a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h index e448faad2d..8920c4ee8f 100644 --- a/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h +++ b/arch/arm/mach-snapdragon/include/mach/sysmap-qcs404.h @@ -12,6 +12,7 @@ /* Clocks: (from CLK_CTL_BASE) */ #define GPLL0_STATUS (0x21000) +#define GPLL1_STATUS (0x20000) #define APCS_GPLL_ENA_VOTE (0x45000) #define APCS_CLOCK_BRANCH_ENA_VOTE (0x45004) @@ -54,4 +55,17 @@ #define USB2A_PHY_SLEEP_CBCR (0x4102C) #define USB_HS_PHY_CFG_AHB_CBCR (0x41030) +/* ETH controller clock control registers */ +#define ETH_PTP_CBCR (0x4e004) +#define ETH_RGMII_CBCR (0x4e008) +#define ETH_SLAVE_AHB_CBCR (0x4e00c) +#define ETH_AXI_CBCR (0x4e010) +#define EMAC_PTP_CMD_RCGR (0x4e014) +#define EMAC_PTP_CFG_RCGR (0x4e018) +#define EMAC_CMD_RCGR (0x4e01c) +#define EMAC_CFG_RCGR (0x4e020) +#define EMAC_M (0x4e024) +#define EMAC_N (0x4e028) +#define EMAC_D (0x4e02c) + #endif