Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp125671pxk; Tue, 15 Sep 2020 23:14:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBpdbH41WJSVIhDwv4vUc3gGuFoGL0aTP2R/htGAipGR0Wg/ArByWGb2bO1vFOYftZND5C X-Received: by 2002:a17:906:4805:: with SMTP id w5mr16965057ejq.313.1600236845705; Tue, 15 Sep 2020 23:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600236845; cv=none; d=google.com; s=arc-20160816; b=PUMwghHgYAHDYp1ENwnOnQgkWTpJi9jnvEItnoAJumOevYzO/0mdP1Q4kgCY/WLaf7 FjR9rDxomPlvQz9X3luiwuD8SuM6H/3GbijmoKKK0s27ul70k69bWVF2veKt6W7plM5o MUoBAWxg9tUmhA2QbZPt+wAKsoBo6LIPthjylwD1ZILOrE7n91/x80tdBOToX9nIrgBm Vi7e7VuqoGAhtjE9XzPr7UtwV7A7OTy+RSqdsvUfboGx2E07DvDwrbq4NnxGPUfgO8P8 cYQO4/YH0zBbjoVPx97GG9WpS4ZGfMgsv65g/m1E+5im2TQQBQwuCcIQeSY4D036oVVA iVqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rJpnVdWiUMwCFExchyaGuy/XCi3k7H/Zs6KArO/4CYo=; b=QfGj+0zZyBK8Et5d76ejB2t1FejMi/41rA2O52ApU1fZz9kjPyMD/8OSmybYqfzyXJ VOdnaD5os66ZJ3PVBT/1yNLq98WLn4jeVmLkwMHWrlJwpe2QJ3IV3fL8mWbZd6G6IjlN qJE8PjcYMHHlLVd3TUxDUtxN4xcsREljUAfSgptgVnfXs2/3uddQbcJcUXQStYdhk8ba TMd/5cCGOXQ1q/qimevSMVaYN2+Lv9vb8MdnAZauozyDV5h1XTDldGT/XUImX1DhsijT i4jQMS2z/mFjF4bdRB8xYDf429sS0kltKxceHpftqbbQcZ3oFhPle1DQbUZuKhjtJCcv nOdA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si11987990ejd.606.2020.09.15.23.13.43; Tue, 15 Sep 2020 23:14:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726155AbgIPGKo (ORCPT + 99 others); Wed, 16 Sep 2020 02:10:44 -0400 Received: from foss.arm.com ([217.140.110.172]:53422 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbgIPGKo (ORCPT ); Wed, 16 Sep 2020 02:10:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2655B1FB; Tue, 15 Sep 2020 23:10:43 -0700 (PDT) Received: from [192.168.1.205] (unknown [10.37.8.121]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B8223F68F; Tue, 15 Sep 2020 23:10:39 -0700 (PDT) Subject: Re: [PATCH v1] soc: fsl: rcpm: Add ACPI support To: Ran Wang , kuldip dwivedi , Leo Li , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Cc: Biwen Li , Varun Sethi , Arokia Samy , Samer El-Haj-Mahmoud , Paul Yang , tanveer References: <20200915110647.846-1-kuldip.dwivedi@puresoftware.com> <4e008f0a-69da-d5c2-4dfc-ef8695e17f47@arm.com> From: Ard Biesheuvel Message-ID: Date: Wed, 16 Sep 2020 09:10:36 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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, >>> >