Skip to content

QCM6490 (Particle Tachyon): auto-detect gpiochip for f100000.pinctrl - #1111

Merged
makermelissa merged 4 commits into
adafruit:mainfrom
tyeth-ai-assisted:tachyon-qcm6490-gpiochip4-fix
May 23, 2026
Merged

QCM6490 (Particle Tachyon): auto-detect gpiochip for f100000.pinctrl#1111
makermelissa merged 4 commits into
adafruit:mainfrom
tyeth-ai-assisted:tachyon-qcm6490-gpiochip4-fix

Conversation

@tyeth-ai-assisted

@tyeth-ai-assisted tyeth-ai-assisted commented May 18, 2026

Copy link
Copy Markdown

Summary

  • On Ubuntu 20.04 BSP, the QCM6490 main GPIO bank (f100000.pinctrl, 176 lines) was enumerated as gpiochip0, so plain Pin(n) worked fine.
  • On later BSPs it appears as gpiochip4, making gpiochip0 only 12 lines (PMIC GPIOs) — any line > 11 fails with EINVAL.
  • Replace the hardcoded Pin(GPIO_BASE + n) form with a _pin(line) helper that auto-detects the correct chip at import time using gpiod.ChipIter() (1.x) or /dev/gpiochipN probing (2.x), then uses Pin((chip, line)) tuples — already supported by both Blinka libgpiod layers.
  • Falls back to chip 0 if f100000.pinctrl is not found, preserving Ubuntu 20.04 behaviour unchanged.

Test plan

  • Verify GPIO_CHIP detects 4 on current Particle Tachyon BSP - Ubuntu 24.04 (gpiodetect shows gpiochip4 [f100000.pinctrl])
  • Verify GPIO_CHIP detects 0 on Ubuntu 20.04 BSP (or any system where f100000.pinctrl is gpiochip0)
  • SPI TFT (ILI9341) GPIO pins (lines 24, 44, 59) initialise without EINVAL
  • gpiod.ChipIter() path exercised on gpiod 1.x
  • /dev/gpiochipN probe path exercised on gpiod 2.x

🤖 Generated with Claude Code

tyeth and others added 3 commits May 18, 2026 14:39
All 40-pin header GPIOs are on gpiochip4 (176 lines).  gpiochip0 has
only 12 lines, so plain Pin(n) fails for any line > 11.  Introduce
_pin(line) which passes a (chip, line) tuple — safe for both gpiod 1.x
(OPEN_BY_NUMBER) and 2.x.  The version branch is kept explicit for easy
future divergence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On Ubuntu 20.04 BSP f100000.pinctrl (176-line main bank) was gpiochip0
so plain Pin(n) worked.  On later BSPs it is gpiochip4, making gpiochip0
only 12 lines and breaking any line > 11.

Replace the hardcoded GPIO_CHIP=4 with _find_qcm6490_chip() which:
 - uses gpiod.ChipIter() on gpiod 1.x (zero overhead, clean API)
 - falls back to probing /dev/gpiochipN on gpiod 2.x
 - returns 0 if f100000.pinctrl is not found (Ubuntu 20.04 fallback)

_pin() always uses Pin((GPIO_CHIP, line)) tuples; both Blinka libgpiod
layers (1.x and 2.x) handle the tuple form correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a reflection loop that publishes all GPIO_N names from the pin
module (GPIO_6, GPIO_24, GPIO_44, …) as board.GPIO_N, consistent with
other boards (dragonboard_410c, beaglebone_black, etc.) that expose
raw GPIO line-number names alongside their header-pin aliases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tyeth

tyeth commented May 19, 2026

Copy link
Copy Markdown
Member

I needed this on Ubuntu 24 when testing blinka with 2.2" ILI9341 + EYESPI Beret

@tyeth
tyeth marked this pull request as ready for review May 23, 2026 01:31
@tyeth

tyeth commented May 23, 2026

Copy link
Copy Markdown
Member

This does return proper pin objects, and pass CI, but not sure if it's an ideal fix, @makermelissa you'd probably know best.

@tyeth
tyeth requested a review from makermelissa May 23, 2026 01:31

@makermelissa makermelissa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me. Since these files are specific to each board, it's fine if it's a bit quirky.

@makermelissa
makermelissa merged commit f89b764 into adafruit:main May 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants