Debian 7.6 console image 3.14 kernel LCD cape and device tree modification

I’ve been googling and watching device tree tutorials… all targeted at 3.8 kernel.
This is great for learning the basics, but I have 3.14 kernel: Linux beaglebone 3.14.19-ti-r30 #1 SMP PREEMPT Mon Oct 13 20:34:06 UTC 2014 armv7l GNU/Linux
From what I can find, the friendly device tree tools haven’t been ported to 3.14 yet.

The best way to work with the device tree is to decompile your existing dtb (I have a 4D LCD display, so I’ve decompiled the dub for it below)

#dtc -I dtb -O dts /boot/dtbs/3.14.19-ti-r30/am335x-boneblack-4dcape-43t.dtb > am335x-boneblack-4dcape-43t.dts

My goal is to set up the following changes for a A/D light sensor, RGB PWM LED driver, 2 stepper motors with 2 zero crossing sensors (switches)

ANALOG P9-39 AIN0 Light Sensor A/D
OUT P8-19 gpio0[22] 22 0x820 EHRPWM2A RED LED PWM
OUT P8-13 pgio0[23] 23 0x824 EHRPWM2B GREEN LED PWM
OUT P9-14 gpio1[18] 50 0x848 EHRPWM1A BLUE LED PWM
IN P8-14 gpio0[26] 26 0x828 GPIO0_26 Sensor 1 Zero Crossing
IN P8-17 gpio0[27] 27 0x82c GPIO0_27 Sensor 2 Zero Crossing
OUT P8-12 gpio1[12] 44 0x830 GPIO1_12 Stepper A1
OUT P8-11 gpio1[13] 45 0x834 GPIO1_13 Stepper B1
OUT P8-16 gpio1[14] 46 0x838 GPIO1_14 Stepper C1
OUT P8-15 gpio1[15] 47 0x83c GPIO1_15 Stepper D1
OUT P9-15 gpio1[16] 48 0x840 GPIO1_16 Stepper A2
OUT P9-23 gpio1[17] 49 0x844 GPIO1_17 Stepper B2
OUT P9-12 gpio1[28] 60 0x878 GPIO1_28 Stepper C2
OUT P8-26 gpio1[29] 61 0x87c GPIO1_29 Stepper D2

The decompiled DTS is pretty confusing. I’m not sure what sections to change to tie all the pieces together.

Is there a tutorial somewhere to describe how to do this for kernel 3.14?

I just saw the post below mine (how did I miss it before?) that mentioned
https://github.com/cdsteinkuehler/beaglebone-universal-io

for 3.14 kernel.
I’m reading through it now, sounds like it may answer my question…

Take a look at:

https://github.com/RobertCNelson/dtb-rebuilder/tree/3.14-ti

Specifically:

Main dtb:
https://github.com/RobertCNelson/dtb-rebuilder/blob/3.14-ti/src/arm/am335x-bone-4dcape-43t.dts

Main include:
https://github.com/RobertCNelson/dtb-rebuilder/blob/3.14-ti/src/arm/am335x-bone-4dcape-43t.dtsi

Direction are here:
http://elinux.org/Beagleboard:Capes_3.8_to_3.14#Custom_dtb

Regards,

