From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chen-Yu Tsai Subject: Re: [PATCH 1/2] pinctrl: sunxi: Deal with per-bank regulators Date: Wed, 9 Jan 2019 12:36:19 +0800 Message-ID: References: <3401ca7517927243f567899819e0d02eee12984f.1544104801.git-series.maxime.ripard@bootlin.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Maxime Ripard Cc: linux-gpio@vger.kernel.org, Linus Walleij , Mylene Josserand , linux-arm-kernel , Thomas Petazzoni List-Id: linux-gpio@vger.kernel.org On Mon, Jan 7, 2019 at 1:20 PM Chen-Yu Tsai wrote: > > On Thu, Dec 6, 2018 at 10:02 PM Maxime Ripard wrote: > > > > The Allwinner SoCs have on most of their GPIO banks a regulator input. > > > > This issue was mainly ignored so far because either the regulator was a > > static regulator that would be providing power anyway, or the bank was used > > for a feature unsupported so far (CSI). For the odd cases, enabling it in > > the bootloader was the preferred option. > > > > However, now that we are starting to support those features, and that we > > can't really rely on the bootloader for this, we need to model those > > regulators as such in the DT. > > > > This is slightly more complicated than what it looks like, since some > > regulators will be tied to the PMIC, and in order to have access to the > > PMIC bus, you need to mux its pins, which will need the pinctrl driver, > > that needs the regulator driver to be registered. And this is how you get a > > circular dependency. > > > > In practice however, the hardware cannot fall into this case since it would > > result in a completely unusable bus. In order to avoid that circular > > dependency, we can thus get and enable the regulators at pin_request time. > > We'll then need to account for the references of all the pins of a > > particular branch to know when to put the reference, but it works pretty > > nicely once implemented. > > > > Signed-off-by: Maxime Ripard > > I'm getting a warning on my Bananapi M1+: > > [ +0.004918] sun4i-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply > vcc-pa not found, using dummy regulator > [ +0.009931] sun7i-dwmac 1c50000.ethernet: PTP uses main clock > [ +0.005764] sun7i-dwmac 1c50000.ethernet: no reset control found > [ +0.006111] ------------[ cut here ]------------ > [ +0.004640] WARNING: CPU: 1 PID: 1 at drivers/regulator/core.c:2054 > _regulator_put.part.8+0xf8/0xfc > [ +0.009065] Modules linked in: > [ +0.003085] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc1 #5 > [ +0.006179] Hardware name: Allwinner sun7i (A20) Family > [ +0.005252] [] (unwind_backtrace) from [] > (show_stack+0x10/0x14) > [ +0.007755] [] (show_stack) from [] (dump_stack+0x88/0x9c) > [ +0.007233] [] (dump_stack) from [] (__warn+0xd4/0xf0) > [ +0.006881] [] (__warn) from [] > (warn_slowpath_null+0x40/0x48) > [ +0.007576] [] (warn_slowpath_null) from [] > (_regulator_put.part.8+0xf8/0xfc) > [ +0.008876] [] (_regulator_put.part.8) from [] > (regulator_put+0x28/0x38) > [ +0.008446] [] (regulator_put) from [] > (sunxi_pmx_free+0x38/0x48) > [ +0.007837] [] (sunxi_pmx_free) from [] > (pin_free+0x9c/0xfc) > [ +0.007402] [] (pin_free) from [] > (pinmux_disable_setting+0x118/0x184) > [ +0.008271] [] (pinmux_disable_setting) from [] > (pinctrl_free+0x13c/0x144) > [ +0.008619] [] (pinctrl_free) from [] > (release_nodes+0x1bc/0x200) > [ +0.007839] [] (release_nodes) from [] > (really_probe+0x110/0x2cc) > [ +0.007838] [] (really_probe) from [] > (driver_probe_device+0x60/0x16c) > [ +0.008270] [] (driver_probe_device) from [] > (__driver_attach+0xdc/0xe0) > [ +0.008444] [] (__driver_attach) from [] > (bus_for_each_dev+0x74/0xb4) > [ +0.008184] [] (bus_for_each_dev) from [] > (bus_add_driver+0x1bc/0x200) > [ +0.008270] [] (bus_add_driver) from [] > (driver_register+0x74/0x108) > [ +0.008098] [] (driver_register) from [] > (do_one_initcall+0x7c/0x1a8) > [ +0.008187] [] (do_one_initcall) from [] > (kernel_init_freeable+0x13c/0x1d8) > [ +0.008705] [] (kernel_init_freeable) from [] > (kernel_init+0x8/0x110) > [ +0.008184] [] (kernel_init) from [] > (ret_from_fork+0x14/0x2c) > [ +0.007570] Exception stack(0xef04ffb0 to 0xef04fff8) > [ +0.005054] ffa0: 00000000 > 00000000 00000000 00000000 > [ +0.008180] ffc0: 00000000 00000000 00000000 00000000 00000000 > 00000000 00000000 00000000 > [ +0.008179] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 > [ +0.006654] ---[ end trace 2bdb4a597b3c54ef ]--- > > Note that sun7i-dwmac probe is deferred here. The instance where the > probe succeeds shows > no warning. Found the issue. There's a mismatch on the conditions when the regulator is enabled and disabled. I'll send a fix for it. ChenYu 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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30D3DC43387 for ; Wed, 9 Jan 2019 04:36:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E98B32070B for ; Wed, 9 Jan 2019 04:36:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KpzFZ6f1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E98B32070B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csie.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hxgeUqX1F4jL5YwmGM9QW3YEk6NzEoDaF9Cka9qdTHs=; b=KpzFZ6f1lJn3qR ghy6pxMnUTv2fakE7BVRrBuHc1AjZ+ltx5nGtSpxLuvTxZgWAN1nE0OMa7SEX+bx/mXQzEIZPbrfK IY33Q2oN5x2bp8nP60Li/PzrL5Z7S/JzDJVz+yhbivVUHAPILKs47kgvh25mZPJJ4D+DP6n0CGksu A+qDevbt/NO0dagRXCkETThEcjZSdhJ3555YF3JbVNyF9PPn3rxkApHTTq5WVZEglfl4fDYzFrjl/ OzJ77k5o1pAagrfag/XMvvNWk+e58E1vmzqZxcO8wOMsX98BhS8SmamfwnKBwKOYP8SFcubukiHcz qs6+oPw/yLF9JdbnRLoA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gh5bd-0004N1-RM; Wed, 09 Jan 2019 04:36:41 +0000 Received: from mail-ed1-f68.google.com ([209.85.208.68]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gh5bZ-0004ML-LE for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2019 04:36:39 +0000 Received: by mail-ed1-f68.google.com with SMTP id f23so6199357edb.3 for ; Tue, 08 Jan 2019 20:36:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hMiRvmPPuL0u3Lwz9BpRp6GFfUAohmMtvIxqylc792s=; b=eJFGzdkNaqbXN0mOrdvhDJx2709DD3TSbBmZShqVoNFqMHkiVv4BOgPJxP+gmn20D6 mPljTPfSINA2tssWl9sHkxzdPLYxpaxeVQ256+3wPEtAahlnwgsXa3Kz9yINd1uxy5wW PPSEVuO7v0u2IiihIiUA4sVd2riji5acHfyDft+KIPhrsbnisDnIVuRBLyrUK6WHmLP+ NUhrAt9pgISRw4RE79yaeZXMsLp1MZYF449l+W0vs/qUmKVyh768M7drAz1cmpO+VeOb /mT2/Jm/vir/DydSsb6ABwIf9wdhs2rQaxoi33Ssup9sREL4tBYepNtmRkeVuZdwlL2p D6Jg== X-Gm-Message-State: AJcUukcNpqy1r46DKjVpVSFETyI2OJNBdpbjGmwgMSZIAw4OdhAGsiuT qayjMP1gpaOrOkuY7/r0eJpApBORBbE= X-Google-Smtp-Source: ALg8bN7Nb3rbG5ml8LxhnImSSoZ1x/KL1U12nLLEXHbMWYXj6MkRvuLs0ZY8x5X9OJVswNr++VR5Eg== X-Received: by 2002:a17:906:6a14:: with SMTP id o20-v6mr3989140ejr.71.1547008594423; Tue, 08 Jan 2019 20:36:34 -0800 (PST) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com. [209.85.128.45]) by smtp.gmail.com with ESMTPSA id k31sm1166897ede.5.2019.01.08.20.36.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jan 2019 20:36:34 -0800 (PST) Received: by mail-wm1-f45.google.com with SMTP id t200so6702326wmt.0 for ; Tue, 08 Jan 2019 20:36:33 -0800 (PST) X-Received: by 2002:a1c:c008:: with SMTP id q8mr3453866wmf.99.1547008593626; Tue, 08 Jan 2019 20:36:33 -0800 (PST) MIME-Version: 1.0 References: <3401ca7517927243f567899819e0d02eee12984f.1544104801.git-series.maxime.ripard@bootlin.com> In-Reply-To: From: Chen-Yu Tsai Date: Wed, 9 Jan 2019 12:36:19 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] pinctrl: sunxi: Deal with per-bank regulators To: Maxime Ripard X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190108_203637_697304_16A0E9E0 X-CRM114-Status: GOOD ( 22.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Linus Walleij , Mylene Josserand , linux-arm-kernel , Thomas Petazzoni Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jan 7, 2019 at 1:20 PM Chen-Yu Tsai wrote: > > On Thu, Dec 6, 2018 at 10:02 PM Maxime Ripard wrote: > > > > The Allwinner SoCs have on most of their GPIO banks a regulator input. > > > > This issue was mainly ignored so far because either the regulator was a > > static regulator that would be providing power anyway, or the bank was used > > for a feature unsupported so far (CSI). For the odd cases, enabling it in > > the bootloader was the preferred option. > > > > However, now that we are starting to support those features, and that we > > can't really rely on the bootloader for this, we need to model those > > regulators as such in the DT. > > > > This is slightly more complicated than what it looks like, since some > > regulators will be tied to the PMIC, and in order to have access to the > > PMIC bus, you need to mux its pins, which will need the pinctrl driver, > > that needs the regulator driver to be registered. And this is how you get a > > circular dependency. > > > > In practice however, the hardware cannot fall into this case since it would > > result in a completely unusable bus. In order to avoid that circular > > dependency, we can thus get and enable the regulators at pin_request time. > > We'll then need to account for the references of all the pins of a > > particular branch to know when to put the reference, but it works pretty > > nicely once implemented. > > > > Signed-off-by: Maxime Ripard > > I'm getting a warning on my Bananapi M1+: > > [ +0.004918] sun4i-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply > vcc-pa not found, using dummy regulator > [ +0.009931] sun7i-dwmac 1c50000.ethernet: PTP uses main clock > [ +0.005764] sun7i-dwmac 1c50000.ethernet: no reset control found > [ +0.006111] ------------[ cut here ]------------ > [ +0.004640] WARNING: CPU: 1 PID: 1 at drivers/regulator/core.c:2054 > _regulator_put.part.8+0xf8/0xfc > [ +0.009065] Modules linked in: > [ +0.003085] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc1 #5 > [ +0.006179] Hardware name: Allwinner sun7i (A20) Family > [ +0.005252] [] (unwind_backtrace) from [] > (show_stack+0x10/0x14) > [ +0.007755] [] (show_stack) from [] (dump_stack+0x88/0x9c) > [ +0.007233] [] (dump_stack) from [] (__warn+0xd4/0xf0) > [ +0.006881] [] (__warn) from [] > (warn_slowpath_null+0x40/0x48) > [ +0.007576] [] (warn_slowpath_null) from [] > (_regulator_put.part.8+0xf8/0xfc) > [ +0.008876] [] (_regulator_put.part.8) from [] > (regulator_put+0x28/0x38) > [ +0.008446] [] (regulator_put) from [] > (sunxi_pmx_free+0x38/0x48) > [ +0.007837] [] (sunxi_pmx_free) from [] > (pin_free+0x9c/0xfc) > [ +0.007402] [] (pin_free) from [] > (pinmux_disable_setting+0x118/0x184) > [ +0.008271] [] (pinmux_disable_setting) from [] > (pinctrl_free+0x13c/0x144) > [ +0.008619] [] (pinctrl_free) from [] > (release_nodes+0x1bc/0x200) > [ +0.007839] [] (release_nodes) from [] > (really_probe+0x110/0x2cc) > [ +0.007838] [] (really_probe) from [] > (driver_probe_device+0x60/0x16c) > [ +0.008270] [] (driver_probe_device) from [] > (__driver_attach+0xdc/0xe0) > [ +0.008444] [] (__driver_attach) from [] > (bus_for_each_dev+0x74/0xb4) > [ +0.008184] [] (bus_for_each_dev) from [] > (bus_add_driver+0x1bc/0x200) > [ +0.008270] [] (bus_add_driver) from [] > (driver_register+0x74/0x108) > [ +0.008098] [] (driver_register) from [] > (do_one_initcall+0x7c/0x1a8) > [ +0.008187] [] (do_one_initcall) from [] > (kernel_init_freeable+0x13c/0x1d8) > [ +0.008705] [] (kernel_init_freeable) from [] > (kernel_init+0x8/0x110) > [ +0.008184] [] (kernel_init) from [] > (ret_from_fork+0x14/0x2c) > [ +0.007570] Exception stack(0xef04ffb0 to 0xef04fff8) > [ +0.005054] ffa0: 00000000 > 00000000 00000000 00000000 > [ +0.008180] ffc0: 00000000 00000000 00000000 00000000 00000000 > 00000000 00000000 00000000 > [ +0.008179] ffe0: 00000000 00000000 00000000 00000000 00000013 00000000 > [ +0.006654] ---[ end trace 2bdb4a597b3c54ef ]--- > > Note that sun7i-dwmac probe is deferred here. The instance where the > probe succeeds shows > no warning. Found the issue. There's a mismatch on the conditions when the regulator is enabled and disabled. I'll send a fix for it. ChenYu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel