Dear all,
Happy new year!
I am working with the imx6ulevk.
To follow with my device tree customization, I want to add pwm functionality to some pins. I have chosen sd1_nrst (gpio_9) and sd1_vselect (gpio_5). According to imx6ul-pinfunc.h they can be used as pwm2 and pwm4.
at imx6ul-14x14-evk.dts I have modified the following:
//backlight
&pwm1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm1>;
status = "okay";
};
//added by me
&pwm2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm2>;
status = "okay";
};
&pwm4 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm4>;
status = "okay";
};
//end
I have redefined the functionality of GPIO1_IO05 and GPIO1_IO09 at iomuxc as it is done for pwm1 (backlight):
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog_1>;
imx6ul-evk {
pinctrl_hog_1: hoggrp-1 {
fsl,pins = <
//MX6UL_PAD_GPIO1_IO05__USDHC1_VSELECT 0x17059 /* SD1 VSELECT */
//MX6UL_PAD_GPIO1_IO09__GPIO1_IO09 0x17059 /* SD1 RESET */
>;
};
.....
pinctrl_pwm1: pwm1grp {
fsl,pins = <
MX6UL_PAD_GPIO1_IO08__PWM1_OUT 0x110b0
>;
};
pinctrl_pwm2: pwm2grp {
fsl,pins = <
MX6UL_PAD_GPIO1_IO09__PWM2_OUT 0x110b0
>;
};
pinctrl_pwm4: pwm4grp {
fsl,pins = <
MX6UL_PAD_GPIO1_IO05__PWM4_OUT 0x110b0
>;
};
I have not replaced the kernel, as I understand the pwm support is already enabled at Device drivers > pwm support > i.MX pwm support.
I can modify brightness of the backlight and it works: echo 5 > /sys/class/backlight/backlight.8/brightness
However, when I try to configure pwm2 and pwm4 at command line, the operating system does not respond and I have to reboot.
to work with pwm2 (gpio_9, sd1_nreset), I do the following:
$echo 0 > /sys/class/pwm/pwmchip1/export
it creates pwm0 folder and I try to set the period (1sec)
$echo 1000000000 > /sys/class/pwm/pwmchip1/pwm0/period
The system crashes here.
It happens the same if instead of trying to set the period, I enable the output or try to do any other thing.
It also happens with pwm4 (gpio_5, sd1_vselect)
$echo 0 > /sys/class/pwm/pwmchip3/export
it creates pwm0 folder and I try to set the period (1sec)
$echo 1000000000 > /sys/class/pwm/pwmchip3/pwm0/period
The system crashes here.
I happens the same if instead of trying to set the period, I enable the output or try to do any other thing.
If I execute cat /sys/kernel/debug/pwm, I get:
platform/20fc000.pwm, 1 PWM device
pwm-0 ((null) ):
platform/20f8000.pwm, 1 PWM device
pwm-0 ((null) ):
platform/20f4000.pwm, 1 PWM device
pwm-0 ((null) ):
platform/20f0000.pwm, 1 PWM device
pwm-0 ((null) ):
platform/208c000.pwm, 1 PWM device
pwm-0 ((null) ):
platform/2088000.pwm, 1 PWM device
pwm-0 ((null) ):
platform/2084000.pwm, 1 PWM device
pwm-0 ((null) ):
platform/2080000.pwm, 1 PWM device
pwm-0 (backlight ): requested enabled
Could you give me any hints about what I am doing wrong??
Thank you in advance!
BR
解決済! 解決策の投稿を見る。
imx6ul.dtsi
pwm1:
409 pwm2: pwm@02084000 {
410 compatible = "fsl,imx6ul-pwm", "fsl,imx27-pwm";
411 reg = <0x02084000 0x4000>;
412 interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
413 clocks = <&clks IMX6UL_CLK_PWM2>,
414 <&clks IMX6UL_CLK_PWM2>;
415 clock-names = "ipg", "per";
416 #pwm-cells = <2>;
417 };
echo 0 > /sys/class/pwm/pwmchip1/export
cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
echo 1 >/sys/class/pwm/pwmchip1/pwm0/enable
echo 1000 > /sys/class/pwm/pwmchip1/pwm0/period
echo 10 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
root@imx6ulevk:~# echo 0 > /sys/class/pwm/pwmchip1/export
root@imx6ulevk:~#
root@imx6ulevk:~#
root@imx6ulevk:~# cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
0
0
0
root@imx6ulevk:~#
root@imx6ulevk:~# echo 1 >/sys/class/pwm/pwmchip1/pwm0/enable
root@imx6ulevk:~#
root@imx6ulevk:~# echo 1000 > /sys/class/pwm/pwmchip1/pwm0/period
root@imx6ulevk:~#
root@imx6ulevk:~# echo 10 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
root@imx6ulevk:~#
root@imx6ulevk:~# cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
1
1000
10
root@imx6ulevk:~#
root@imx6ulevk:~# cat /sys/kernel/debug/pwm
wm-0 ((null) ):
platform/2084000.pwm, 1 PWM device
pwm-0 (sysfs ): requested enabled
platform/2080000.pwm, 1 PWM device
pwm-0 (backlight ): requested enabled
i found the imx6ul.dtsi and imx6ull.dtsi files under "/tmp/work-shared/imx6ull14x14evl/kernel-source/arch/arm/boot/dts
i changed them
but i dont know how rebuild the project
Can you help me ?
i can not find imx6ul.dtsi or another dtsi files. can you tell me how can i find and change this files
Hi
I would like to know where i can do this kind of pin customization, i've been reading the manufacturer documentation but never mention how to make something like this.
I would be very glad if you can share some resources, thanks in regards.
Dear Alvaro,
Sorry to disturb you, I am suffering a PWM problem and still can not get my excepted PWM waveform.
I am using an imx6solox platform to develop, and want to add a new PWM channel to control a motor. actually, I follow your steps and some feedbacks, which from other guys to change my 'imx6sx.dts' and 'imx6sx-sdb.dts' files. However, I can not get PWM waveform what I needs.
Could you tell me how to do that in further, many thanks.
I am looking forward to your reply.
Kind regards
Wei Gao
Thank you very much Biyong, Ethan for your help and time!
It is working for me know.
Just let me comment that, in the given example by Byong, both period and duty_cycle values are in nanoseconds and so, it would probably be better to choose other values for testing purposes with an oscilloscope:
root@imx6ulevk:~# echo 1000000 > /sys/class/pwm/pwmchip1/pwm0/period
root@imx6ulevk:~# echo 500000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
for pwm1 1KHz, 50% duty cycle.
BR
Alvaro Matinez,
If the answer is correct, please mark as correct.
That way, other developer can have clear information this ticket can be a reference.
Thanks a lot.
imx6ul.dtsi
pwm1:
409 pwm2: pwm@02084000 {
410 compatible = "fsl,imx6ul-pwm", "fsl,imx27-pwm";
411 reg = <0x02084000 0x4000>;
412 interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
413 clocks = <&clks IMX6UL_CLK_PWM2>,
414 <&clks IMX6UL_CLK_PWM2>;
415 clock-names = "ipg", "per";
416 #pwm-cells = <2>;
417 };
echo 0 > /sys/class/pwm/pwmchip1/export
cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
echo 1 >/sys/class/pwm/pwmchip1/pwm0/enable
echo 1000 > /sys/class/pwm/pwmchip1/pwm0/period
echo 10 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
root@imx6ulevk:~# echo 0 > /sys/class/pwm/pwmchip1/export
root@imx6ulevk:~#
root@imx6ulevk:~#
root@imx6ulevk:~# cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
0
0
0
root@imx6ulevk:~#
root@imx6ulevk:~# echo 1 >/sys/class/pwm/pwmchip1/pwm0/enable
root@imx6ulevk:~#
root@imx6ulevk:~# echo 1000 > /sys/class/pwm/pwmchip1/pwm0/period
root@imx6ulevk:~#
root@imx6ulevk:~# echo 10 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
root@imx6ulevk:~#
root@imx6ulevk:~# cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
1
1000
10
root@imx6ulevk:~#
root@imx6ulevk:~# cat /sys/kernel/debug/pwm
wm-0 ((null) ):
platform/2084000.pwm, 1 PWM device
pwm-0 (sysfs ): requested enabled
platform/2080000.pwm, 1 PWM device
pwm-0 (backlight ): requested enabled
Hi BiyongSUN,
I have a similar problem as almarto, however I am not able to solve it. I made the changes that you explained. Please, could you tell me if it is something missing?
Moreover, when I enable the PWM in the sysfs, the operative system blocks.
1) File: "imx6ul.dtsi"
pwm7: pwm@020f8000 {
compatible = "fsl,imx6ul-pwm", "fsl,imx27-pwm";
reg = <0x020f8000 0x4000>;
interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6UL_CLK_DUMMY>,
<&clks IMX6UL_CLK_DUMMY>;
clock-names = "ipg", "per";
#pwm-cells = <2>;
};
2) File: "imx6ul-14x14-ddr3-u15.dts"
&pwm7 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm7>;
status = "okay";
};
pinctrl_pwm7: pwm7grp {
fsl,pins = <
MX6UL_PAD_CSI_VSYNC__PWM7_OUT 0x110b0
>;
};
3) Finally, when I tried:
And the it blocks.
Do you have any idea what could it happen?
Thanks a lot.
Javier.
Did you override the dummy clock of pwm2 and pwm4 in imx6ul.dtsi with appropriate clocks?