Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp4737113pxb; Mon, 28 Mar 2022 02:29:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzqNml+kWo0gfAOethwG98PZYXUgZ48PHeSkEcp+I1Ii1hWXRF8pCjPgtB8pD4ilUJYhvS X-Received: by 2002:a17:902:bf07:b0:14f:a3a7:97a0 with SMTP id bi7-20020a170902bf0700b0014fa3a797a0mr25044303plb.105.1648459763695; Mon, 28 Mar 2022 02:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648459763; cv=none; d=google.com; s=arc-20160816; b=hDkXvI09QOh59/vL3kyShhx4+rWSlvUza8Gv4OV+eWhpAFJxHGwq9FXIG/FCWpH9h4 l1uua/LM6r1c2yBYpg9hGhyli0l6+O7KxnACrgVqGWdGIMU2BG4/l/YEQCFPHSxGIiuX GY/3IkECw9iZF+6flquC6CMQZNY1hPlz3NSzBFC1WAwSV6dpDhBRJu3uGftdwKop6UZj UhgNdJ9MgIlE8LWqJ9CMBhRtlSh2719WlxpWvSs2hJhY40IXnuyY9NWdYsgA/otswGnm fX+OgquFBmS5umn47HLzMEST/hVcpPyhYuQPN4BckDH5fYYnqS1EFG+7B37nMl9AybEx OH+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0OnOYnWbKBOx8TDVywfCrwMlRr6WkNrB+huo8muKs9o=; b=CtH51+iq8ieU23Til+tW9V/h3J7bXoB1u3w+TJiU81UXj4aBSQlBDhhxWJawyJEIDp JoHdqdkh/Am+Q3kXNqEGsbrpZSgINrygmlocPX3qa0YAHx3RJddedQ7T2FedHsns8dDP drjkIVp7ja7iQcxnvMzpaxQTzc9TpJA4gkn7TeT6AguY4yQpaUencWlQGNbu604MW3bl FbFot/GGND5tDSxzirxnlGOUkp3gGfp+30Lh6u5BQ9Mib5v+NaPcfYyKPOFe39giqw9i jCK6OyPOw1HY2qN3aWenhhfaVsdHZ8Fpng/idRbbaiWS4pgDNQ9TptfgE1BPTn4JYikU hpdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cjbfxrVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020a170902f70f00b00153b7e108bbsi2310459plo.489.2022.03.28.02.28.55; Mon, 28 Mar 2022 02:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cjbfxrVb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233394AbiCZOp0 (ORCPT + 99 others); Sat, 26 Mar 2022 10:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbiCZOpP (ORCPT ); Sat, 26 Mar 2022 10:45:15 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B402102A8; Sat, 26 Mar 2022 07:43:37 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id k125so8129768qkf.0; Sat, 26 Mar 2022 07:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0OnOYnWbKBOx8TDVywfCrwMlRr6WkNrB+huo8muKs9o=; b=cjbfxrVbMkrDr0KXh0iFZddnkTfRsTYS9dfaLk04lNN4lnEgXN6tIa/yzosPfOMO0A jktwrc51whcVCEI452+v+rn4bnOkHro85ulLAn+z8KMf0oSR9kDCIK+Uo4xn8Sa4AmGR eZeu8FZ+OsG4J5YCPEJQGFY/BEoizJ5BAE9eyQ8trXk+3ecxLsTHtJMW8q9zNq2k3dTL vhGGWT1zDnaGPgmE9OZoXezZRHl4vIJcDhxNghHk3uNlcjP5acTswVYS1Y8koTnh0hdZ 1a5vrXvRjJIjorJzHylPPbu5k6K/B4eXPBaLK8j6qViYD0pbF+P8pOLdmJbmHeDLv19j Ppvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0OnOYnWbKBOx8TDVywfCrwMlRr6WkNrB+huo8muKs9o=; b=ubdkjD5aySoTE05plahMdHvLwdzhSUp7LgdzMEspg+fF+fmHZ1RvU2cWcVBFlc1NYV gyKVm6EonywpGpWN6ZmEDSnppseOINEKHjfU6rH2iD+QivhnzPmj5+Om0/jCuf3ebz/M MZ0CdK4YeJMuEQxvPqL3d3VRzZoi2e6zX7vvPHYv2KQm9KvfNFW7F107qaDa67RCgF9o UyiEjZAj13jD5SarraWOKM4gMsRxUv6mXtn+KZdWOptlBPYsWoymuvqzzlqy6f+L7sag mjUNQzEZ5KxMFSMJ8eHvGXnaxNl0Rdk2vQ/UT1NwKZUD/pAzMKBoPefubFb+f29ZbvS9 uqvQ== X-Gm-Message-State: AOAM530ACxQjsez6PcXjvq2HaAe3ksiaDuwoYzOo8Jnt/4dae8sogEpb o8ElvaWXNvpEw9WVhfTJeys= X-Received: by 2002:a05:620a:2889:b0:67a:ee33:3c15 with SMTP id j9-20020a05620a288900b0067aee333c15mr10336073qkp.236.1648305816191; Sat, 26 Mar 2022 07:43:36 -0700 (PDT) Received: from jesse-desktop.jtp-bos.lab (146-115-144-188.s4282.c3-0.nwt-cbr1.sbo-nwt.ma.cable.rcncustomer.com. [146.115.144.188]) by smtp.gmail.com with ESMTPSA id 70-20020a370649000000b0067b4cd8ffbasm4908918qkg.60.2022.03.26.07.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 07:43:35 -0700 (PDT) From: Jesse Taube X-Google-Original-From: Jesse Taube To: linux-imx@nxp.com Cc: robh+dt@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, aisheng.dong@nxp.com, stefan@agner.ch, linus.walleij@linaro.org, daniel.lezcano@linaro.org, tglx@linutronix.de, arnd@arndb.de, olof@lixom.net, soc@kernel.org, linux@armlinux.org.uk, abel.vesa@nxp.com, dev@lynxeye.de, marcel.ziswiler@toradex.com, tharvey@gateworks.com, leoyang.li@nxp.com, sebastian.reichel@collabora.com, cniedermaier@dh-electronics.com, Mr.Bossman075@gmail.com, clin@suse.com, giulio.benetti@benettiengineering.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH v1 06/12] ARM: clk: imx: Update pllv3 to support i.MXRT1170 Date: Sat, 26 Mar 2022 10:43:07 -0400 Message-Id: <20220326144313.673549-7-Mr.Bossman075@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220326144313.673549-1-Mr.Bossman075@gmail.com> References: <20220326144313.673549-1-Mr.Bossman075@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The i.MXRT1170 has a pll that has the multiplier bits inverted and cannot be changed add IMX_PLLV3_GENERICV2. The i.MXRT1170 also has the lock bit moved as well as the power bit inverted the power bit also is in different locations on each pll control register. Signed-off-by: Jesse Taube --- drivers/clk/imx/clk-pllv3.c | 57 +++++++++++++++++++++++++++++++++++-- drivers/clk/imx/clk.h | 4 +++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c index 20ee9611ba6e..a1dbc3a2e280 100644 --- a/drivers/clk/imx/clk-pllv3.c +++ b/drivers/clk/imx/clk-pllv3.c @@ -23,6 +23,7 @@ #define BM_PLL_POWER (0x1 << 12) #define BM_PLL_LOCK (0x1 << 31) +#define BM_PLL_LOCK_V2 (0x1 << 29) #define IMX7_ENET_PLL_POWER (0x1 << 5) #define IMX7_DDR_PLL_POWER (0x1 << 20) @@ -34,6 +35,7 @@ * @base: base address of PLL registers * @power_bit: pll power bit mask * @powerup_set: set power_bit to power up the PLL + * @lock_bit: pll lock bit mask * @div_mask: mask of divider bits * @div_shift: shift of divider bits * @ref_clock: reference clock rate @@ -48,6 +50,7 @@ struct clk_pllv3 { void __iomem *base; u32 power_bit; bool powerup_set; + u32 lock_bit; u32 div_mask; u32 div_shift; unsigned long ref_clock; @@ -65,7 +68,7 @@ static int clk_pllv3_wait_lock(struct clk_pllv3 *pll) if ((pll->powerup_set && !val) || (!pll->powerup_set && val)) return 0; - return readl_relaxed_poll_timeout(pll->base, val, val & BM_PLL_LOCK, + return readl_relaxed_poll_timeout(pll->base, val, val & pll->lock_bit, 500, PLL_LOCK_TIMEOUT); } @@ -101,7 +104,7 @@ static int clk_pllv3_is_prepared(struct clk_hw *hw) { struct clk_pllv3 *pll = to_clk_pllv3(hw); - if (readl_relaxed(pll->base) & BM_PLL_LOCK) + if (readl_relaxed(pll->base) & pll->lock_bit) return 1; return 0; @@ -155,6 +158,39 @@ static const struct clk_ops clk_pllv3_ops = { .set_rate = clk_pllv3_set_rate, }; +static int clk_pllv3_genericv2_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct clk_pllv3 *pll = to_clk_pllv3(hw); + u32 val, div; + + div = (readl_relaxed(pll->base) >> pll->div_shift) & pll->div_mask; + val = (div == 0) ? parent_rate * 22 : parent_rate * 20; + + if (rate == val) + return 0; + + return -EINVAL; +} + +static unsigned long clk_pllv3_genericv2_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct clk_pllv3 *pll = to_clk_pllv3(hw); + u32 div = (readl_relaxed(pll->base) >> pll->div_shift) & pll->div_mask; + + return (div == 0) ? parent_rate * 22 : parent_rate * 20; +} + +static const struct clk_ops clk_pllv3_genericv2_ops = { + .prepare = clk_pllv3_prepare, + .unprepare = clk_pllv3_unprepare, + .is_prepared = clk_pllv3_is_prepared, + .recalc_rate = clk_pllv3_genericv2_recalc_rate, + .round_rate = clk_pllv3_round_rate, + .set_rate = clk_pllv3_genericv2_set_rate, +}; + static unsigned long clk_pllv3_sys_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { @@ -407,6 +443,13 @@ static const struct clk_ops clk_pllv3_enet_ops = { .recalc_rate = clk_pllv3_enet_recalc_rate, }; +void imx_clk_hw_pll3_powerbit(struct clk_hw *hw, u8 shift) +{ + struct clk_pllv3 *pll = to_clk_pllv3(hw); + + pll->power_bit = shift; +} + struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name, const char *parent_name, void __iomem *base, u32 div_mask) @@ -422,10 +465,20 @@ struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name, return ERR_PTR(-ENOMEM); pll->power_bit = BM_PLL_POWER; + pll->lock_bit = BM_PLL_LOCK; pll->num_offset = PLL_NUM_OFFSET; pll->denom_offset = PLL_DENOM_OFFSET; switch (type) { + case IMX_PLLV3_GENERICV2: + pll->lock_bit = BM_PLL_LOCK_V2; + pll->powerup_set = true; + ops = &clk_pllv3_genericv2_ops; + break; + case IMX_PLLV3_SYSV2: + pll->lock_bit = BM_PLL_LOCK_V2; + pll->powerup_set = true; + fallthrough; case IMX_PLLV3_SYS: ops = &clk_pllv3_sys_ops; break; diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index 7d220a01de1f..e70e985840a4 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -220,6 +220,8 @@ struct clk_hw *imx_clk_hw_sscg_pll(const char *name, enum imx_pllv3_type { IMX_PLLV3_GENERIC, + IMX_PLLV3_GENERICV2, + IMX_PLLV3_SYSV2, IMX_PLLV3_SYS, IMX_PLLV3_USB, IMX_PLLV3_USB_VF610, @@ -231,6 +233,8 @@ enum imx_pllv3_type { IMX_PLLV3_AV_IMX7, }; +void imx_clk_hw_pll3_powerbit(struct clk_hw *hw, u8 shift); + struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name, const char *parent_name, void __iomem *base, u32 div_mask); -- 2.34.1