-
Notifications
You must be signed in to change notification settings - Fork 176
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
BBB and BBAI compatible BBORG motorCape overlay #188
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
/* | ||
* Copyright (C) 2020 Deepak Khatri <[email protected]> | ||
* | ||
* Based on BBORG_MOTOR-00A2.dts from Robert Nelson for kernel <4.14 | ||
* Copyright (C) 2018 Robert Nelson <[email protected]> | ||
* | ||
* Note: Requires Compaibility code from BeagleBoard-DeviceTrees/pull/17 | ||
* | ||
* 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. | ||
|
@@ -9,135 +14,97 @@ | |
/dts-v1/; | ||
/plugin/; | ||
|
||
#include <dt-bindings/gpio/gpio.h> | ||
#include <dt-bindings/pinctrl/am33xx.h> | ||
/* | ||
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/ | ||
*/ | ||
&{/chosen} { | ||
overlays { | ||
BBORG_MOTOR-00A2 = __TIMESTAMP__; | ||
}; | ||
}; | ||
|
||
/ { | ||
/* | ||
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/ | ||
*/ | ||
fragment@0 { | ||
target-path="/"; | ||
__overlay__ { | ||
/* | ||
* Free up the pins used by the cape from the pinmux helpers. | ||
*/ | ||
&ocp { | ||
P8_13_pinmux { status = "disabled"; }; /* motor3 speed */ | ||
P8_14_pinmux { status = "disabled"; }; /* motor3 direction */ | ||
P8_16_pinmux { status = "disabled"; }; /* motor2 direction */ | ||
P8_18_pinmux { status = "disabled"; }; /* motor1 direction */ | ||
P8_19_pinmux { status = "disabled"; }; /* motor4 speed */ | ||
P8_26_pinmux { status = "disabled"; }; /* motor4 direction */ | ||
P9_14_pinmux { status = "disabled"; }; /* motor2 speed */ | ||
P9_16_pinmux { status = "disabled"; }; /* motor1 speed */ | ||
}; | ||
|
||
chosen { | ||
overlays { | ||
BBORG_MOTOR-00A2 = __TIMESTAMP__; | ||
}; | ||
}; | ||
}; | ||
}; | ||
/* | ||
* Enable and Update the default state of the pins | ||
*/ | ||
&ocp { | ||
P8_13_pinmux { status = "okay"; pinctrl-0 = <&P8_13_pwm_pin>; }; /* motor3 speed */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given this approach, I don't think disabling the pinmux helper is needed. As only loosely mentioned in the comment, what you are doing here is changing the default mode with the pinmux helper, rather than using the driver to simply define the mode. This may be an OK approach, but it is a bit error-prone if someone messes with the pinmux helper. This change needs to be a bit better documented for users in some kind of changelog. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right we don't need those disabling I will try things without it. There was a much bigger problem in the previous implementation method. we were limiting users to use labels we defined for the buses. With this approach and good documentation, the user can create new overlays without chaing in the compatibility code. I will write the documentation soon :) |
||
P8_14_pinmux { status = "okay"; pinctrl-0 = <&P8_14_gpio_pin>; }; /* motor3 direction */ | ||
P8_16_pinmux { status = "okay"; pinctrl-0 = <&P8_16_gpio_pin>; }; /* motor2 direction */ | ||
P8_18_pinmux { status = "okay"; pinctrl-0 = <&P8_18_gpio_pin>; }; /* motor1 direction */ | ||
P8_19_pinmux { status = "okay"; pinctrl-0 = <&P8_19_pwm_pin>; }; /* motor4 speed */ | ||
P8_26_pinmux { status = "okay"; pinctrl-0 = <&P8_26_gpio_pin>; }; /* motor4 direction */ | ||
P9_14_pinmux { status = "okay"; pinctrl-0 = <&P9_14_pwm_pin>; }; /* motor2 speed */ | ||
P9_16_pinmux { status = "okay"; pinctrl-0 = <&P9_16_pwm_pin>; }; /* motor1 speed */ | ||
}; | ||
|
||
/* | ||
* Free up the pins used by the cape from the pinmux helpers. | ||
*/ | ||
fragment@1 { | ||
target = <&ocp>; | ||
__overlay__ { | ||
P8_13_pinmux { status = "disabled"; }; /* m3.pwm2.b */ | ||
P8_14_pinmux { status = "disabled"; }; /* m3.high */ | ||
P8_16_pinmux { status = "disabled"; }; /* m2.high */ | ||
P8_18_pinmux { status = "disabled"; }; /* m1.high */ | ||
P8_19_pinmux { status = "disabled"; }; /* m4.pwm2.a */ | ||
P8_26_pinmux { status = "disabled"; }; /* m4.high */ | ||
P9_14_pinmux { status = "disabled"; }; /* m2.pwm1.a */ | ||
P9_16_pinmux { status = "disabled"; }; /* m1.pwm1.b */ | ||
}; | ||
}; | ||
// Motor 1, 2 | ||
&bone_pwmss_1 { | ||
status = "okay"; | ||
}; | ||
|
||
fragment@2 { | ||
target = <&am33xx_pinmux>; | ||
__overlay__ { | ||
bborg_motor_led_pins: pinmux-bborg-proto-led-pins { | ||
pinctrl-single,pins = < | ||
AM33XX_IOPAD(0x0828, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE7) /* P8_14: gpmc_ad10.gpio0_26 */ | ||
AM33XX_IOPAD(0x0838, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE7) /* P8_16: gpmc_ad14.gpio1_14 */ | ||
AM33XX_IOPAD(0x088c, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE7) /* P8_18: gpmc_clk.gpio2_1 */ | ||
AM33XX_IOPAD(0x087c, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE7) /* P8_26: gpmc_csn0.gpio1_29 */ | ||
>; | ||
}; | ||
&bone_pwm_1 { | ||
status = "okay"; | ||
}; | ||
|
||
bborg_motor_ehrpwm1_pins: pinmux-bborg-proto-ehrpwm1-pins { | ||
pinctrl-single,pins = < | ||
AM33XX_IOPAD(0x0848, PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* P9_14: gpmc_a2.ehrpwm1a */ | ||
AM33XX_IOPAD(0x084c, PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* P9_16: gpmc_a3.ehrpwm1b */ | ||
>; | ||
}; | ||
// Motor 3, 4 | ||
&bone_pwmss_2 { | ||
status = "okay"; | ||
}; | ||
|
||
bborg_motor_ehrpwm2_pins: pinmux-bborg-proto-ehrpwm2-pins { | ||
pinctrl-single,pins = < | ||
AM33XX_IOPAD(0x0824, PIN_OUTPUT_PULLDOWN | MUX_MODE4) /* P8_13: gpmc_ad9.ehrpwm2b */ | ||
AM33XX_IOPAD(0x0820, PIN_OUTPUT_PULLDOWN | MUX_MODE4) /* P8_19: gpmc_ad8.ehrpwm2a */ | ||
>; | ||
}; | ||
}; | ||
}; | ||
&bone_pwm_2 { | ||
status = "okay"; | ||
}; | ||
|
||
fragment@3 { | ||
target = <&epwmss1>; | ||
__overlay__ { | ||
status = "okay"; | ||
}; | ||
}; | ||
|
||
fragment@4 { | ||
target = <&ehrpwm1>; | ||
__overlay__ { | ||
pinctrl-names = "default"; | ||
pinctrl-0 = <&bborg_motor_ehrpwm1_pins>; | ||
/* | ||
* Easy Motor direction control through sysfs (/sys/class/leds/motor*) using gpio-leds driver | ||
* See these files for the led_P8_#/led_P9_# definition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting to carry these led definitions at the "bus" level. I suppose it works if they are useful enough. We need a sane way to document helpers that are exposed by the "bus". Please update the wiki page specification with usage guidelines for what interfaces are exposed for overlays to use. |
||
* https://github.com/beagleboard/BeagleBoard-DeviceTrees/src/arm/bbai-bone-buses.dtsi | ||
* https://github.com/beagleboard/BeagleBoard-DeviceTrees/src/arm/bbb-bone-buses.dtsi | ||
* | ||
*/ | ||
&{/} { | ||
leds { | ||
// Motor 1 | ||
led_P8_18 { | ||
status = "okay"; | ||
label = "motor1"; | ||
default-state = "off"; | ||
}; | ||
}; | ||
|
||
fragment@5 { | ||
target = <&epwmss2>; | ||
__overlay__ { | ||
// Motor 2 | ||
led_P8_16 { | ||
status = "okay"; | ||
label = "motor2"; | ||
default-state = "off"; | ||
}; | ||
}; | ||
|
||
fragment@6 { | ||
target = <&ehrpwm2>; | ||
__overlay__ { | ||
pinctrl-names = "default"; | ||
pinctrl-0 = <&bborg_motor_ehrpwm2_pins>; | ||
// Motor 3 | ||
led_P8_14 { | ||
status = "okay"; | ||
label = "motor3"; | ||
default-state = "off"; | ||
}; | ||
}; | ||
|
||
fragment@7 { | ||
target-path="/"; | ||
__overlay__ { | ||
|
||
leds { | ||
pinctrl-names = "default"; | ||
pinctrl-0 = <&bborg_motor_led_pins>; | ||
compatible = "gpio-leds"; | ||
|
||
m1_high { | ||
label = "m1_high"; | ||
gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>; | ||
default-state = "off"; | ||
}; | ||
|
||
m2_high { | ||
label = "m2_high"; | ||
gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>; | ||
default-state = "off"; | ||
}; | ||
|
||
m3_high { | ||
label = "m3_high"; | ||
gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>; | ||
default-state = "off"; | ||
}; | ||
|
||
m4_high { | ||
label = "m4_high"; | ||
gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>; | ||
default-state = "off"; | ||
}; | ||
}; | ||
// Motor 4 | ||
led_P8_26 { | ||
status = "okay"; | ||
label = "motor4"; | ||
default-state = "off"; | ||
}; | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right approach is to add your copyright, not remove someone else's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new code is very different from the old code that's why I dropped that. I will do that if you say so, talked to ds2 he suggested to include the comment you are seeing.