Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5563596rwn; Mon, 12 Sep 2022 10:52:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ZV9sAmmWHqUZqNDTEnxdaW1BqH7l1ad6s3QeBc0K93Wf4BC4JnStwrXFSRcDPkggTPLUW X-Received: by 2002:a63:2b01:0:b0:439:2e26:7996 with SMTP id r1-20020a632b01000000b004392e267996mr1947126pgr.28.1663005177911; Mon, 12 Sep 2022 10:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663005177; cv=none; d=google.com; s=arc-20160816; b=pE0SxLfC/ylsWSAA8H8vZobUhm0fSLvsANOBNPsgHK7uYG/cfbgEamqnRRG7q2j72O YIPYzb2dUVRAB+oZYdZhGms+/KNwUvs0qtcrSFgqFSVvATMof74XVEWkHBLGQYYd45eD +OFpXdTQN8wnjbGTyMVNB8i/lyCZmAGQma19tOp69V7eulMRZ68FH0vAGSvwNQUBO0II RSHdHxRKLOJtKq/EN547GDA4gpKaIGipIq2B6qImzcvfGX/eqSkFkOkCGCpVoIsyXVM4 oDuo70aDKUcb8rh6c/dla4GsttUG3Zi4yEaveUoKuscRI9D7caeuOwrfrDzjLF5/tqar /LIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qd0zc7fGhqBh9AbN0Tbs1DG34cl/lreYFTNXxxRPmTs=; b=TlCqGWbL4pHcSYV9QK7KCRaTC/rAP0DJybXYBbD01aR3pizrQG5EBSfpuGzxEHziFQ 0DR8pwM/1SHNaushNoI1Yn87MU4c+oDU5yiYBVTLObOcbuCK1wPOu3AAFA+ucP42YU0R 7IAJ7iSrd9ZOHG+EQWrhmWD5tphXxHC2fHK7QlzV+gVe/ofH+MUsXwVLR8dTotEB2Ihh 7C8OFfXTFdBlUG9/ayJmqMhNGn5jKPEQ+gLosZTqtF28vX9HE8SL2e9M2u7OBqIMsEEs ij3AFJ5HNpy2LZOry9Yl7TKbBfrcVpCiTATriUQePEBc8Lem4eVy9OO5MOBxCSkQuSdK oEgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gateworks-com.20210112.gappssmtp.com header.s=20210112 header.b=hck1MJGc; 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 v21-20020a056a00149500b0050df0383302si8801033pfu.255.2022.09.12.10.52.45; Mon, 12 Sep 2022 10:52:57 -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=@gateworks-com.20210112.gappssmtp.com header.s=20210112 header.b=hck1MJGc; 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 S229801AbiILRQB (ORCPT + 99 others); Mon, 12 Sep 2022 13:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbiILRP6 (ORCPT ); Mon, 12 Sep 2022 13:15:58 -0400 Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A725237190 for ; Mon, 12 Sep 2022 10:15:54 -0700 (PDT) Received: by mail-oo1-xc36.google.com with SMTP id u19-20020a4a9e93000000b004757198549cso558476ook.0 for ; Mon, 12 Sep 2022 10:15:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=qd0zc7fGhqBh9AbN0Tbs1DG34cl/lreYFTNXxxRPmTs=; b=hck1MJGckV938hOMLfxLlSjnhjEBraOtrc7lREdlBCM5HFTGV3OZmPEvv5+3Sl21Ap Yt8LYSgZqBQtdQ2k0zhHPsnBejGIGzLaSPovYIKxSDC1LaI5amhPapXUvT9FQi9phAAl APnbZ9b4NRtkMh/w6LSKndFaZ46/HAxjxPRS5bkrpByQmpqxoReePPBAfgOJ01jpMoU2 /P8CeaHv3o42/byWvGXeghO9CiF8pNre8pq1RtmqAm3KGJONZr/z85bvCZQQJTntwITy 45HragL26K0ZDJpXE9Lv78ZpVz7VbzsWHw7w0Jei8o7DQRc7L0mEJke1XLliz+XifV5C +LOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=qd0zc7fGhqBh9AbN0Tbs1DG34cl/lreYFTNXxxRPmTs=; b=Io2deCaIJ8WTYdxwpbGhFQvhk9M0lG85O3VyVrloXCSSxhQxjgSpdmctQYn4jcleE2 QWdBiBEMCHH5GxwdQDizxMU4aGPrkctpi6WMl8EHWDZ5KX2k6WQX6l1bxbHTApX7P4C3 zd4wZ/m4MV1HtzhT0ENZwZgFZQz4JvNXblfqTI9ONkJu5Gasq1Fp6cF3omStmIC3S4SQ UVvMHf5CDTJ9kWOEs4/br9c4kc1967IlHp44rvk9O8rM2tJ/pilRVeVBJiKFdT60Tn8y +JccvvHdKPrOMAuRg60fYg8E4G0tkavXzIqg/qPJXciihjjsKl3OhrG4U6FyeMDZRgcq fA5Q== X-Gm-Message-State: ACgBeo3frU0q4H1BqaVpT0fBhKdF0uMRLJBy5pZ7SYyk5h5E8zF7Kx57 BmvnJx8UqC4Pf6Ke2MByVpxEjEwwwLxEAfnzZlY3fA== X-Received: by 2002:a4a:1b03:0:b0:475:4a4c:e29d with SMTP id 3-20020a4a1b03000000b004754a4ce29dmr5041258oop.79.1663002953138; Mon, 12 Sep 2022 10:15:53 -0700 (PDT) MIME-Version: 1.0 References: <59b6dd0a-7cbb-5dbd-8da0-57baeba3327e@gmail.com> <2ab24cc4-4aa2-d364-9b29-55f5d6b23626@denx.de> <8736ba4e-1c61-995a-f090-ef322d84e5f6@gmail.com> <0c924574-d2b4-2a23-0cc2-63f32d521854@oss.nxp.com> In-Reply-To: <0c924574-d2b4-2a23-0cc2-63f32d521854@oss.nxp.com> From: Tim Harvey Date: Mon, 12 Sep 2022 10:15:41 -0700 Message-ID: Subject: Re: BD71847 clk driver disables clk-32k-out causing RTC/WDT failure To: Peng Fan Cc: Matti Vaittinen , Marek Vasut , Peng Fan , Stephen Boyd , linux-clk , open list , Fabio Estevam , Shawn Guo , dl-linux-imx , Michael Turquette Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 On Mon, Sep 12, 2022 at 12:40 AM Peng Fan wrote: > > > > On 9/9/2022 1:06 PM, Matti Vaittinen wrote: > > Hi dee Ho peeps, > > > > On 9/9/22 05:35, Marek Vasut wrote: > >> On 9/9/22 04:06, Peng Fan wrote: > >>>> Subject: Re: BD71847 clk driver disables clk-32k-out causing RTC/WDT > >>>> failure > >>>> > >>>> On 9/8/22 21:25, Tim Harvey wrote: > >>>>> On Thu, Sep 8, 2022 at 9:55 AM Marek Vasut wrote: > >>>>>> > >>>>>> On 9/8/22 18:00, Tim Harvey wrote: > >>>>>>> On Thu, Sep 1, 2022 at 9:14 PM Matti Vaittinen > >>>> wrote: > >>>>>>>> > >>>>>>>> Hi Tim, > >>>>>>>> > >>>>>>>> On 9/2/22 01:23, Tim Harvey wrote: > >>>>>>>>> Greetings, > >>>>>>>>> > >>>>>>>>> I've found that the bd71847 clk driver > >>>> (CONFIG_COMMON_CLK_BD718XX > >>>>>>>>> drivers/clk/clk-bd718x7.c) disables clk-32k-out (the BD71847 > >>>>>>>>> C32K_OUT > >>>>>>>>> pin) which is connected IMX8MM RTC_XTALI which ends up disabling > >>>>>>>>> the IMX RTC as well as the IMX WDOG functionality. > >>>>>>>> > >>>>>>>> //snip > >>>>>>>> > >>>>>>>>> This happens via clk_unprepare_unused() as nothing is flagging the > >>>>>>>>> clk-32k-out as being used. What should be added to the device-tree > >>>>>>>>> to signify that this clk is indeed necessary and should not be > >>>>>>>>> disabled? > >>>>>>>> > >>>>>>>> I have seen following proposal from Marek Vasut: > >>>>>>>> > >>>>>>>> > >>>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fl > >>>>>>>> ore.kernel.org%2Fall%2F20220517235919.200375-1- > >>>> marex%40denx.de%2FT% > >>>>>>>> > >>>> 2F%23m52d6d0831bf43d5f293e35cb27f3021f278d0564&data=05%7C0 > >>>> 1%7Cp > >>>>>>>> > >>>> eng.fan%40nxp.com%7C07d48edcc47c4694e08208da91da2bf4%7C686ea1d > >>>> 3bc2b > >>>>>>>> > >>>> 4c6fa92cd99c5c301635%7C0%7C0%7C637982664162868785%7CUnknown% > >>>> 7CTWFpb > >>>>>>>> > >>>> GZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI > >>>> 6 > >>>>>>>> > >>>> Mn0%3D%7C3000%7C%7C%7C&sdata=uF26u9g4onuqCWzPRAvD%2F% > >>>> 2FLByaEhh5 > >>>>>>>> Dtah9K8CcAOAM%3D&reserved=0 > >>>>>>>> > >>>>>>>> I am not sure if the discussion is completed though. I guess it was > >>>>>>>> agreed this was needed/usefull and maybe the remaining thing to > >>>>>>>> decide was just the property naming. > >>>>>>>> > >>>>>>>> Best Regards > >>>>>>>> -- Matti > >>>>>>>> > >>>>>>> > >>>>>>> Thanks Matti, > >>>>>>> > >>>>>>> Marek - has there been any progress on determining how best to keep > >>>>>>> certain clocks from being disabled? > >>>>>> > >>>>>> No. You can read the discussion above. > >>>>> > >>>>> Marek, > >>>>> > >>>>> I wasn't on the linux-clk list at that time so can't respond to the > >>>>> thread but the discussion seems to have died out a couple of months > >>>>> ago with no agreement between you or Stephen on how to deal with it. > >>>>> > >>>>> So where do we take this from here? It looks like there are about 18 > >>>>> boards with dt's using "rohm,bd718*" which would all have non working > >>>>> RTC/WDOG with CONFIG_COMMON_CLK_BD718XX enabled (which it is in > >>>>> arch/arm64/configs/defconfig) right? > > > > Yeah. The ROHM BD71837 and BD71847 (and BD71850 - which is one of the > > variants) are used quite a lot. I am pretty sure not fixing this in > > upstream is increasing downstream solutions. I don't think that should > > be preferred. > > > >>> > >>> Is there any requirement that the bd718xx clk needs to be runtime > >>> on/off? > >> > >> Yes, the 32kHz clock on BD71xxx should behave like any other clock, > >> unless specified otherwise, see below. > >> > >>> I suppose the clk should always be never be off, if yes, why not have > >>> something: > >> > >> What is needed in this specific case of BD718xx is I think clock > >> consumer on the MX8M clock driver side which would claim the 32kHz > >> input from the PMIC and up the clock enable count to keep the 32 kHz > >> clock always on. > > > > This sounds like a solution that would describe the actual HW setup. I > > don't know the CCF of the i.MX8 well enough to tell whether this can > > ensure the clk is not disabled before the consumer is found or when the > > consumer is going down though. Simplest thing to me would really be to > > just mark the clk as "do-not-touch" one on the boards where it must not > > be touched. > > > > The PMIC is most likely supplying 32 kHz clock to the MX8M, > >> which if the 32 kHz clock are turned off would hang (I observed that > >> before too). > >> > >> What I tried to address in this thread is a generic problem which > >> commonly appears on various embedded systems, except every time anyone > >> tried to solve it in a generic manner, it was rejected or they gave up. > > > > I agree with Marek - generic solution would be nice. I don't think this > > is something specific to this PMIC. > > > >> The problem is this -- you have an arbitrary clock, and you need to > >> keep it running always otherwise the system fails, and you do not have > >> a clock consumer in the DT for whatever reason e.g. because the SoC is > >> only used as a clock source for some unrelated clock net. There must > >> be a way to mark the clock as "never disable these", i.e. > >> critical-clock. (I feel like I keep repeating this over and over in > >> this thread, so please read the whole thread backlog) > > > > Thanks for the explanation and effor you did Marek. > > > > My take on this is that from a (generic) component vendor perspective it > > is a bad idea to hard-code the clock status (enable/disable) in the PMIC > > driver. A vendor wants to provide a driver which allows use of the > > component in wide variety of systems/boards. When the PMIC contains a > > clock gate, the PMIC driver should provide the means of controlling it. > > Some setups may want it enabled, other disabled and some want runtime > > control. This "use-policy" must not be hard coded in the driver - it > > needs to come from HW description which explains how the clk line is > > wired and potentially also from the consumer drivers. This enables the > > same PMIC driver to support all different setups with their own needs, > > right? > > > > I am not sure if some non email discussions have been ongoing around > > this topic but just by reading the emails it seemed to me that Marek's > > suggestion was acked by the DT folks - and I don't think that Stephen > > was (at the end of the day) against that either(?). Maybe I missed > > something. > > After a thought, maybe an easier way is to add a optional property > xxx,32k-always-on to the pmic node/driver. > > Regards, > Peng. Is there simply a way to add the clk to the snvs_rtc and the wdog dt nodes so they have a use count and don't get disabled? Best Regards, Tim