I just ran across BBIOConfig (https://github.com/strahlex/BBIOConfig)
Very cool and easy to understand.
I saw there was a utility “config-pin” for setting up the pin configuration.
Does this work on BBB 3.14 now?
Is there an apt-get install package that will install it?

That's the plan with 3.14, not all the pins are controlled by config-pin yet..

Regards,

Using the dtb-rebuilder, I see the main include file for my cape, am335x-bone-4dcape-43t.dtsi.

I see the various includes for they key mappings and led includes.

However, I don’t see any includes for PWM configurations.
Looking at some of the existing includes, they seem a little different from a 3.8 kernel overlay.
Are there examples somewhere for what the include needs to look like to enable PWM functionality?
Do the A/D analog pins need include files also or are they always enabled?

Using the dtb-rebuilder, I see the main include file for my cape,
am335x-bone-4dcape-43t.dtsi.
I see the various includes for they key mappings and led includes.
However, I don't see any includes for PWM configurations.

I haven't figured out the pwm's yet. :wink:

Looking at some of the existing includes, they seem a little different from
a 3.8 kernel overlay.
Are there examples somewhere for what the include needs to look like to
enable PWM functionality?
Do the A/D analog pins need include files also or are they always enabled?

The analog pins are always muxed.

Here's an example for 3 adc pins:

https://github.com/RobertCNelson/dtb-rebuilder/blob/3.14-ti/src/arm/am335x-bone-basic-proto-cape.dtsi

Regards,

Using http://kilobaser.com/blog/2014-07-28-beaglebone-black-devicetreeoverlay-generator
I get an overlay file that looks like:

/*

  • Copyright © 2013 CircuitCo
  • Copyright © 2013 Texas Instruments

Thanks for the ADC example.
Is there a good general purpose output pin example?
I see the LED examples, is that the same as a generic output pin?

This works for what i needed at the time:

https://github.com/RobertCNelson/dtb-rebuilder/blob/3.14-ti/src/arm/am335x-bone-rtc-01-00a1.dtsi#L16

but i'd like to find a more generic gpio option, something that you
can easily access from userspace..

Regards,

I know config-pin will solve a lot of the pain of mapping IO pins / features.
The BBIOConfig Qt GUI for allocating the pins looks very slick.
I’m looking forward to the release of the working versions. :slight_smile:

The example you linked looks like the interface configuration for Microchip’s RTC I2C module. I’ve used them in a few projects before.
The RTC multi-purpose pin appears to be used for the alarm, so the GPIO pin on the am335x is configured for input, with an interrupt to wake up the CPU if in sleep.
So, based on that example, if I set up all the pins (I’ll skip PWM for now and use them as output pins) it looks like I need an include file that looks like:

&ocp {
P8_19_pinmux {
/* gpio0[22] /
status = “disabled”;
};
P8_13_pinmux {
/
gpio0[23] /
status = “disabled”;
};
P9_14_pinmux {
/
gpio1[18] /
status = “disabled”;
};
P8_14_pinmux {
/
gpio0[26] /
status = “disabled”;
};
P8_17_pinmux {
/
gpio0[27] /
status = “disabled”;
};
P8_12_pinmux {
/
gpio1[12] /
status = “disabled”;
};
P8_11_pinmux {
/
gpio1[13] /
status = “disabled”;
};
P8_16_pinmux {
/
gpio1[14] /
status = “disabled”;
};
P8_15_pinmux {
/
gpio1[15] /
status = “disabled”;
};
P9_15_pinmux {
/
gpio1[16] /
status = “disabled”;
};
P9_23_pinmux {
/
gpio1[17] /
status = “disabled”;
};
P9_12_pinmux {
/
gpio1[28] /
status = “disabled”;
};
P8_26_pinmux {
/
gpio1[29] */
status = “disabled”;
};
};

/ {
gpio_keys {
compatible = “gpio-keys”;
pinctrl-names = “default”;
pinctrl-0 = <&gpio0_22_pins>;
pinctrl-1 = <&gpio0_23_pins>;
pinctrl-2 = <&gpio1_18_pins>;
pinctrl-3 = <&gpio0_26_pins>;
pinctrl-4 = <&gpio0_27_pins>;
pinctrl-5 = <&gpio1_12_pins>;
pinctrl-6 = <&gpio1_13_pins>;
pinctrl-7 = <&gpio1_14_pins>;
pinctrl-8 = <&gpio1_15_pins>;
pinctrl-9 = <&gpio1_16_pins>;
pinctrl-10 = <&gpio1_17_pins>;
pinctrl-11 = <&gpio1_13_pins>;
pinctrl-12 = <&gpio1_28_pins>;
pinctrl-13 = <&gpio1_29_pins>;

};
};

I didn’t see how to specify direction of default value. Does it just default to input?
Can you group the pins together like that in the gpio_keys section?

Sorry for being such a noob.

There's an example in the hdmi audio:

https://github.com/RobertCNelson/dtb-rebuilder/blob/3.14-ti/src/arm/am335x-boneblack-nxp-hdmi-audio.dtsi

* i need to migrate all the hdml/lcd files to this pinmux setup..

P8_27_pinmux {
      mode = "hdmi";
};

