Repository navigation
anyka: pad mux and GPIO for the AK3918AV100 family (AV100, AV100X, EV300L) - #291
Conversation
…300L) ipctool had no Anyka pad-mux backend and no Anyka `gpio get/set/scan`, so `gpio mux` and `gpio scan` on these cameras had nothing to say. An owner hunting the IR-cut pins on an AK3918EV300L with sysfs GPIOs hung the camera on pads 0..11 and 71: those are the Ethernet MAC's RMII lines and the PHY reset (OpenIPC/majestic#380). The layout is the vendor kernel's: a three-bit field per pad in the SYSCTRL share-pin registers at 0x08000178 + 4 * reg (ak_3918av100_pinctrl.c, pin_set_share()), and the function each value selects is the device-tree binding header's XGPIO_nnn_FUNC_name. - tools/gen_anyka_padmux.py reads ak_sharepin[] and the binding header into src/hal/anyka_padmux.h, one table per machine: it evaluates the driver's #ifdef CONFIG_MACH_* for AK3918AV100 (93 pads) and AK3918EV300L (59 pads). It refuses a selector past the driver's func_mux_max or wider than the field, a pad whose GPIO function is not GPIO<pad> at the driver's gpio_func_no, duplicate selectors, functions for a pad the driver lacks, and preprocessor lines it cannot evaluate. From OpenIPC/linux anyka-ak3918av100@10a8a32b. - src/hal/anyka_padmux.c is the backend. A pad is its GPIO number. GPIO is found by name, since it is selector 3 on pad 22 and 1 on pad 98. GPIO37/GPIO50 have no field and their rows no address; GPIO80/81 are the PMU's and are left out. Only the selector is written. A pad on SPI0_* (the NOR), RMII_* or OPCLK* (the network) is in_use(), so moving it takes --force. - src/hal/anyka_gpio.c drives the GPIO block at 0x20170000 (DIR, OUT, IN at +0x00/+0x14/+0x28), as ak_gpio_get/ak_gpio_set do: an output reads OUT, an input IN, and a write sets the level before the direction. `gpio get/set/scan` and the IR-cut guess use it on AV100 and EV300L, for pads muxed to GPIO only; `gpio set` on a pad that is not refuses. - The other Anyka generations dispatch to the backend and answer NO_TABLE rather than falling through to the HiSilicon tables. - The in-use refusal now says "its boot flash or network". - CMake family "anyka", dropped when the Anyka HAL is not selected; padmux_names regenerated; the CI pad-mux sweep builds "anyka" alone. - reginfo_test: AV100 and EV300L in the integrity sweep, and test_anyka() with the values from that EV300L's pinmux-pins: PWM0 on pad 16 at 2, CSI0_SCLK on 22 with GPIO at 3, OPCLK1/RMII on 0 and 1 refused, GPIO37's no-op, a pad the EV300L lacks. - docs/padmux.md: the Anyka section and the regenerate recipe. On qemu-bench ak3918ev300l (OpenIPC kernel, static arm32 build): `gpio mux` reads OPCLK1 on 0, RMII_RXER on 1, PWM0 on 16, CSI0_SCLK on 22 and SPI0_WP on 42, matching the kernel's pinmux-pins; `gpio set 25 1` then `gpio get 25` reads 1; `gpio set 0 1` and moving pad 1 to GPIO are refused; `gpio scan` lists only GPIO-muxed pads. Not yet run on a camera.
PR Summary by QodoAdd Anyka AK3918AV100-family pad mux and GPIO support
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
Review of #291: - A pad the kernel holds is in_use() and `gpio set` refuses it without --force. anyka_gpio_owner() reads, once per run, the pinctrl mux owners (debugfs pinctrl/*/pinmux-pins), the GPIOs handed to drivers (debugfs gpio; a sysfs export by the user does not count) and the *-gpio(s) properties of enabled device-tree nodes. On #380's EV300L that is the PHY's reset-gpios on GPIO71, the MAC's GPIO23, the SD card's GPIO37 and GPIO98, the sensor resets and the MIPI switch select. `gpio scan` says "held by <owner>" for those, and the IR-cut guess skips them. - A pad whose selector the table has no name for is no longer moved by an unforced ipchw_padmux_set(), on any backend with an in_use() hook (Anyka, Fullhan). reginfo_test's Fullhan sequence now expects that. - `gpio get` on a pad not muxed to GPIO refuses, as `gpio set` did, instead of printing the controller's latch as the pin's level. - The header comment lists the network pads as the table has them (OPCLK1 on 0, RMII_* on 1..8 and 11) and names the held ones; the over-long comment line is rewrapped. - reginfo_test: owners from a fabricated debugfs and device tree (a user export, a disabled node and the 0xffff "no pin" are nobody's), pad 23 refused, the unknown selector refused and then forced. On qemu-bench ak3918ev300l: `gpio set 71 0` and `gpio set 18 0` are refused naming reset-gpios and sensor-reset, `gpio mux 23 CSI_D4` and `gpio get 0` are refused, and `gpio scan` lists the held pads with their owners.
|
On the Qodo review, all five are addressed in c9c1c72:
Re-tested: |
Problem
ipctool had no Anyka pad-mux backend and no Anyka
gpio get/set/scan, so on Anyka camerasgpio muxandgpio scanhad nothing to say.On OpenIPC/majestic#380, an owner hunting the IR-cut pins of an AK3918EV300L through sysfs GPIOs hung the camera on pads 0–11 and 71. Those are the Ethernet MAC's RMII lines and the PHY reset.
Change
The register layout comes from the vendor kernel (OpenIPC/linux
anyka-ak3918av100):0x08000178 + 4 * reg, asak_3918av100_pinctrl.c'spin_set_share()writes it.XGPIO_nnn_FUNC_name.tools/gen_anyka_padmux.pybuildssrc/hal/anyka_padmux.hfromak_sharepin[]and the binding header.#ifdef CONFIG_MACH_*per machine: AK3918AV100 has 93 pads, AK3918EV300L 59.func_mux_max, or wider than the field;GPIO<pad>at the driver'sgpio_func_no;src/hal/anyka_padmux.cis the backend.SPI0_*(the NOR flash),RMII_*orOPCLK*(the network) isin_use(), so moving it needs--force.src/hal/anyka_gpio.cdrives the GPIO block at0x20170000:DIR,OUTandINat+0x00,+0x14and+0x28, as the kernel'sak_gpio_get/ak_gpio_setdo.gpio get,gpio set,gpio scanand the IR-cut guess use it on AV100 and EV300L.gpio getandgpio setrefuse any other pad.anyka_gpio_owner()names the pads the kernel holds. It reads the debugfs pinctrl mux owners, the GPIOs handed to drivers (a user's sysfs export doesn't count), and the*-gpio(s)properties of enabled device-tree nodes.in_use(), andgpio setrefuses them without--force.gpio scanshows "held by " for them, and the IR-cut guess skips them.--force. This applies to Fullhan too.Also:
anyka, dropped when the Anyka HAL is not selected;padmux_namesregenerated; the CI pad-mux sweep now buildsanykaon its own.docs/padmux.mdhas the Anyka section and the regeneration recipe.Tests
reginfo_test:test_anyka()uses that EV300L's kernelpinmux-pinsvalues: PWM0 on pad 16 at selector 2, CSI0_SCLK on 22 with GPIO at 3, OPCLK1/RMII on pads 0 and 1 refused unless forced, GPIO37's no-op, and a pad the EV300L doesn't have.IPCHW_PADMUX=none,v4,anyka,v4;anykaandallall build and pass.ipchwbuilds, and so does the trimmed configuration.gen_padmux_names.py --checkandgen_anyka_padmux.py --verifypass.ak3918ev300l(OpenIPC kernel, static arm32 build):gpio muxreads OPCLK1 on 0, RMII_RXER on 1, PWM0 on 16, CSI0_SCLK on 22 and SPI0_WP on 42. That matches the kernel's/sys/kernel/debug/pinctrl/*/pinmux-pins.gpio set 25 1followed bygpio get 25reads 1.gpio set 0 1, and moving pad 1 to GPIO without--force, are both refused.gpio scanlists only GPIO-muxed pads.Not yet run on a camera.