Skip to content

ingenic: T41 pad-mux from the HDK workbook, and MIS sensor probing - #286

Merged
dimerr merged 3 commits into
OpenIPC:masterfrom
dimerr:ingenic-t41-padmux
Nov 17, 2026
Merged

dimerr merged 3 commits into
OpenIPC:masterfrom
dimerr:ingenic-t41-padmux

Conversation

@dimerr

@dimerr dimerr commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Two Ingenic gaps that T41 support in OpenIPC firmware (OpenIPC/firmware#2877) runs into.

1. MIS sensors were never probed on Ingenic

detect_imagedesign_sensor() already identifies MIS2003, MIS2006, MIS2008, MIS4001 and MIS5001. But the Ingenic HAL's address list never included the ImageDesign vendor, so the probe never ran on an Ingenic camera.

openingenic has drivers for all of these:

  • T21: mis2003
  • T31: mis2006, mis2008, mis4001, mis5001
  • T41: mis4001

The change adds ImageDesign at 0x30 (7-bit) to the Ingenic list.

2. Pad-mux for T41

Source. The table comes from the T41 HDK (T41 HDK_20230418.zip, shipped in the Tomcat SDK release). Its GPIO Recommended Allocation Table has a sheet, "T41 IO function list", that gives FUNC0..FUNC3 for every pad, named per wire, like T31's GPIO spec. (T40GPIO.xlsx is a different kind of spreadsheet: one reference board's net list.) The generator gains a fourth source kind, sheet. 88 of 128 pads are covered, across four ports.

Cross-checks:

  • t41-pinctrl.dtsi: every routing agrees with the sheet (152 pins), except the three vic_pa_* nodes.
    • Those nodes put DVP on FUNCTION0 of PA00..PA14.
    • The T41L data sheet (Pin Description, v0.9) has the static-memory bus on FUNCTION0 and DVP on FUNCTION1, as the sheet does.
    • The nodes would also collide with the devicetree's own i2c0_pa (PA12/PA13, FUNCTION1).
    • So the vic_pa_* nodes look copied from T40.
  • Gaps in the sheet, confirmed by the data sheet: the sheet leaves out FUNCTION0 (static memory) on PA06..PA19, and PA10/PA11 entirely. The generated header records both.
  • Left out: the six analog MIPI pins at the bottom of port A have no GPIO name in the sheet, so they are not in the table.

Controller. No change is needed:

  • GPIO_IOBASE and the register defines in the soc-t41 headers are T40's.
  • The kernel pinctrl driver gives ingenic,t41-pinctrl the same data as ingenic,t40-pinctrl.
  • reginfo dumps T40's four-port register list for T41.

The generated banner now quotes --spec, because the workbook's file name has spaces.

Testing

