Skip to content

ARM: fullhan: add FH8626V100 platform support - #53

Open
ArthurKoba wants to merge 2 commits into
OpenIPC:fullhan-fh8852v200from
ArthurKoba:fullhan-fh8626v100
Open

ARM: fullhan: add FH8626V100 platform support#53
ArthurKoba wants to merge 2 commits into
OpenIPC:fullhan-fh8852v200from
ArthurKoba:fullhan-fh8626v100

Conversation

@ArthurKoba

@ArthurKoba ArthurKoba commented Sep 4, 2026

Copy link
Copy Markdown

Hi! This adds Linux 4.9.129 support for the Fullhan FH8626V100. The work was done and tested on an Anjia AJL33PQ0866 camera.

The port started from the existing fullhan-fh8852v200 tree because it provides the closest Fullhan 4.9.129 base. I would prefer the result to live in a separate fullhan-fh8626v100 branch. Please let me know if a different integration flow is preferred.

What was tested on the camera:

  • native kernel boot from U-Boot and normal operation with the OpenIPC userspace;
  • SPI NOR detection, MTD partition access and reads;
  • microSD detection, FAT mounting, file creation and read/write access;
  • USB host operation;
  • Ethernet link and traffic, including passing the real U-Boot MAC address to Linux instead of the placeholder address;
  • RTL8188FU USB Wi-Fi detection, module loading, wlan0 creation, radio-up and network scanning;
  • all three I2C controllers;
  • SADC input used by the board light sensor;
  • GPIO and pinmux switching for the IR and white illumination paths;
  • PWM register access and a bounded physical PWM output test;
  • watchdog expiry and userspace feeding, plus normal reboot through the PMU reset path;
  • Fullhan media clocks, ARC firmware startup and the vendor media/ISP/VPU/PAE module ABI;
  • GC1054 camera initialization and actual image/video streaming;
  • microphone capture and speaker playback through the board RTX audio path.

RTC and temperature measurement are the two parts that could not be qualified on this board. The product does not provide a usable RTC setup, and the temperature sensor uses the same RTC command channel. Both the ported kernel and the original vendor kernel time out on that channel. Generic RTC support is kept in the SoC code, while the AJL33PQ0866 board configuration will leave RTC and TSENSOR disabled until they can be tested on suitable hardware.

A follow-up pull request is planned for the OpenIPC firmware profile and board integration. Divinus support may also be submitted separately once that part is ready for review.

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

Copy link
Copy Markdown

PR Summary by Qodo

ARM: add legacy Fullhan FH8626V100 platform support

✨ Enhancement 🐞 Bug fix ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Adds legacy non-DT FH8626V100 machine support, clocks, PMU, pinmux, and peripherals.
• Propagates validated bootloader MAC addresses and supports JL1101 PHY variants.
• Fixes pinctrl, SADC, PWM, RTC, and optional USB VBUS behavior.
Diagram

graph TD
  CFG["Kernel Config"] --> MACH["Legacy Machine"] --> SVC["SoC Services"] --> DEV["Platform Devices"] --> DRV["Fullhan Drivers"] --> HW["FH8626 Hardware"]
  BOOT["Bootloader ATAGs"] --> MACH
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Device Tree migration
  • ➕ Uses the standard declarative ARM hardware-description model
  • ➕ Separates SoC definitions from board policy more naturally
  • ➕ Simplifies future support for additional FH8626V100 boards
  • ➖ Requires bootloader DT support or an appended DTB strategy
  • ➖ Expands bring-up scope beyond the validated stock ATAG contract
  • ➖ Risks regressions while translating recovered MMIO, clock, and pinmux data
2. Split platform and driver fixes
  • ➕ Makes generic GMAC, PWM, RTC, SADC, and USB fixes easier to review
  • ➕ Allows shared corrections to be tested and backported independently
  • ➖ Creates ordering dependencies for a platform requiring those corrections
  • ➖ Fragments the end-to-end hardware validation represented by this change
  • ➖ Delays availability of a bootable, usable base port

Recommendation: Retain the legacy non-DT approach for initial support because it matches the existing U-Boot ATAG handoff and minimizes risk while reproducing validated stock hardware contracts. A later Device Tree migration is preferable for long-term board scalability; generic driver corrections could also be separated into follow-up commits without changing the platform architecture.

Files changed (23) +2643 / -42

