Message ID | 20230803063703.5659-2-zhuyinbo@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp956087vqx; Wed, 2 Aug 2023 23:56:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGVEQXfB4x4SUM0Ijzh3WxsLI6n8eI1Zf4PTDnHIkIdjSsry6mGiZatxE/KGos001l8uz+g X-Received: by 2002:a17:906:196:b0:993:d0e1:f308 with SMTP id 22-20020a170906019600b00993d0e1f308mr12916799ejb.2.1691045769250; Wed, 02 Aug 2023 23:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691045769; cv=none; d=google.com; s=arc-20160816; b=X+9qFU98ZP4OkL6LgSQB7jktb/eu7+pcNYIv6Yr+45Wjk5n57MlwzMQIFGoecXe8K/ JBjJR9MP8DSyokLib5afVmDy8ioo9MG3lX1PQma3n6ievpQ8BxCZUY3ClPPCq8GBcz9D QttqKfD9EmvvSjVWQDATOXkKZ+AUBdEQOZHzsA/NY/a40jkHwkWjlUSef/88ugJOcd6f 9HKKoE2dJ93STqH4IJTPZgDemC5++OdT6segWr3or1zUsZCz4WwvO8BReOeCj5nXIuLd mRzt5VNgtJha/67cdckRNPX8ulqag+9hOOSOe0mncP2VuK7P2mjl9Ofo9QMrkqaC78N6 o8SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sR5jwjmq/TivRmqXpi8qo4+MElRa5/UpHg/sgck0Y+c=; fh=7Lrr1Qa/Qb50OF7gQgNE65JJu5uJCRZupxzFREr7FVs=; b=hfa+W9Kagbjk8lcImYemdnhEmryS9AN300fGBE3/CvAPrMpRDEjCOnVIjwJB9iwP6R XMOjTfML74FIO1DQ2nZmHvSIMuInj09qcbwnZ03iI3AKNqJ//QZL0gnZjDB97S1hWdSE HNbxy0LmeTxXsdZDOk/2zLqrYvazEpQNlVEXw+3ddRHKHWZ0lSbMw4THprVgVgE3BLUC r40s8JSV4+s3LrBAFdTkVyczqANr8VshXoEQFe7egtj2xqyCe7cIEcQzeflMeT5kyi4z FzAGaB9Reg2TUaLCF12xzYgtOQ53IXCjZ7sPxMqfdErPH6rIoQg3E4dICBgtdc/dD6Uu CjfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay21-20020a170906d29500b0099bcee97a5dsi11632082ejb.761.2023.08.02.23.55.45; Wed, 02 Aug 2023 23:56:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233393AbjHCGhb (ORCPT <rfc822;cambridge8321@gmail.com> + 99 others); Thu, 3 Aug 2023 02:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233351AbjHCGh1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 3 Aug 2023 02:37:27 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 67B0330E3; Wed, 2 Aug 2023 23:37:23 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.201]) by gateway (Coremail) with SMTP id _____8CxfOoiS8tkFoYPAA--.9019S3; Thu, 03 Aug 2023 14:37:22 +0800 (CST) Received: from localhost.localdomain (unknown [10.20.42.201]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxF80aS8tkMsZGAA--.49295S3; Thu, 03 Aug 2023 14:37:20 +0800 (CST) From: Yinbo Zhu <zhuyinbo@loongson.cn> To: Arnd Bergmann <arnd@arndb.de>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, soc@kernel.org, Ulf Hansson <ulf.hansson@linaro.org> Cc: Jianmin Lv <lvjianmin@loongson.cn>, wanghongliang@loongson.cn, Liu Peibao <liupeibao@loongson.cn>, loongson-kernel@lists.loongnix.cn, Yinbo Zhu <zhuyinbo@loongson.cn>, loongarch@lists.linux.dev, Liu Yun <liuyun@loongson.cn>, Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Subject: [PATCH v6 1/2] soc: dt-bindings: add loongson-2 pm Date: Thu, 3 Aug 2023 14:37:02 +0800 Message-Id: <20230803063703.5659-2-zhuyinbo@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230803063703.5659-1-zhuyinbo@loongson.cn> References: <20230803063703.5659-1-zhuyinbo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8CxF80aS8tkMsZGAA--.49295S3 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773190008971715002 X-GMAIL-MSGID: 1773190008971715002 |
Series |
soc: loongson2_pm: add power management support
|
|
Commit Message
Yinbo Zhu
Aug. 3, 2023, 6:37 a.m. UTC
Add the Loongson-2 SoC Power Management Controller binding with DT schema format using json-schema. Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> --- .../soc/loongson/loongson,ls2k-pmc.yaml | 52 +++++++++++++++++++ MAINTAINERS | 6 +++ 2 files changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml
Comments
On Thu, Aug 3, 2023, at 08:37, Yinbo Zhu wrote: > + loongson,suspend-address: > + $ref: /schemas/types.yaml#/definitions/uint64 > + description: > + The "loongson,suspend-address" is a deep sleep state (Suspend To > + RAM) firmware entry address which was jumped from kernel and it's > + value was dependent on specific platform firmware code. In > + addition, the PM need according to it to indicate that current > + SoC whether support Suspend To RAM. > + I just commented on this in the driver patch, assuming this was an MMIO address, but I'm even more confused now, since we try hard to not rely on being able to just interface with firmware like this. If this is executable code, where does this actually reside? Is this some SRAM that needs to execute the suspend logic in order to shut down memory and cache controllers? Or is this a runtime firmware interface similar to how UEFI handles its runtime services to keep the implementation out of the kernel? Does the code work with both traditional suspend-to-ram and modern suspend-to-idle logic? Arnd
在 2023/8/3 下午3:44, Arnd Bergmann 写道: > On Thu, Aug 3, 2023, at 08:37, Yinbo Zhu wrote: > >> + loongson,suspend-address: >> + $ref: /schemas/types.yaml#/definitions/uint64 >> + description: >> + The "loongson,suspend-address" is a deep sleep state (Suspend To >> + RAM) firmware entry address which was jumped from kernel and it's >> + value was dependent on specific platform firmware code. In >> + addition, the PM need according to it to indicate that current >> + SoC whether support Suspend To RAM. >> + > > I just commented on this in the driver patch, assuming this > was an MMIO address, but I'm even more confused now, since > we try hard to not rely on being able to just interface with > firmware like this. > > If this is executable code, where does this actually reside? Pmon firmware code. > Is this some SRAM that needs to execute the suspend logic > in order to shut down memory and cache controllers? Yes, The suspend-to-ram after into pmon firmware code and set self-refresh mode in memory controller and ensure that memory data is not lost then shut down memory controller. > Or is > this a runtime firmware interface similar to how UEFI handles > its runtime services to keep the implementation out of > the kernel? No, The main cpu and other cpu will offline that after into firmware and finished Corresponding operations, the pmon firmware will not run. > > Does the code work with both traditional suspend-to-ram and > modern suspend-to-idle logic? Yes, It can support suspend-to-ram and suspend-to-idle. Thanks, Yinbo
On Fri, Aug 4, 2023, at 04:54, Yinbo Zhu wrote: > 在 2023/8/3 下午3:44, Arnd Bergmann 写道: >> On Thu, Aug 3, 2023, at 08:37, Yinbo Zhu wrote: >> >>> + loongson,suspend-address: >>> + $ref: /schemas/types.yaml#/definitions/uint64 >>> + description: >>> + The "loongson,suspend-address" is a deep sleep state (Suspend To >>> + RAM) firmware entry address which was jumped from kernel and it's >>> + value was dependent on specific platform firmware code. In >>> + addition, the PM need according to it to indicate that current >>> + SoC whether support Suspend To RAM. >>> + >> >> I just commented on this in the driver patch, assuming this >> was an MMIO address, but I'm even more confused now, since >> we try hard to not rely on being able to just interface with >> firmware like this. >> >> If this is executable code, where does this actually reside? > > > Pmon firmware code. > >> Is this some SRAM that needs to execute the suspend logic >> in order to shut down memory and cache controllers? > > > Yes, The suspend-to-ram after into pmon firmware code and set > self-refresh mode in memory controller and ensure that memory data is > not lost then shut down memory controller. I'm sorry I missed your reply earlier, getting back to the thread now. So it's clear that this code needs to run in a special memory from your description, but I'm still trying to understand the details better. I found https://github.com/loongson-community/pmon source code, and a reference to its origin at LSI Logic at https://www.linux-mips.org/wiki/PMON but otherwise have no idea about what this actually is, or how it relates to your UEFI firmware. Did you add UEFI support to PMON, or do you use it as a first stage loader that loads the actual UEFI implementation (EDK2 or u-boot, I guess)? >> Or is >> this a runtime firmware interface similar to how UEFI handles >> its runtime services to keep the implementation out of >> the kernel? > > > No, The main cpu and other cpu will offline that after into firmware and > finished Corresponding operations, the pmon firmware will not run. I'm still trying to understand your explanations here. You say that pmon no longer runs, but that seems to contradict what you said earlier about branching into pmon firmware code for suspend. Is this executing directly from ROM then? Arnd
在 2023/8/12 下午8:25, Arnd Bergmann 写道: > On Fri, Aug 4, 2023, at 04:54, Yinbo Zhu wrote: >> 在 2023/8/3 下午3:44, Arnd Bergmann 写道: >>> On Thu, Aug 3, 2023, at 08:37, Yinbo Zhu wrote: >>> >>>> + loongson,suspend-address: >>>> + $ref: /schemas/types.yaml#/definitions/uint64 >>>> + description: >>>> + The "loongson,suspend-address" is a deep sleep state (Suspend To >>>> + RAM) firmware entry address which was jumped from kernel and it's >>>> + value was dependent on specific platform firmware code. In >>>> + addition, the PM need according to it to indicate that current >>>> + SoC whether support Suspend To RAM. >>>> + >>> >>> I just commented on this in the driver patch, assuming this >>> was an MMIO address, but I'm even more confused now, since >>> we try hard to not rely on being able to just interface with >>> firmware like this. >>> >>> If this is executable code, where does this actually reside? >> >> >> Pmon firmware code. >> >>> Is this some SRAM that needs to execute the suspend logic >>> in order to shut down memory and cache controllers? >> >> >> Yes, The suspend-to-ram after into pmon firmware code and set >> self-refresh mode in memory controller and ensure that memory data is >> not lost then shut down memory controller. > > I'm sorry I missed your reply earlier, getting back to the > thread now. So it's clear that this code needs to run in a > special memory from your description, but I'm still trying > to understand the details better. > > I found https://github.com/loongson-community/pmon source > code, and a reference to its origin at LSI Logic at > https://www.linux-mips.org/wiki/PMON but otherwise have > no idea about what this actually is, or how it relates > to your UEFI firmware. Did you add UEFI support to PMON, > or do you use it as a first stage loader that loads > the actual UEFI implementation (EDK2 or u-boot, I guess)? Pmon and uefi are two different firmware, and there is no connection between them. > >>> Or is >>> this a runtime firmware interface similar to how UEFI handles >>> its runtime services to keep the implementation out of >>> the kernel? >> >> >> No, The main cpu and other cpu will offline that after into firmware and >> finished Corresponding operations, the pmon firmware will not run. > > I'm still trying to understand your explanations here. > You say that pmon no longer runs, but that seems to contradict > what you said earlier about branching into pmon firmware code > for suspend. It's not contradictory. The suspend-to-ram is that from kernel goto to pmon firmware code, then pmon finished corresponding operations, which was to set self-refresh mode in memory controller, then memory HW will maintain its own data and no longer requires software processing, pmon firmware will not run. > > Is this executing directly from ROM then? Yes. Thanks, Yinbo
On Mon, Aug 14, 2023, at 09:57, Yinbo Zhu wrote: > 在 2023/8/12 下午8:25, Arnd Bergmann 写道: >> On Fri, Aug 4, 2023, at 04:54, Yinbo Zhu wrote: >>> 在 2023/8/3 下午3:44, Arnd Bergmann 写道: >>>> On Thu, Aug 3, 2023, at 08:37, Yinbo Zhu wrote: >>> >>>> Is this some SRAM that needs to execute the suspend logic >>>> in order to shut down memory and cache controllers? >>> >>> >>> Yes, The suspend-to-ram after into pmon firmware code and set >>> self-refresh mode in memory controller and ensure that memory data is >>> not lost then shut down memory controller. >> >> I'm sorry I missed your reply earlier, getting back to the >> thread now. So it's clear that this code needs to run in a >> special memory from your description, but I'm still trying >> to understand the details better. >> >> I found https://github.com/loongson-community/pmon source >> code, and a reference to its origin at LSI Logic at >> https://www.linux-mips.org/wiki/PMON but otherwise have >> no idea about what this actually is, or how it relates >> to your UEFI firmware. Did you add UEFI support to PMON, >> or do you use it as a first stage loader that loads >> the actual UEFI implementation (EDK2 or u-boot, I guess)? > > > Pmon and uefi are two different firmware, and there is no connection > between them. It sounds like we still have problems with terminology. I don't think categorizing UEFI as a firmware is correct, it's the interface used by various firmware implementations to load the operating system. As far as I understand, loongarch currently mandates the use of UEFI in whichever firmware is used, so if you have Pmon installed in ROM, and Pmon does not itself implement UEFI, it would have to load some other firmware such as u-boot in order to load a kernel through the UEFI protocol, right? Has the assumption that loongarch requires UEFI changed? >>>> Or is >>>> this a runtime firmware interface similar to how UEFI handles >>>> its runtime services to keep the implementation out of >>>> the kernel? >>> >>> >>> No, The main cpu and other cpu will offline that after into firmware and >>> finished Corresponding operations, the pmon firmware will not run. >> >> I'm still trying to understand your explanations here. >> You say that pmon no longer runs, but that seems to contradict >> what you said earlier about branching into pmon firmware code >> for suspend. > > > It's not contradictory. The suspend-to-ram is that from kernel goto to > pmon firmware code, then pmon finished corresponding operations, which > was to set self-refresh mode in memory controller, then memory HW will > maintain its own data and no longer requires software processing, pmon > firmware will not run. That is what I mean with a "runtime firmware interface", i.e. you jump into firmware in order to request services from it. Clearly the firmware itself does not run while the OS is executing code, but it is still there and waiting to be called here, which is similar to things like UEFI runtime services, PowerPC RTAS, Arm EL3/trustzone based firmware or x86 SMM firmware, except that this is much less formalized and only consists of an entry point with undocument calling conventions. >> Is this executing directly from ROM then? > > Yes. Is this the only runtime call into the firmware, or are there others that are either already called from mainline kernels or in your downsteam implementation? How do you ensure that the DTB matches the actual ROM code after rebuilding Pmon? Does Pmon itself fill that field with the correct address, or do you rely on it being a hardcoded constant? Arnd
在 2023/8/14 下午4:19, Arnd Bergmann 写道: > On Mon, Aug 14, 2023, at 09:57, Yinbo Zhu wrote: >> 在 2023/8/12 下午8:25, Arnd Bergmann 写道: >>> On Fri, Aug 4, 2023, at 04:54, Yinbo Zhu wrote: >>>> 在 2023/8/3 下午3:44, Arnd Bergmann 写道: >>>>> On Thu, Aug 3, 2023, at 08:37, Yinbo Zhu wrote: >>>> >>>>> Is this some SRAM that needs to execute the suspend logic >>>>> in order to shut down memory and cache controllers? >>>> >>>> >>>> Yes, The suspend-to-ram after into pmon firmware code and set >>>> self-refresh mode in memory controller and ensure that memory data is >>>> not lost then shut down memory controller. >>> >>> I'm sorry I missed your reply earlier, getting back to the >>> thread now. So it's clear that this code needs to run in a >>> special memory from your description, but I'm still trying >>> to understand the details better. >>> >>> I found https://github.com/loongson-community/pmon source >>> code, and a reference to its origin at LSI Logic at >>> https://www.linux-mips.org/wiki/PMON but otherwise have >>> no idea about what this actually is, or how it relates >>> to your UEFI firmware. Did you add UEFI support to PMON, >>> or do you use it as a first stage loader that loads >>> the actual UEFI implementation (EDK2 or u-boot, I guess)? >> >> >> Pmon and uefi are two different firmware, and there is no connection >> between them. > > It sounds like we still have problems with terminology. > > I don't think categorizing UEFI as a firmware is correct, Sorry to have confused you, uefi firmware is our internal name, which is actually what you referred to as EDK2, the EDK2 need use UEFI. > it's the interface used by various firmware implementations > to load the operating system. As far as I understand, > loongarch currently mandates the use of UEFI in whichever > firmware is used, so if you have Pmon installed in ROM > and Pmon does not itself implement UEFI, it would have > to load some other firmware such as u-boot in order to > load a kernel through the UEFI protocol, right? PMON is an independent firmware and loader that can directly load the operating system and it does not require the use of UEFI. > > Has the assumption that loongarch requires UEFI changed? LoongArch embedded board was use Pmon firmware, The other one uses UEFI firmware (EDK2) on LoongArch platform. > >>>>> Or is >>>>> this a runtime firmware interface similar to how UEFI handles >>>>> its runtime services to keep the implementation out of >>>>> the kernel? >>>> >>>> >>>> No, The main cpu and other cpu will offline that after into firmware and >>>> finished Corresponding operations, the pmon firmware will not run. >>> >>> I'm still trying to understand your explanations here. >>> You say that pmon no longer runs, but that seems to contradict >>> what you said earlier about branching into pmon firmware code >>> for suspend. >> >> >> It's not contradictory. The suspend-to-ram is that from kernel goto to >> pmon firmware code, then pmon finished corresponding operations, which >> was to set self-refresh mode in memory controller, then memory HW will >> maintain its own data and no longer requires software processing, pmon >> firmware will not run. > > That is what I mean with a "runtime firmware interface", i.e. you > jump into firmware in order to request services from it. Clearly the > firmware itself does not run while the OS is executing code, but it is > still there and waiting to be called here, which is similar to > things like UEFI runtime services, PowerPC RTAS, Arm EL3/trustzone > based firmware or x86 SMM firmware, except that this is much less > formalized and only consists of an entry point with undocument > calling conventions. > >>> Is this executing directly from ROM then? >> >> Yes. > > Is this the only runtime call into the firmware, Only when suspend-to-ram occurs, the kernel will call into the firmware. No other case. > or are there > others that are either already called from mainline kernels > or in your downsteam implementation? > > How do you ensure that the DTB matches the actual ROM code > after rebuilding Pmon? Does Pmon itself fill that field with > the correct address, or do you rely on it being a hardcoded > constant? Use Pmon, firmware team will always ensure that DTB matches the actual ROM code. The "suspend-address" of dtb and pmon entry address will synchronized modification by firmware team. Thanks, Yinbo
On Mon, Aug 14, 2023, at 13:57, Yinbo Zhu wrote: > 在 2023/8/14 下午4:19, Arnd Bergmann 写道: >> On Mon, Aug 14, 2023, at 09:57, Yinbo Zhu wrote: >>> 在 2023/8/12 下午8:25, Arnd Bergmann 写道: >>>> I found https://github.com/loongson-community/pmon source >>>> code, and a reference to its origin at LSI Logic at >>>> https://www.linux-mips.org/wiki/PMON but otherwise have >>>> no idea about what this actually is, or how it relates >>>> to your UEFI firmware. Did you add UEFI support to PMON, >>>> or do you use it as a first stage loader that loads >>>> the actual UEFI implementation (EDK2 or u-boot, I guess)? >>> >>> >>> Pmon and uefi are two different firmware, and there is no connection >>> between them. >> >> It sounds like we still have problems with terminology. > >> I don't think categorizing UEFI as a firmware is correct, > > > Sorry to have confused you, uefi firmware is our internal name, which is > actually what you referred to as EDK2, the EDK2 need use UEFI. Ok >> it's the interface used by various firmware implementations >> to load the operating system. As far as I understand, >> loongarch currently mandates the use of UEFI in whichever >> firmware is used, so if you have Pmon installed in ROM > and Pmon does not itself implement UEFI, it would have >> to load some other firmware such as u-boot in order to >> load a kernel through the UEFI protocol, right? > > > PMON is an independent firmware and loader that can directly load the > operating system and it does not require the use of UEFI. >> >> Has the assumption that loongarch requires UEFI changed? > > > LoongArch embedded board was use Pmon firmware, The other one uses UEFI > firmware (EDK2) on LoongArch platform. I'm pretty sure we discussed this when the loongarch port was originally merged, with the decisionto just use UEFI for booting any kernel, as the legacy entry point for the ACPI based environment was not really well-defined and the UEFI stub was an easy alternative to have more commonality with other architectures. I see this was already extended for embedded CPUs to use the uefi stub with DT in commit 88d4d957edc70 ("LoongArch: Add FDT booting support from efi system table"), which seems like the right direction. Can you explain why this board would want yet another method for entering the kernel? Is there any documentation for the boot protocol? >>>> Is this executing directly from ROM then? >>> >>> Yes. >> >> Is this the only runtime call into the firmware, > > > Only when suspend-to-ram occurs, the kernel will call into the firmware. > No other case. Ok >> or are there >> others that are either already called from mainline kernels >> or in your downsteam implementation? >> >> How do you ensure that the DTB matches the actual ROM code >> after rebuilding Pmon? Does Pmon itself fill that field with >> the correct address, or do you rely on it being a hardcoded >> constant? > > > Use Pmon, firmware team will always ensure that DTB matches the actual > ROM code. The "suspend-address" of dtb and pmon entry address will > synchronized modification by firmware team. Ok. So it's linked against libfdt to fill the dtb information, or do you have to provide a dtb blob that matches the firmware? Arnd
在 2023/8/14 下午9:41, Arnd Bergmann 写道: > On Mon, Aug 14, 2023, at 13:57, Yinbo Zhu wrote: >> 在 2023/8/14 下午4:19, Arnd Bergmann 写道: >>> On Mon, Aug 14, 2023, at 09:57, Yinbo Zhu wrote: >>>> 在 2023/8/12 下午8:25, Arnd Bergmann 写道: >>>>> I found https://github.com/loongson-community/pmon source >>>>> code, and a reference to its origin at LSI Logic at >>>>> https://www.linux-mips.org/wiki/PMON but otherwise have >>>>> no idea about what this actually is, or how it relates >>>>> to your UEFI firmware. Did you add UEFI support to PMON, >>>>> or do you use it as a first stage loader that loads >>>>> the actual UEFI implementation (EDK2 or u-boot, I guess)? >>>> >>>> >>>> Pmon and uefi are two different firmware, and there is no connection >>>> between them. >>> >>> It sounds like we still have problems with terminology. > >>> I don't think categorizing UEFI as a firmware is correct, >> >> >> Sorry to have confused you, uefi firmware is our internal name, which is >> actually what you referred to as EDK2, the EDK2 need use UEFI. > > Ok > >>> it's the interface used by various firmware implementations >>> to load the operating system. As far as I understand, >>> loongarch currently mandates the use of UEFI in whichever >>> firmware is used, so if you have Pmon installed in ROM > and Pmon does not itself implement UEFI, it would have >>> to load some other firmware such as u-boot in order to >>> load a kernel through the UEFI protocol, right? >> >> >> PMON is an independent firmware and loader that can directly load the >> operating system and it does not require the use of UEFI. >>> >>> Has the assumption that loongarch requires UEFI changed? >> >> >> LoongArch embedded board was use Pmon firmware, The other one uses UEFI >> firmware (EDK2) on LoongArch platform. > > I'm pretty sure we discussed this when the loongarch port > was originally merged, with the decisionto just use UEFI for > booting any kernel, as the legacy entry point for the ACPI > based environment was not really well-defined and the UEFI > stub was an easy alternative to have more commonality > with other architectures. > > I see this was already extended for embedded CPUs to use > the uefi stub with DT in commit 88d4d957edc70 ("LoongArch: Add > FDT booting support from efi system table"), which seems like > the right direction. > > Can you explain why this board would want yet another method > for entering the kernel? Is there any documentation for the > boot protocol? Yes, you're right, the latest PMON does indeed support UEFI, the PMON used in the product code is still outdated and does not support UEFI. Actually, whether using EDK2, Pmon firmware, or other firmware, the LoongArch platform's s3 (suspend-to-ram) requires a suspend-address to be defined, if dts is supported, it is defined in dts, and if acpi table is supported, it is defined in acpi table. > >>>>> Is this executing directly from ROM then? >>>> >>>> Yes. >>> >>> Is this the only runtime call into the firmware, >> >> >> Only when suspend-to-ram occurs, the kernel will call into the firmware. >> No other case. > > Ok > >>> or are there >>> others that are either already called from mainline kernels >>> or in your downsteam implementation? >>> >>> How do you ensure that the DTB matches the actual ROM code >>> after rebuilding Pmon? Does Pmon itself fill that field with >>> the correct address, or do you rely on it being a hardcoded >>> constant? >> >> >> Use Pmon, firmware team will always ensure that DTB matches the actual >> ROM code. The "suspend-address" of dtb and pmon entry address will >> synchronized modification by firmware team. > > Ok. So it's linked against libfdt to fill the dtb information, > or do you have to provide a dtb blob that matches the firmware? For pmon firmware, the dtb was as part of firmware, the firmware has defined the address of the DTB's suspend and the address of the firmware entry, and is consistent. Thanks, Yinbo
diff --git a/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml new file mode 100644 index 000000000000..da2dcfeebf12 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/loongson/loongson,ls2k-pmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson-2 Power Manager controller + +maintainers: + - Yinbo Zhu <zhuyinbo@loongson.cn> + +properties: + compatible: + items: + - enum: + - loongson,ls2k0500-pmc + - loongson,ls2k1000-pmc + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + loongson,suspend-address: + $ref: /schemas/types.yaml#/definitions/uint64 + description: + The "loongson,suspend-address" is a deep sleep state (Suspend To + RAM) firmware entry address which was jumped from kernel and it's + value was dependent on specific platform firmware code. In + addition, the PM need according to it to indicate that current + SoC whether support Suspend To RAM. + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + power-management@1fe27000 { + compatible = "loongson,ls2k1000-pmc", "syscon"; + reg = <0x1fe27000 0x58>; + interrupt-parent = <&liointc1>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + loongson,suspend-address = <0x0 0x1c000500>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 1089ef3319f2..608a00473498 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12365,6 +12365,12 @@ S: Maintained F: Documentation/devicetree/bindings/hwinfo/loongson,ls2k-chipid.yaml F: drivers/soc/loongson/loongson2_guts.c +LOONGSON-2 SOC SERIES PM DRIVER +M: Yinbo Zhu <zhuyinbo@loongson.cn> +L: linux-pm@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/soc/loongson/loongson,ls2k-pmc.yaml + LOONGSON-2 SOC SERIES PINCTRL DRIVER M: zhanghongchen <zhanghongchen@loongson.cn> M: Yinbo Zhu <zhuyinbo@loongson.cn>