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 EBA9AC433F5 for ; Thu, 26 May 2022 04:57:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25F6F8430F; Thu, 26 May 2022 06:57:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.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=samsung.com header.i=@samsung.com header.b="Yel3roCp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B66958430E; Thu, 26 May 2022 06:57:05 +0200 (CEST) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 99E7E8430F for ; Thu, 26 May 2022 06:57:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jh80.chung@samsung.com Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220526045657epoutp02e125f7f289c1e8fb4cf8cfdb15d2f2b8~yjstvRN7e1739917399epoutp02j for ; Thu, 26 May 2022 04:56:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220526045657epoutp02e125f7f289c1e8fb4cf8cfdb15d2f2b8~yjstvRN7e1739917399epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653541017; bh=stv4VO1sYiKfiqarGH8xk/edkNXQOhWnCrB3RbUnvBE=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=Yel3roCpyiek3Y2aOPrbptGDF1DQ6pnBM9suBstu6R//HLeou9PUnIo6CtfxWnJ8h rZlusUACfRA7CcdautXFX28kNk6qTBT25v22u73O0BhMjgfiNtoAfKs1g5NbcSC/XS dTbattkmg1AV1k+J3S0vRVOqLTF4BVJsT6lZnIaI= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20220526045657epcas1p23903da502499250a49e8ee0c4619f97d~yjstb_33p0685706857epcas1p2X; Thu, 26 May 2022 04:56:57 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.38.235]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4L7wdh19j2z4x9Pp; Thu, 26 May 2022 04:56:56 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.FC.10354.8980F826; Thu, 26 May 2022 13:56:56 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220526045655epcas1p22438682fe9a212f68fac93a023a1212c~yjsrZkD6V1002410024epcas1p2_; Thu, 26 May 2022 04:56:55 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220526045655epsmtrp238cc0d17c80468c6ba453031ffff309e~yjsrYtAKI1999419994epsmtrp2Y; Thu, 26 May 2022 04:56:55 +0000 (GMT) X-AuditID: b6c32a38-4b5ff70000002872-17-628f0898492f Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id AE.8B.08924.6980F826; Thu, 26 May 2022 13:56:54 +0900 (KST) Received: from [10.113.113.235] (unknown [10.113.113.235]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220526045654epsmtip2ddfbbfd9b80cdafa30bdcd4e0cde9b55~yjsrGaq301409614096epsmtip2K; Thu, 26 May 2022 04:56:54 +0000 (GMT) Message-ID: Date: Thu, 26 May 2022 13:56:54 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 2/2] rockchip: Add option to prevent booting on power plug-in Content-Language: en-US To: Chris Morgan , u-boot@lists.denx.de Cc: kever.yang@rock-chips.com, philipp.tomsich@vrull.eu, sjg@chromium.org, Chris Morgan From: Jaehoon Chung In-Reply-To: <20220523193001.13715-3-macroalpha82@gmail.com> Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKJsWRmVeSWpSXmKPExsWy7bCmge4Mjv4kg0PT2C22Tf/JZtFwfSW7 RUd/A6tF98pqi29btjFavN3bye7A5jG74SKLx85Zd9k9HvecYfM4e2cHo8ffWfuBYrcfMgWw RWXbZKQmpqQWKaTmJeenZOal2yp5B8c7x5uaGRjqGlpamCsp5CXmptoqufgE6Lpl5gCdoaRQ lphTChQKSCwuVtK3synKLy1JVcjILy6xVUotSMkpMC3QK07MLS7NS9fLSy2xMjQwMDIFKkzI zpjc8p254JZSxfJNJ5gbGG9JdzFyckgImEhM+HePsYuRi0NIYAejxJKDl9khnE+MEqd/vGOG cD4zSrxv+8MG03Lh2ESoll2MErdPrWeDcN4zSqzYsAUow87BK2AnsToPpJ5FQFXi/qzVjCA2 r4CgxMmZT1hAbFGBCImVrW/AbGGBYImmhQeYQGxmAXGJW0/mA9kcHCIC9hLNN3IhwsUSHbsf sILYbAI6Etu/HQcr5xSwkbj0aDdUq7zE9rdzmCHO7OWQaP3mDTJGQsBF4s8XS4iwsMSr41vY IWwpic/v9oIdLyHQzCixdMlBVginh1Hi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oP1cgrYSFx6tBusl1lAXWL9PCGIXnmJ7W/nME9gFJqF5IpZ SLbNQuiYhaRjASPLKkbJ1ILi3PTcYsMCo7zUcr3ixNzi0rx0veT83E2M4FjR0trBuGfVB71D jEwcjIcYJTiYlUR4LzztTRLiTUmsrEotyo8vKs1JLT7EKM3BoiTOe6HrZLyQQHpiSWp2ampB ahFMlomDU6qB6Sz7oSmnjQpYzxVeat4dN+/j3xu3Kk3rG3dkqN0LyfbK2+CdUlHPUj+1/WhL BtvhF0ss/KV7+kKnCs3z/VxwNvWjfUKMfsBMb/OX5xeli8+K/MnxoPLQivUPTr3Wm6H5Za1t vhrHaV6Gq19TK4wqFjCxzNSuVNoWLnmIM609PmXHFRHfLzaPlacwMXPMPvgu0WPmuknbytZM if464f423rKQO9dzfY7NOGQfPtGx67xL5PGdDda3p/b+UkqX3XniRM3OksbAdMYVTkvYt5w1 N9NbZ7rNWfqIG8vJFc1fPkt9XSUgoySYW1TG/qH34F7VwvRvzR2NOzQeZembur/t+8fdvPGc lf5KzkVdZpaXlViKMxINtZiLihMBUWfJMgQDAAA= X-CMS-MailID: 20220526045655epcas1p22438682fe9a212f68fac93a023a1212c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220523193014epcas1p4334e8ed0a5f7593c8f344289865bb705 References: <20220523193001.13715-1-macroalpha82@gmail.com> <20220523193001.13715-3-macroalpha82@gmail.com> 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 5/24/22 04:30, Chris Morgan wrote: > From: Chris Morgan > > For Rockchip boards with the all rk8xx series PMICs (excluding the > rk808), it is sometimes desirable to not boot whenever the device is > plugged in. An example would be for the Odroid Go Advance. > > This provides a configurable option to check the PMIC says it was > powered because of a plug-in event. If the value is 1 and this option > is selected, the device shuts down shortly after printing a message > to console stating the reason why it's shutting down. Powering up the > board with the power button is not affected. > > This patch parallels the work done in the following patch series: > https://lore.kernel.org/u-boot/20220121133732.2397273-1-andre.przywara@arm.com/ > > Signed-off-by: Chris Morgan > --- > arch/arm/mach-rockchip/Kconfig | 10 +++++++++ > drivers/power/pmic/rk8xx.c | 37 ++++++++++++++++++++++++++++++++++ > include/power/rk8xx_pmic.h | 3 +++ > 3 files changed, 50 insertions(+) > > diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig > index 18aff5480b..c561a77e6a 100644 > --- a/arch/arm/mach-rockchip/Kconfig > +++ b/arch/arm/mach-rockchip/Kconfig > @@ -361,6 +361,16 @@ config ROCKCHIP_BOOT_MODE_REG > The Soc will enter to different boot mode(defined in asm/arch-rockchip/boot_mode.h) > according to the value from this register. > > +config ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON > + bool "Disable device boot on power plug-in" > + depends on PMIC_RK8XX > + default n > + ---help--- > + Say Y here to prevent the device from booting up because of a plug-in > + event. When set, the device will boot briefly to determine why it was > + powered on, and if it was determined because of a plug-in event > + instead of a button press event it will shut back off. > + > config ROCKCHIP_STIMER > bool "Rockchip STIMER support" > default y > diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c > index 1ffbecc02a..b59675a10e 100644 > --- a/drivers/power/pmic/rk8xx.c > +++ b/drivers/power/pmic/rk8xx.c > @@ -51,6 +51,41 @@ U_BOOT_DRIVER(rk8xx_sysreset) = { > .ops = &rk8xx_sysreset_ops, > }; > > +void rk8xx_off_for_plugin(struct udevice *dev) > +/* In the event of a plug-in and the appropriate option has been > + * selected, we simply shutdown instead of continue the normal boot > + * process. Please note the rk808 is not supported as it doesn't > + * have the appropriate register. > + */ Could you move comment to above or into function? > +{ > + struct rk8xx_priv *priv = dev_get_priv(dev); > + bool plug_in = 0; > + > + switch (priv->variant) { > + case RK805_ID: > + case RK816_ID: > + case RK818_ID: > + plug_in = pmic_reg_read(dev, RK8XX_ON_SOURCE) & RK8XX_ON_PLUG_IN; > + if (plug_in) { It seems that doesn't need to use plug_in. Can't use "if (pmic_reg_read() & RK8XX_ON_PLUG_IN)"? Best Regards, Jaehoon Chung > + printf("Power Off due to plug-in event\n"); > + pmic_clrsetbits(dev, REG_DEVCTRL, 0, BIT(0)); > + } > + break; > + case RK809_ID: > + case RK817_ID: > + plug_in = pmic_reg_read(dev, RK817_ON_SOURCE) & RK8XX_ON_PLUG_IN; > + if (plug_in) { > + printf("Power Off due to plug-in event\n"); > + pmic_clrsetbits(dev, RK817_REG_SYS_CFG3, 0, > + BIT(0)); > + } > + break; > + default: > + printf("PMIC RK%x: Cannot read boot reason.\n", > + priv->variant); > + } > +} > + > static struct reg_data rk817_init_reg[] = { > /* enable the under-voltage protection, > * the under-voltage protection will shutdown the LDO3 and reset the PMIC > @@ -211,6 +246,8 @@ static int rk8xx_probe(struct udevice *dev) > pmic_reg_read(dev, on_source), > pmic_reg_read(dev, off_source)); > printf("\n"); > + if (CONFIG_IS_ENABLED(ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON)) > + rk8xx_off_for_plugin(dev); > > return 0; > } > diff --git a/include/power/rk8xx_pmic.h b/include/power/rk8xx_pmic.h > index 8ff0af35c5..3cbfc02195 100644 > --- a/include/power/rk8xx_pmic.h > +++ b/include/power/rk8xx_pmic.h > @@ -214,6 +214,9 @@ enum { > #define RK817_ON_SOURCE 0xf5 > #define RK817_OFF_SOURCE 0xf6 > > +#define RK8XX_ON_PWRON BIT(7) > +#define RK8XX_ON_PLUG_IN BIT(6) > + > struct reg_data { > u8 reg; > u8 val;