From patchwork Mon Feb 26 08:04:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 775825 Delivered-To: patch@linaro.org Received: by 2002:a5d:6103:0:b0:33d:da16:65b6 with SMTP id v3csp213119wrt; Mon, 26 Feb 2024 00:06:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXcI9zv4vHCsWv6399Q8Weg5l1Xsgzyt4I+775UYQ1qCxxEYZnGv9IBIH44YyjCDsB1sT78qdwMdK2/BgG3PzC1 X-Google-Smtp-Source: AGHT+IEmfZ9Kzhicf71b1Pk6gGukky0UtJ0jEJXcjhP+fIH/IYXjAs9+kJXb7Klr7k3JiTmLduES X-Received: by 2002:a05:6000:1961:b0:33d:3566:b5c8 with SMTP id da1-20020a056000196100b0033d3566b5c8mr3987232wrb.13.1708934771723; Mon, 26 Feb 2024 00:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708934771; cv=none; d=google.com; s=arc-20160816; b=QnoUeVQVfuFwyWP+b2IeqWsf8q9lfQwhj4JyBG33Yu6UkqbHAdhWazA0ScgbKKPbpW 8rrksSympOQBv2+mK9SxLca375B6Tjmu7R5EBJaYg5ZEM6FkW5YSJct9mnusrsvYC2Gs JsYGyTkcGPqrtWdmPqeEXfOYm47/Q9OPik59Noo31o83SAGqg3MkilydQg7QcU5eMGgX itrxYPkcR2B91dGRJJ2htbPMtzjcQXjDte8BdrHMvT2zG9aWxNKd0viXGsomUrmTfNq9 Evo/bGIzyM33GBsZ3/2L5ZTcKVUnWeCU+EpnC10M9HTpWFAJBWeLUkcO34Qs42oeXWj/ OuyQ== 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=We+fvmTIWTWost47vKSyC3bkS9Lb+gyVjLQt2bCVGyA=; fh=Fs1zbWKIxSIVLTQCFo9FCJbHBYUHE1QsCA7Q0S6FH1g=; b=YtIxnh1bn0Gcky3d2xdw+a6aB1GzCbJASQYcSfkeNjM7koD2b7D1rtv0Aod1pncOoV yIXQnz1y0KFPLQ3tDlDA9tCduYJlbFkdl1GdxNyyDfud+RN0/Pafal0PNJmURs/e3wzK vVOEo1k3s62+X6f1OfiYE9rWPQYwOk15nCMe8sP69mHv2s8lMtgUz/T5sP9+JTNvIzKr 1ImstlQY3zm0JJjvwbnAKNusySFQ1VG+cWoflOx+5YAqaCVkWxzfs7jp6UxVWBlDesFH sFqAGrB5dSmu/gBfRbtvsa/X2gpk5KL5w0jAFMeZj16u4zVByDCxibhHcTPzPidyK9X+ 4HsQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnwsUeNd; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id f9-20020adff8c9000000b0033d855ca2fesi2231932wrq.432.2024.02.26.00.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:06:11 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnwsUeNd; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 2D70887EB7; Mon, 26 Feb 2024 09:05:44 +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="wnwsUeNd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0583F87EA7; Mon, 26 Feb 2024 09:05:43 +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=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 B0C8A87EB2 for ; Mon, 26 Feb 2024 09:05:36 +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-pf1-x430.google.com with SMTP id d2e1a72fcca58-6e435542d41so1580680b3a.1 for ; Mon, 26 Feb 2024 00:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708934735; x=1709539535; darn=lists.denx.de; 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=We+fvmTIWTWost47vKSyC3bkS9Lb+gyVjLQt2bCVGyA=; b=wnwsUeNdAOFRxylbrpV4ZEQescFfx7u0SdDiuAtCGKOjKijmBo0I77E08ZbIc7/+if fEBTJyv3RPsW4e2pHucKPPUvFANVKUX3ct2++Tqa2qNBWWHTL1XZ+JMNAUc1k16XVDlV wtgI85wpS4lwl7dm0tQ+b+FB/Nv9sH3FaMz3cIDKzcWcm5q2ZbQNd+7b6cSBVeu/Sl1M Pr6ftu3p5WTeip/RXoM23s5LoCiJMTrvV/0jToujg0SIRBSUNKXteHustLq0oazNvCMl ILVe1p7ipGY4Gu9PazKzdr1jPq//PovtkeBe0221/Rb1Cdo6JuyspYnE7nxqoCjMdLq8 w3Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708934735; x=1709539535; 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=We+fvmTIWTWost47vKSyC3bkS9Lb+gyVjLQt2bCVGyA=; b=Bytp1Jb5RGMn5JX1+jKVeAO3HT+JpYTJAwmUiZkwzpwlydVwtbFnmMWEdw4JEo/yWb FbugvM5szq5JrgkOHTXXkP6+xdmNlsKmUcMt/EgF73KaQ/FiptsToTzz21gmDc2NqAdI 930/NDPo418ivGrbXcJ97ilKH2NrwlA/1xq91//9oXrREseCunnRxGDjwEqU7vmS+5aF XJJmtNKF3BTlMzxByh4Jm+DAMJGstHMm28d17a/5I3gWpY83QP135wsVJ4OsoGk8ynDB b48PLHkMgDgDLH9qtzEKK/OhSKTtY5XOOr9FAaNTqz8tXnhvEZI1knUO7X0YLF0Sno1m +L/A== X-Gm-Message-State: AOJu0YwvOguIO1cLtc1heeWuEzUF7tyw0mILWTA5jYTw+x6eD9cEcWk+ 3k56YVu0NDrnkPuAX3kp2OyUHxir0EsR4MdrBylC9acRLLKxMxiVqudiSCgI816Du8qdckNEsXI L X-Received: by 2002:a05:6a00:1b57:b0:6e4:65a7:c806 with SMTP id o23-20020a056a001b5700b006e465a7c806mr4589240pfv.8.1708934734742; Mon, 26 Feb 2024 00:05:34 -0800 (PST) Received: from sumit-X1.. ([223.178.208.32]) by smtp.gmail.com with ESMTPSA id k2-20020aa788c2000000b006e13a88d52esm3392842pff.61.2024.02.26.00.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:05:34 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: marcel.ziswiler@toradex.com, francesco@dolcini.it, trini@konsulko.com, lukma@denx.de, seanga2@gmail.com, jh80.chung@samsung.com, festevam@denx.de, andrejs.cainikovs@toradex.com, sjg@chromium.org, peng.fan@nxp.com, aford173@gmail.com, marex@denx.de, ilias.apalodimas@linaro.org, sahaj.sarup@linaro.org, fathi.boudra@linaro.org, remi.duraffort@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH v2 4/8] imx8mp: power-domain: Expose high performance PLL clock Date: Mon, 26 Feb 2024 13:34:29 +0530 Message-Id: <20240226080433.3307154-5-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240226080433.3307154-1-sumit.garg@linaro.org> References: <20240226080433.3307154-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.8 at phobos.denx.de X-Virus-Status: Clean Expose the high performance PLL as a regular Linux clock, so the PCIe PHY can use it when there is no external refclock provided. Inspired from counterpart Linux kernel v6.8-rc3 driver: drivers/pmdomain/imx/imx8mp-blk-ctrl.c Signed-off-by: Sumit Garg --- drivers/power/domain/imx8mp-hsiomix.c | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/power/domain/imx8mp-hsiomix.c b/drivers/power/domain/imx8mp-hsiomix.c index 58cc3f63bb56..3e514a603578 100644 --- a/drivers/power/domain/imx8mp-hsiomix.c +++ b/drivers/power/domain/imx8mp-hsiomix.c @@ -6,9 +6,15 @@ #include #include #include +#include #include #include #include +#include +#include +#include +#include +#include #include #include @@ -18,6 +24,15 @@ #define USB_CLOCK_MODULE_EN BIT(1) #define PCIE_PHY_APB_RST BIT(4) #define PCIE_PHY_INIT_RST BIT(5) +#define GPR_REG1 0x4 +#define PLL_LOCK BIT(13) +#define GPR_REG2 0x8 +#define P_PLL_MASK GENMASK(5, 0) +#define M_PLL_MASK GENMASK(15, 6) +#define S_PLL_MASK GENMASK(18, 16) +#define GPR_REG3 0xc +#define PLL_CKE BIT(17) +#define PLL_RST BIT(31) struct imx8mp_hsiomix_priv { void __iomem *base; @@ -137,6 +152,68 @@ static int imx8mp_hsiomix_of_xlate(struct power_domain *power_domain, return 0; } +static int hsio_pll_clk_enable(struct clk *clk) +{ + void *base = (void *)dev_get_driver_data(clk->dev); + u32 val; + int ret; + + /* Setup HSIO PLL */ + clrsetbits_le32(base + GPR_REG2, + P_PLL_MASK | M_PLL_MASK | S_PLL_MASK, + FIELD_PREP(P_PLL_MASK, 12) | + FIELD_PREP(M_PLL_MASK, 800) | + FIELD_PREP(S_PLL_MASK, 4)); + + /* de-assert PLL reset */ + setbits_le32(base + GPR_REG3, PLL_RST); + + /* enable PLL */ + setbits_le32(base + GPR_REG3, PLL_CKE); + + /* Check if PLL is locked */ + ret = readl_poll_sleep_timeout(base + GPR_REG1, val, + val & PLL_LOCK, 10, 100000); + if (ret) + dev_err(clk->dev, "failed to lock HSIO PLL\n"); + + return ret; +} + +static int hsio_pll_clk_disable(struct clk *clk) +{ + void *base = (void *)dev_get_driver_data(clk->dev); + + clrbits_le32(base + GPR_REG3, PLL_CKE); + clrbits_le32(base + GPR_REG3, PLL_RST); + + return 0; +} + +static const struct clk_ops hsio_pll_clk_ops = { + .enable = hsio_pll_clk_enable, + .disable = hsio_pll_clk_disable, +}; + +U_BOOT_DRIVER(hsio_pll) = { + .name = "hsio-pll", + .id = UCLASS_CLK, + .ops = &hsio_pll_clk_ops, +}; + +int imx8mp_hsiomix_bind(struct udevice *dev) +{ + struct driver *drv; + + drv = lists_driver_lookup_name("hsio-pll"); + if (!drv) + return -ENOENT; + + return device_bind_with_driver_data(dev, drv, "hsio-pll", + (ulong)dev_read_addr_ptr(dev), + dev_ofnode(dev), NULL); +} + static int imx8mp_hsiomix_probe(struct udevice *dev) { struct imx8mp_hsiomix_priv *priv = dev_get_priv(dev); @@ -207,6 +284,7 @@ U_BOOT_DRIVER(imx8mp_hsiomix) = { .id = UCLASS_POWER_DOMAIN, .of_match = imx8mp_hsiomix_ids, .probe = imx8mp_hsiomix_probe, + .bind = imx8mp_hsiomix_bind, .priv_auto = sizeof(struct imx8mp_hsiomix_priv), .ops = &imx8mp_hsiomix_ops, };