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 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 CECC5C433EF for ; Thu, 27 Jan 2022 22:28:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1F91D830AB; Thu, 27 Jan 2022 23:28:46 +0100 (CET) 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="txNLuFlK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EB6DB83388; Thu, 27 Jan 2022 23:28:44 +0100 (CET) Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 98C2082BA6 for ; Thu, 27 Jan 2022 23:28:38 +0100 (CET) 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 epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220127222835epoutp01d863d1d6e06f3dde2cb858c40f634c66~OQR7ox_No2842728427epoutp01W for ; Thu, 27 Jan 2022 22:28:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220127222835epoutp01d863d1d6e06f3dde2cb858c40f634c66~OQR7ox_No2842728427epoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1643322515; bh=MNq0hFnTIt+65uDWa3yCqcPGV/5ansd07PTr2sC18Jk=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=txNLuFlKesYQTpoLqUfZa2flAcgFOCpiTmV7RXZZIuyaOWU0fGL7UDAEUwPx7nrv3 8PDgujHs63tw6c42CpIl+z0wiMz2SiC3q2XlW7J0bhKr5t7iRUwQMPnS2DWuQ3e0d1 UwHJGEHtI/YqRxalp9RYCWmwmZCcBbQ5ElEc9D5Y= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20220127222834epcas1p1c3419f6938c5330e54218ce5a4aa9c8c~OQR7bPHcW1816218162epcas1p13; Thu, 27 Jan 2022 22:28:34 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.36.136]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4JlFbx3Zjnz4x9Pv; Thu, 27 Jan 2022 22:28:29 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 44.C9.09592.D8C13F16; Fri, 28 Jan 2022 07:28:29 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20220127222828epcas1p3c0497f561e52ea0d9e71b52fe80cebd7~OQR1usu5y1051010510epcas1p3X; Thu, 27 Jan 2022 22:28:28 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220127222828epsmtrp231d8f59312d98740ff5a359e562019ec~OQR1t4yyp3075730757epsmtrp2h; Thu, 27 Jan 2022 22:28:28 +0000 (GMT) X-AuditID: b6c32a37-28fff70000002578-0b-61f31c8ddd86 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 8B.8B.29871.C8C13F16; Fri, 28 Jan 2022 07:28:28 +0900 (KST) Received: from [10.113.113.235] (unknown [10.113.113.235]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220127222828epsmtip2f7fb44ec915f0a49a02f6b000788c4ad~OQR1Ot4D90483504835epsmtip2m; Thu, 27 Jan 2022 22:28:28 +0000 (GMT) Message-ID: Date: Fri, 28 Jan 2022 07:29:18 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2 7/9] power: domain: apple: Add reset support Content-Language: en-US To: Mark Kettenis Cc: kettenis@openbsd.org, u-boot@lists.denx.de, sjg@chromium.org, trini@konsulko.com, sven@svenpeter.dev, marcan@marcan.st, bmeng.cn@gmail.com From: Jaehoon Chung In-Reply-To: Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLJsWRmVeSWpSXmKPExsWy7bCmgW6vzOdEg642E4upPfEWx24dY7Y4 fW0Bu0Xnuj3MFt+2bGO0+HP7P5PF1Emb2S3e7u1kd+DwmN1wkcVj56y77B6vDqxi9zh7Zwej x+JlO9k8zn5tYvbon9fP5HHq62f2AI6obJuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11D SwtzJYW8xNxUWyUXnwBdt8wcoNOUFMoSc0qBQgGJxcVK+nY2RfmlJakKGfnFJbZKqQUpOQWm BXrFibnFpXnpenmpJVaGBgZGpkCFCdkZ7RdeMxX80qh43NTB0sC4QrGLkZNDQsBEonf/MvYu Ri4OIYEdjBKXL3xihHA+MUoc6tvKBOF8Y5Q48/4JC0zLvLlnoKr2MkpMv3Icquo9o0Tb45tA DgcHr4CdxMGfqiAmi4CqxNvn8iC9vAKCEidnQswRFYiQeHnkLxOILSzgLLH7yx9GEJtZQFzi 1pP5YHERAW2JXVubwXYxC0xgl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soceDPV0aQ OK+AncTBn6ogJouAqsTb5/IgnbwCghInZz5hAbFFBSIk2pZNYQaxhQWcJXZ/+cMIYjMLiEvc ejKfCcQWEdCW2LW1GewEZoEJjBK75j6FumcBk8TzO7fZQarYBHQktn87DtbBKWAh8XTXA1aQ xcwC6hLr5wlBDJWX2P52DvMERqFZSO6YhWTfLISOWUg6FjCyrGKUTC0ozk3PLTYsMMxLLdcr TswtLs1L10vOz93ECI4sLc0djNtXfdA7xMjEwXiIUYKDWUmEd8amT4lCvCmJlVWpRfnxRaU5 qcWHGKU5WJTEeS90nYwXEkhPLEnNTk0tSC2CyTJxcEo1MM39felXkeKPN2tdriXGTDwcEG2+ xfL9Lxand0//HmRzUPFYzt8rMoXv/uO3DnyP+pYeXHHCy2dmj8jEzdFPW7RF7hzMmPjH6/Du EzNWbAyOUuf5s7N6003lgA89wUdP7ncqMrZREnf/0hnVWz2vZ+MXbgcZ+x/RVw/877jF9/6L k86rqf+qz5xKfjp7skVfmq7oDEOWX2mph1csbjQriamSnbFki+7pmX8Pv9gqtWLe8fjJ59K+ HWDu3/ygYZN+xMNnTVIzj21VKeObwqLl9OW2/vHp4lIF755x/Pi8k5FvpYtzHvfTIA3nZO7e Zb5qvEbZ1yraBLn+crcmSvbfVMx+ncH4+sW5fe1xEwUmhPAosRRnJBpqMRcVJwIApEz+BBsD AAA= X-CMS-MailID: 20220127222828epcas1p3c0497f561e52ea0d9e71b52fe80cebd7 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: 20220122193845epcas1p1845136d893845bdfa78624169f37bd9d References: <20220122193819.84907-1-kettenis@openbsd.org> <20220122193819.84907-8-kettenis@openbsd.org> <1e140d19-034a-6b06-5180-c268c55f5e15@samsung.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 1/27/22 20:48, Mark Kettenis wrote: >> Date: Thu, 27 Jan 2022 08:54:29 +0900 >> From: Jaehoon Chung >> >> Hi, >> >> On 1/23/22 04:38, Mark Kettenis wrote: >>> The power management controller found on Apple SoCs als provides >>> a way to reset all devices within a power domain. This is needed >>> to cleanly shutdown the NVMe controller before we hand over >>> control to the OS. >>> >>> Signed-off-by: Mark Kettenis >>> Reviewed-by: Simon Glass >>> Tested on: Macbook Air M1 >>> Tested-by: Simon Glass >> >> Reviewed-by: Jaehoon Chung >> >> Add minor comment. > > Hi Jaehoon, > >>> --- >>> arch/arm/Kconfig | 1 + >>> drivers/power/domain/apple-pmgr.c | 73 ++++++++++++++++++++++++++++++- >>> 2 files changed, 73 insertions(+), 1 deletion(-) >>> >>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig >>> index ecacd6860b..14c83ea19e 100644 >>> --- a/arch/arm/Kconfig >>> +++ b/arch/arm/Kconfig >>> @@ -935,6 +935,7 @@ config ARCH_APPLE >>> select DM_GPIO >>> select DM_KEYBOARD >>> select DM_MAILBOX >>> + select DM_RESET >>> select DM_SERIAL >>> select DM_USB >>> select DM_VIDEO >>> diff --git a/drivers/power/domain/apple-pmgr.c b/drivers/power/domain/apple-pmgr.c >>> index d25f136b9d..4d06e76ff5 100644 >>> --- a/drivers/power/domain/apple-pmgr.c >>> +++ b/drivers/power/domain/apple-pmgr.c >>> @@ -6,14 +6,22 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> >>> -#define APPLE_PMGR_PS_TARGET GENMASK(3, 0) >>> +#define APPLE_PMGR_RESET BIT(31) >>> +#define APPLE_PMGR_DEV_DISABLE BIT(10) >>> +#define APPLE_PMGR_WAS_CLKGATED BIT(9) >>> +#define APPLE_PMGR_WAS_PWRGATED BIT(8) >> >> Bit description is specified "WAS_CLKGATED"? >> I think it can be removed "WAS". CLKGATED has already similar meaning. > > The names are taken from the Linux driver and I would prefer to keep > them the same to make it easier to compare the two drivers since > nobody outside of Apple has access to documentation for this block. Thanks for explanation. Best Regards, Jaehoon Chung > >>> #define APPLE_PMGR_PS_ACTUAL GENMASK(7, 4) >>> +#define APPLE_PMGR_PS_TARGET GENMASK(3, 0) >>> + >>> +#define APPLE_PMGR_FLAGS (APPLE_PMGR_WAS_CLKGATED | APPLE_PMGR_WAS_PWRGATED) >>> >>> #define APPLE_PMGR_PS_ACTIVE 0xf >>> #define APPLE_PMGR_PS_PWRGATE 0x0 >>> @@ -25,6 +33,65 @@ struct apple_pmgr_priv { >>> u32 offset; /* offset within regmap for this domain */ >>> }; >>> >>> +static int apple_reset_of_xlate(struct reset_ctl *reset_ctl, >>> + struct ofnode_phandle_args *args) >>> +{ >>> + if (args->args_count != 0) >>> + return -EINVAL; >>> + >>> + return 0; >>> +} >>> + >>> +static int apple_reset_request(struct reset_ctl *reset_ctl) >>> +{ >>> + return 0; >>> +} >>> + >>> +static int apple_reset_free(struct reset_ctl *reset_ctl) >>> +{ >>> + return 0; >>> +} >>> + >>> +static int apple_reset_assert(struct reset_ctl *reset_ctl) >>> +{ >>> + struct apple_pmgr_priv *priv = dev_get_priv(reset_ctl->dev->parent); >>> + >>> + regmap_update_bits(priv->regmap, priv->offset, >>> + APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE, >>> + APPLE_PMGR_DEV_DISABLE); >>> + regmap_update_bits(priv->regmap, priv->offset, >>> + APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, >>> + APPLE_PMGR_RESET); >>> + >>> + return 0; >>> +} >>> + >>> +static int apple_reset_deassert(struct reset_ctl *reset_ctl) >>> +{ >>> + struct apple_pmgr_priv *priv = dev_get_priv(reset_ctl->dev->parent); >>> + >>> + regmap_update_bits(priv->regmap, priv->offset, >>> + APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, 0); >>> + regmap_update_bits(priv->regmap, priv->offset, >>> + APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE, 0); >>> + >>> + return 0; >>> +} >>> + >>> +struct reset_ops apple_reset_ops = { >>> + .of_xlate = apple_reset_of_xlate, >>> + .request = apple_reset_request, >>> + .rfree = apple_reset_free, >>> + .rst_assert = apple_reset_assert, >>> + .rst_deassert = apple_reset_deassert, >>> +}; >>> + >>> +static struct driver apple_reset_driver = { >>> + .name = "apple_reset", >>> + .id = UCLASS_RESET, >>> + .ops = &apple_reset_ops, >>> +}; >>> + >>> static int apple_pmgr_request(struct power_domain *power_domain) >>> { >>> return 0; >>> @@ -78,6 +145,7 @@ static const struct udevice_id apple_pmgr_ids[] = { >>> static int apple_pmgr_probe(struct udevice *dev) >>> { >>> struct apple_pmgr_priv *priv = dev_get_priv(dev); >>> + struct udevice *child; >>> int ret; >>> >>> ret = dev_power_domain_on(dev); >>> @@ -92,6 +160,9 @@ static int apple_pmgr_probe(struct udevice *dev) >>> if (ret < 0) >>> return ret; >>> >>> + device_bind(dev, &apple_reset_driver, "apple_reset", NULL, >>> + dev_ofnode(dev), &child); >>> + >>> return 0; >>> } >>> >> >> >