Enabling ADC on a Beaglebone Black running FreeBSD 12.0-CURRENT (BEAGLEBONE)
Dr. Rolf Jansen
rj at obsigna.com
Tue Mar 28 23:55:03 UTC 2017
Today I updated once again my Beaglebone Black by merging-in the latest FreeBSD 12.0-CURRENT (BEAGLEBONE) snapshot, and once again I enabled the ADCs on the Beaglebone in the device tree blob am335x-boneblack.dtb, and the ADC is still working fine.
Even if it is not that a big hassle to modify the device tree blob, I am curious on why the ADC has been disabled in the blob in the first place, end even more, given the fact that the device ti_adc driver is built-in to kernel and once enabled, the ADC is functional.
Didn't it work at some time in the past? Now it is.
What is missing to activate the ADC in the device tree blob by default?
Best regards
Rolf
Am 12.03.2017 um 18:38 schrieb Dr. Rolf Jansen <rj at obsigna.com>:
> The ADC is disabled in the respective device tree file am335x-boneblack.dtb. In order to enable the it, I did:
>
> 1. decompile the device tree blob (.dtb) into a device tree source file (.dts):
>
> cd /boot/dtb
> dtc -I dtb -O dts am335x-boneblack.dtb > am335x-boneblack.dts
>
>
> 2. edit the .dts file, and change the entry for tscadc to the following:
>
> tscadc at 44e0d000 {
> compatible = "ti,am3359-tscadc";
> reg = <0x44e0d000 0x1000>;
> interrupt-parent = <0x1>;
> interrupts = <0x10>;
> ti,hwmods = "adc_tsc";
> status = "okay";
> dmas = <0x29 0x35 0x0 0x29 0x39 0x0>;
> dma-names = "fifo0", "fifo1";
>
> tsc {
> compatible = "ti,am3359-tsc";
> };
>
> adc {
> #io-channel-cells = <0x1>;
> compatible = "ti,am3359-adc";
> ti,adc-channels = <0 1 2 3 4 5 6>;
> };
> };
>
> ActualLy I changed the status from "disabled" to "okay" and I added the ti,adc-channels descriptor to the adc section.
>
> 3. save the original DTB and compile the DTS:
>
> mv am335x-boneblack.dtb am335x-boneblack.dtb.orig
> dtc -O dtb -o am335x-boneblack.dtb -b 0 am335x-boneblack.dts
>
> 4. restart
>
> 5. check it:
>
> sysctl dev.ti_adc
> ....
> dev.ti_adc.0.ain.6.input: 0
> dev.ti_adc.0.ain.6.samples_avg: 0
> dev.ti_adc.0.ain.6.open_delay: 0
> dev.ti_adc.0.ain.6.enable: 0
> dev.ti_adc.0.ain.5.input: 0
> dev.ti_adc.0.ain.5.samples_avg: 0
> dev.ti_adc.0.ain.5.open_delay: 0
> dev.ti_adc.0.ain.5.enable: 0
> dev.ti_adc.0.ain.4.input: 0
> dev.ti_adc.0.ain.4.samples_avg: 0
> dev.ti_adc.0.ain.4.open_delay: 0
> dev.ti_adc.0.ain.4.enable: 0
> dev.ti_adc.0.ain.3.input: 0
> dev.ti_adc.0.ain.3.samples_avg: 0
> dev.ti_adc.0.ain.3.open_delay: 0
> dev.ti_adc.0.ain.3.enable: 0
> dev.ti_adc.0.ain.2.input: 0
> dev.ti_adc.0.ain.2.samples_avg: 0
> dev.ti_adc.0.ain.2.open_delay: 0
> dev.ti_adc.0.ain.2.enable: 0
> dev.ti_adc.0.ain.1.input: 0
> dev.ti_adc.0.ain.1.samples_avg: 0
> dev.ti_adc.0.ain.1.open_delay: 0
> dev.ti_adc.0.ain.1.enable: 0
> dev.ti_adc.0.ain.0.input: 3071
> dev.ti_adc.0.ain.0.samples_avg: 0
> dev.ti_adc.0.ain.0.open_delay: 0
> dev.ti_adc.0.ain.0.enable: 1
> dev.ti_adc.0.clockdiv: 2400
> dev.ti_adc.0.%parent: simplebus0
> dev.ti_adc.0.%pnpinfo: name=tscadc at 44e0d000 compat=ti,am3359-tscadc
> dev.ti_adc.0.%location:
> dev.ti_adc.0.%driver: ti_adc
> dev.ti_adc.0.%desc: TI ADC controller
> dev.ti_adc.%parent:
>
> I can enable the ADC channels, and when connecting a 1002 mV DC source to AIN0 the reading was 2279, which is perfectly in line with 1002*4095/1800 = 2279.55.
>
> Best regards
>
> Rolf
More information about the freebsd-arm
mailing list