Enhancement (10) +2465 / -2
board.cDefine the legacy FH8626V100 machine and peripherals +888/-0

Define the legacy FH8626V100 machine and peripherals

• Implements early MMIO, interrupt, timer, PMU, pinmux, restart, and platform-device initialization. Registers UART, GPIO, GMAC, I2C, optional MMC/RTC/audio/DMA, PWM, SADC, eFuse, USB, watchdog, and SPI NOR resources while validating the bootloader MAC and preserving the factory flash geometry.

arch/arm/mach-fh/fh8626v100/board.c

chip.cRegister the FH8626V100 clock tree +570/-0

Register the FH8626V100 clock tree

• Defines oscillator, PLL, bus, multimedia, storage, networking, audio, RTC, PWM, SADC, USB, watchdog, and timer clocks with FH8626V100-specific gates, divisors, resets, and phases.

arch/arm/mach-fh/fh8626v100/chip.c

chip.hDefine FH8626V100 hardware constants +109/-0

Define FH8626V100 hardware constants

• Adds the SoC memory map, IRQ assignments, PMU registers, peripheral clocks, GPIOs, and reset masks used by machine and driver code.

arch/arm/mach-fh/fh8626v100/chip.h

iopad.hAdd the FH8626V100 pinmux database +575/-0

Add the FH8626V100 pinmux database

• Adds recovered pin functions, mux alternatives, peripheral groups, GPIO groups, and default selections. Includes one-bit SD profiles needed to preserve board GPIO usage.

arch/arm/mach-fh/fh8626v100/iopad.h

platform.hDeclare non-DT interrupt and timer initialization +9/-0

Declare non-DT interrupt and timer initialization

• Declares the legacy Fullhan interrupt-controller and timer entry points used by the FH8626V100 machine descriptor.

arch/arm/mach-fh/fh8626v100/platform.h

pmu.cImplement FH8626V100 PMU operations +283/-0

Implement FH8626V100 PMU operations

• Implements PMU register access, chip identification, resets, timestamps, audio clocks, Ethernet speed control, restart, watchdog control, ARC startup, and USB PHY sequencing.

arch/arm/mach-fh/fh8626v100/pmu.c

fh_gmac_plat.hCarry MAC addresses through GMAC platform data +2/-1

Carry MAC addresses through GMAC platform data

• Extends non-DT GMAC platform data with a six-byte MAC address supplied by machine code.

arch/arm/mach-fh/include/mach/fh_gmac_plat.h

pmu.hExpose common PMU register accessors +4/-0

Expose common PMU register accessors

• Declares direct and masked PMU read/write helpers for platform and driver consumers.

arch/arm/mach-fh/include/mach/pmu.h

fh_gmac_phyt.cSupport JL1101 PHY variants on FH8626V100 +20/-1

Support JL1101 PHY variants on FH8626V100

• Recognizes five JL1101 PHY identifiers and applies the existing RTL8201-compatible setup. Preserves the bootloader RMII mux on FH8626V100 instead of remuxing it during PHY discovery.

drivers/net/ethernet/fullhan/fh_gmac_phyt.c

fh_gmac_phyt.hDefine supported JL1101 PHY identifiers +5/-0

Define supported JL1101 PHY identifiers

• Adds PHY IDs for JL1101 revisions 0x4023 through 0x4027.

drivers/net/ethernet/fullhan/fh_gmac_phyt.h

Bug fix (7) +90 / -37
pinctrl.hAdd persistent pinctrl register storage +4/-3

Add persistent pinctrl register storage

• Adds per-pad register snapshots to the pinctrl object so selected pins no longer retain pointers to temporary stack values.

arch/arm/mach-fh/include/mach/pinctrl.h

pinctrl.cPrevent dangling pinctrl register pointers +2/-5

Prevent dangling pinctrl register pointers

• Stores register state in persistent per-pad storage rather than assigning each pin a pointer to a local variable.

arch/arm/mach-fh/pinctrl.c

fh_sadc_v2.cSafely initialize the SADC IRQ name +2/-1

Safely initialize the SADC IRQ name

• Replaces a size-mismatched strncpy call with bounded strlcpy using the destination buffer size.

drivers/misc/fh_sadc_v2.c

fh_gmac_main.cCorrect GMAC address selection and runtime changes +31/-10

Correct GMAC address selection and runtime changes

