Repository navigation
Ingenic T23 (CIP 6.12.114-cip34) - #261
Conversation
PR Summary by QodoAdd Ingenic T23 platform and in-kernel camera support
AI Description
Diagram
High-Level Assessment
Files changed (185)
|
Code Review by Qodo
1.
|
5d76dc0 to
6f73844
Compare
|
Updated the series on Flash layout cleanup
Qodo review responses (
|
openipc-ai
left a comment
There was a problem hiding this comment.
Thanks for the port. Moving T23 from the 3.10.14 SDK with binary libimp to standard V4L2/MC, M2M and ASoC drivers is a big step, and the series is well organised. The diff is over GitHub's 20k-line API limit, so I fetched the PR head (6f73844) and diffed it against 36226b6.
I read every change to existing shared code, plus the new SFC, AES, reset, efuse and PTZ motor drivers. I have not reviewed the new media drivers yet (tx-isp, helix, ipu, smartsens sensors, about 20k lines). They will get a separate pass.
I'm requesting changes, mainly because several T23 workarounds change code that every XBurst/Ingenic SoC uses, and nothing limits them to T23. JZ47xx and X1000 boards would pick up behaviour nobody has tested on them. Details are in the inline comments:
Shared code, affects all Ingenic SoCs
8250_ingenic.c: earlycon from the kernel command line no longer reads/ext(regression on every Ingenic SoC).tlb-r4k.c: amips_machtype == MACH_INGENIC_T23check in generic TLB setup.c-r4k.c: an unexplainedConfig7 BIT(1)is set after every icache flush on all XBurst parts.sc-mips.c:write_c0_ecc(0)runs on every XBurst part that has an L2 cache.cgu.c: the divider stop bit is now used on disable for every SoC, but set_rate still clears it.
T23 drivers
6. dwmac-ingenic.c: the PHY reset pulse and raw MDIO writes happen after phylink has attached the PHY.
7. jz4740-i2s.c: startup reprograms a TX/RX clock that both directions share.
8. jz4740-i2s.c (aic-loop): a dangling pointer to the AIC's driver data, and the LOOP bits are never cleared.
9. spi-ingenic-sfc.c: a mutex is taken on the polling path meant for panic/IRQs-off context. The DMA mask is also 32-bit, but probe rejects buffers above 29 bits.
10. rtc-jz4740.c: system-power-controller makes the whole RTC probe fail on T23.
Smaller points: the dwmac reg_offset is guessed from the regmap max register; the stmmac ring sizes are changed after probe; efuse support is a new driver even though the jz4780-efuse binding was extended to cover T23 (please either reuse nvmem/jz4780-efuse.c or drop the binding change).
You mention that on-board validation of the 6.12 rebase is still pending. Please attach a JA-A12/T23N boot log, plus network, audio and flash smoke tests, once you have them. Also, if you have a JZ4780 or X1000 board, a quick boot of this branch on it would help confirm the shared changes (or gate them all behind T23 and we can skip that).
| prop = fdt_getprop(fdt, offset, "clock-frequency", NULL); | ||
| if (!prop) | ||
| return; | ||
| if (!dev->port.uartclk && fdt) { |
There was a problem hiding this comment.
On the command-line path (earlycon=jz4740_uart,mmio32,0x10030000,115200), earlycon.c parse_options() has already set port->uartclk = BASE_BAUD * 16 before setup runs, so uartclk is never 0 here and /ext is never read. Before this change /ext always overrode it, so this breaks command-line earlycon on all Ingenic SoCs (the divisor is computed from 1.8432 MHz instead of 24/48 MHz). Could you keep the old unconditional override and use the 24 MHz fallback only when /ext is missing?
|
|
||
| /* From this point on the ARC firmware is dead. */ | ||
| if (!cpu_has_tlbinv) | ||
| if (!cpu_has_tlbinv && mips_machtype != MACH_INGENIC_T23) |
There was a problem hiding this comment.
Generic r4k TLB code shouldn't test a single platform's mips_machtype. The MACH_* values from different platforms share one integer space, and inserting MACH_INGENIC_T23 in the middle of the enum also renumbers X2000/X2100. What goes wrong in r4k_tlb_uniquify() on T23? If it's a CPU property, please express it as a cpu feature/quirk (for example in cpu-probe.c for this PRID), or fix the root cause.
| } | ||
|
|
||
| if (boot_cpu_type() == CPU_XBURST) | ||
| set_c0_config7(BIT(1)); |
There was a problem hiding this comment.
This now runs after every flush_icache_range on all XBurst CPUs (JZ4740 to X1830), including hot paths such as module load and signal trampolines. What does Config7 bit 1 do on T23, and is it defined the same way on older XBurst cores? Please give it a named define with a comment, and limit it to the cores that need it (for example via the PRID in cpu-probe).
| c->scache.ways = 4; | ||
| break; | ||
| } | ||
| write_c0_ecc(0x0); |
There was a problem hiding this comment.
write_c0_ecc(0) runs for every XBurst part with an L2 cache, which clears the ErrCtl/ECC state that firmware set up on JZ4770/JZ4775/JZ4780/X1000. Please limit it to T23, or explain why it is safe on the other parts.
| spin_unlock_irqrestore(&cgu->lock, flags); | ||
| } | ||
| if (clk_info->type & CGU_CLK_DIV) | ||
| ret = ingenic_cgu_div_set_enabled(cgu, &clk_info->div, false); |
There was a problem hiding this comment.
Stopping the divider through stop_bit on disable now applies to every SoC that defines stop_bit (for example JZ4780 i2s/msc/lcd dividers), but ingenic_clk_set_rate() still clears stop_bit unconditionally. A clk_set_rate() on a disabled clock (after disable_unused, or before prepare_enable) restarts the divider in hardware while the enable count is 0, and is_enabled() then disagrees with the clock framework. set_rate should either keep the current stop state, or this new enable/disable behaviour should be opt-in per SoC.
| int phy, id1, bmcr; | ||
|
|
||
| if (mac && mac->phy_reset) { | ||
| gpiod_set_value_cansleep(mac->phy_reset, 1); |
There was a problem hiding this comment.
fix_soc_reset is called from stmmac_reset() inside stmmac_hw_setup(), which runs after stmmac_init_phy() has attached the PHY and run its config_init. Pulsing the PHY reset line here throws away that setup (RMII ref-clk direction, LEDs, quirks). The raw GMAC_MII_ADDR/DATA accesses to all 32 addresses also run without mdio_lock, while phylib may be polling at the same time. The PHY reset belongs in the MDIO bus/PHY reset handling (reset-gpios on the PHY node, or snps,reset-gpio), not in the MAC soft-reset hook.
| } | ||
|
|
||
| if (clk) { | ||
| ret = clk_set_rate(clk, 8000 * 256); |
There was a problem hiding this comment.
When the DT doesn't provide separate spk/mic clocks, clk_rx == clk_tx, so opening capture while playback is running at 48 kHz sets the shared clock to 2.048 MHz and playback slows to 1/6 speed. If capture never reaches hw_params, it stays that way. Please skip this when the other direction is active, or drop it and rely on hw_params.
| return -EPROBE_DEFER; | ||
|
|
||
| loop->aic = &aic->dev; | ||
| loop->i2s = platform_get_drvdata(aic); |
There was a problem hiding this comment.
loop->i2s points at the AIC driver's devm-allocated data, but put_device()/get_device() only pins the struct device, not its driver binding. Unbinding the AIC frees i2s and its regmap while the loop component is still registered, so the next loop trigger or hw_params is a use-after-free. Please use a device link (DL_FLAG_AUTOREMOVE_CONSUMER), or make the loop DAI a part of the AIC driver. Also, the LOOP enable bits are never cleared when the main capture stops.
|
|
||
| use_dma = nbytes > SFC_PIO_MAX_BYTES; | ||
|
|
||
| mutex_lock(&sfc->lock); |
There was a problem hiding this comment.
exec_op has a polling branch for irqs_disabled() || oops_in_progress (the mtdoops case), but it takes mutex_lock() unconditionally first. That is illegal in that context: it either warns 'sleeping function called from invalid context', or deadlocks if the oops hit while another task held the lock. Either use a mutex_trylock() fallback for the oops path, or drop the polling branch. Separately, the DMA mask is set to 32 bits while probe rejects memory above 29 bits; dma_set_mask_and_coherent(DMA_BIT_MASK(29)) would let the DMA API bounce buffers instead.
| @@ -350,6 +352,8 @@ static int jz4740_rtc_probe(struct platform_device *pdev) | |||
| return -ENOMEM; | |||
|
|
|||
| rtc->type = (uintptr_t)device_get_match_data(dev); | |||
| if (rtc->type == ID_T23 && of_device_is_system_power_controller(np)) | |||
| return -EOPNOTSUPP; | |||
There was a problem hiding this comment.
If a T23 board DT marks the RTC as system-power-controller (which the shared binding allows), the RTC device disappears completely: no /dev/rtc0, no hwclock. Please just skip registering power-off for T23 (and/or forbid the property in the binding for ingenic,t23-rtc).
|
wrt the JZ4780 or X1000 issues: this branch is specifically for T23 SoC, so those JZ4780 or X1000 boards does not apply. However, for code hygiene issues, I'll port them properly in the next few commits. |
6f73844 to
c30cecd
Compare
|
Thanks for the thorough review @openipc-ai — all of those points were completely legitimate. Since Force-pushed reconsolidated Shared code & DT schemas (100% T23-isolated)
T23 driver fixes retained from review
Re-verification on
Physical JA-A12/T23N 6.12 boot and smoke-test logs ( |
c30cecd to
52c971b
Compare
|
Thanks for the fast and thorough turnaround. I checked
Build check on my side (OpenIPC One nit: in What's left before merge:
|
Register the vendor prefixes used by the T23 camera board and sensor bindings. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the Ingenic T23 SoC and the Jooan JA-A12, JA-A10 and OpenIPC QEMU board compatibles. Signed-off-by: Difan Zhang <alex@osqdu.org>
Register the T23 machine and board selection, and use the CPM scratch signature and TCU watchdog for system restart. Memory size and reusable camera CMA are supplied by Device Tree using the standard kernel command line. Signed-off-by: Difan Zhang <alex@osqdu.org>
Name CP0 Config7 bit 1 (MIPS_CONF7_XBURST_BTB_INV) and restrict the BTB invalidation after I-cache range maintenance to T23 XBurst1 cores so older JZ47xx and XBurst2 parts are unaffected. Signed-off-by: Difan Zhang <alex@osqdu.org>
Order secondary-cache maintenance against device accesses and use indexed cache blasts for ranges covering the cache on XBurst T23, leaving other MIPS platforms untouched. Clear the T23 CP0 ErrCtl state and record scache_size only during XBurst MACH_INGENIC_T23 setup. Signed-off-by: Difan Zhang <alex@osqdu.org>
Allow CGU dividers opting into cgu->stop_div_on_disable (T23) to handshake CE/STOP bits around divider enable/disable and rate updates, skip empty sparse clock slots, and resolve forward-referenced parents without altering existing Ingenic CGU SoCs. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 clock generator and publish clock identifiers for its CPU, bus, peripheral and audio clocks. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add the T23 APLL and MPLL, clock muxes, dividers and peripheral gates. Provide fractional I2S dividers for the microphone and speaker clocks. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the CPM bus-stop reset controller and define reset identifiers for the ISP and Helix VPU. Signed-off-by: Difan Zhang <alex@osqdu.org>
Stop bus traffic before asserting ISP or VPU reset and wait for the CPM acknowledgement before releasing the block. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 pin controller and its GPIO-bank compatibles. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add the T23 PA-PD pin groups and functions, 0x1000 bank stride, shadow register access, and per-pin pull-up and pull-down configuration. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 hardware compatible and its resources using the existing Ingenic controller schema. Signed-off-by: Difan Zhang <alex@osqdu.org>
Match the T23 two-bank interrupt controller to the existing Ingenic INTC implementation. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 hardware compatible and its resources using the existing Ingenic controller schema. Signed-off-by: Difan Zhang <alex@osqdu.org>
Register the ingenic,t23-ost compatible in ingenic-sysost and clear OST_REG_OSTFR in the event IRQ handler only on T23. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 hardware compatible and its resources using the existing Ingenic controller schema. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 internal codec register window, clocks and audio interfaces. Signed-off-by: Difan Zhang <alex@osqdu.org>
Provide the T23 microphone and speaker routes, gain and mute controls, and playback reference interface through ASoC. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 AIC and playback-reference DMA interface used for audio capture and playback. Signed-off-by: Difan Zhang <alex@osqdu.org>
Handle the T23 speaker and microphone clocks, mono and stereo channel routing, FIFO resets, and playback-reference FIFO DMA capture. Signed-off-by: Difan Zhang <alex@osqdu.org>
Define the T23 ISP statistics and extensible parameter metadata layouts, pixel-format identifiers and user control range. Document the buffer interfaces for userspace 3A services. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the GPIO phase outputs, travel limits and reset steps of the T23 camera PTZ mechanism. Signed-off-by: Difan Zhang <alex@osqdu.org>
Drive the camera pan and tilt stepper phases using GPIO descriptors and an hrtimer pulse generator, exposed through V4L2 motor controls. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the GC2053 CSI-2 sensor clocks, reset and power-down GPIOs, and media endpoint. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add active-state subdevice formats, exposure and analogue gain controls, writable VBLANK with exposure-range updates, and frame interval configuration for the GC2053. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the SC1A4T, SC2336 and SC2337P sensor variants and their CSI-2 endpoint and board resources. Signed-off-by: Difan Zhang <alex@osqdu.org>
Provide the T23 SmartSens sensor variants with common register, power and V4L2 control handling. Support active subdevice state, live VBLANK and exposure limits, and stream-time Bayer flip locking. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 ISP register windows, clocks, interrupts and reset resources. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add the T23 CSI, VIC, ISP, MDNS and multi-scaler capture pipeline with Media Controller topology, NV12/NV21 outputs, per-frame statistics and parameter metadata, scratch-buffer parking and dual-input frame synchronization. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 Helix encoder register windows, clocks, interrupts and reset resources. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add the T23 V4L2 memory-to-memory H.264 and JPEG encoder with per-context reference buffers, DMA-BUF input, rate control, aligned DMA staging and encoder STOP/EOS draining. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 IPU converter register windows, clocks, interrupts and reset resources. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add the T23 IPU v1.3 memory-to-memory color converter with DMA-BUF import and NV12/NV21, RGB565 and ARGB32/XRGB32 formats. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the T23 CPU, clocks, interrupts, memory-mapped peripherals and media blocks with board-specific devices disabled by default. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the JA-A12 64 MiB board, 24 MiB reusable camera CMA, SPI NOR layout, dual SC1A4T endpoints, USB Wi-Fi power and audio routes. Name the IR-cut GPIO lines for userspace ownership. Signed-off-by: Difan Zhang <alex@osqdu.org>
Describe the JA-A10 board with 32 MiB RAM, 8 MiB reusable camera CMA, sensor, audio and GPIO-controlled peripherals. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add QEMU profiles for the dual SC1A4T, GC2053 and SC2336 pipelines based on the JA-A12 description. Enable the virtual UART and Ethernet interface for emulated regression tests. Signed-off-by: Difan Zhang <alex@osqdu.org>
Configure the T23 camera kernel for LZMA-compressed SPI NOR boot with appended DTB, reusable CMA and writable overlay storage. Build media, sensor, audio and wireless support as modules to fit the flash and RAM budgets. Signed-off-by: Difan Zhang <alex@osqdu.org>
Document the openipc,t23 compatible string for generic OpenIPC Ingenic T23 IP camera boards. Signed-off-by: Difan Zhang <alex@osqdu.org>
Add a generic OpenIPC Ingenic T23 device tree (t23-openipc.dts) covering standard SoC peripherals, 64 MiB RAM with a 24 MiB CMA pool for camera buffers, jz_sfc 8 MiB OpenIPC NOR partition layout, RMII Ethernet MAC/MDIO, USB OTG, MMC0 with GPIO card detect, internal audio codec, and a default 2-lane GC2053 MIPI CSI-2 sensor on I2C0 without vendor board-specific GPIOs. Signed-off-by: Difan Zhang <alex@osqdu.org>
Commit f399df5 ("hwrng: ingenic: Add the T23 DTRNG compatible") added the ingenic,t23-dtrng compatible to ingenic-trng.c, but HW_RANDOM_INGENIC_TRNG in Kconfig still depended only on MACH_X1830 || COMPILE_TEST. Add MACH_T23 to the dependency so the T23 DTRNG driver can be enabled on T23-only builds. Signed-off-by: Difan Zhang <alex@osqdu.org>
Keep core boot/bus drivers (I2C, regulator, watchdog, SFC) built in while modularizing media, Ethernet/PHY, TUN, LEDs, RTC, PWM, and DTRNG so vmlinux.bin stays comfortably under the 4.5 MiB U-Boot decompression cap. Signed-off-by: Difan Zhang <alex@osqdu.org>
337e474 to
12dfae2
Compare
|
Pushed updated (Corresponding OpenIPC firmware branch: Summary of Review Fixes (
|
openipc-ai
left a comment
There was a problem hiding this comment.
Thanks, this is a big step up. I checked 12dfae26 against 337e474a, and all eight inline points from the media review are fixed:
- ext params are copied into a kernel shadow in
buf_prepare, and check + merge only ever see that copy; V4L2_CID_USER_T23_BASEmoved to+0x1250, which is free in current mainline;- PTZ absolute controls are
VOLATILE | EXECUTE_ON_WRITE, and the motor is now aMEDIA_ENT_F_LENSsubdev with no fake video node; - gc2053 powers off exactly once on the error path;
- Helix sends LAST/EOS whatever the encode result;
- the IPU
panic()is gone; - the ISP bounce buffer grows when needed;
- the ISP binding now matches what probe requires.
I also checked a few of the summary points: MDNS top[] is masked, the Helix workqueue is destroyed from the final kref release, the SmartSens drivers are down to 3 with the chip ID checked in probe, and the duplicate UAPI header is gone. The jz4740_mmc change keeps END_CMD_RES-only behaviour for every non-T23 SoC.
On my side, a W=1 build of t23_defconfig (vmlinux, 129 modules, all T23 DTBs) gives no warnings in PR files, and checkpatch --strict over the 78 commits has 0 errors. Together with your JA-A12 results (both sensors binding, 0-error RTSP decode, NV12 capture on the second camera, audio, Wi-Fi, and v4l2-compliance with no warnings), I'm happy to approve this for the ingenic-t23-6.12 branch.
Small follow-ups, none of them blocking:
ingenic,t23-helix.yamlstill doesn't listresetsunderrequired, buthelix_drv.c:218usesdevm_reset_control_get_exclusive().- The earlycon dedup you mentioned (drop the T23 entry or the x1000 fallback compatible).
- The
crbufs.reservedfailure should go away with a current v4l-utils, since 1.24.1 predates themax_num_buffersfield. A run with a newer version would confirm it isn't a driver issue. - If this ever goes upstream: split H.264 and JPEG into separate Helix m2m nodes, and expect another review round on the reworked SmartSens common code and PTZ lens driver. I only spot-checked those here.
See #254
Adds Ingenic T23 SoC, board, peripheral, audio, and V4L2/MC media support on top of CIP Linux
6.12.114-cip34(36226b6091bffd759f9e73ff9ce00e05b02130fc), replacing the frozen 3.10.14 vendor SDK tree and binarylibimpstack with in-kernel drivers (78 commits, 179 files,+32991/−127). All changes in shared MIPS/Ingenic drivers and DT bindings are strictly gated to T23 (MACH_INGENIC_T23/ingenic,t23-*) so non-T23 SoCs are left untouched.Summary
MACH_INGENIC_T23+ TCU watchdog restart, T23-scoped XBurst BTB invalidation + scache DMA range fixes, CGU clocks & opt-in divider/bus-stop reset handshakes, INTC, pinctrl/GPIO, system OST (ingenic-sysost), TCU PWM & WDT, RTC, PDMA (jz4780-dma), SFC v1 SPI-MEM flash controller (+ ZbitZB25VQ64/ZB25VQ128), SSI SPI, I2C (jz4780), 8250 UART + T23 earlycon fallback, USB OTG PHY + DWC2 params, MSC/MMC (jz4740_mmc), GMAC (dwmac-ingenic), SAR ADC (IIO), eFuse (NVMEM), AES (ingenic-crypto), DTRNG (ingenic-trng), DDR register window mapping, and RISC-V coprocessorremoteprocskeleton.drivers/media/platform/ingenic/tx-isp) with UAPI metadata stats/params (include/uapi/linux/media/ingenic/t23-isp-config.h).drivers/media/platform/ingenic/helix) and IPU v1.3 V4L2 M2M converter (drivers/media/platform/ingenic/ipu).drivers/media/platform/ingenic/ptz-motor.c) and I2C sensor drivers for GalaxyCoreGC2053and SmartSensSC1A4T,SC2336, andSC2337P.tx-isp/avpu3.10.14 sources and T23N board bring-up, rewritten as standalone mainline-style V4L2/MC and V4L2 M2M drivers with no SDK blobs or/proc/jzbackdoors.)t23.dtsi,t23-openipc.dts(generic 8 MiB SPI NOR board withGC2053, 24 MiBalloc-rangesCMA pool, and standardfixed-partitionslayout matchingu-boot-t23n-nor.bin),ja-a10.dts(T23DL),ja-a12.dts(T23N),t23-qemu*.dtsprofiles, DT bindings, andt23_defconfig.Tested
t23_defconfigbuildsvmlinux.bin(4621600bytes, < 4.5 MiB U-Boot decompression limit), 128 modules, and all 6 T23 DTBs (make ARCH=mips W=1 dtbswith 0 warnings;scripts/checkpatch.pl --strictwith 0 errors across all 18 reconsolidated commits; 35 modified YAML bindings validated with PyYAML).BOARD=t23_litefirmware: Full Buildroot image builds standard fixed-slot NOR outputs within 8 MiB flash slots (uImage.t231479 KB / 2048 KB,rootfs.squashfs.t234064 KB / 5120 KB) alongside companion branchesdifanz/openipc-divinus:ingenic-t23-v4l2(PROpenIPC/divinus#102) anddifanz/openipc-firmware:ingenic/t23-6.12.-M t23E2E (run_openipc_e2e.py): Verified 2-bootu-boot-t23n-nor.bin+uImage.t23(0x50000) +rootfs.squashfs.t23(0x250000) flow (osmem=40M->load_ingenicupdatesosmem=64M-> watchdog reboot; Boot 2mem=64M,24576 kBCMA,MemAvailable: 22208 kB, standard 5cmdlinepartpartitions with/dev/mtdblock3SquashFS root and/dev/mtdblock4JFFS2/overlay,eth0DHCP,aplay -lcard 0,ingenic-sadcin_voltage0_scale = 0.439453125),t23-ipa3A loop +divinus,1920x1080HTTP JPEG snapshots, and 15 RTSP H.264 frames decoded withffmpeg -err_detect explode(0 errors).JA-A12) on our 4.19 port; on-board validation of this 6.12 rebase is pending next.