Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Miao Wang <shankerwangmiao@gmail.com>
To: Xi Ruoyao <xry111@xry111.site>
Cc: Binbin Zhou <zhoubinbin@loongson.cn>,
	Chong Qiao <qiaochong@loongson.cn>, Lee Jones <lee@kernel.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	Corey Minyard <corey@minyard.net>,
	Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>, Yinbo Zhu <zhuyinbo@loongson.cn>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	mfd@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-gpio@vger.kernel.org,
	openipmi-developer@lists.sourceforge.net
Subject: Re: [PATCH RFC v2 7/7] mfd: ls2kbmc: Capture the reset event of BMC through GPIO
Date: Wed, 8 Jul 2026 22:16:49 +0800	[thread overview]
Message-ID: <D141EDD3-BEC0-458B-B477-9227B3FB93AC@gmail.com> (raw)
In-Reply-To: <5d6ea500e983035a2e5748e1bbf8ed6c26ac6f4b.camel@xry111.site>

Hi,

> 2026年7月8日 21:14,Xi Ruoyao <xry111@xry111.site> 写道:
> 
> On Wed, 2026-07-08 at 05:16 +0800, Miao Wang via B4 Relay wrote:
>> From: Miao Wang <shankerwangmiao@gmail.com>
>> 
>> The reset event of BMC is captured through GPIO. However, this driver
>> bypasses the GPIO framework and directly accesses the GPIO controller
>> through the fixed address. When the same GPIO controller is also
>> exposed through ACPI and probed by the corresponding GPIO driver,
>> there would be a conflict between the two drivers.
>> 
>> This patch will try to find the GPIO through declared GPIO pin in the
>> _CRS resources of the ACPI node. If no such delaration is found, the
>> driver will fall back to search for the correct GPIO controller and pin
>> according to the fixed address and pin number. A possible DSDT
>> declaration for the GPIO pin might be as follows:
>> 
>>     Device (BMC0) {
>>         Name (_ADR, ...) // Match the PCI address of the BMC device
>>         // \_SB.GPO1 is the ACPI path of the GPIO controller
>>         Name (_CRS, ResourceTemplate () {
>>             GpioInt (Edge, ActiveLow, Exclusive, PullNone, 0,
>>                      "\\_SB.GPO1", 0) {
>>                 14 // 14 is the GPIO pin number
>>             }
>>     }
> 
> I think this is a proposal without real implementation yet?  If so...
> 
> /* snip */
> 
>> + adev = to_acpi_device_node(fwnode);
>> + if (!adev)
>> + goto out;
>> +
>> + INIT_LIST_HEAD(&resource_list);
>> +
>> + ret = acpi_dev_get_memory_resources(adev, &resource_list);
>> + if (ret < 0)
>> + goto out;
>> + rentry = list_first_entry_or_null(&resource_list, struct resource_entry, node);
>> + if (!rentry)
>> + goto free_resource_list;
>> + if (rentry->res->start == start_addr)
>> + found = 1;
>> +
>> +free_resource_list:
>> + acpi_dev_free_resource_list(&resource_list);
> 
> ... consider adding a _DSD method to label (like "bmc-reset") the GPIO
> for the proposed BMC0 device so you can use devm_gpiod_get to get the
> GPIO, instead of using the hand-brew code to parse the ACPI node. 
> See https://www.kernel.org/doc/html/latest/firmware-guide/acpi/gpio-properties.html.

Yes, it is a proposal. GpioInt() in the _CRS() should be at least
required to associate the BMC device to the GPIO pin. Having a _DSD
might be better to label the gpio pin with human readable label. I
however don't think _DSD is important because there is only one pin
needed, and devm_gpiod_get_index can be used to obtain the gpio line
description using the index in _CRS()

> 
> Combining this with Bartosz's comment, the logic would be like:
> 
>  if (missing the ACPI node)
>    assign a swnode to label "gpio14" as "bmc-reset";

I'll further look into whether swnode can be used.

>  gpio_desc = devm_gpiod_get(&dev, "bmc-reset", GPIOD_IN);
> 
> And such a proposal will need to be discussed with Loongson.  Yes I know
> people may hate the "control" from the vendor, but having some
> effectively dead code (i.e. supporting some non-exist firmware) in the
> kernel is worse.

I'm open with such discussions.

Cheers,

Miao Wang



      reply	other threads:[~2026-07-08 14:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 21:16 [PATCH RFC v2 0/7] mfd: ls2kbmc: multiple fixes for this driver Miao Wang via B4 Relay
2026-07-07 21:16 ` [PATCH RFC v2 1/7] mfd: ls2kbmc: Make a copy when parsing mode string Miao Wang via B4 Relay
2026-07-07 21:16 ` [PATCH RFC v2 2/7] mfd: ls2kbmc: Sanity check for the connected pci port Miao Wang via B4 Relay
2026-07-07 21:16 ` [PATCH RFC v2 3/7] mfd: ls2kbmc: Redraw using exported functions Miao Wang via B4 Relay
2026-07-07 21:16 ` [PATCH RFC v2 4/7] mfd: ls2kbmc: Cancel the work queue on removal Miao Wang via B4 Relay
2026-07-07 21:16 ` [PATCH RFC v2 5/7] ipmi: ls2k: Relax the dependency to its mfd driver Miao Wang via B4 Relay
2026-07-07 21:16 ` [PATCH RFC v2 6/7] mfd: ls2kbmc: Able to be compiled as a module Miao Wang via B4 Relay
2026-07-07 21:16 ` [PATCH RFC v2 7/7] mfd: ls2kbmc: Capture the reset event of BMC through GPIO Miao Wang via B4 Relay
2026-07-08 11:36   ` Bartosz Golaszewski
2026-07-08 12:15     ` Miao Wang
2026-07-08 12:55       ` Bartosz Golaszewski
2026-07-08 13:14   ` Xi Ruoyao
2026-07-08 14:16     ` Miao Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D141EDD3-BEC0-458B-B477-9227B3FB93AC@gmail.com \
    --to=shankerwangmiao@gmail.com \
    --cc=brgl@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=corey@minyard.net \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=lee@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=qiaochong@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=zhoubinbin@loongson.cn \
    --cc=zhuyinbo@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox