1# SPDX-FileCopyrightText: Copyright (c) 2024 Carl Zeiss Meditec AG
2# SPDX-License-Identifier: Apache-2.0
3
4description: |
5  Analog Devices TMC5041 Stepper Motor Controller
6
7  Example:
8
9    #include <zephyr/dt-bindings/stepper/adi/tmc5041_reg.h>
10
11    &spi0 {
12        /* SPI bus options here, not shown */
13
14        /* Dual controller/driver for up to two 2-phase bipolar stepper motors */
15        tmc5041: tmc5041@0 {
16            compatible = "adi,tmc5041";
17            reg = <0>;
18            spi-max-frequency = <DT_FREQ_M(24)>; /* Maximum SPI bus frequency */
19
20            #address-cells = <1>;
21            #size-cells = <0>;
22
23            poscmp_enable; test_mode; lock_gconf; /* ADI TMC Global configuration flags */
24            clock-frequency = <DT_FREQ_M(16)>; /* Internal/External Clock frequency */
25
26            motor: motor@0 {
27                status = "okay";
28                reg = <0>;
29
30                /* common stepper controller settings */
31                invert-direction;
32                micro-step-res = <256>;
33
34                /* ADI TMC stallguard settings specific to TMC5041 */
35                activate-stallguard2;
36                stallguard-velocity-check-interval-ms=<100>;
37                stallguard2-threshold=<9>;
38                stallguard-threshold-velocity=<500000>;
39
40                /* ADI TMC ramp generator as well as current settings */
41                vstart = <10>;
42                a1 = <20>;
43                v1 = <30>;
44                d1 = <40>;
45                vmax = <50>;
46                amax = <60>;
47                dmax = <70>;
48                tzerowait = <80>;
49                vhigh = <90>;
50                vcoolthrs = <100>;
51                ihold = <1>;
52                irun = <2>;
53                iholddelay = <3>;
54            };
55        };
56    };
57
58
59compatible: "adi,tmc5041"
60
61include:
62  - name: spi-device.yaml
63  - name: adi,trinamic-gconf.yaml
64    property-allowlist:
65      - poscmp_enable
66      - shaft1
67      - shaft2
68      - test_mode
69      - lock_gconf
70
71properties:
72  "#address-cells":
73    default: 1
74    const: 1
75
76  "#size-cells":
77    default: 0
78    const: 0
79
80  clock-frequency:
81    type: int
82    required: true
83    description: |
84      The frequency of the clock signal provided to the TMC5041.
85      This is used for real world conversion.
86
87      Hint: µstep velocity v[Hz] µsteps / s v[Hz] = v[5041] * ( fCLK[Hz]/2 / 2^23 )
88            where v[5041] is the value written to the TMC5041.
89
90child-binding:
91  include:
92    - name: stepper-controller.yaml
93    - name: base.yaml
94      property-allowlist:
95        - reg
96    - name: adi,trinamic-ramp-generator.yaml
97      property-allowlist:
98        - vstart
99        - a1
100        - v1
101        - amax
102        - vmax
103        - dmax
104        - d1
105        - vstop
106        - tzerowait
107        - vhigh
108        - vcoolthrs
109        - ihold
110        - irun
111        - iholddelay
112    - name: adi,trinamic-stallguard.yaml
113      property-allowlist:
114        - activate-stallguard2
115        - stallguard2-threshold
116        - stallguard-threshold-velocity
117        - stallguard-velocity-check-interval-ms
118