Enabling ADC on a Beaglebone Black running FreeBSD 12.0-CURRENT (BEAGLEBONE)

Dr. Rolf Jansen rj at obsigna.com
Thu Jul 6 21:40:21 UTC 2017


> Am 30.03.2017 um 18:11 schrieb Dr. Rolf Jansen <rj at obsigna.com>:
> 
> Am 30.03.2017 um 17:28 schrieb Oleksandr Tymoshenko <gonzo at bluezbox.com>:
>> Dr. Rolf Jansen (rj at obsigna.com) wrote:
>>> 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?
>> 
>> Few months ago FreeBSD switched to using upstream DTB files
>> instead of custom-made ones. For some reason ADC is disabled
>> in upstream. If you're running recent FreeBSD you can use
>> dtb overlays to enable ADC without hassle of maintaining
>> custom dts file. You can do following:
>> 
>> 1. Create am335x-beaglebone-tscadc.dts with following
>> content:
>> 
>> /dts-v1/;
>> /plugin/;
>> 
>> / {
>>   compatible = "ti,am335x-bone-green", "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
>> 
>>   fragment at 0 {
>>       target = <&tscadc>;
>>       __overlay__ {
>>           status = "okay";
>>           adc {
>>               ti,adc-channels = <0 1 2 3 4 5 6>;
>>           };
>>       };
>>   };
>> };
>> 
>> 2. Compile overlay:
>> $ dtc -I dts -O dtb -o am335x-beaglebone-tscadc.dtbo am335x-beaglebone-tscadc.dts
>> 
>> 3. Copy it to /boot/dtb/ directory on your BBB
>> 
>> 4. Enable overlay in /boot/loader.conf by adding following line:
>> 
>> fdt_overlays="am335x-beaglebone-tscadc.dtbo"
> 
> 
> Oleksandr, thank you very much for drawing my attention to the dtb overlay facility.
> 
> I created and enabled the adc-dtb-overlay file as you explained above, and it works.
> 
> Best regards
> 
> Rolf

With the last two 12.0-CURRENT BBB snapshots (r320360 and r320599), the dtb oberlay facility is broken. I can get the above overlay working only if I compile it with the dtc tool from the previous June, 19th snapshot (r320095), and in addition it is necessary to re-add the phandle to the tscadc at 44e0d000 definitions of the base dtb file. Said phandle was removed together with almost all phandles of other device definitions between r320095 and r320360.

Since I need to edit the base dtb anyway, for the time being, I enable the ADC and its channels right in there. This one can be compiled with the new dtc, and in addition the ADC phandle is not necessary.

By the way, the decompiler of the new dtc commes with a formatting glitch. The sections are no more devided by an empty line, instead an empty line is introduced below the section headers -- this looks spoiled somehow. Anyway, here are my working changes: 

--- am335x-boneblack.dts.orig	2017-07-06 18:32:10.321019000 -0300
+++ am335x-boneblack.dts	2017-07-06 16:00:22.255994000 -0300
@@ -1711,7 +1711,7 @@
 			interrupt-parent = <0x1>;
 			interrupts = <0x10>;
 			ti,hwmods = "adc_tsc";
-			status = "disabled";
+			status = "okay";
 			dmas = <0x29 0x35 0x0 0x29 0x39 0x0>;
 			dma-names = "fifo0", "fifo1";
 			tsc {
@@ -1722,8 +1722,19 @@
 
 				#io-channel-cells = <0x1>;
 				compatible = "ti,am3359-adc";
+				ti,adc-channels = <0 1 2 3 4 5 6 7>;
 			};
 		};
+		pruss at 4A300000 {
+
+			compatible = "ti,pruss-v2";
+			ti,deassert-hard-reset = "pruss", "pruss";
+			reg = <0x4a300000 0x80000>;
+			ti,pintc-offset = <0x20000>;
+			interrupt-parent = <0x1>;
+			interrupts = <0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B>;
+			status = "okay";
+		};
 		gpmc at 50000000 {
 
 			compatible = "ti,am3352-gpmc";
@@ -1969,6 +1980,7 @@
 		ehrpwm2_tbclk = "/ocp/l4_wkup at 44c00000/scm at 210000/scm_conf at 0/clocks/ehrpwm2_tbclk at 44e10664";
 		ehrpwm0_tbclk = "/ocp/l4_wkup at 44c00000/scm at 210000/scm_conf at 0/clocks/ehrpwm0_tbclk at 44e10664";
 		tscadc = "/ocp/tscadc at 44e0d000";
+		pruss = "/ocp/pruss at 4A300000";
 		clkout2_pin = "/ocp/l4_wkup at 44c00000/scm at 210000/pinmux at 800/pinmux_clkout2_pin";
 		aes0_fck = "/ocp/l4_wkup at 44c00000/scm at 210000/scm_conf at 0/clocks/aes0_fck";
 		gpio3_dbclk = "/ocp/l4_wkup at 44c00000/prcm at 200000/clocks/gpio3_dbclk at b4";




More information about the freebsd-arm mailing list