From 5546ee3d9b4a4fca10c0484955685dad4dc05dc7 Mon Sep 17 00:00:00 2001 From: Deepak Khatri Date: Mon, 13 Jul 2020 20:17:31 +0530 Subject: [PATCH 1/3] Rewritting the overlay To make it compatible for both BBB and BBAI by using code from beagleboard/BeagleBoard-DeviceTrees/pull/17 and new DT format. --- src/arm/BBORG_MOTOR-00A2.dts | 143 ----------------------------------- 1 file changed, 143 deletions(-) diff --git a/src/arm/BBORG_MOTOR-00A2.dts b/src/arm/BBORG_MOTOR-00A2.dts index 22e0e4aa..e69de29b 100644 --- a/src/arm/BBORG_MOTOR-00A2.dts +++ b/src/arm/BBORG_MOTOR-00A2.dts @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2018 Robert Nelson - * - * 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. - */ - -/dts-v1/; -/plugin/; - -#include -#include - -/ { - /* - * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/ - */ - fragment@0 { - target-path="/"; - __overlay__ { - - chosen { - overlays { - BBORG_MOTOR-00A2 = __TIMESTAMP__; - }; - }; - }; - }; - - /* - * 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 */ - }; - }; - - 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 */ - >; - }; - - 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 */ - >; - }; - - 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 */ - >; - }; - }; - }; - - fragment@3 { - target = <&epwmss1>; - __overlay__ { - status = "okay"; - }; - }; - - fragment@4 { - target = <&ehrpwm1>; - __overlay__ { - pinctrl-names = "default"; - pinctrl-0 = <&bborg_motor_ehrpwm1_pins>; - status = "okay"; - }; - }; - - fragment@5 { - target = <&epwmss2>; - __overlay__ { - status = "okay"; - }; - }; - - fragment@6 { - target = <&ehrpwm2>; - __overlay__ { - pinctrl-names = "default"; - pinctrl-0 = <&bborg_motor_ehrpwm2_pins>; - status = "okay"; - }; - }; - - 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"; - }; - }; - }; - }; -}; From d72fe5ac661e95f5fd572cc92c207c97f3a16a60 Mon Sep 17 00:00:00 2001 From: Deepak Khatri Date: Mon, 13 Jul 2020 20:20:48 +0530 Subject: [PATCH 2/3] BBB and BBAI compatible motorCape DT overlay This DT is using code from beagleboard/BeagleBoard-DeviceTrees/pull/17 to create compatible led_P8_* / led_P8_* nodes for both BBB and BBAI. The PWM nodes are also made compatible on both the boards. Rewritten based on the BBORG_MOTOR-00A2.dts written by Robert Nelson for kernel <4.14 --- src/arm/BBORG_MOTOR-00A2.dts | 108 +++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/src/arm/BBORG_MOTOR-00A2.dts b/src/arm/BBORG_MOTOR-00A2.dts index e69de29b..50574186 100644 --- a/src/arm/BBORG_MOTOR-00A2.dts +++ b/src/arm/BBORG_MOTOR-00A2.dts @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2020 Deepak Khatri + * + * Based on BBORG_MOTOR-00A2.dts from Robert Nelson for kernel <4.14 + * 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. + */ + +/dts-v1/; +/plugin/; + +/* + * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/ + */ +&{/chosen} { + overlays { + BBORG_MOTOR-00A2 = __TIMESTAMP__; + }; +}; + +/* + * 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 */ +}; + +/* + * Enable and Update the default state of the pins + */ +&ocp { + P8_13_pinmux { status = "okay"; pinctrl-0 = <&P8_13_pwm_pin>; }; /* motor3 speed */ + 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 */ +}; + +// Motor 1, 2 +&bone_pwmss_1 { + status = "okay"; +}; + +&bone_pwm_1 { + status = "okay"; +}; + +// Motor 3, 4 +&bone_pwmss_2 { + status = "okay"; +}; + +&bone_pwm_2 { + status = "okay"; +}; + + +/* + * Easy Motor direction control through sysfs (/sys/class/leds/motor*) using gpio-leds driver + * See these files for the led_P8_#/led_P9_# definition + * 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"; + }; + + // Motor 2 + led_P8_16 { + status = "okay"; + label = "motor2"; + default-state = "off"; + }; + + // Motor 3 + led_P8_14 { + status = "okay"; + label = "motor3"; + default-state = "off"; + }; + + // Motor 4 + led_P8_26 { + status = "okay"; + label = "motor4"; + default-state = "off"; + }; + }; +}; From 861e9a19b232f24b97cd394e51dd623eb173f535 Mon Sep 17 00:00:00 2001 From: Deepak Khatri Date: Tue, 14 Jul 2020 14:24:00 +0530 Subject: [PATCH 3/3] update copyright info --- src/arm/BBORG_MOTOR-00A2.dts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arm/BBORG_MOTOR-00A2.dts b/src/arm/BBORG_MOTOR-00A2.dts index 50574186..8dda82f6 100644 --- a/src/arm/BBORG_MOTOR-00A2.dts +++ b/src/arm/BBORG_MOTOR-00A2.dts @@ -1,7 +1,9 @@ /* * Copyright (C) 2020 Deepak Khatri - * + * * Based on BBORG_MOTOR-00A2.dts from Robert Nelson for kernel <4.14 + * Copyright (C) 2018 Robert Nelson + * * Note: Requires Compaibility code from BeagleBoard-DeviceTrees/pull/17 * * This program is free software; you can redistribute it and/or modify