Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp14561pxk; Tue, 22 Sep 2020 17:03:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznPeGuST9H2as6rk6Db3pi8icsBdg5bA2jgHk9MNIqYxvA5UwZFhwEutIFkQnhKvw/5pIk X-Received: by 2002:aa7:d059:: with SMTP id n25mr6687873edo.270.1600819389426; Tue, 22 Sep 2020 17:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600819389; cv=none; d=google.com; s=arc-20160816; b=zLixU8kOHkHrdE5SZwYRI3wTsiA3zjdex+QKJsULafJaW9eCk2gruWhp4oQRgSmQaX 0dSyZrduCntJrifq4u0sJeOreJWBqMXGGo9hvvS81r/vFwLbocv/XIwYWm9jfhGUykD0 ZbQhfr6BqqpIVlpczx+bt7S9Wns2Dsr4Limp+zFcZSOExLQm6GwqSh+KQz7hen9Qekae OndwGu2P6/sbBPSOEinoVmrZKpSXxxK85f0a8qshThMlTsNvD38+8St5rWl+a7PnXxPJ txzShFiurX35rX7g3dvO9tVO/KgnDfSMHr1aEH8ia14xgKbmUJtQ72eO6ICE+oBgeNQQ JLFA== 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; bh=kGTx/Fj2zjNke6CRvCD9QIl8uae51LrS8iKAvA6PRAw=; b=bzBsu33sKNGEFK9WsWiNorjPT1zkWPLfW/KBU3x/deE6iaJpHt+FJT6ZiZfvz3ZBml gaYknx+8Y7kfzo3t65fHCFRanmgfuBsfR3VRtPkfdeF/YakStaWtY6Z805LVvvSVvQ81 TYjDzucRh0YUUZJNEqy50NU4UYUD5olL79BXM2p1ClNlA6s13IEh9sY4cDbAeEDPH9DI s4kVpMVc0K6vIesW3ZABEej89j+SWLOExf/EDVCEU+7PyCm9Vp7HcALNZOuM50TTtCbg SARPXeLiQkPNaRYtNyOJjw7juD9Pt4lobbw6vKFNsRHcNccSBGxAxij5IT69hnP5yNSN 1Szg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si11486823eji.17.2020.09.22.17.02.45; Tue, 22 Sep 2020 17:03:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726723AbgIVXNS (ORCPT + 99 others); Tue, 22 Sep 2020 19:13:18 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:35967 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgIVXNR (ORCPT ); Tue, 22 Sep 2020 19:13:17 -0400 Received: by mail-ot1-f65.google.com with SMTP id 60so17241597otw.3 for ; Tue, 22 Sep 2020 16:13:16 -0700 (PDT) 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=kGTx/Fj2zjNke6CRvCD9QIl8uae51LrS8iKAvA6PRAw=; b=DjrXCvQCehA1tMyNTo4eutnjicWIl8n7tQ1S4eZuP6O94XRFOShgMuPwO/7vRm9X7I qd1xYpGmBbzSeOu75FmB3K2mwGdd4elnxv5ARWYMul5YnsgkmJVgyzEfubDWdWypUb+X wvqu6dRLgLMXmWhWChUhzvv2kn8ZlVx5bP93tsy+5Y+4nrvbtxA5j4qkQOGCWmPXNdZ6 zLsaI23bq4GaF3lIKMsLqtZ5uxVjnUtTPryeFuZXtR2h+jFDub9wGmzcE6FsPU9lF0vd eDfSKcdJesW4Y9f3qcI4Z1UCYeeVHTyt8f36qAUlYXxYBM48az58kjPYaFG/XVN02/cg JlYA== X-Gm-Message-State: AOAM533qVoa7aAeZavAVYnUaYByHQHyRJ20Ktfxg2h+t8jWDlZAbDg4l qGjIw58RNMk+r/dAhIaxGYAa7OjcOE5JAQ== X-Received: by 2002:a05:6830:101:: with SMTP id i1mr4473157otp.300.1600816396176; Tue, 22 Sep 2020 16:13:16 -0700 (PDT) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com. [209.85.167.177]) by smtp.gmail.com with ESMTPSA id l79sm7998263oih.41.2020.09.22.16.13.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Sep 2020 16:13:15 -0700 (PDT) Received: by mail-oi1-f177.google.com with SMTP id c13so22921785oiy.6 for ; Tue, 22 Sep 2020 16:13:14 -0700 (PDT) X-Received: by 2002:a05:6808:2d7:: with SMTP id a23mr3898652oid.51.1600816394656; Tue, 22 Sep 2020 16:13:14 -0700 (PDT) MIME-Version: 1.0 References: <20200915110647.846-1-kuldip.dwivedi@puresoftware.com> <4e008f0a-69da-d5c2-4dfc-ef8695e17f47@arm.com> In-Reply-To: From: Li Yang Date: Tue, 22 Sep 2020 18:13:02 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1] soc: fsl: rcpm: Add ACPI support To: Ard Biesheuvel Cc: Ran Wang , kuldip dwivedi , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Biwen Li , Varun Sethi , Arokia Samy , Samer El-Haj-Mahmoud , Paul Yang , tanveer Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 16, 2020 at 1:12 AM Ard Biesheuvel wrote: > > On 9/16/20 3:32 AM, Ran Wang wrote: > > Hi Ard, > > > > On Tuesday, September 15, 2020 7:10 PM, Ard Biesheuvel wrote: > >> Subject: Re: [PATCH v1] soc: fsl: rcpm: Add ACPI support > >> > >> On 9/15/20 1:06 PM, kuldip dwivedi wrote: > >>> Add ACPI support in fsl RCPM driver. This is required to support ACPI > >>> S3 state. S3 is the ACPI sleep state that is known as "sleep" or > >>> "suspend to RAM". > >>> It essentially turns off most power of the system but keeps memory > >>> powered. > >>> > >>> Signed-off-by: tanveer > >>> Signed-off-by: kuldip dwivedi > >> > >> Why does the OS need to program this device? Can't this be done by > >> firmware? > > > > This device is use to tell HW which IP (such as USB, SDHC, SATA, etc) should not be > > clock gated during system enter low power state (to allow that IP work as a > > wakeup source). And user does this configuration in device tree. > > The point of ACPI is *not* to describe a DT topology using a table > format that is not suited for it. The point of ACPI is to describe a > machine that is more abstracted from the hardware than is typically > possible with DT, where the abstractions are implemented by AML code > that is provided by the firmware, but executed in the context of the OS. > > So the idea is *not* finding the shortest possible path to get your > existing DT driver code running on a system that boots via ACPI. > Instead, you should carefully think about the abstract ACPI machine that > you will expose to the OS, and hide everything else in firmware. > > In this particular case, it seems like your USB, SDHC and SATA device > objects may need power state dependent AML methods that program this > block directly. The platform PM driver was created to support PM on systems without a runtime PM firmware. Even with PSCI firmware on later systems, there is no standard interface to communicate the wakeup source information directly from peripheral drivers to the PSCI firmware. So we still need this platform power management driver in kernel to deal with this setup for non-ACPI scenarios. From the code re-use perspective, I think it is probably better to keep this generic implementation in kernel instead of moving it to ACPI byte-code for each platform. > > > > > So implement > > this RCPM driver to do it in kernel rather than firmware. > > > > Regards, > > Ran > > > >>> --- > >>> > >>> Notes: > >>> 1. Add ACPI match table > >>> 2. NXP team members are added for confirming HID changes > >>> 3. There is only one node in ACPI so no need to check for > >>> current device explicitly > >>> 4. These changes are tested on LX2160A and LS1046A platforms > >>> > >>> drivers/soc/fsl/rcpm.c | 22 +++++++++++++++++++--- > >>> 1 file changed, 19 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/drivers/soc/fsl/rcpm.c b/drivers/soc/fsl/rcpm.c index > >>> a093dbe6d2cb..e75a436fb159 100644 > >>> --- a/drivers/soc/fsl/rcpm.c > >>> +++ b/drivers/soc/fsl/rcpm.c > >>> @@ -2,10 +2,12 @@ > >>> // > >>> // rcpm.c - Freescale QorIQ RCPM driver > >>> // > >>> -// Copyright 2019 NXP > >>> +// Copyright 2019-2020 NXP > >>> +// Copyright 2020 Puresoftware Ltd. > >>> // > >>> // Author: Ran Wang > >>> > >>> +#include > >>> #include > >>> #include > >>> #include > >>> @@ -57,8 +59,13 @@ static int rcpm_pm_prepare(struct device *dev) > >>> rcpm->wakeup_cells + 1); > >>> > >>> /* Wakeup source should refer to current rcpm device */ > >>> - if (ret || (np->phandle != value[0])) > >>> - continue; > >>> + if (is_acpi_node(dev->fwnode)) { > >>> + if (ret) > >>> + continue; > >>> + } else { > >>> + if (ret || (np->phandle != value[0])) > >>> + continue; > >>> + } > >>> > >>> /* Property "#fsl,rcpm-wakeup-cells" of rcpm node defines the > >>> * number of IPPDEXPCR register cells, and "fsl,rcpm-wakeup" > >>> @@ -139,10 +146,19 @@ static const struct of_device_id rcpm_of_match[] > >> = { > >>> }; > >>> MODULE_DEVICE_TABLE(of, rcpm_of_match); > >>> > >>> +#ifdef CONFIG_ACPI > >>> +static const struct acpi_device_id rcpm_acpi_match[] = { > >>> + { "NXP0015", }, > >>> + { } > >>> +}; > >>> +MODULE_DEVICE_TABLE(acpi, rcpm_acpi_match); #endif > >>> + > >>> static struct platform_driver rcpm_driver = { > >>> .driver = { > >>> .name = "rcpm", > >>> .of_match_table = rcpm_of_match, > >>> + .acpi_match_table = ACPI_PTR(rcpm_acpi_match), > >>> .pm = &rcpm_pm_ops, > >>> }, > >>> .probe = rcpm_probe, > >>> > > >