2021-03-12 01:26 PM
Hi everyone.
I'm using a STM32MP151CAC and I have the following DTS:
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
/*
* Copyright (C) STMicroelectronics 2018 - All Rights Reserved
* Author: Alexandre Torgue <alexandre.torgue@st.com>.
*/
/dts-v1/;
#include "stm32mp157a-dk1.dts"
#include <dt-bindings/rtc/rtc-stm32.h>
/ {
model = "NNBoard IT2";
compatible = "st,stm32mp157c-dk2", "st,stm32mp157";
aliases {
serial3 = &usart2;
serial4 = &usart6;
};
wifi_pwrseq: wifi-pwrseq {
compatible = "mmc-pwrseq-simple";
reset-gpios = <&gpioh 4 GPIO_ACTIVE_LOW>;
};
led {
compatible = "gpio-leds";
blue {
status = "disabled";
};
ledtxrx {
label ="ledtxrx";
gpios = <&gpioh 7 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
ledtxrs485 {
label ="ledtxrs485";
gpios = <&gpioe 11 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
ledrxrs485 {
status = "disabled";
label ="ledrxrs485";
gpios = <&gpioe 13 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
};
};
&pinctrl {
u-boot,dm-pre-reloc;
usart2_pins_mx: usart2_mx-0 {
pins1 {
pinmux = <STM32_PINMUX('F', 5, AF7)>;
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
pins2 {
pinmux = <STM32_PINMUX('A', 3, AF7)>;
bias-disable;
};
};
usart2_sleep_pins_mx: usart2_sleep_mx-0 {
pins {
pinmux = <STM32_PINMUX('A', 1, ANALOG)>, /* USART2_RTS */
<STM32_PINMUX('A', 3, ANALOG)>, /* USART2_RX */
<STM32_PINMUX('D', 3, ANALOG)>, /* USART2_CTS */
<STM32_PINMUX('F', 5, ANALOG)>; /* USART2_TX */
};
};
usart6_pins_mx: usart6_mx-0 {
pins1 {
pinmux = <STM32_PINMUX('G', 12, AF7)>, /* USART6_RTS */
<STM32_PINMUX('C', 6, AF7)>; /* USART6_TX */
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
pins2 {
pinmux = <STM32_PINMUX('C', 7, AF7)>; /* USART6_RX */
bias-pull-up;
};
};
usart6_sleep_pins_mx: usart6_sleep_mx-0 {
pins {
pinmux = <STM32_PINMUX('G', 12, ANALOG)>, /* USART6_RTS */
<STM32_PINMUX('C', 7, ANALOG)>, /* USART6_RX */
<STM32_PINMUX('C', 6, ANALOG)>; /* USART6_TX */
};
};
tim1_pwm_pins_mx: tim1_pwm_mx-0 {
pins {
pinmux = <STM32_PINMUX('E', 13, AF1)>; /* TIM1_CH3 */
bias-pull-down;
drive-push-pull;
slew-rate = <0>;
};
};
tim1_pwm_sleep_pins_mx: tim1_pwm_sleep_mx-0 {
pins {
pinmux = <STM32_PINMUX('E', 13, ANALOG)>; /* TIM1_CH3 */
};
};
/* USER CODE BEGIN pinctrl */
/* USER CODE END pinctrl */
};
&rtc {
st,lsco = <RTC_OUT2_RMP>;
pinctrl-0 = <&rtc_out2_rmp_pins_a>;
pinctrl-names = "default";
};
&sdmmc2 {
arm,primecell-periphid = <0x10153180>;
pinctrl-names = "default", "opendrain", "sleep";
pinctrl-0 = <&sdmmc2_b4_pins_b>;
pinctrl-1 = <&sdmmc2_b4_od_pins_b>;
pinctrl-2 = <&sdmmc2_b4_sleep_pins_a>;
non-removable;
st,neg-edge;
bus-width = <4>;
vmmc-supply = <&v3v3>;
mmc-pwrseq = <&wifi_pwrseq>;
#address-cells = <1>;
#size-cells = <0>;
keep-power-in-suspend;
status = "okay";
brcmf: bcrmf@1 {
reg = <1>;
compatible = "brcm,bcm4329-fmac";
};
};
&timers1{
status = "okay";
/delete-property/dmas;
/delete-property/dma-names;
pwm{
pinctrl-0 = <&tim1_pwm_pins_mx>;
pinctrl-1 = <&tim1_pwm_sleep_pins_mx>;
pinctrl-names = "default", "sleep";
status = "okay";
};
};
&usart2 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&usart2_pins_mx>;
pinctrl-1 = <&usart2_sleep_pins_mx>;
/*st,hw-flow-ctrl;*/
status = "okay";
bluetooth {
shutdown-gpios = <&gpioz 6 GPIO_ACTIVE_HIGH>;
compatible = "brcm,bcm43438-bt";
max-speed = <115200>;
};
};
&usart6 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&usart6_pins_mx>;
pinctrl-1 = <&usart6_sleep_pins_mx>;
st,hw-flow-ctrl;
linux,rs485-enabled-at-boot-time;
status = "okay";
};
&fmc {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&fmc_pins_a>;
pinctrl-1 = <&fmc_sleep_pins_a>;
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
nand: nand@0 {
reg = <0>;
nand-on-flash-bbt;
#address-cells = <1>;
#size-cells = <1>;
};
};
ðernet0 {
status = "disabled";
};
&sdmmc1 {
status = "disabled";
};
&i2c1 {
status = "disabled";
};
&sai2 {
status = "disabled";
};
&adc {
status = "disabled";
};
&usbotg_hs {
/delete-property/ extcon;
};
&sdmmc3 {
status = "disabled";
};
&timers2 {
status = "disabled";
};
As you can see it's a dts that includes dtsi of the development kit for STM32MP157 and overwrites some of its configurations.
All the devices are working well but PWM in PE13 not.
After compiling and loading the DTB, I follow the steps indicated in https://wiki.st.com/stm32mpu/wiki/PWM_overview#How_to_use_PWM_with_sysfs_interface
(Exporting PWM2 in this case, as PE13 is TIM1_CH3 non-inverted output).
What is wrong in my DTS? Am I missing something?
Thank you in advance.
2021-06-21 06:51 AM
Hi areify (Community Member),
You might have solved your issue by now, but just in case.
Did you use CubeMx/CubeIDE to generate your DTS file? I am surprised to see a pull-down configuration here, I would set bias-disable here.
tim1_pwm_pins_mx: tim1_pwm_mx-0 {
pins {
pinmux = <STM32_PINMUX('E', 13, AF1)>; /* TIM1_CH3 */
bias-pull-down;
By the way, there is a nice tutorial which configures the PE12 as TIM1_CH3_N in PWM output
https://www.youtube.com/watch?list=PLnMKNibPkDnFeV4sBarnsAtFTg7h6V-9_&v=XhB0rGLjl_Q&feature=youtu.be
Regards,
Olivier
2021-06-23 01:41 AM
Hi,
Alternatively, for test purposes (using pwm-leds), could you try adding in your &timer1 node:
pwmleds {
compatible = "pwm-leds";
example {
label = "stm32-pwm-leds-example";
/* Use pwm1 channel 3 (e.g. TIM1_CH3) */
/* period in nanoseconds (500000), normal polarity (0) */
pwms = <&pwm1 3 500000 0>;
max-brightness = <255>;
};
};
then this command should start your PWM with 50% duty cycle:
echo 127 > /sys/class/leds/stm32-pwm-leds-example/brightness
Regards.