Device Tree Overlay and devices - modmaker/BeBoPr GitHub Wiki

This is the 2191-R2.dts device tree overlay for the BeBoPr. Compile it with the following command:

dtc -O dtb -o 2191-R2.dtbo -b 0 -@ 2191-R2.dts

And put the resulting 2191-R2.dtbo in the /lib/firmware directory of your boot disk.

/*
 * Copyright (C) 2013 Bas Laarhoven
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * version 1.1 - 2013-06-17 cleanup for release
 */
/dts-v1/;
/plugin/;

/ {
	compatible = "aes,bebopr", "ti,beaglebone", "ti,beaglebone-black";

	/* identification */
	part-number = "2191";
	version = "R2";

	exclusive-use =
	/* state the resources this cape uses */

	/* ------ IO POWER ------ */

		"P8.3",		/* gpio1.6     gpio38    old Enable  */
		"P8.5",		/* gpio1.2     gpio34    old Enablen */
		"P8.7",		/* timer4      gpio66    new Enablen */

	/* ------ PWM ------ */

		"P8.36",	/* gpio2.16       J4_PWM  */
		"P8.45",	/* pru1.r30.0     J3_PWM  */
		"P8.46",	/* pru1.r30.1     J2_PWM  */
		"ehrpwm1A",
		"ehrpwm2A",
		"ehrpwm2B",

	/* ------ STEPPERS ------ */

		"P8.41",	/* gpio2.10  #X_ENA */
		"P8.44",	/* gpio2.9   #X_DIR */
		"P8.43",	/* gpio2.8   #X_STP */
		"P8.40",	/* gpio2.13  #Y_ENA */
		"P8.39",	/* gpio2.12  #Y_DIR */
		"P8.42",	/* gpio2.11  #Y_STP */
		"P8.28",	/* gpio2.24  #Z_ENA */
		"P8.29",	/* gpio2.23  #Z_DIR */
		"P8.27",	/* gpio2.22  #Z_STP */
		"P8.20",	/* gpio1.31  #E_ENA */
		"P8.21",	/* gpio1.30  #E_DIR */
		"P8.30",	/* gpio2.25  #E_STP */
		"pru1",
		"pruss",

	/* ------ SENSORS ------ */

		"P8.31",	/* gpio0.10   #X_MIN */
		"P8.32",	/* gpio0.11   #X_MAX */
		"P8.35",	/* gpio0.8    #Y_MIN */
		"P8.33",	/* gpio0.9    #Y_MAX */
		"P8.38",	/* gpio2.15   #Z_MIN */
		"P8.37",	/* gpio2.14   #Z_MAX */

	/* ------ ADC ------ */

		"P9.40",	/* AIN1 */
		"P9.38",	/* AIN3 */
		"P9.36",	/* AIN5 */
		"tscadc",

	/* ------ LED ------ */

				"P8.25";        /* gpio1.0        LED     */

		

	/* ----------- IO POWER ------------ */

	fragment@0 {
		target = <&am33xx_pinmux>;
		__overlay__ {

			bebopr_io_ena_pins: pinmux_bebopr_io_ena_pins {
				pinctrl-single,pins = <
					0x018 0x07  /*  P8-3 GPIO1_6    gpmc_ad6.gpio1[6]      */
					0x008 0x07  /*  P8-5 GPIO1_2    gpmc_ad2.gpio1[2]      */
					0x090 0x07  /*  P8-7 TIMER4     gpmc_advn_ale.gpio2[2] */
				>;
			};
		};
	};

	fragment@1 {
		target = <&ocp>;
		__overlay__ {

			bebopr_io_ena {
				compatible = "aes,bebopr";
				pinctrl-names = "default";
				pinctrl-0 = <&bebopr_io_ena_pins>;

				bebopr-io-enable {
					label = "bebopr:io_enables";
					gpios = <&gpio2 2 1>, <&gpio2 6 0>, <&gpio3 2 1>;
					default-state = "off";
				};
			};
		};
	};

	/* ----------- PWM ------------ */

	fragment@15 {
		target = <&am33xx_pinmux>;
		__overlay__ {

			P8_46_ehrpwm_pin: pinmux_P8_46_ehrpwm_pin {
				pinctrl-single,pins = <0x0a4  0x3>; /* P8_46 (ZCZ ball R2) | MODE 3 */
			};

			P8_46_gpio_pin: pinmux_P8_46_gpio_pin {
				pinctrl-single,pins = <0x0a4  0x7>; /* P8_46 (ZCZ ball R2) | MODE 7 */
			};

			P8_46_pruss_pin: pinmux_P8_46_pruss_pin {
				pinctrl-single,pins = <0x0a4  0x5>; /* P8_46 (ZCZ ball R2) | MODE 5 */
			};

			P8_45_ehrpwm_pin: pinmux_P8_45_ehrpwm_pin {
				pinctrl-single,pins = <0x0a0  0x3>; /* P8_45 (ZCZ ball R1) | MODE 3 */
			};

			P8_45_gpio_pin: pinmux_P8_45_gpio_pin {
				pinctrl-single,pins = <0x0a0  0x7>; /* P8_45 (ZCZ ball R1) | MODE 7 */
			};

			P8_45_pruss_pin: pinmux_P8_45_pruss_pin {
				pinctrl-single,pins = <0x0a0  0x5>; /* P8_45 (ZCZ ball R1) | MODE 5 */
			};

			P8_36_ehrpwm_pin: pinmux_P8_36_ehrpwm_pin {
				pinctrl-single,pins = <0x0c8  0x2>; /* P8_36 (ZCZ ball U3) | MODE 2 */
			};

			P8_36_gpio_pin: pinmux_P8_36_gpio_pin {
				pinctrl-single,pins = <0x0c8  0x7>; /* P8_36 (ZCZ ball U3) | MODE 7 */
			};
		};
	};

	fragment@16 {
		target = <&ocp>;
		__overlay__ {

			bebopr_pwm_J2_pinmux {
				compatible = "bone-pinmux-helper";
				status = "okay";

				pinctrl-names = "default", "gpio", "pruss";
				pinctrl-0 = <&P8_46_ehrpwm_pin>;
				pinctrl-1 = <&P8_46_gpio_pin>;
				pinctrl-2 = <&P8_46_pruss_pin>;
			};

			bebopr_pwm_J3_pinmux {
				compatible = "bone-pinmux-helper";
				status = "okay";

				pinctrl-names = "default", "gpio", "pruss";
				pinctrl-0 = <&P8_45_ehrpwm_pin>;
				pinctrl-1 = <&P8_45_gpio_pin>;
				pinctrl-2 = <&P8_45_pruss_pin>;
			};

			bebopr_pwm_J4_pinmux {
				compatible = "bone-pinmux-helper";
				status = "okay";

				pinctrl-names = "default", "gpio";
				pinctrl-0 = <&P8_36_ehrpwm_pin>;
				pinctrl-1 = <&P8_36_gpio_pin>;
			};

			bebopr_pwm_J2 {
				compatible	= "pwm_test";
				pwms		= <&ehrpwm2 1 10000000 0>;
				pwm-names	= "PWM_J2_FAN";
				enabled		= <0>;
				duty		= <0>;
				status		= "okay";
			};

			bebopr_pwm_J3 {
				compatible	= "pwm_test";
				pwms		= <&ehrpwm2 0 10000000 0>;
				pwm-names	= "PWM_J3_EXTR";
				enabled		= <0>;
				duty		= <0>;
				status		= "okay";
			};

			bebopr_pwm_J4 {
				compatible	= "pwm_test";
				pwms		= <&ehrpwm1 0 100000000 0>;
				pwm-names	= "PWM_J4_BED";
				enabled		= <0>;
				duty		= <0>;
				status		= "okay";
			};
		};
	};

	fragment@11 {
		target = <&epwmss1>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@12 {
		target = <&ehrpwm1>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@13 {
		target = <&epwmss2>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@14 {
		target = <&ehrpwm2>;
		__overlay__ {
			status = "okay";
		};
	};

	/* ----------- STEPPERS ------------ */

	fragment@21 {
		target = <&am33xx_pinmux>;
		__overlay__ {

			bebopr_pruss_pins: pinmux_bebopr_pruss_pins {
				status = "okay";
				pinctrl-single,pins = <
					0xb0 5	/* #X_ENA, pr1_pru1_pru_r30_4,  P8_41, gpio2.10, mode5 out */
					0xac 5	/* #X_DIR, pr1_pru1_pru_r30_3,  P8_44, gpio2.9,  mode5 out */
					0xa8 5	/* #X_STP, pr1_pru1_pru_r30_2,  P8_43, gpio2.8,  mode5 out */
					0xbc 5	/* #Y_ENA, pr1_pru1_pru_r30_7,  P8_40, gpio2.13, mode5 out */
					0xb8 5	/* #Y_DIR, pr1_pru1_pru_r30_6,  P8_39, gpio2.12, mode5 out */
					0xb4 5	/* #Y_STP, pr1_pru1_pru_r30_5,  P8_42, gpio2.11, mode5 out */
					0xe8 5	/* #Z_ENA, pr1_pru1_pru_r30_10, P8_28, gpio2.24, mode5 out */
					0xe4 5	/* #Z_DIR, pr1_pru1_pru_r30_9,  P8_29, gpio2.23, mode5 out */
					0xe0 5	/* #Z_STP, pr1_pru1_pru_r30_8,  P8_27, gpio2.22, mode5 out */
					0x84 5	/* #E_ENA, pr1_pru1_pru_r30_13, P8_20, gpio1.31, mode5 out */
					0x80 5	/* #E_DIR, pr1_pru1_pru_r30_12, P8_21, gpio1.30, mode5 out */
					0xec 5	/* #E_STP, pr1_pru1_pru_r30_11, P8_30, gpio2.25, mode5 out */
				>;
			};
		};	
	};


	fragment@22 {
		target = <&pruss>;
		__overlay__ {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&bebopr_pruss_pins>;
		};
	};

	fragment@23 {
		target = <&ocp>;
		__overlay__ {

			bebopr_pruss {
				compatible = "pruss_uio";
				status = "okay";

				pinctrl-names = "default";
				pinctrl-0 = <&bebopr_pruss_pins>;

				stepper_x {
					pin-names = "bebopr:x_ena", "bebopr:x_dir", "bebpor:x_stp";
					gpios = <&gpio3 10 0>, <&gpio3  9 0>, <&gpio3  8 0>;
				};
				stepper_y {
					pin-names = "bebopr:y_ena", "bebopr:y_dir", "bebpor:y_stp";
					gpios = <&gpio3 13 0>, <&gpio3 12 0>, <&gpio3 11 0>;
				};
				stepper_z {
					pin-names = "bebopr:z_ena", "bebopr:z_dir", "bebpor:z_stp";
					gpios = <&gpio3 24 0>, <&gpio3 23 0>, <&gpio3 22 0>;
				};
				stepper_e {
					pin-names = "bebopr:e_ena", "bebopr:e_dir", "bebpor:e_stp";
					gpios = <&gpio2 31 0>, <&gpio2 30 0>, <&gpio3 25 0>;
				};
			};
		};
	};

	/* ----------- SENSORS ------------ */

	fragment@31 {
		target = <&am33xx_pinmux>;
		__overlay__ {

			bebopr_sensor_pins: pinmux_bebopr_sensor_pins {
				pinctrl-single,pins = <
					/* all inputs with pull-downs */
					0xd8 0x2f	/* #X_MIN, P8_31, gpio0.10, mode7 in */
					0xdc 0x2f	/* #X_MAX, P8_32, gpio0.11, mode7 in */
					0xd0 0x2f	/* #Y_MIN, P8_35, gpio0.8,  mode7 in */
					0xd4 0x2f	/* #Y_MAX, P8_33, gpio0.9 , mode7 in */
					0xc4 0x2f	/* #Z_MIN, P8_38, gpio2.15, mode7 in */
					0xc0 0x2f	/* #Z_MAX, P8_37, gpio2.14, mode7 in */
				>;
			};
		};
	};

	fragment@33 {
		target = <&ocp>;
		__overlay__ {

			compatible = "bone-pinmux-helper";

			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&bebopr_sensor_pins>;

			sensors_x {
				pin-names = "bebopr:x_min", "bebopr:x_max";
				gpios = <&gpio1 10 0>, <&gpio1 11 0>;
			};
			sensors_y {
				pin-names = "bebopr:y_min", "bebopr:y_max";
				gpios = <&gpio1 8 0>, <&gpio1 9 0>;
			};
			sensors_z {
				pin-names = "bebopr:z_min", "bebopr:z_max";
				gpios = <&gpio3 15 0>, <&gpio3 14 0>;
			};
		};
	};

	/* ----------- ADC ------------ */

	fragment@41 {
		target = <&ocp>;
		__overlay__ {

			#address-cells = <1>;
			#size-cells = <1>;

			tscadc {
				compatible = "ti,ti-tscadc";
				reg = <0x44e0d000 0x1000>;
				interrupt-parent = <&intc>;
				interrupts = <16>;
				ti,hwmods = "adc_tsc";
				status = "okay";
				adc {
					ti,adc-channels = <8>;
				};
			};

			bebopr_adc {
				compatible = "bone-iio-helper";
				vsense-name  = "AIN0", "AIN1", "AIN2", "AIN3", "AIN4", "AIN5", "AIN6", "AIN7";
				vsense-scale = < 228     228     228     228     228     228     228     228>;
				status = "okay";
			};
		};
	};

	/* ----------- LED ------------ */

	fragment@51 {
		target = <&am33xx_pinmux>;
		__overlay__ {

			bebopr_led_pins: pinmux_bebopr_led_pins {
				pinctrl-single,pins = <
					0x000 0x07    /* P8-25 GPIO1_0    gpmc_ad0 .gpio1[0]     */
				>;
			};
		};
	};


	fragment@52 {
		target = <&ocp>;
		__overlay__ {

			bebopr_leds {
				compatible = "gpio-leds";
				pinctrl-names = "default";
				pinctrl-0 = <&bebopr_led_pins>;

				status_led {
					label = "bebopr:status_led";
					gpios = <&gpio2 0 0>;
					linux,default-trigger = "heartbeat";
					default-state = "off";
				};
			};
		};
	};

};

This overlay gives some kernel warnings:

[    4.248026] ehrpwm 48302200.ehrpwm: unable to select pin group
[    4.271978] ehrpwm 48304200.ehrpwm: unable to select pin group
[    4.308336] omap_hwmod: pruss: failed to hardreset
[    4.341429] tiadc tiadc: Initialized
[    4.349170] ti_tscadc 44e0d000.tscadc: Initialized OK.
[    4.361245] bone-iio-helper bebopr_adc.18: ready
[    4.371474] of_get_named_gpio_flags exited with status 32
[    4.371498] of_get_named_gpio_flags exited with status 32
[    4.374484] bone-capemgr bone_capemgr.8: slot #0: Applied #16 overlays.
[    4.381443] bone-capemgr bone_capemgr.8: loader: done slot-0 2191:R2 (prio 0)
[    5.572893] pwm_test bebopr_pwm_J2.14: Unable to select pin group
[    5.624501] pwm_test bebopr_pwm_J3.15: Unable to select pin group
[    5.649901] pwm_test bebopr_pwm_J4.16: Unable to select pin group

The BeBoPr devices


The BeBoPr devices can be found in /sys/devices/ocp.2/

bebopr_adc.18
bebopr_io_ena.10
bebopr_leds.19
bebopr_pruss.17
bebopr_pwm_J2.14
bebopr_pwm_J2_pinmux.11
bebopr_pwm_J3.15
bebopr_pwm_J3_pinmux.12
bebopr_pwm_J4.16
bebopr_pwm_J4_pinmux.13

PWM source selection


The bebopr_pwm_J*_pinmux* entries can be used to select the source for the PWM output. By default the signals are driven by the ehrpwm devices. All outputs can also be driven as gpio output and pin 45 (J2) and 46 (J3) can also as pruss output. The selection is made by writing 'default', 'pruss' or 'gpio' to the state file in the pinmux directory.

E.g. to control the FAN on J2 via GPIO instead of as PWM signal:

echo gpio > /sys/devices/ocp.2/bebopr_pwm_J2_pinmux.*/state

Now the FAN can be controlled via GPIO2_16.

Note: Be carefull with the PWM devices: Setting different cycle times for the two ehrpwm2 channels will block further access. This is a restrictiong (read: bug) in the pwm-tiehrpwm.c driver.

BeBoPr status LED


Next to the green power LED, the BeBoPr has a programmable status LED. The DT overlay programs this LED to act like the BBB's heartbeat. But by changing the trigger file, several other drivers including gpio are possible.

root@arm# cat /sys/devices/ocp.2/bebopr_leds.19/leds/bebopr:status_led/trigger
none nand-disk mmc0 timer oneshot [heartbeat] backlight gpio cpu0 default-on transient

ADC


The device tree overlay sets the ADC scaling so that the values returned correspond with the raw ADC reading to stay compatible with the Beaglebone White.

⚠️ **GitHub.com Fallback** ⚠️