pinctrl-names = "default", "off";
    /* pinctrl-0 = <&nxp_hdmi_bonelt_pins>; */

Regards,

So, it need to look more like this?

&ocp {
P8_19_pinmux {
/* gpio0[22] /
mode = “gpio_output”;
};
P8_13_pinmux {
/
gpio0[23] /
mode = “gpio_output”;
};
P9_14_pinmux {
/
gpio1[18] /
mode = “gpio_output”;
};
P8_14_pinmux {
/
gpio0[26] /
mode = “gpio_output”;
};
P8_17_pinmux {
/
gpio0[27] /
mode = “gpio_output”;
};
P8_12_pinmux {
/
gpio1[12] /
mode = “gpio_output”;
};
P8_11_pinmux {
/
gpio1[13] /
mode = “gpio_output”;
};
P8_16_pinmux {
/
gpio1[14] /
mode = “gpio_output”;
};
P8_15_pinmux {
/
gpio1[15] /
mode = “gpio_output”;
};
P9_15_pinmux {
/
gpio1[16] /
mode = “gpio_output”;
};
P9_23_pinmux {
/
gpio1[17] /
mode = “gpio_output”;
};
P9_12_pinmux {
/
gpio1[28] /
mode = “gpio_output”;
};
P8_26_pinmux {
/
gpio1[29] */
mode = “gpio_output”;
};
};

/ {
gpio_output {
compatible = “ti”;
pinctrl-names = "default”, “off”;
};
};

Is there a place to set the default direction to output?

After looking through the dts and dtsi files, I think my problem lies in understanding how they all fit together.
The beaglebone default configurations appear in am335x-bone-common-pinmux.dtsi.
It lacks OUTPUT configuration for the pins (except the PWM configurations)
So, you have to disable the default configuration for the output pins and build your own.

Does this look correct?

/* configure output pins */

&am33xx_pinmux {

stepper_driver: stepper_driver_pins {

pinctrl-single,pins = <

0x030 (PIN_OUTPUT | MUX_MODE7) /* P8_12 */

0x034 (PIN_OUTPUT | MUX_MODE7) /* P8_11 */

0x038 (PIN_OUTPUT | MUX_MODE7) /* P8_16 */

0x03C (PIN_OUTPUT | MUX_MODE7) /* P8_15 */

0x040 (PIN_OUTPUT | MUX_MODE7) /* P9_15 */

0x044 (PIN_OUTPUT | MUX_MODE7) /* P9_23 */

0x078 (PIN_OUTPUT | MUX_MODE7) /* P9_12 */

0x07c (PIN_OUTPUT | MUX_MODE7) /* P8_26 */

;

};

};

/* Modify default pin configurations defined in am335x-bone-common-pinmux.dtsi */

&ocp {

/* Enable PWM mode for these pins */

P8_19_pinmux {

/* gpio0[22] */

mode = “P8_19_pwm_pin”;

};

P8_13_pinmux {

/* gpio0[23] */

mode = “P8_13_pwm_pin”;

};

P9_14_pinmux {

/* gpio1[18] */

mode = “P8_14_pwm_pin”;

};

/* Enable input with pullups for these pins */

P8_14_pinmux {

/* gpio0[26] */

mode = “P8_14_gpio_pu_pin”;

};

P8_17_pinmux {

/* gpio0[27] */

mode = “P8_17_gpio_pu_pin”;

};

/* There is no output configuration - disable the default configuration */

P8_12_pinmux {

/* gpio1[12] */

status = “disabled”;

};

P8_11_pinmux {

/* gpio1[13] */

status = “disabled”;

};

P8_16_pinmux {

/* gpio1[14] */

status = “disabled”;

};

P8_15_pinmux {

/* gpio1[15] */

status = “disabled”;

};

P9_15_pinmux {

/* gpio1[16] */

status = “disabled”;

};

P9_23_pinmux {

/* gpio1[17] */

status = “disabled”;

};

P9_12_pinmux {

/* gpio1[28] */

status = “disabled”;

};

P8_26_pinmux {

/* gpio1[29] */

status = “disabled”;

};

};

/* Enable the output configuration defined above */

&stepper_driver {

status = “okay”;

};