This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using timer4 for PWM output :- device node not created for timer4 and how to configure timer for frequncy/duty cycle .


Hi all,

We Have customized board based on AM437x and our hardware design  uses TIMER4  for PWM output ,for driving Haptic trigger.
We are using TI SDK 7.0 and kernel version 3.12.10

I have done modification in board DTS file for TIMER mode : MOD2 as follows:
am43xx pin mux :


timer4_4in: timer4_pin{
pinctrl-single,pins = <
0x270 (PIN_OUTPUT_PULLUP | MUX_MODE2) /* TIMER4 -> timer4 -> D24 */
>;

};

/* for timer4 device node */
&timer4 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&timer4_pin>;
};

Entry for pinmux is created but timer4 device  node is not created in /sys/  entries

My understanding is that  pin mux changes are sufficient for creating device node for timer and same device  node  will be used for  user space access.

Bur node is not created for TIMER4. When looked at timer driver for AM43xx, It seems that it only supports system timer/clock event etc.
PWM functionality  is not  provided  in default driver. It is obvious that system timer are not exposed to user, but We have to expose TIMER4 to use-space for setting frequency/duty cycle etc.

Has anybody worked previously for same? Any other modifications are required for working timer as PWM other than pin mux changes?

I had got one old kernel modeul for omap3 which is configuring timer 8,9,10,11 as pwm and exposing device node to user space from :
http://bdml.stanford.edu/Profiles/UsingTheGumstixCOM


But this is 2.6.x kernel and when I modified for AM43xx ,timer4 and our kernel is giving error as

root@am437x-evm:/home# insmod pwm.ko servo=0 timers=4 frequency=1024
[ 267.383006] pwm_init_timer_list : 593
[ 267.387228] pwm_init_timer_list : 620 success
[ 267.394731] pwm_timer_init : 303 start
[ 267.398871] omap_dm_timer_request_specific: Please use omap_dm_timer_request_by_cap/node()
[ 267.407778] pwm_timer_init : 358 ===== timer init failed ====
insmod: can't insert 'pwm.ko': Operation not permitted

This might be beacuase of module uses timer id  for initializing device and module is not using Device tree overlays. 

Right now I am looking for both approaches developing driver with Device tree with reference to above driver or modify exiting omap2 timer driver for PWM mode.
If anybody has optimized solution or pointers for configuring timer4 as PWM , will be very helpful.

  • Welcome to the TI E2E forum. I hope you will find many good answers here and in the TI.com documents and in the TI Wiki Pages (for processor issues). Be sure to search those for helpful information and to browse for the questions others may have asked on similar topics (e2e.ti.com).

    Moved this thread to correct forum for faster response. Thank you.
  • Hi,

    I will ask the SW team to check this.

  • Hi,

    I am checking the am437x gp evm schematics to see if xdma_event_intr0 pin is pinned out on an expansion header, so I can try to reproduce your problem.

    In the mean time I have a couple of suggestions:
    1. Make sure that there isn't another module in your code uses the xdma_event_intr0 signal
    2. Have you removed the setting of xdma_event_intr0 pin (D24) from the unused_pins: unused_pins dts node (am437x-gp-evm.dts):
    0x270 (PIN_INPUT_PULLDOWN | MUX_MODE7) ?
    3. Consider CTRL_STS[25]SYSBOOT17 bit, check if your code modifies this bit. Check Section 5.2.5.2 SYSBOOT Configuration Pins, paragraph after Table 5-10. SYSBOOT Configuration Pins (continued) in device TRM, for more details.

    Best Regards,
    Yordan
  • Hi  Yordan,

    Thanks for your reply.  Considering your suggestions,please find our details

    1. Make sure that there isn't another module in your code uses the xdma_event_intr0 signal

    >> No. Other module is not using xdma_event_intr0 pin in our code.

    2. Have you removed the setting of xdma_event_intr0 pin (D24) from the unused_pins: unused_pins dts node (am437x-gp-evm.dts):

    0x270 (PIN_INPUT_PULLDOWN | MUX_MODE7) ?

    >> We are not using unused_pins from pinmuxing  we have modified DTS file according to our board, No pinmux defined as unused_pins.  

    3. Consider CTRL_STS[25]SYSBOOT17 bit, check if your code modifies this bit. Check Section 5.2.5.2 SYSBOOT Configuration Pins, paragraph after Table 5-10. SYSBOOT Configuration Pins (continued) in device TRM, for more details.

    >> Here sysboot configuration is defined in hardware and we are not controlling these pins via software or code. As per our HW design by default sysboot configuration have disabled   CTRL_STS[25]SYSBOOT17 bit :

  • Debi,

    Adding the following code:
    timer4_pins_default: timer4_pins_default {
    pinctrl-single,pins = <
    0x270 (PIN_OUTPUT_PULLUP | MUX_MODE2) /* TIMER4 -> timer4 -> D24 */
    >;
    };
    &timer4 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&timer4_pins_default>;
    };
    Will make the dmtimer.c driver initialize timer4 & will add its memory space at /proc/iomem as:
    48044000-480443ff : /ocp/timer@48044000

    But it is not enough to register a device node. You need to modify the dmtimer.c to register timer4 as char or block device, or use device_create & populate the class structure in order to see it in /sys/class/

    Hope this helps.

    Best Regards,
    Yordan