Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp682778rwl; Sat, 25 Mar 2023 09:05:13 -0700 (PDT) X-Google-Smtp-Source: AKy350ZAhcbQk/CnVvxTqbdv5ggn0Pa9lTpdZ3HMYVKhCxveCKDmR+DIshy9MhLZHDgCqKN0unuE X-Received: by 2002:a17:90b:1809:b0:237:bf05:40b with SMTP id lw9-20020a17090b180900b00237bf05040bmr7314862pjb.20.1679760313019; Sat, 25 Mar 2023 09:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679760313; cv=none; d=google.com; s=arc-20160816; b=GpKYf3lvdzJjl6hcJbGMxfq05O/qr5PyQNqjgzc3UgCeWE3tcAdbXdHhQZn6MPmkmw UO7prSCGbUcx7OGgJ9BqHeCn477N7KxSphYgAyrX+Ec6TeiBUv7QuRsLAjGXwLfGjf8Q Shx8dbNzaiKwYKzeJbj2dkQ6Og6vmmZNseCWEOwasaVcuJkAv9c+oYpf5UKRlx8LVrJm plJ4tKgi1HJKZh8amW8sSwlOVx2J+90CV7ZHQbxpZr3amgcin/tBIBcqMV9jvt8rVkGb C87S8p0fYHt3O0anPFV9sluHbsKW18bpzsYEHUdASqQNLmXB+5MzipFQo5M9lnSceXda AjLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=mBeeZlBcY1r/gHCVPPPeasOeiONh7rt7R09svbOb+PY=; b=rPcyiHA58ROojVhZZoQmJK5qOTj6sjLi5flEGKSQZy5rT1sJPrgNNHItlaYWbS0FGD hY85uQRI/XbOs1zv7s8PhPilDb07Ow69t4x3Zktvs+9xsAA9+ff/tHkZ4vt2m6sMegJ1 EudtWrIleBOK69CvgGd3j0G7f7UlEP80ThlXJhrTuSTQVt3I1skuLPj91jSeKz3fy1Ou /W2CNt9KV1JLe29jlrpOtYIaQtuYAlzyKlroMw/s/SnRPtQDz33nmOl1BON4pmRSrgHA 5gKG4WzRCaG5PBDa49/PBSRAAf64AnU+7BN5O8xntVKA0nTKb3k9GqCaITG2gKMAFBBz Oohg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a634c55000000b0050be02f0893si24032950pgl.697.2023.03.25.09.05.00; Sat, 25 Mar 2023 09:05:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbjCYPzD (ORCPT + 99 others); Sat, 25 Mar 2023 11:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbjCYPy6 (ORCPT ); Sat, 25 Mar 2023 11:54:58 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC0471206D; Sat, 25 Mar 2023 08:54:48 -0700 (PDT) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 8BEAB24DC09; Sat, 25 Mar 2023 23:54:45 +0800 (CST) Received: from EXMBX172.cuchost.com (172.16.6.92) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 25 Mar 2023 23:54:45 +0800 Received: from [172.16.16.231] (113.72.145.48) by EXMBX172.cuchost.com (172.16.6.92) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sat, 25 Mar 2023 23:54:44 +0800 Message-ID: Date: Sat, 25 Mar 2023 23:54:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v6 13/21] clk: starfive: Add StarFive JH7110 system clock driver Content-Language: en-US To: Emil Renner Berthing CC: , , , Stephen Boyd , "Michael Turquette" , Philipp Zabel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Palmer Dabbelt" , Paul Walmsley , Albert Ou , Ben Dooks , "Daniel Lezcano" , Thomas Gleixner , Marc Zyngier , References: <20230320103750.60295-1-hal.feng@starfivetech.com> <20230320103750.60295-14-hal.feng@starfivetech.com> From: Hal Feng In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [113.72.145.48] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX172.cuchost.com (172.16.6.92) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-0.0 required=5.0 tests=NICE_REPLY_A, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 On Fri, 24 Mar 2023 15:39:54 +0100, Emil Renner Berthing wrote: > On Mon, 20 Mar 2023 at 11:38, Hal Feng wrote: [...] >> diff --git a/drivers/clk/starfive/clk-starfive-jh7110-sys.c b/drivers/clk/starfive/clk-starfive-jh7110-sys.c >> new file mode 100644 >> index 000000000000..f98a508969c3 >> --- /dev/null >> +++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c >> @@ -0,0 +1,450 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * StarFive JH7110 System Clock Driver >> + * >> + * Copyright (C) 2022 Emil Renner Berthing >> + * Copyright (C) 2022 StarFive Technology Co., Ltd. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> + >> +#include "clk-starfive-jh71x0.h" >> + >> +/* external clocks */ >> +#define JH7110_SYSCLK_OSC (JH7110_SYSCLK_END + 0) >> +#define JH7110_SYSCLK_GMAC1_RMII_REFIN (JH7110_SYSCLK_END + 1) >> +#define JH7110_SYSCLK_GMAC1_RGMII_RXIN (JH7110_SYSCLK_END + 2) >> +#define JH7110_SYSCLK_I2STX_BCLK_EXT (JH7110_SYSCLK_END + 3) >> +#define JH7110_SYSCLK_I2STX_LRCK_EXT (JH7110_SYSCLK_END + 4) >> +#define JH7110_SYSCLK_I2SRX_BCLK_EXT (JH7110_SYSCLK_END + 5) >> +#define JH7110_SYSCLK_I2SRX_LRCK_EXT (JH7110_SYSCLK_END + 6) >> +#define JH7110_SYSCLK_TDM_EXT (JH7110_SYSCLK_END + 7) >> +#define JH7110_SYSCLK_MCLK_EXT (JH7110_SYSCLK_END + 8) >> +#define JH7110_SYSCLK_PLL0_OUT (JH7110_SYSCLK_END + 9) >> +#define JH7110_SYSCLK_PLL1_OUT (JH7110_SYSCLK_END + 10) >> +#define JH7110_SYSCLK_PLL2_OUT (JH7110_SYSCLK_END + 11) >> + >> +static const struct jh71x0_clk_data jh7110_sysclk_data[] __initconst = { >> + /* root */ >> + JH71X0__MUX(JH7110_SYSCLK_CPU_ROOT, "cpu_root", 2, >> + JH7110_SYSCLK_OSC, >> + JH7110_SYSCLK_PLL0_OUT), >> + JH71X0__DIV(JH7110_SYSCLK_CPU_CORE, "cpu_core", 7, JH7110_SYSCLK_CPU_ROOT), [...] >> + /* qspi */ >> + JH71X0_GATE(JH7110_SYSCLK_QSPI_AHB, "qspi_ahb", CLK_IGNORE_UNUSED, JH7110_SYSCLK_AHB1), >> + JH71X0_GATE(JH7110_SYSCLK_QSPI_APB, "qspi_apb", CLK_IGNORE_UNUSED, JH7110_SYSCLK_APB_BUS), > > Hi Hal, > > Thanks for going through clocks marked with CLK_IGNORE_UNUSED and > either remove the flags or mark them as critical.. It seems you've > missed these two though. The QSPI module of JH7110 supported by Cadence, requires three clocks (qspi_ahb, qspi_apb and qspi_ref), but the Cadence QSPI driver only supports one clock. As the StarFive QSPI support patches [1] had been accepted, I kept these two flags here. [1] https://lore.kernel.org/all/20230302105221.197421-1-william.qiu@starfivetech.com/ > [...] >> diff --git a/drivers/clk/starfive/clk-starfive-jh71x0.c b/drivers/clk/starfive/clk-starfive-jh71x0.c >> index b372083d11c3..a8c60630ae73 100644 >> --- a/drivers/clk/starfive/clk-starfive-jh71x0.c >> +++ b/drivers/clk/starfive/clk-starfive-jh71x0.c >> @@ -5,6 +5,7 @@ >> * Copyright (C) 2021-2022 Emil Renner Berthing >> */ >> >> +#include >> #include >> #include >> #include >> @@ -331,3 +332,52 @@ const struct clk_ops *starfive_jh71x0_clk_ops(u32 max) >> return &jh71x0_clk_inv_ops; >> } >> EXPORT_SYMBOL_GPL(starfive_jh71x0_clk_ops); >> + >> +#if IS_ENABLED(CONFIG_CLK_STARFIVE_JH7110_SYS) >> + >> +static void jh7110_reset_unregister_adev(void *_adev) >> +{ >> + struct auxiliary_device *adev = _adev; >> + >> + auxiliary_device_delete(adev); >> +} >> + >> +static void jh7110_reset_adev_release(struct device *dev) >> +{ >> + struct auxiliary_device *adev = to_auxiliary_dev(dev); >> + >> + auxiliary_device_uninit(adev); >> +} >> + >> +int jh7110_reset_controller_register(struct jh71x0_clk_priv *priv, >> + const char *adev_name, >> + u32 adev_id) >> +{ >> + struct auxiliary_device *adev; >> + int ret; >> + >> + adev = devm_kzalloc(priv->dev, sizeof(*adev), GFP_KERNEL); >> + if (!adev) >> + return -ENOMEM; >> + >> + adev->name = adev_name; >> + adev->dev.parent = priv->dev; >> + adev->dev.release = jh7110_reset_adev_release; >> + adev->id = adev_id; >> + >> + ret = auxiliary_device_init(adev); >> + if (ret) >> + return ret; >> + >> + ret = auxiliary_device_add(adev); >> + if (ret) { >> + auxiliary_device_uninit(adev); >> + return ret; >> + } >> + >> + return devm_add_action_or_reset(priv->dev, >> + jh7110_reset_unregister_adev, adev); >> +} >> +EXPORT_SYMBOL_GPL(jh7110_reset_controller_register); >> + >> +#endif > > Hey, sorry for not noticing this before, but is there a reason these > JH7110-specific functions must be added to the generic JH71x0 code? > Can't they be added to the JH7110 SYSCRG driver, and then let the > other CRG drivers depend on that (which they already do because of > clock dependencies)? It's ok to move these functions to clk-starfive-jh7110-sys.c. By the way, could I still keep the declaration in clk-starfive-jh71x0.h? Best regards, Hal > >> diff --git a/drivers/clk/starfive/clk-starfive-jh71x0.h b/drivers/clk/starfive/clk-starfive-jh71x0.h >> index 34bb11c72eb7..cfe69aabd65a 100644 >> --- a/drivers/clk/starfive/clk-starfive-jh71x0.h >> +++ b/drivers/clk/starfive/clk-starfive-jh71x0.h >> @@ -120,4 +120,12 @@ struct jh71x0_clk_priv { >> >> const struct clk_ops *starfive_jh71x0_clk_ops(u32 max); >> >> +#if IS_ENABLED(CONFIG_CLK_STARFIVE_JH7110_SYS) >> + >> +int jh7110_reset_controller_register(struct jh71x0_clk_priv *priv, >> + const char *adev_name, >> + u32 adev_id); >> + >> +#endif >> + >> #endif >> -- >> 2.38.1 >>