|
| 1 | +######## |
| 2 | +DM TIMER |
| 3 | +######## |
| 4 | + |
| 5 | +- This guide covers a general overview on DM Timer. |
| 6 | + It supports timers found on TI's |__PART_FAMILY_NAME__| SoCs. |
| 7 | + |
| 8 | +- Each timer contains a free-running upward counter with autoreload capability on overflow. |
| 9 | + Each timer includes compare logic to allow an interrupt event on a programmable counter |
| 10 | + matching value. A dedicated output signal can be pulsed/toggled on an overflow or a match |
| 11 | + event. This offers time-stamp trigger signaling or PWM signal sources. A dedicated input |
| 12 | + signal can be used to trigger an automatic timer counter capture or an interrupt event on a |
| 13 | + programmable input signal transition. |
| 14 | + |
| 15 | +- Each timer comes with pins that can be used as Timer Capture interrupts |
| 16 | + or as timer PWM outputs. |
| 17 | + |
| 18 | +- For more detailed information on timers, please refer to the: |
| 19 | + ``Peripherals/Timer Modules/Timers`` section of the device specific TRM. |
| 20 | + |
| 21 | +************** |
| 22 | +Driver Sources |
| 23 | +************** |
| 24 | + |
| 25 | +- Driver source location: :file:`drivers/clocksource/ti,timer-dm.c` |
| 26 | +- Binding source location: :file:`Documentation/device-tree/bindings/timer/ti,timer-dm.yaml` |
| 27 | + |
| 28 | +PWM mode: |
| 29 | + |
| 30 | +- Driver source location: :file:`drivers/pwm/pwm-omap-dmtimer.c` |
| 31 | +- Binding source location: :file:`Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt` |
| 32 | + |
| 33 | +******************** |
| 34 | +Kernel Configuration |
| 35 | +******************** |
| 36 | + |
| 37 | +Configs to be enabled in kernel: |
| 38 | + |
| 39 | +.. code-block:: menuconfig |
| 40 | +
|
| 41 | + Device Drivers ---> |
| 42 | + -> Clock Source drivers |
| 43 | + -> OMAP dual-mode timer driver (OMAP_DM_TIMER [=y]) |
| 44 | +
|
| 45 | +PWM mode: |
| 46 | + |
| 47 | +.. code-block:: menuconfig |
| 48 | +
|
| 49 | + Device Drivers ---> |
| 50 | + Pulse-Width Modulation (PWM) Support (PWM [=y]) |
| 51 | + -> OMAP Dual-Mode Timer PWM support (PWM_OMAP_DMTIMER [=m]) |
| 52 | +
|
| 53 | +.. rubric:: Device tree configuration example |
| 54 | + |
| 55 | +In this example, we take am62x SK DT node as an example. In general all the timer nodes |
| 56 | +should be described in its appropriate domain .dtsi file, for example the following node |
| 57 | +can be found in k3-am62-main.dtsi: |
| 58 | + |
| 59 | +.. code-block:: dts |
| 60 | +
|
| 61 | + main_timer3: timer@2430000 { |
| 62 | + compatible = "ti,am654-timer"; |
| 63 | + reg = <0x00 0x2430000 0x00 0x400>; |
| 64 | + interrupts = <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>; |
| 65 | + clocks = <&k3_clks 39 2>; |
| 66 | + clock-names = "fck"; |
| 67 | + assigned-clocks = <&k3_clks 39 2>; |
| 68 | + assigned-clock-parents = <&k3_clks 39 3>; |
| 69 | + power-domains = <&k3_pds 39 TI_SCI_PD_EXCLUSIVE>; |
| 70 | + ti,timer-pwm; |
| 71 | + }; |
| 72 | +
|
| 73 | +PWM mode: |
| 74 | + |
| 75 | +The "ti,timer-pwm" DT attribute is required in the timer node in order to use this timer instance |
| 76 | +in PWM mode, if the timer supports PWM mode. |
| 77 | + |
| 78 | +An additional DT node is required to enable timer in PWM mode as shown below. The |
| 79 | +``main_timer3_pins_default`` is also required and not listed here, use sysconfig tool to get pinumux |
| 80 | +configuration. |
| 81 | + |
| 82 | +.. code-block:: dts |
| 83 | +
|
| 84 | + main_pwm3: dmtimer-main-pwm-3 { |
| 85 | + compatible = "ti,omap-dmtimer-pwm"; |
| 86 | + #pwm-cells = <3>; |
| 87 | + ti,timers = <&main_timer3>; |
| 88 | + pinctrl-names = "default"; |
| 89 | + pinctrl-0 = <&main_timer3_pins_default>; |
| 90 | + }; |
| 91 | +
|
| 92 | +************ |
| 93 | +Driver Usage |
| 94 | +************ |
| 95 | + |
| 96 | +For information on using DM timer in non-PWM mode, please refer to the detailed |
| 97 | +descriptions in the TRM ``Timers Functional Description`` and ``Low-Level Programming Models`` |
| 98 | +under ``Peripherals/Timers Modules/Timers``. |
| 99 | + |
| 100 | +Timers in non-PWM mode should be enabled by default in Linux DT. |
| 101 | + |
| 102 | +.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62AX', 'AM62PX') |
| 103 | + |
| 104 | + In MAIN domain: |
| 105 | + |
| 106 | + - 8 DM timers in MAIN domain |
| 107 | + |
| 108 | + In MCU domain: |
| 109 | + |
| 110 | + - 4 DM timers in MCU domain |
| 111 | + |
| 112 | +.. ifconfig:: CONFIG_part_variant in ('AM64X') |
| 113 | + |
| 114 | + In MAIN domain: |
| 115 | + |
| 116 | + - 12 DM timers in MAIN domain |
| 117 | + |
| 118 | + In MCU domain: |
| 119 | + |
| 120 | + - 4 DM timers in MCU domain |
| 121 | + |
| 122 | +PWM mode |
| 123 | + |
| 124 | +Once the driver is probed, each device is exposed as a PWM device |
| 125 | +by kernel to be used by userspace in :file:`/sys/class/pwm`. |
| 126 | + |
| 127 | +For controlling the PWM chip via sysfs interface please refer to the official Linux |
| 128 | +documentation: `here <https://docs.kernel.org/driver-api/pwm.html#using-pwms-with-the-sysfs-interface>`__ |
| 129 | +or go to :ref:`Using-PWM-with-sysfs`. |
| 130 | + |
| 131 | +******** |
| 132 | +Examples |
| 133 | +******** |
| 134 | + |
| 135 | +To enable DM timer in PWM mode, there is an example DT overlay found in |
| 136 | +Linux source: :file:`arch/arm64/boot/dts/ti/k3-am62x-sk-dmtimer-pwm.dtso` |
| 137 | +that applied for am62x family devices and can be referenced for other K3 |
| 138 | +Sitara devices. |
0 commit comments