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 B560AC77B78 for ; Thu, 4 May 2023 00:00:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BD9784799; Thu, 4 May 2023 01:59:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1683158399; bh=JvdpL732DY7cqEnhA1HL0II6e1aDXdsYTwVajqkzDAs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=p/53oZPmD12ewl7kKvxIUhDO/ORsav/ltPSpKA4zbkYYnWo9cOXkZu2NaTJ2EI27V +6oJX55fB4cb4hbNjj1z2wQv0ybCLqUtsxv9RXRBroY/+y3IfpBOS4Ff+fqUrLVA3N zbayspe9VIR8SNxbJAYBWLk8UsoUnIBf90HZWOyOqoN5tCb+riwTAAABGCo1uQLb4/ /s+C/cvjnv88kWBLDYCclCeklM4hsUJh7EaWSFf5mLcllVuEOGVuaf5iARlaT42hEP M943dvSSQoaSIQDraHS5I8PdmFn+byiDtAji18dlTHD1LprPk2PGH3A5yYYr4N+NQO gMHegwhr+ZtJg== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 10FAB84784; Thu, 4 May 2023 01:59:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1683158395; bh=JvdpL732DY7cqEnhA1HL0II6e1aDXdsYTwVajqkzDAs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=oOzBOafgmV/fo+A9xNvlaDy+wcKIPQB2o276QTie3HmS2gDWmzC+KS6Mrt6QaEN1I z/Ux3/z6+U2Po/fJmcKk5JEaKT48C+Z89Xovn1DcArqAW9+zEWAudKqfRXdSB9jxWe PrdCxzAIUvxLLyqGUfgLVyvng7Sw73bYKUeqHCrSZjzmYusynEUF3CLuCUJVwN6B8y AFVqdhzL790yuaUaVcvqNR8jvC5Im8jIRcoQVNv6YodsCzflC5frGXPMNX+Ycmv/qC RuzOuNlQYzp/xlaqKU2XNE7HaoysUESQWvvwzutNy4QYxdHz7Ut24yMMnfnddFDoSw OVObQFlztN5Jw== Message-ID: Date: Wed, 3 May 2023 23:54:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] usb: ehci-mx6: replace regulator_set_enable with *_if_allowed Content-Language: en-US To: Eugen Hristev , u-boot@lists.denx.de, tharvey@gateworks.com Cc: sjg@chromium.org References: <20230502065104.32242-1-eugen.hristev@collabora.com> <76acce9d-e61c-814a-5dd4-1c54c1417cf1@collabora.com> <477daa1f-a42c-6c88-4e7c-7d67dd8a13f3@denx.de> <085be031-b802-a5ce-5bb9-623093336f7d@collabora.com> From: Marek Vasut In-Reply-To: <085be031-b802-a5ce-5bb9-623093336f7d@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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.8 at phobos.denx.de X-Virus-Status: Clean On 5/2/23 13:18, Eugen Hristev wrote: > On 5/2/23 13:53, Marek Vasut wrote: >> On 5/2/23 12:41, Eugen Hristev wrote: >>> On 5/2/23 12:18, Marek Vasut wrote: >>>> On 5/2/23 08:51, Eugen Hristev wrote: >>>>> regulator_set_enable_if_allowed already handles cases when the >>>>> regulator is already enabled, or already disabled, and does not >>>>> treat these as errors. >>>>> With this change, the driver can work correctly even if the regulator >>>>> is already taken or already disabled by another consumer. >>>> >>>> Can that ever happen for Vbus supply (the 5V coming out of USB port) ? >>>> Can you elaborate how ? >>> >>> >>> Hi Marek, >> >> Hi, >> >>> Recently I developed a series of patches to add a reference counter >>> for regulators : >>> >>> https://marc.info/?l=u-boot&m=168191189309879&w=2 >> >> Ah yes, this is super cool stuff, thanks ! >> >>> But with this series, having a regulator already enabled or already >>> disabled results in an error returned by regulator_set_enable >>> >>> Hence, one option is to replace calls with >>> regulator_set_enable_if_allowed >>> >>> There is a discussion ongoing here: >>> >>> https://marc.info/?l=u-boot&m=168295920316621&w=2 >> >> Pardon my ignorance, but uh ... how does Linux deal with regulators >> which are enabled by prior stage, like U-Boot ? Does it set their >> enable refcount to =1 or =0 ? > > Please correct me if I am wrong, I did not dig too much into regulators, > but , from my understanding : > > Normally software(in this case Linux) reads the state of the regulator > when it's probed, and sets the refcount accordingly. If the state cannot > be read then regulator-boot-on tells Linux that it should have been left > enabled by prior stage > In Uboot I believe that regulators that have 'regulator-boot-on' are > added to a list and set to enable during probe, and the probe is forced > even if Uboot normally uses lazy probing (should have the same behavior > for regulator-always-on property) > > So if a regulator is enabled by an initial stage but it's not described > with 'regulator-boot-on' , appears to be a bad hardware description in DT. Thanks for checking this. It seems like Tim found the root cause of the problem in the meantime, so let's see where that discussion moves on to.