Re: [PATCH RFC v2 7/7] mfd: ls2kbmc: Capture the reset event of BMC through GPIO
From: Xi Ruoyao
Date: Wed Jul 08 2026 - 09:18:39 EST
On Wed, 2026-07-08 at 05:16 +0800, Miao Wang via B4 Relay wrote:
> From: Miao Wang <shankerwangmiao@xxxxxxxxx>
>
> 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.
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";
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.
--
Xi Ruoyao <xry111@xxxxxxxxxxx>