• Validates runtime MAC changes before updating driver state and hardware. Sources probe-time addresses from standard platform helpers or non-DT platform data, falls back to a random address, and removes a redundant checksum feature flag.

drivers/net/ethernet/fullhan/fh_gmac_main.c

pwm-fullhan-common.cHarden PWM configuration and status reporting +29/-6

Harden PWM configuration and status reporting

• Handles zero clocks, unconfigured periods, and unavailable channel data without division or null-pointer faults. Uses 64-bit duty percentage arithmetic and reduces high-frequency diagnostics to debug logging.

drivers/pwm/pwm-fullhan-common.c

rtc-fh_v2.cPropagate RTC command failures +20/-10

Propagate RTC command failures

• Returns hardware read and write errors through RTC class operations instead of interpreting negative command results as timestamps.

drivers/rtc/rtc-fh_v2.c

platform.cTreat absent USB VBUS GPIO as optional +2/-2

Treat absent USB VBUS GPIO as optional

• Downgrades the missing VBUS-control GPIO message to debug output, supporting boards whose USB host power is always enabled.

drivers/usb/dwc2/platform.c

Other (6) +88 / -3
KconfigAdd FH8626V100 architecture and machine options +48/-0

Add FH8626V100 architecture and machine options

• Adds ARMv6 FH8626V100 SoC and legacy machine selections. Introduces optional on-chip RTC and AJL33PQ0866 one-bit SD0 board capabilities.

arch/arm/mach-fh/Kconfig

MakefileSelect the FH8626V100-specific PMU implementation +7/-2

Select the FH8626V100-specific PMU implementation

• Excludes the shared PMU object for FH8626V100 so the platform-specific implementation can provide its hardware contract. Retains common clock and pinctrl builds for non-DT machines.

arch/arm/mach-fh/Makefile

MakefileBuild FH8626V100 platform sources +1/-0

Build FH8626V100 platform sources

• Adds the board, clock/chip, and PMU objects to the FH8626V100 machine build.

arch/arm/mach-fh/fh8626v100/Makefile

board_config.fh8626v100.appboardAdd generic FH8626V100 board defaults +30/-0

Add generic FH8626V100 board defaults

• Defines multimedia clock rates and a generic peripheral pinmux selection while intentionally excluding sensor-specific power and reset policy.

arch/arm/mach-fh/fh8626v100/board_config.fh8626v100.appboard

mach-typesRegister the FH8626V100 machine type +1/-0

Register the FH8626V100 machine type

• Adds the legacy ARM machine identifier used by U-Boot and the kernel machine descriptor.

arch/arm/tools/mach-types

MakefileBuild the Fullhan V2.1 PWM driver +1/-1

Build the Fullhan V2.1 PWM driver

• Connects CONFIG_PWM_FULLHAN_V21 to the pwmv2 implementation independently of the FH885xV200-specific PWM path.

drivers/pwm/Makefile

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

qodo-free-for-open-source-projects Bot commented Sep 4, 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


Action required

1. DT configuration omits PMU ✓ Resolved 🐞 Bug ≡ Correctness
Description
When MACH_FH8626V100=y, the Makefile removes the generic PMU for every configuration, while the
replacement FH8626 PMU is only built when USE_OF=n. Because Kconfig permits ARCH_FH8626V100 with
USE_OF=y, that combination leaves calls such as fh_pmu_init() unresolved at link time.
Code

arch/arm/mach-fh/Makefile[R6-7]

+ifneq ($(CONFIG_MACH_FH8626V100),y)
+obj-y	+= pmu.o
Evidence
The top-level Makefile excludes pmu.o solely from MACH_FH8626V100, but includes the chip
directory containing the replacement PMU only inside the non-DT block. Kconfig does not prohibit
USE_OF, while fullhan_init_early() unconditionally references fh_pmu_init().

