[26.04_linux-nvidia-bos] i2c: mediatek: add ACPI/MT8901 support and gpiolib zero-debounce fix - #518
Conversation
…or zero debounce Some GPIO controllers (e.g. MediaTek EINT used in pinctrl-paris) reject set_config(PIN_CONFIG_INPUT_DEBOUNCE, 0) with -EINVAL when the underlying interrupt is edge-triggered, even though the argument is 0 (meaning "no debounce"). ACPI _CRS GpioInt/GpioIo resources that declare DebounceTimeout=0 caused gpio_set_debounce_timeout() to call into that path, the chip returned -EINVAL, and the error propagated through gpiod_get_index() and acpi_dev_gpio_irq_get(), breaking ACPI consumers. A debounce timeout of 0 means "no debounce" - there is nothing to configure, so short-circuit the call inside gpio_set_debounce_timeout() itself and return success without touching the controller. This fixes all callers (the ACPI core call sites and any future ones) without having to add the same guard at every call site. Signed-off-by: Abhishek Sahu <abhsahu@nvidia.com> Signed-off-by: Kiran Maddaraki <kmaddaraki@nvidia.com>
…naged clocks On MT8901-based platforms the I2C controllers are described through ACPI (HID NVDA0200) rather than device tree. The upstream i2c-mt65xx driver is DT-only: no acpi_match_table, no propagation of the ACPI fwnode to the i2c_adapter device, and clock/timing properties read through of_property_read_*() helpers that don't operate on ACPI nodes. Compounding that, on these platforms firmware keeps the controller's "main" and "dma" clocks running and does not expose them via the Linux clk framework, so devm_clk_get() returns -ENOENT for both. Consequently the driver does not bind on ACPI systems: no i2c_adapter is created, HID-over-I2C never enumerates child devices, and the internal I2C keyboard stays silent. Wire up ACPI and accept firmware-managed clocks: * Add mt8901_compat (v3 register layout, default_parent_rate=124.8 MHz as a stand-in for clk_get_rate() when no clock provider is exposed) and an acpi_match_table entry NVDA0200 -> mt8901_compat. * Replace of_device_get_match_data() with device_get_match_data() in probe (with a NULL-match check), and switch mtk_i2c_parse_dt() to the fwnode-aware device_property_read_*() helpers so DT and ACPI share the same probe path. * Call device_set_node(&adap->dev, dev_fwnode(&pdev->dev)) so the ACPI fwnode reaches the i2c_adapter device; without it, has_acpi_companion() on the adapter returns 0 and i2c_acpi_register_devices() exits early, leaving HID children unenumerated. * Gate devm_clk_get() for "main"/"dma" on has_acpi_companion() - use devm_clk_get_optional() in the ACPI branch so absent clocks are accepted, and substitute i2c->dev_comp->default_parent_rate when mtk_i2c_set_speed() has no clock handle to query. Signed-off-by: Housong Zhang <housong.zhang@mediatek.com> Signed-off-by: Kiran Maddaraki <kmaddaraki@nvidia.com>
PR Validation ReportPatchscan ✅ No Missing FixesAll cherry-picked commits checked — no missing upstream fixes found. PR Lint ❌ Errors foundDetailsChecking 2 commits... Cherry-pick digest: ┌──────────────┬──────────────────────────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐ │ Local │ Referenced upstream / Patch subject │ Patch-ID │ Subject │ SoB chain │ ├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤ │ 5877724aeb09 │ [SAUCE] i2c: mediatek: add acpi/mt8901 support and firmware-mana │ N/A │ N/A │ zhang, kmaddara │ ├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤ │ 0bc959452137 │ [SAUCE] gpiolib: return early in gpio_set_debounce_timeout() for │ N/A │ N/A │ abhsahu, kmaddara │ └──────────────┴──────────────────────────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘ Lint: all checks passed. PR metadata: E: PR targets 26.04_linux-nvidia-bos but body has no https://bugs.launchpad.net/... link |
BaseOS Kernel ReviewSummaryThe gpiolib change leaves existing hardware debounce enabled when firmware requests zero, while the MediaTek I2C change masks malformed clock-div properties and may program incorrect bus timing. Findings: Critical: 0, High: 0, Medium: 2, Low: 0 Latest watcher review: open review Generated test plan: open test plan Kernel deb build: successful (download debs, 4 files) Head: This comment is maintained by nv-pr-bot. It is updated when the GitHub watcher publishes a newer review. |
Additionally, my review with Codex had one finding: Medium: drivers/i2c/busses/i2c-mt65xx.c:1390 now defaults missing clock-div to 1 for both ACPI and DT. The comment says this is for ACPI, but DT still uses this same parser, and the binding requires clock-div at Documentation/devicetree/bindings/i2c/i2c-mt65xx.yaml:110. Previously a missing or bad DT clock-div failed probe; now it silently probes with different timing. I’d gate the default on has_acpi_companion(i2c->dev) and keep returning the property-read error for DT. |
|
@nvmochs
What is the target platform for this? Spark?
Related, is there a NVbug associated with these patches?
This same PR needs to also be submitted against the 7.0-lts kernel (26.04_linux-nvidia). |
@kmaddaraki Thanks for clarifying. Please address the codex/claude findings listed here and in PR 507 and then we should be able to get this merged. |
Two small SAUCE patches to bring up the MediaTek MT8901 I²C host controller under ACPI on Ubuntu 24.04 nvidia-7.0.
gpiolib: return early in gpio_set_debounce_timeout() for zero debounce
Some GPIO controllers (MediaTek EINT among them) reject set_config(PIN_CONFIG_INPUT_DEBOUNCE, 0) with -EINVAL on edge-triggered lines. When an ACPI _CRS GpioInt/GpioIo declares DebounceTimeout=0, the error propagates through gpiod_get_index() / acpi_dev_gpio_irq_get() and blocks HID-over-I²C from acquiring its interrupt. A debounce timeout of 0 means "no debounce" — nothing to configure — so short-circuit inside gpio_set_debounce_timeout() itself. Fixes all call sites (present and future) without per-site guards.
i2c: mediatek: add ACPI/MT8901 support and firmware-managed clocks
Adds ACPI binding to the DT-only i2c-mt65xx driver so the MT8901 I²C controllers enumerate under NVDA0200:
New mt8901_compat (v3 register layout, default_parent_rate=124.8 MHz) and an acpi_match_table entry NVDA0200 → mt8901_compat.
Switch probe to device_get_match_data() and fwnode-aware device_property_read_*() so DT and ACPI share the same code path.
device_set_node(&adap->dev, dev_fwnode(&pdev->dev)) so i2c_acpi_register_devices() walks the child HID nodes and instantiates them.
Gate devm_clk_get() for main/dma on has_acpi_companion() — use devm_clk_get_optional() for the ACPI path (firmware keeps those clocks running and does not expose them via the Linux clk framework), and fall back to dev_comp->default_parent_rate in mtk_i2c_set_speed() when no clock handle is available.
DT behaviour is unchanged: both device_get_match_data() and device_property_read_*() fall through to the existing OF helpers for DT-described nodes, and the DT clock path is preserved.