Repository navigation
hisi: report every sensor on Hi3519DV500 dual-sensor boards; fix V5 DDR rate, DV500 CPU clock - #294
Conversation
…DR rate, DV500 CPU clock A Hi3519DV500 kit with an OS04A10 on SENSOR0 and an OS08A20 on SENSOR1 reported one sensor. Three things stood in the way, and the clock report was wrong in two places. - The report stopped at the first sensor. detect_sensors() now probes the remaining i2c buses and lists every sensor it finds, one entry per bus. Both sweeps now run to bus 7: the vendor SDK puts sensors 0..3 on I2C4, I2C5, I2C3 and I2C6. Buses the first probe already found empty are not probed again. getsensorid() and libipchw are unchanged. - On DV500 the SENSOR1 bus is I2C5, whose pads (iocfg_reg109/110 at 0x0EFF0024/28) the stock sys_config.ko leaves as GPIO1_0/1_1 unless built with I2C_EX_EN, so every transfer timed out. The OT arm switches them to function 2 (I2C5) only while both are GPIO inputs -- never in SPI1 mode, never a GPIO the board drives -- and puts back what it found if the pad still holds our word. Our word keeps the found drive and pull bits, unlike the vendor's 0x1752, so the undo can survive the SPI arm, which has no cleanup of its own. - PERI_CRG8464/8472 reset to cksel 0, which is 74.25 MHz on CV610 and DV500 alike, above the 27 MHz an OS08A10/A20 or the 36 MHz an OS04A10 accepts. A clock we ungate from that state now gets 24 MHz. A running clock, or one whose select somebody chose, is left alone. - OS08A10 and OS08A20 share 0x300A..C = 53 08 41 and 0x302A = 0xB0 in every data sheet revision; only Nyxel NIR sensitivity differs. sensor_id stays OS08A10, which is what consumers select a driver by, and the report adds `id_shared_with: OS08A20`. - clocks: the V5 DDR rate was the DRAM clock. With DFI 1:2 the DRAM runs at twice the DPLL and moves data on both edges, so the rate is DPLL * (1 << dficlk_ratio) * 2. The DV500 data sheet's clock tree runs the DPLL at 667 MHz for "up to 2666 Mbps DDR4"; the kit (boot table ..._DDR4_2666M-4GB) reads 664 MHz and now reports 2656 MT/s, not 1328. - clocks: on DV500 the A55 does not have to run from the APLL. PERI_CRG2064 a55_cksel [10:8] picks one of seven sources; the kit reads 6, the fixed 1000 MHz source, with the APLL at 750 MHz beside it. A new `cpu` entry decodes it. CV610's A7 uses a different register and is left out. hal_hisi_test gains ten cases for the clock select and the I2C5 pads. Breaking the 24 MHz value or the pad undo makes them fail. Verified on the kit (MPP V2.0.1.1): both sensors found with the pads already muxed (0x1752, left untouched), with stock pads (0x1300, restored afterwards), and with both sensor CRGs at their reset value 0x3.
PR Summary by QodoReport all DV500 sensors and correct V5 clock rates
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
…nly for a probe Review fixes (Qodo on #294): - The extra sweep ran on every platform after every hit, and a probe is not a read: the two-byte register address is a write to a one-byte part, and some families write page registers. It is now opt-in through a new HAL global, hal_sensor_buses, and covers only the buses listed there. DV500 lists the vendor SDK's SENSOR0..3 buses, {4, 5, 3, 6}. Everywhere else the report stops at the first sensor, as before, and the fallback sweep is back to buses 0..5. This also rules out a sensor being listed under several bus numbers by an opener that ignores i2c_adapter_nr (V1, XM, Allwinner, Tegra, Rockchip, Novatek): only a HAL whose opener honours it may set the list. - i2c_bus_openable() was called before i2c_adapter_nr was set, and every opener reads the global, so it tested the previous adapter. - setup_hal_hisi() arms the clocks, and with them the DV500 pads, but a chip-name or clocks query never reaches the cleanup that puts the pads back. The pads are now armed only by hal_enable_sensor_clock, which is to say by a probe; setup still arms the clocks alone, as before. - A probe whose own open fails returns without a cleanup; the sweep now runs one after any failed probe. A cleanup after one that already ran is a no-op, because each undo is spent. - clocks: the DV500 CPU decoder runs first, on its own registers, so a failed DDR PHY read no longer hides it. It reads the APLL through the PLL table, via a new pll_read_freq_mhz() that decode_pll() now shares, instead of a second copy of the field layout. It moved above the DDR comment, which again sits directly over v5_extra(). hal_hisi_test checks that setup alone leaves the pads alone; that check fails if setup arms them. It also checks that hal_sensor_buses is set on DV500 and on nothing else. On the DV500 kit: `ipctool -c` and `ipctool clocks` leave stock pads at 0x1300; the report finds both sensors with stock pads (restored after), muxed pads, and sensor CRGs at reset; 14.6 s instead of 15.0 s. ipcinfo is unchanged in size on arm32.
A Hi3519DV500 kit with an OS04A10 on SENSOR0 and an OS08A20 on SENSOR1 reported one sensor. Three things stood in the way, and the clock report was wrong in two places.
Sensors
hal_sensor_buses, lets a HAL list the i2c buses its board family carries sensors on. When it is set,detect_sensors()probes those buses after the first hit and lists every sensor, one entry per bus. DV500 sets{4, 5, 3, 6}, the vendor SDK's SENSOR0..3. Every other platform leaves it NULL and reports exactly as before. Probes write (two-byte register addresses, page registers), so they must not reach unrelated buses. The fallback sweep is unchanged (0..5).getsensorid()and libipchw are unchanged.iocfg_reg109/110,0x0EFF0024/28) the stocksys_config.koleaves as GPIO1_0/1_1 unless built withI2C_EX_EN. Every transfer on/dev/i2c-5timed out. The OT arm switches them to function 2 only while both are GPIO inputs, and only from a probe's arm, never at HAL setup, soipctool -candclocksleave them alone. It never touches them in SPI1 mode or as a driven GPIO, and puts back what it found if the pad still holds our word. Our word keeps the found drive/pull bits, unlike the vendor's0x1752, so the undo survives the SPI arm, which has no cleanup.PERI_CRG8464/8472reset tocksel0 = 74.25 MHz on CV610 and DV500 alike, above the 27 MHz an OS08A10/A20 and the 36 MHz an OS04A10 accept. A clock we ungate from that state now gets 24 MHz. A running clock, or one whose select somebody chose, is left alone.0x300A..C = 53 08 41and0x302A = 0xB0in every data sheet revision; only Nyxel NIR sensitivity differs.sensor_idstaysOS08A10, which is what consumers pick a driver by, and the report addsid_shared_with: OS08A20.Clocks
DPLL * (1 << dficlk_ratio) * 2. The DV500 data sheet's clock tree runs the DPLL at 667 MHz for "up to 2666 Mbps DDR4". The kit (boot table..._DDR4_2666M-4GB) reads 664 MHz and now reports 2656 MT/s instead of 1328.PERI_CRG2064a55_cksel[10:8] picks one of seven sources, only one of them the APLL. The kit reads 6, the fixed 1000 MHz source, with the APLL at 750 MHz beside it. A newclocks.cpuentry decodes it. CV610's A7 uses a different register and is left out.Tests
hal_hisi_test: +10 cases covering:tools/test_pipeline.shpass. arm64 and arm32 build clean; mips32 was not built locally.On hardware
Hi3519DV500 kit, MPP V2.0.1.1, OS04A10 on SENSOR0 and OS08A20 on SENSOR1:
0x1752)0x1300)0x1300afterwards0x3)Cost: a full report takes 14.6 s on this board instead of 13.0 s, from the two extra listed buses. Most of the time, before and after, is unmuxed adapters timing out in the fallback sweep. Skipping adapters whose pads aren't I2C, using the pad table, would be a follow-up.
ipcinfois unchanged in size on arm32.Review round 1 (Qodo, 7 findings) is addressed in 3939e17.