arch/arm/mach-fh/Makefile[6-13]
arch/arm/mach-fh/fh8626v100/Makefile[1-1]
arch/arm/mach-fh/Kconfig[71-81]
arch/arm/mach-fh/fullhan.c[39-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
FH8626V100 removes the generic PMU whenever its machine symbol is enabled, but its replacement PMU is only compiled on the non-DT path. Prevent configurations that enable FH8626V100 with `USE_OF=y`, or make PMU selection consistent across both paths.
## Issue Context
The platform is explicitly implemented as legacy non-DT support. `fullhan.o` still calls PMU functions unconditionally, so a DT-enabled FH8626 configuration cannot link.
## Fix Focus Areas
- arch/arm/mach-fh/Kconfig[71-81]
- arch/arm/mach-fh/Makefile[6-13]
- arch/arm/mach-fh/fh8626v100/Makefile[1-1]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. SD phase bits accumulate ✓ Resolved 🐞 Bug ☼ Reliability
Description
The new SDC phase clocks use the common phase operation, which ORs the requested encoding into the
register without first clearing the clock's phase field. In particular, the board's sample phase of
zero performs no change, so bootloader or prior phase bits can survive and produce incorrect SD
sampling timing.
Code

arch/arm/mach-fh/fh8626v100/chip.c[R132-136]

+	.flag			= CLOCK_NOGATE | CLOCK_PHASE,
+	.parent			= { &sdc0_clk },
+	.prediv			= 1,
+	.sel_reg_offset		= REG_PMU_ETH_CTRL,
+	.sel_reg_mask		= 0x00000180,
Evidence
Each added SDC phase clock supplies a shifted field mask. fh_clk_set_phase() currently executes
reg |= local_degree << shift, so zero cannot clear the field and transitions between nonzero
encodings retain stale bits; the MMC initialization invokes this operation with the board-provided
phases.

arch/arm/mach-fh/fh8626v100/chip.c[130-145]
arch/arm/mach-fh/fh8626v100/chip.c[160-175]
arch/arm/mach-fh/clock.c[238-265]
drivers/mmc/host/fhmci/fhmci.c[1679-1702]
arch/arm/mach-fh/fh8626v100/board.c[402-408]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The common Fullhan clock phase setter must replace the selected phase field instead of OR-ing new bits into its previous value. It should also mask the encoded value to the declared field and return zero on success.
## Issue Context
FH8626V100 introduces SDC driver/sample phase clocks. The MMC driver requests sample phase zero and driver phase two, but the current setter cannot clear existing bits.
## Fix Focus Areas
- arch/arm/mach-fh/clock.c[238-265]
- arch/arm/mach-fh/fh8626v100/chip.c[130-145]
- arch/arm/mach-fh/fh8626v100/chip.c[160-175]
- drivers/mmc/host/fhmci/fhmci.c[1688-1701]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. PWM failures report success ✓ Resolved 🐞 Bug ≡ Correctness
Description
Registering PWM on FH8626V100 activates fh_pwm_config(), which discards errors from
fh_pwm_set_config() and always reports success. Periods that are zero after conversion, exceed the
hardware limit, or have duty greater than period therefore leave PWM disabled while callers believe
configuration succeeded.
Code

arch/arm/mach-fh/fh8626v100/board.c[R800-802]

+	&fh_usb_device,
+	&fh_pwm_device,
+	&fh_gmac_device,
Evidence
The new board registers fh_pwm, and the PR adds the V21 implementation to the build. The common
setter returns -EINVAL for several rejected configurations, but its framework callback ignores
that return and unconditionally returns zero.

arch/arm/mach-fh/fh8626v100/board.c[471-481]
arch/arm/mach-fh/fh8626v100/board.c[800-804]
drivers/pwm/Makefile[49-52]
drivers/pwm/pwm-fullhan-common.c[243-273]
drivers/pwm/pwm-fullhan-common.c[409-428]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Return the result of `fh_pwm_set_config()` from the PWM framework callback rather than unconditionally returning success. Preserve cleanup of the temporary configuration object.
## Issue Context
The new FH8626V100 board registers the `fh_pwm` device and enables the V21 implementation, exposing this common callback to platform consumers.
## Fix Focus Areas
- arch/arm/mach-fh/fh8626v100/board.c[800-804]
- drivers/pwm/Makefile[49-52]
- drivers/pwm/pwm-fullhan-common.c[243-273]
- drivers/pwm/pwm-fullhan-common.c[409-428]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can route each action level your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread arch/arm/mach-fh/Makefile
Comment thread arch/arm/mach-fh/fh8626v100/chip.c
Comment thread arch/arm/mach-fh/fh8626v100/board.c
Keep the legacy FH8626V100 platform restricted to non-DT builds so its PMU implementation is always available.

Replace the complete clock phase field instead of accumulating stale bits, fix phase readback, and report success using the clock API convention.

Validate PWM timing before disabling an active channel and propagate configuration failures to callers.
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.

1 participant