Repository navigation
hi3516cv100: a driver for the SAR ADC, where boards wire the photocell - #265
Conversation
The Hi3518 V100 family has a 10-bit, two-channel SAR ADC (Hi3518 Data Sheet, 13.8) that day/night boards hang a photoresistor on. HiSilicon's V1 SDK ships no driver for it, so OpenIPC could not read one (OpenIPC/firmware#2595, a Hi3518EV100 dome with its photocell on channel 0). open_adc.ko brings the block out of reset, clocks it from PERI_CRG32 and exposes each channel as a misc device, /dev/ADC_CH0 and /dev/ADC_CH1 (the names the vendor firmware used). A read() of at least four bytes runs one conversion and returns it as an int, 0..1023. The conversion interrupt is shared with the IR receiver, so completion is polled from the raw status. The first conversion out of reset reads 0 whatever is on the pin, and is spent at load time. Measured on a hi3516cv100 (kernel 3.0.8): both channels convert, with floating pins reading 3..22; 20000 reads with no timeout; unloading puts the block back in reset.
PR Summary by QodoAdd SAR ADC driver for hi3516cv100-family photocell inputs
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
… (review) The warm-up conversion at load time ignored its result, so a block that never completed a conversion still registered both nodes, and every read then timed out. Its failure now fails the load through the existing cleanup path.
|
Qodo finding addressed in 29b9190: the warm-up conversion's result is now checked, and a timeout fails the load ( |
Thanks for the update. |
…pensdk 4cdb9ae (#2595) Bumps hisilicon-opensdk to 4cdb9ae (OpenIPC/openhisilicon#265), which builds open_adc.ko for the hi3516cv100 family: a driver for the SoC's SAR ADC, where boards like the Hi3518EV100 GF_YTJ010E dome wire their photoresistor. The bump carries nothing else. Install it as hi_adc.ko and load it beside pwm.ko, so /dev/ADC_CH0 and /dev/ADC_CH1 exist on every V1 camera. The module keeps its own name, open_adc, which is what remove_ko has to give rmmod.
For OpenIPC/firmware#2595: a Hi3518EV100 dome whose photoresistor is on SAR ADC channel 0. HiSilicon's V1 SDK ships no driver for the block, so OpenIPC could not read it.
What
kernel/adc/hi3516cv100/adc.cbuildsopen_adc.ko(GPL, plain kernel APIs, no OSAL), wired intokernel/hi3516cv100.kbuild.0x200B0000, 10-bit, two channels with dedicated pins (no pinmux). Clock and reset are inPERI_CRG32(0x20030080: bit1 cken, bit0 srst).ADC_INT_RAW(1 ms timeout, then-ETIMEDOUT)./dev/ADC_CH0and/dev/ADC_CH1are misc devices; the names match what vendor firmware used. Aread()of at least 4 bytes runs one conversion and returns anint, 0..1023. Shorter reads get-EINVAL.Tested on a hi3516cv100 (kernel 3.0.8, lite)
devmem. At bootPERI_CRG32reads0x1(in reset, clock gated).hi3516cv100_litewith this tree as the opensdk source), flashed, and loaded at boot byload_hisilicon.rmmodreturnsPERI_CRG32to0x1./dev/ADC_CH0and switches night and day.Not yet built against the neo (7.0) kernel. That is #264, and it matters because the firmware install step for cv100 is not variant-gated.
The firmware change (install as
hi_adc.ko, insmod inload_hisilicon) follows once this is merged and the opensdk pin is bumped.