Host only; not run on a T41 camera.

  • reginfo_test: the table sweep and the set/get round trip now include T41. New per-wire checks cover PC15 (PWM0 at FUNCTION2, EXCLK at 3) and I2C0 on PA12, and check that unnamed pads (PA00, PA10) are absent.
  • All other runs passed: every build/*_test passes, as does tools/test_pipeline.sh; gen_padmux_names.py --check is up to date.
  • mips32 build: builds with the OpenIPC musl toolchain; ipcinfo grows by 16 bytes.
  • Not done: clang-format is not installed here, so scripts/format-changed did not run. New lines are kept within 80 columns by hand.

A T41 board can settle it the way the other parts were: run ipctool reginfo --pads, decode PxINT/PxMSK/PxPAT1/PxPAT0 independently, and diff the two.

detect_imagedesign_sensor() knows MIS2003, MIS2006, MIS2008, MIS4001 and
MIS5001, but the Ingenic HAL never listed the vendor, so on an Ingenic
camera the probe never ran and these sensors came out as no sensor.
openingenic carries drivers for all of them: mis2003 for T21,
mis2006/2008/4001/5001 for T31 and mis4001 for T41. They sit at 0x30
(7-bit), the address SmartSens uses.
T41 has a source T40 did not: the T41 HDK ships a GPIO Recommended
Allocation Table whose "T41 IO function list" sheet gives FUNC0..FUNC3 for
every pad of the SoC, named per wire like T31's GPIO spec. Not the kind of
spreadsheet T40GPIO.xlsx is -- that one is a reference board's net list.
The generator reads it as a fourth source kind, "sheet", and finds its
columns by header text. 88 of 128 pads across four ports.

Checked against the two other sources there are. Every routing in the
kernel's t41-pinctrl.dtsi agrees with it -- 152 pins -- except the three
vic_pa_* nodes, which put DVP on FUNCTION0 of PA00..PA14. The T41L data
sheet (Pin Description, v0.9) has the static-memory bus on FUNCTION0 and
DVP on FUNCTION1, as the sheet does, and those nodes would also overlap
the devicetree's own i2c0_pa on PA12/PA13 at FUNCTION1: a T40 copy. The
data sheet also shows what the sheet leaves out -- the static-memory
function of PA06..PA19, and PA10/PA11 -- so the header says so. The six
analog MIPI pins at the bottom of port A have no GPIO name in the sheet
and are not in the table.

The controller needs nothing: GPIO_IOBASE and the register defines in
soc-t41's headers are T40's, and the kernel's pinctrl driver gives
ingenic,t41-pinctrl the same data as ingenic,t40-pinctrl. reginfo dumps
T40's four-port list.

The spec path in the generated banner is quoted now: the workbook's name
has spaces.

No T41 camera, so this is host-verified only: reginfo_test's sweep and
set/get round trip now include T41, plus per-wire checks on PC15 (PWM0 at
FUNCTION2, EXCLK at 3) and I2C0 on PA12; all unit tests,
test_pipeline.sh, and a mips32 build. ipcinfo +16 bytes.
@dimerr
dimerr marked this pull request as ready for review November 17, 2026 04:33
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add T41 pad-mux names and enable Ingenic MIS sensor probing

✨ Enhancement 🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add HDK-derived T41 pad-mux names so supported pads can be inspected and selected.
• Probe MIS sensors on Ingenic cameras by adding ImageDesign’s I²C address.
• Document source limitations and extend host tests for T41 routing and table integrity.
Diagram

graph TD
  Workbook["T41 workbook"] --> Generator["Pad-mux generator"] --> Table["T41 pad table"] --> Backend["Ingenic backend"] --> GPIO["GPIO registers"]
  Dispatch["Pad-mux dispatch"] --> Backend
  HAL["Ingenic HAL"] --> Probe["MIS sensor probe"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Generate T41 mappings from pinctrl devicetree
  • ➕ Reuses the existing devicetree parser.
  • ➖ Provides device-and-port names rather than per-wire names.
  • ➖ Its three VIC port-A routes conflict with the workbook and data sheet.

Recommendation: Keep the workbook as the T41 source: it provides per-wire FUNC0–FUNC3 mappings and avoids the conflicting VIC devicetree routes. Retain explicit omissions rather than inferring undocumented functions, and validate the resulting table against live T41 registers when a board is available.

Files changed (10) +606 / -56

Enhancement (7) +554 / -52
ingenic_padmux.cSelect the T41 pad table in the Ingenic backend +2/-0

Select the T41 pad table in the Ingenic backend

• Maps the T41 chip generation to its new pad table while retaining the existing Ingenic register handling.

src/hal/ingenic_padmux.c

ingenic_padmux.hAdd HDK-derived mappings for 88 T41 pads +105/-1

Add HDK-derived mappings for 88 T41 pads

• Adds per-wire FUNC0–FUNC3 entries across four ports. The generated comments identify workbook gaps, and pads without a GPIO name remain absent.

src/hal/ingenic_padmux.h

padmux.cRoute T41 to the Ingenic pad-mux operations +1/-0

Route T41 to the Ingenic pad-mux operations

• Enables pad-mux API dispatch to the existing Ingenic implementation for T41.

src/padmux.c

padmux_names.cInitialize names used by the T41 mappings +118/-16

Initialize names used by the T41 mappings

• Adds Ingenic-gated signal and pad strings, including BT656, SFC, clock, PWM, I²C, and UART names needed by the new table.

src/padmux_names.c

padmux_names.hDefine T41 name fields and pad-mux offsets +236/-32

Define T41 name fields and pad-mux offsets

• Mirrors the new Ingenic-gated names in the name structure and its PMX offset macros so the T41 table can reference them.

src/padmux_names.h

reginfo.cInclude T41 in Ingenic register dumps +2/-0

Include T41 in Ingenic register dumps

• Uses the existing four-port T40 register list and dump mask for T41.

src/reginfo.c

gen_ingenic_padmux.pyParse T41 IO-function workbook sheets +90/-3

Parse T41 IO-function workbook sheets

• Adds a sheet source that locates FUNC columns by header, normalizes wire names, skips unnamed pads, and rejects duplicate or invalid mappings. Quotes source filenames in the generated command banner.

tools/gen_ingenic_padmux.py

Bug fix (1) +5 / -0
ingenic.cInclude ImageDesign in Ingenic sensor candidates +5/-0

Include ImageDesign in Ingenic sensor candidates

• Adds the MIS sensor address to the Ingenic candidate list, allowing the existing ImageDesign identification probe to run.

src/hal/ingenic.c

Tests (1) +30 / -0
reginfo_test.cTest T41 pad lookups and table integrity +30/-0

Test T41 pad lookups and table integrity

• Checks PC15 PWM0 and EXCLK routing, I²C0 on PA12, absent unnamed pads, and out-of-range access. Adds T41 to the table sweep and set/get round-trip coverage.

src/reginfo_test.c

Documentation (1) +17 / -4
padmux.mdDocument the T41 workbook source and coverage limits +17/-4

Document the T41 workbook source and coverage limits

• Adds the T41 generation command and explains why the HDK IO function list is preferred to its pinctrl devicetree. Records omitted pads, blank static-memory functions, and the lack of on-device validation.

docs/padmux.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Informational

1. Comment still says T41 has no pad table ✓ Resolved
Description
The comment on the 0xAAAA branch of get_cpu_id() still says this T41NQ has no pad table because
ingenic_soc() only knows T21, T23, T31 and T40, and that a T41 table would be the fix. This PR
adds case T41: return &T41_padmux;, so that camera now uses the new table for lookups and sets; a
reader debugging pad muxing there will be told the opposite of what the code does.

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

The comment on that branch of get_cpu_id() still said T41 had no table.
@dimerr
dimerr merged commit 231064e into OpenIPC:master Nov 17, 2026
5 checks passed
@dimerr
dimerr deleted the ingenic-t41-padmux branch November 17, 2026 04:40
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.

2 participants