New ADC driver for Amlogic Meson
Vincent DEFERT <[email protected]> Sat, 26 Jul 2025 16:07:42 +0000
| Newsgroups | gmane.os.netbsd.ports.arm |
|---|---|
| Message-ID | <[email protected]> |
I have written a driver for the Amlogic Meson SoC's ADC and tested it on the ODROID C2. The ADC's 8 channels are exposed through the envsys(2) framework, so it is not limited to the 2 channels exposed on the ODROID C2's GPIO header. For each conversion, a series of 8 samples is averaged, which takes over 40 microseconds. This driver is thus not suited for fast data acquisition. I don't know if attachments are ok on the mailing-list, so I made thesource code available here: http://www.defert.com/meson_adc.c It belongs in sys/arch/arm/amlogic. In addition, the following lines must be added in sys/arch/arm/amlogic/files.meson: # ADC device mesonadc attach mesonadc at fdt with meson_adc file arch/arm/amlogic/meson_adc.c meson_adc and the line below in sys/arch/evbarm/config/GENERIC64: mesonadc* at fdt? # Amlogic Meson SAR ADC While you're at it, please also add to GENERIC64 the missing line for the I2C driver, which I had forgotten to mention lately: mesoniic* at fdt? # Amlogic Meson I2C To test the driver, apply a known voltage __under 1.8V__ to pin 40 (ch0) or 37 (ch1) of the ODROID C2's GPIO header and simply run envstat with no argument. The C2's ADC has a 10-bit resolution, that is more or less 3 digits after the decimal point.