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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0B8FC4167B for ; Thu, 17 Mar 2022 15:13:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D853183A9D; Thu, 17 Mar 2022 16:13:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="GwHNmDyL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7846E83CCB; Thu, 17 Mar 2022 16:13:36 +0100 (CET) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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 D95A1833ED for ; Thu, 17 Mar 2022 16:13:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tommaso.merciai@amarulasolutions.com Received: by mail-ej1-x62a.google.com with SMTP id qa43so11327219ejc.12 for ; Thu, 17 Mar 2022 08:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OQdWpjQgKSoxF4vOlltfrdfMiGhV3MIpwNHz+hYhdTE=; b=GwHNmDyL9Qpelmw5hjYEL4vo/JlGnrGl4AWKdVLDEVUQij3r4mxDdhSlQSxAX5fEan 3IkbTfyuPp+KQaC9zCw2IEyJGWvDA8T97f4Ibg4AoJSHYBW1CLSM0xxzp+yGwlWqrn9S sbMbSj1LUCeiMqJlyEvdMHCNYUxx5IKEa4DQ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OQdWpjQgKSoxF4vOlltfrdfMiGhV3MIpwNHz+hYhdTE=; b=FU3eEY8e+amyeckrGbmXzTNpG3LMAPiahXGU7vhNzybFKgVPnAoj2fvK7eQLUlZfIi dKzLA8x1UHqKgBKNULsql9BfpMMAkJ7rixN7eAF06GEHet8V1A8WiNdaqEoN5kWEFLAp fidKB/RK/gWGjF/zbM4PKkJkP8hnyd8fDFk4eV/ZKLO2lP8zy9+NcmKb+w3tOMRR/Evf TrMQfpRrVF2JzIE3IHXOus+ps6HRqqAOJIDucn32OVpm68MhsQO0CL8M/PTJIUBtuUSL 62uvpuTqv2L3bvWJBMUQS+oXW/ZVKma5tUfO34vLcPYdPACCdBB2ez/NQM0DjSIJjJ1f uN9A== X-Gm-Message-State: AOAM533XVT1ZQoUXrLUSLVgOAKvk15WQK8FaViDBNHiuZ3BdUAjqgfzF AAmqW8h8OJnb5RL9oad3SIFreA== X-Google-Smtp-Source: ABdhPJw7Jn+BtDdVIA44F1QV6icFAyVaXWROr1qD8jfSmHK44ym4qcyq3cfNhBmvhS85C1c+7fxu9g== X-Received: by 2002:a17:907:7d93:b0:6da:8f57:68fa with SMTP id oz19-20020a1709077d9300b006da8f5768famr4971574ejc.42.1647530011344; Thu, 17 Mar 2022 08:13:31 -0700 (PDT) Received: from tom-ThinkPad-T14s-Gen-2i (net-188-217-56-61.cust.vodafonedsl.it. [188.217.56.61]) by smtp.gmail.com with ESMTPSA id sh42-20020a1709076eaa00b006df78692a9csm2478766ejc.94.2022.03.17.08.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 08:13:31 -0700 (PDT) Date: Thu, 17 Mar 2022 16:13:28 +0100 From: Tommaso Merciai To: Marek Vasut Cc: Stefano Babic , Fabio Estevam , "NXP i.MX U-Boot Team" , Peng Fan , Ye Li , Alice Guo , Andrey Zhizhikin , Marek =?iso-8859-1?Q?Beh=FAn?= , u-boot@lists.denx.de Subject: Re: [PATCH v2 4/9] arm: imx: imx8mm: add enable_pwm_clk function Message-ID: <20220317151328.GG29139@tom-ThinkPad-T14s-Gen-2i> References: <20220316152746.47768-1-tommaso.merciai@amarulasolutions.com> <20220316152746.47768-5-tommaso.merciai@amarulasolutions.com> <1225773a-10e9-d90b-d1b1-0b749c96129d@denx.de> <20220317073927.GC29139@tom-ThinkPad-T14s-Gen-2i> <1ed2f6d2-1bd7-4737-dcd5-10d7b6eb9542@denx.de> <20220317123818.GE29139@tom-ThinkPad-T14s-Gen-2i> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220317123818.GE29139@tom-ThinkPad-T14s-Gen-2i> 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.5 at phobos.denx.de X-Virus-Status: Clean On Thu, Mar 17, 2022 at 01:38:18PM +0100, Tommaso Merciai wrote: > On Thu, Mar 17, 2022 at 12:58:31PM +0100, Marek Vasut wrote: > > On 3/17/22 08:39, Tommaso Merciai wrote: > > > On Wed, Mar 16, 2022 at 09:54:34PM +0100, Marek Vasut wrote: > > > > On 3/16/22 16:27, Tommaso Merciai wrote: > > > > > Add function enable_pwm_clk into in clock_imx8mm.c. This > > > > > function first configure, then enable pwm clock from clock control > > > > > register. The following configuration is used: > > > > > > > > > > source(0) -> 24 MHz ref clock > > > > > div(0) -> no division for this clock > > > > > > > > > > References: > > > > > - iMX8MMRM.pdf p 303 > > > > > > > > > > Signed-off-by: Tommaso Merciai > > > > > --- > > > > > Changes since v1: > > > > > - Fix enable_pwm_clk function implementation. Now is generic for all pwm clks > > > > > > > > > > arch/arm/mach-imx/imx8m/clock_imx8mm.c | 53 ++++++++++++++++++++++++++ > > > > > 1 file changed, 53 insertions(+) > > > > > > > > Why is this not in drivers/clk/imx/ DM driver ? > > > > > > Hi Marek, > > > All function that enable/configure clk from CCGR are in arch/arm/mach-imx/imx8m/clock_imx8mm.c. > > > > These seems to be CCGR: > > > > $ grep -C 2 '0x4[0-9a-f]\{3\}' drivers/clk/imx/clk-imx8mm.c | sed "s@^.@@" > > > > clk_dm(IMX8MM_CLK_ECSPI1_ROOT, > > imx_clk_gate4("ecspi1_root_clk", "ecspi1", base + 0x4070, 0)); > > clk_dm(IMX8MM_CLK_ECSPI2_ROOT, > > imx_clk_gate4("ecspi2_root_clk", "ecspi2", base + 0x4080, 0)); > > clk_dm(IMX8MM_CLK_ECSPI3_ROOT, > > imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0)); > > clk_dm(IMX8MM_CLK_I2C1_ROOT, > > imx_clk_gate4("i2c1_root_clk", "i2c1", base + 0x4170, 0)); > > clk_dm(IMX8MM_CLK_I2C2_ROOT, > > imx_clk_gate4("i2c2_root_clk", "i2c2", base + 0x4180, 0)); > > clk_dm(IMX8MM_CLK_I2C3_ROOT, > > imx_clk_gate4("i2c3_root_clk", "i2c3", base + 0x4190, 0)); > > clk_dm(IMX8MM_CLK_I2C4_ROOT, > > imx_clk_gate4("i2c4_root_clk", "i2c4", base + 0x41a0, 0)); > > clk_dm(IMX8MM_CLK_OCOTP_ROOT, > > imx_clk_gate4("ocotp_root_clk", "ipg_root", base + 0x4220, 0)); > > clk_dm(IMX8MM_CLK_USDHC1_ROOT, > > imx_clk_gate4("usdhc1_root_clk", "usdhc1", base + 0x4510, 0)); > > clk_dm(IMX8MM_CLK_USDHC2_ROOT, > > imx_clk_gate4("usdhc2_root_clk", "usdhc2", base + 0x4520, 0)); > > clk_dm(IMX8MM_CLK_WDOG1_ROOT, > > imx_clk_gate4("wdog1_root_clk", "wdog", base + 0x4530, 0)); > > clk_dm(IMX8MM_CLK_WDOG2_ROOT, > > imx_clk_gate4("wdog2_root_clk", "wdog", base + 0x4540, 0)); > > clk_dm(IMX8MM_CLK_WDOG3_ROOT, > > imx_clk_gate4("wdog3_root_clk", "wdog", base + 0x4550, 0)); > > clk_dm(IMX8MM_CLK_USDHC3_ROOT, > > imx_clk_gate4("usdhc3_root_clk", "usdhc3", base + 0x45e0, 0)); > > clk_dm(IMX8MM_CLK_QSPI_ROOT, > > imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0)); > > clk_dm(IMX8MM_CLK_USB1_CTRL_ROOT, > > imx_clk_gate4("usb1_ctrl_root_clk", "usb_bus", base + 0x44d0, 0)); > > > > /* clks not needed in SPL stage */ > > - > > clk_dm(IMX8MM_CLK_ENET1_ROOT, > > imx_clk_gate4("enet1_root_clk", "enet_axi", > > base + 0x40a0, 0)); > > endif > > > > > For that I continue to put here the implementation. After we can port > > > the clk dm part to manipulate clock in drivers/clk/imx/ DM driver. > > > What do you think about? Let me know. > > > > Seems like the clk_dm part is already in place and all you have to do is > > extend it. Hi Marek, I test the solution using DM model, it work: u-boot=> clk dump 24000000 2 | |-- pwm1 24000000 3 | | `-- pwm1_root_clk 24000000 0 | |-- pwm2 24000000 0 | | `-- pwm2_root_clk 24000000 0 | |-- pwm3 24000000 0 | | `-- pwm3_root_clk 24000000 0 | |-- pwm4 24000000 0 | | `-- pwm4_root_clk I test it using the following call on a dummy driver: ret = uclass_get_device_by_name(UCLASS_PWM, "pwm@30660000", &pwm); if (ret) printk("Failed to get pwm dev\n"); ret = clk_get_by_name(pwm, "per", &per_clk); if (ret) { printf("Failed to get per_clk\n"); return ret; } ret = clk_enable(&per_clk); if (ret) { printf("Failed to enable per_clk\n"); return ret; } ret = clk_get_by_name(pwm, "ipg", &ipg_clk); if (ret) { printf("Failed to get ipg_clk\n"); return ret; } ret = clk_enable(&ipg_clk); if (ret) { printf("Failed to enable ipg_clk\n"); return ret; } It's better to keep both the solutions or only based on DM model? I think we can put this initialization into drivers/pwm/pwm-imx.c imx_pwm_of_to_plat function. What do you think about? Let me know. Thanks, Tommaso > > Hi Marek, > I'll try also this way and let you know. > > Thanks, > Tommaso > > -- > Tommaso Merciai > Embedded Linux Engineer > tommaso.merciai@amarulasolutions.com > __________________________________ > > Amarula Solutions SRL > Via Le Canevare 30, 31100 Treviso, Veneto, IT > T. +39 042 243 5310 > info@amarulasolutions.com > www.amarulasolutions.com -- Tommaso Merciai Embedded Linux Engineer tommaso.merciai@amarulasolutions.com __________________________________ Amarula Solutions SRL Via Le Canevare 30, 31100 Treviso, Veneto, IT T. +39 042 243 5310 info@amarulasolutions.com www.amarulasolutions.com