We have custom board based on AM437x and we are using 5 pins for PWM output using ehrpwm0/1/2
3pins are used for LED and other 2 pins for Alram etc.
We are using TI SDK version 7.0 and kernel 3.12.10
Here are pin details :
AD25 -> eHRPWM0(2) -> ehrpwm0A
AC23-> eHRPWM0(2) -> ehrpwm0B
AE21 -> eHRPWM1(1) -> ehrpwm1A
B22-> eHRPWM2(2) -> ehrpwm2A
A21 -> eHRPWM2(2) -> ehrpwm2B
According to this thread We have created and modified kernel for pwm and driving leds.
There is good guide for PWM and we followed same :
processors.wiki.ti.com/.../Linux_Core_PWM_User%27s_Guide
Modifications done in board dts file are as follows (suggested as per above links)
1. pin mux for ehrpwm
ehrpwm0_pins: ehrpwm0_pins {
pinctrl-single,pins = <
0x1D4 MUX_MODE6 /* eHRPWM0(2) -> ehrpwm0A -> AD25 */
0x1D8 MUX_MODE6 /* eHRPWM0(2) -> ehrpwm0B -> AC23 */
>;
};
ehrpwm1_pins: ehrpwm1_pins {
pinctrl-single,pins = <
0x1DC MUX_MODE6 /* eHRPWM1(1) -> ehrpwm1A -> AE21 */
>;
};
ehrpwm2_pins: ehrpwm2_pins{
pinctrl-single,pins = <
0xA0 MUX_MODE3 /* eHRPWM2(2) -> ehrpwm2A -> B22 */
0xA4 MUX_MODE3 /* eHRPWM2(2) -> ehrpwm2B -> A21 */
>;
};
2. ehrpwm entries
ocp {
epwmss0: epwmss@48300000 {
status = "okay";
ehrpwm0:ehrpwm@48300200 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&ehrpwm0_pins>;
};
};
epwmss1: epwmss@48302000 {
status = "okay";
ehrpwm1: ehrpwm@48302200 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&ehrpwm1_pins>;
};
};
};
epwmss2 is also added just removed for testing purpose.
3. PWM led entries:
pwm_led{
compatible = "pwm-leds";
led_red {
pwms = <&ehrpwm0_pins 0 50000 1>;
max-brightness = <255>;
linux,default-trigger = "default-on";
brightness = <127>;
};
led_blue{
pwms = <&ehrpwm0_pins 0 50000 1>;
max-brightness = <255>;
linux,default-trigger = "default-on";
brightness = <127>;
};
};
All other modification for tbclk/am4372.dtsi is also done
added #pwm-cellls = <3>; for erpwm0/1/2 as follows:
epwmss0: epwmss@48300000 {
compatible = "ti,am4372-pwmss","ti,am33xx-pwmss";
reg = <0x48300000 0x10>;
#address-cells = <1>;
#size-cells = <1>;
ranges;
ti,hwmods = "epwmss0";
clocks = <&l4ls_gclk>;
clock-names = "fck";
status = "disabled";
ecap0: ecap@48300100 {
compatible = "ti,am4372-ecap","ti,am33xx-ecap";
reg = <0x48300100 0x80>;
#pwm-cells = <3>;
ti,hwmods = "ecap0";
clocks = <&l4ls_gclk>;
clock-names = "fck";
status = "disabled";
};
ehrpwm0: ehrpwm@48300200 {
compatible = "ti,am4372-ehrpwm","ti,am33xx-ehrpwm";
reg = <0x48300200 0x80>;
#pwm-cells = <3>;
ti,hwmods = "ehrpwm0";
clocks = <&l4ls_gclk>;
clock-names = "fck";
status = "disabled";
};
};
With All these modifications We are able get sys entries for ehrpwm0/1/2 but not for leds..
root@am437x-evm:/sys/class# cd pwm/
root@am437x-evm:/sys/class/pwm# ls
pwmchip0 pwmchip2 pwmchip4
root@am437x-evm:/sys/class/pwm#
root@am437x-evm:/sys/class/pwm#
root@am437x-evm:/sys/class/pwm# cd pwmchip0/
root@am437x-evm:/sys/devices/44000000.ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0#
root@am437x-evm:/sys/devices/44000000.ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0# ls
root@am437x-evm:/sys/devices/44000000.ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0# cat device/
kernel gives error as follows :
[ 1.427086] called led_pwm_probe:153 for pwm_led
[ 1.432680] /pwm_led/led_red: could not get #pwm-cells for /pinmux@44e10800/ehrpwm0_pins
[ 1.441347] leds_pwm pwm_led.5: unable to request PWM for led_red
Configuration for PWM led/LED trigger/PWM subsystem are enabled in kernel configuration.
Anything I am missing for creating LED node in /sys/class/leds, any pwm driver modification is required?
We are digging into PWM core driver and will update for any progress.
Any pointers are welcome as we are struggling for this from last few days..