On Wed, 8 Jul 2026 14:15:55 +0200, Miao Wang <[email protected]> said:
> Hi
>
>> 2026年7月8日 19:36,Bartosz Golaszewski <[email protected]> 写道:
>>
>> On Tue, 7 Jul 2026 23:16:31 +0200, Miao Wang via B4 Relay
>> <[email protected]> said:
>>> From: Miao Wang <[email protected]>
>>>
>>> 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
>>>            }
>>>    }
>>>
>>> Signed-off-by: Miao Wang <[email protected]>
>>> ---
>>> drivers/mfd/ls2k-bmc-core.c | 162 
>>> +++++++++++++++++++++++++++++++-------------
>>> 1 file changed, 115 insertions(+), 47 deletions(-)
>>>
>>> diff --git a/drivers/mfd/ls2k-bmc-core.c b/drivers/mfd/ls2k-bmc-core.c
>>> index 
>>> f87224105b3720cca97dcef089dad63fe57bc8c2..7187b2dfddc3acfb9fdf3cb3b4675299928dd03a
>>>  100644
>>> --- a/drivers/mfd/ls2k-bmc-core.c
>>> +++ b/drivers/mfd/ls2k-bmc-core.c
>>> @@ -26,6 +26,9 @@
>>> #include <linux/stop_machine.h>
>>> #include <linux/vt_kern.h>
>>> #include <linux/console.h>
>>> +#include <linux/gpio/consumer.h>
>>> +#include <linux/gpio/driver.h>
>>> +#include <linux/gpio.h>
>>
>> I've stopped here because this is a legacy header that must not be included
>> and none of the interfaces in it must be used, as per the - very loud - 
>> comment
>> at the top of that file.
>
> I fully understand using the legacy interface is deprecated. However, there
> seems no other way to obtain a gpio line description after a gpio device
> is found using gpio_device_find(). As the comment shows in the code below,
> the only place I use the legacy interface is:
>
> gdev = gpio_device_find(...);
> desc = gpio_device_get_desc(gdev, LS2K_BMC_RESET_GPIO);
>

No, new code using legacy API is *not* acceptable. That's an official NAK.

> // XXX: might be better to use gpiod_request()
> legacy_gpio = desc_to_gpio(desc);
> devm_gpio_request_one(..., legacy_gpio, ...);
> return gpio_to_desc(legacy_gpio);
>
> I just borrowed the legacy gpio interface to request the irq description. I
> think that gpiod_request() should be better to be used here, but it is not
> an interface that is exposed. As a result, I post this patch as a PoC here
> to discuss and find a better way to achieve this.
>

If the firmware doesn't describe the GPIO, you have at least two alternatives.
Please look at Documentation/driver-api/gpio/legacy-boards.rst. You should be
able to use either software nodes or GPIO lookup tables. This document
describes the conversion from the latter to the former but - while software
nodes are preferred - lookup tables are not deprecated so feel free to use
it to set up the descriptors.

Bart


_______________________________________________
Openipmi-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openipmi-developer

Reply via email to