Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix BBB servo cape overlay #174

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 37 additions & 73 deletions src/arm/BBORG_SERVO-00A2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/am33xx.h>

/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
Expand All @@ -35,85 +31,53 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some comments above about the overall function and resources. I think I know now, but a summary in the comments would be nice.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing 👍

P9_19_pinmux { status = "disabled"; }; /* i2c2.scl */
P9_20_pinmux { status = "disabled"; }; /* i2c2.sda */
P8_10_pinmux { status = "disabled"; }; /* servo.enable */
P8_10_pinmux { status = "disabled"; }; /* pca9685.enable */
};

&am33xx_pinmux {

bborg_servo_input_pins: pinmux_bborg_servo_input_pins {
pinctrl-single,pins = <
BONE_P8_12 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* P8_12: gpio1_12 */
BONE_P8_11 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* P8_11: gpio1_13 */
BONE_P9_30 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* P9_30: gpio3_16 */
BONE_P9_27 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* P9_27: gpio3_19 */
BONE_P9_41 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* P9_41: gpio3_20 */
BONE_P9_42 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* P9_42: gpio0_7 */
>;
};


bborg_servo_pca9685_i2c_pins: bborg_servo_pca9685_i2c_pins {
pinctrl-single,pins = <
BONE_P9_19 (PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* P9_19: i2c2.scl */
BONE_P9_20 (PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* P9_20: i2c2.sda */
>;
};

/*
* Enable and Update the default state of the pins
* For pinctrl-0 values see these file
* BeagleBoard-DeviceTrees/src/arm/am572x-bone-common-univ.dtsi
* BeagleBoard-DeviceTrees/src/arm/am335x-bone-common-univ.dtsi
*/
&ocp {
P8_12_pinmux { status = "okay"; pinctrl-0 = <&P8_12_gpio_input_pin>; }; /* IN1 */
P8_11_pinmux { status = "okay"; pinctrl-0 = <&P8_11_gpio_input_pin>; }; /* IN2 */
P9_30_pinmux { status = "okay"; pinctrl-0 = <&P9_30_gpio_input_pin>; }; /* IN3 */
P9_27_pinmux { status = "okay"; pinctrl-0 = <&P9_27_gpio_input_pin>; }; /* IN4 */
P9_41_pinmux { status = "okay"; pinctrl-0 = <&P9_41_gpio_input_pin>; }; /* IN5 */
P9_42_pinmux { status = "okay"; pinctrl-0 = <&P9_42_gpio_input_pin>; }; /* IN6 */

bborg_servo_pca9685_en_pins: pinmux_bborg_servo_pca9685_en_pins {
pinctrl-single,pins = <
BONE_P8_10 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* P9_20: servo.en */
>;
};
P9_19_pinmux { status = "okay"; pinctrl-0 = <&P9_19_i2c_pin>; }; /* i2c_scl */
P9_20_pinmux { status = "okay"; pinctrl-0 = <&P9_20_i2c_pin>; }; /* i2c_sda */
P8_10_pinmux { status = "okay"; pinctrl-0 = <&P8_10_gpio_pin>; }; /* pca9685.enable */
};

&i2c2 {
pinctrl-names = "default";
pinctrl-0 = <&bborg_servo_pca9685_i2c_pins>;
status = "okay";
clock-frequency = <100000>;
#address-cells = <1>;
#size-cells = <0>;
&bone_i2c_2 {
// bone_i2c_2 is enabled by default on BBB and BBAI for cape EEPROM
// status = "okay";
// clock-frequency = <100000>;
// #address-cells = <1>;
// #size-cells = <0>;

pca9685_servo: pca9685_serve@7f {
compatible = "nxp, pca9685";
lable = "pca9685_servo";
pinctrl-names = "default";
pinctrl-0 = <&bborg_servo_pca9685_en_pins>;
enable-gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there or is there not an enable gpio? I'd think you'd need that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is but we handle it separately not, I tried using it this way but I was not able to make it work out.

reg = <0x7f>;
pca: pca@70 {
compatible = "nxp,pca9685-pwm";
#pwm-cells = <2>;
reg = <0x70>;
label = "pca9685_servo";
/* invert; */
/* open-drain; */
};
};

&{/} {
gpio_inputs {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&bborg_servo_input_pins>;

input@1 {
lable = "in1";
gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
};
input@2 {
lable = "in2";
gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
};
input@3 {
lable = "in3";
gpios = <&gpio3 16 GPIO_ACTIVE_HIGH>;
};
input@4 {
lable = "in4";
gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>;
};
input@5 {
lable = "in5";
gpios = <&gpio3 20 GPIO_ACTIVE_HIGH>;
};
input@6 {
lable = "in6";
gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
leds {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called leds?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a different person back then, didn't knew as much as I know now. I will update this accordingly 👍

led_P8_10 {
status = "okay";
label = "pca9685-enable";
// pca9685 Chip enable is ACTIVE-LOW but LEDs are set to ACTIVE-HIGH
// Set default-state to "off" to enable the pca9685 chip by default.
default-state = "off";
};
};
};