From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FCD2C433F5 for ; Sat, 23 Apr 2022 16:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WKRJ7smepJJFBNCjtZdW4VEsoS+XvplAlg4Y1Q924g8=; b=sMMuDgdEV8+4mC m3jYPkpW0Y/xeUjxHLiene/NErJmIJgp2zwBBt7/ZTbal0lH18bl4vSKoF+UY0uaCMRg2uDISVx8M YBG+CEsM+6LhFuZM4YeSdq8u/3gZp0k1uR0buWkKChpQOsAFHAd7hspKpI1oy4kpMdnay0GKy6NhB uHBFRAWxUFti2JxgMbDa6CkkrJbiHCACKrwWLjZA9m+Q1m6Z6e68Gfb4YCdOImlDDfS5R+TX5kgzb PvvFuYB4TLt7TRN9QRyIIwGVNKM1h9DL6rMfvUOh5ekdiqZYpkJhTJeik0kQ2uX+PWMYlK16j0fHU WBbpJCZJ+YocHXnX2caw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1niIM9-004cCg-LX; Sat, 23 Apr 2022 16:11:33 +0000 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1niIM7-004cB7-8d for linux-arm-kernel@lists.infradead.org; Sat, 23 Apr 2022 16:11:32 +0000 Received: by mail-qk1-x72b.google.com with SMTP id s70so7967996qke.8 for ; Sat, 23 Apr 2022 09:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=lQVbIb2JtzfXlFMXF5sUujmihmQB1ITOpgM0dRlM/bE=; b=ad8l34Oy3g2XPQbKV5BOfbYnWHL9BOhdVLt8MCnK6mVOd/h1q9YEE3evE+OIlHSuwn CBUXm5m0Dtn6SYBy9VqsDnR816pbRFPcaDZKm30baLR96P80nZX5xyx8IJ36I/IxFO7s YDuwaQyZi+6VnxE/QcF3+tqIFx/UWV0QntEDQxYGdkwJfAPjnulsvber14U5RK46Uio9 kepo/Id4gojp/BwtMAOqZpUXaYG+utfJVHyHwiOivbnEnLJqXNSNgxUgiO3uDMycnfPV 8mMXhvikabVraP3RqpOS+e9PVKZx+G1Zp0zerh1E+q2CWz05Xaqn7UKS+7conFkou/1Y nrGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=lQVbIb2JtzfXlFMXF5sUujmihmQB1ITOpgM0dRlM/bE=; b=Io+YV5azomioFcrZKX+7nMqVGk0K26kmDk/hWjDPEOtIBjNkHKHJNhgjKpyzPilB6f 9Yd7kG3dF5dx/L5c3XvZXfJTAEhF/DlxbYRKBg0xvQJ5FMtUe4bHrKLXMTn3fFUvRqF5 jn7k2W/z2aMZuRrIY+Y9D6dVJ+NdwB9nELH0KZdPkYKmPRG9yjNvI9a2IpOOBbrOn88A RkxI2duvjPgv2ImL8GZl1CFU3kK1gIz1ZaZuJLQpWi894vVHJ837NJ+am6F9bY9SB6kb 1WKm53dQdqBCOh9pIlR+ha8lyhqX8UmbaqKdXVdU3JuVsWmQ6Y0OvpY1D94TwXy11yNq kGmw== X-Gm-Message-State: AOAM531jHwF/bMEZE7iAttjMDHBRiRgXkEWINAUfDyg31lBsA+SVHJcR 3JOUhX11/EZgNuT3um9LObI= X-Google-Smtp-Source: ABdhPJyEa8wserA/9fHwGUzW4LPvUsGSMRtuwkuiUXVL6tdG873QFklMkWNFcP5Zzqyv413p0LJh+g== X-Received: by 2002:a05:620a:bc6:b0:67d:1870:8b35 with SMTP id s6-20020a05620a0bc600b0067d18708b35mr5751141qki.85.1650730287404; Sat, 23 Apr 2022 09:11:27 -0700 (PDT) Received: from [10.4.10.60] (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 x20-20020ac85f14000000b002e1ee1c56c3sm3047852qta.76.2022.04.23.09.11.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Apr 2022 09:11:26 -0700 (PDT) Message-ID: Date: Sat, 23 Apr 2022 12:11:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v1 08/12] clk: imx: Add initial support for i.MXRT1170 clock driver Content-Language: en-US To: Stephen Boyd , linux-imx@nxp.com Cc: robh+dt@kernel.org, mturquette@baylibre.com, 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, 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 References: <20220326144313.673549-1-Mr.Bossman075@gmail.com> <20220326144313.673549-9-Mr.Bossman075@gmail.com> <20220423030331.0E85CC385A0@smtp.kernel.org> From: Jesse Taube In-Reply-To: <20220423030331.0E85CC385A0@smtp.kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220423_091131_335581_87A217D7 X-CRM114-Status: GOOD ( 21.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 4/22/22 23:03, Stephen Boyd wrote: > Quoting Jesse Taube (2022-03-26 07:43:09) >> diff --git a/drivers/clk/imx/clk-imxrt1170.c b/drivers/clk/imx/clk-imxrt1170.c >> new file mode 100644 >> index 000000000000..041aea3d4b02 >> --- /dev/null >> +++ b/drivers/clk/imx/clk-imxrt1170.c >> @@ -0,0 +1,391 @@ >> +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) >> +/* >> + * Copyright (C) 2022 >> + * Author(s): >> + * Jesse Taube >> + */ >> +#include >> +#include > > Is this include used? > >> +#include > > Is this include used? > >> +#include > > Need to include clk-provider.h > >> +#include >> + >> +#include "clk.h" >> + >> +#define CLOCK_MUX_DEFAULT "rcosc48M_div2", "osc", "rcosc400M", "rcosc16M" >> + >> +#define LPCG_GATE(gate) (0x6000 + (gate * 0x20)) >> + >> +#define DEF_CLOCK(flags, macro, name) \ >> +do { \ >> + hws[macro##_SEL] = imx_clk_hw_mux(#name"_sel", ccm_base + (name * 0x80), \ >> + 8, 3, root_clocks[name], 8); \ >> + hws[macro##_GATE] = imx_clk_hw_gate_dis_flags(#name"_gate", #name"_sel", \ >> + ccm_base + (name * 0x80), 24, flags); \ >> + hws[macro] = imx_clk_hw_divider(#name, #name"_gate", ccm_base + (name * 0x80), 0, 8); \ >> +} while (0) >> + >> +enum root_clock_names { >> + m7, /* root clock m7. */ > > Is the comment adding any value? It has the enum name after "root clock" > and the enum is "root_clock_names" so it looks very obvious. > >> + m4, /* root clock m4. */ >> + bus, /* root clock bus. */ >> + bus_lpsr, /* root clock bus lpsr. */ > [...] >> + end, /* root clock end. */ >> +}; >> + >> +static const char * const root_clocks[79][8] = { >> + {CLOCK_MUX_DEFAULT, "pll_arm", "pll1_sys", "pll3_sys", "pll_video"}, > > Space after { and before } > >> + {CLOCK_MUX_DEFAULT, "pll3_pfd3", "pll3_sys", "pll2_sys", "pll1_div5"}, >> + {CLOCK_MUX_DEFAULT, "pll3_sys", "pll1_div5", "pll2_sys", "pll2_pfd3"}, > [...] >> + {CLOCK_MUX_DEFAULT, "pll2_pfd3", "rcosc48M", "pll3_pfd1", "pll_audio"} >> +}; >> + >> +static const char * const pll_arm_mux[] = {"pll_arm_pre", "osc"}; >> +static const char * const pll3_mux[] = {"pll3_pre", "osc"}; >> +static const char * const pll2_mux[] = {"pll2_pre", "osc"}; >> + >> +static const struct clk_div_table post_div_table[] = { >> + { .val = 3, .div = 1, }, >> + { .val = 2, .div = 8, }, >> + { .val = 1, .div = 4, }, >> + { .val = 0, .div = 2, }, >> + { } >> +}; >> + >> +static struct clk_hw **hws; >> +static struct clk_hw_onecell_data *clk_hw_data; > > Do either of these need to be static global variables? They could be > local function pointers allocated on the heap (like they already are). > >> + >> +static int imxrt1170_clocks_probe(struct platform_device *pdev) >> +{ > [...] >> + hws[IMXRT1170_CLK_PLL2_PFD3] = imx_clk_hw_pfd("pll2_pfd3", "pll2_sys", pll_base + 0x270, 3); >> + >> + /* CCM clocks */ >> + ccm_base = devm_platform_ioremap_resource(pdev, 0); >> + if (WARN_ON(IS_ERR(ccm_base))) >> + return PTR_ERR(ccm_base); >> + >> + DEF_CLOCK(CLK_IS_CRITICAL, IMXRT1170_CLK_M7, m7); > > Don't have macros do things to variables that are in global scope. It > makes things very non-obvious. Instead, pass hw to the macro, or better > yet make a static inline function and let the compiler decide to inline > it or not. Ah I use the enum name as the string clk name so inline unfortunately wont work. Thanks I will fix `ccm_base` and `hws`. Thanks for the reply!!!! > >> + DEF_CLOCK(CLK_IS_CRITICAL, IMXRT1170_CLK_M4, m4); > [...] >> + DEF_CLOCK(0, IMXRT1170_CLK_CSI2_UI, csi2_ui); >> + DEF_CLOCK(0, IMXRT1170_CLK_CSI, csi); >> + DEF_CLOCK(0, IMXRT1170_CLK_CKO1, cko1); >> + DEF_CLOCK(0, IMXRT1170_CLK_CKO2, cko2); >> + >> + hws[IMXRT1170_CLK_USB] = imx_clk_hw_gate("usb", "bus", ccm_base + LPCG_GATE(115), 0); >> + >> + clk_set_rate(hws[IMXRT1170_CLK_PLL_ARM]->clk, 90000000); > > Use assigned-clock-rates? Sry left from testing. > >> + >> + imx_check_clk_hws(hws, IMXRT1170_CLK_END); Thanks, Jesse Taube _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel