1# Copyright (c) 2023 SLB 2# SPDX-License-Identifier: Apache-2.0 3 4description: | 5 Infineon XMC4XXX PWM Capture Compare Unit 8 (CCU8) module 6 7 The PWM CCU8 module can automatically generate a high-side 8 and a low-side PWM signal, where the two signals are complementary 9 to each other. 10 11 The module supports adding a dead time between the high-side and 12 low-side PWM signals. 13 14 The dead time ensures that there is a delay before the PWM state 15 transitions from 0 to 1, preventing the high-side and low-side 16 switches from being on simultaneously. 17 18 There are two CCU8 modules with DTS node labels: pwm_ccu80 and 19 pwm_ccu81. Each module has four slices, and each slice has 20 two channels. A channel consists of a corresponding high-side 21 and low-side PWM signal. 22 23 The CCU8 modules use the CCU clock source. Each slice applies 24 a separate prescaler to divide the clock. The clock divider is 25 defined by the 'slice-prescaler' property. Additionally, each 26 slice has a dead time prescaler, which divides the slice clock 27 for the dead time counter. 28 29 Device tree example: 30 A node can define a 'pwm' field, usually referenced in a 'pwms' 31 property, where the entries include the PWM module phandle, 32 channel number, pulse period (in nanoseconds or set using 33 PWM_XX() macros), and a channel 34 flag (PWM_POLARITY_NORMAL/PWM_POLARITY_INVERTED). 35 36 The 'pwm_ccu8' node must define the following fields: 37 &pwm_ccu80 { 38 slice-prescaler = <15 15 15 15>; 39 slice-deadtime-prescaler = <3 3 3 3>; 40 channel-deadtime-high = <0 0 0 0 PWM_MSEC(100) 0 0 0>; 41 channel-deadtime-low = <0 0 0 0 PWM_MSEC(100) 0 0 0>; 42 pinctrl-0 = <&pwm_out_p5_9_ccu80_ch4_high &pwm_out_p0_0_ccu80_ch4_low>; 43 pinctrl-names = "default"; 44 }; 45 46 This will configure channel 4 with a 100msec deadtime on the high 47 and low side PWM signals. 48 49 Another node can reference the PWM as follows: 50 &test_node { 51 ... 52 pwms = <&pwm_ccu80 0 PWM_SEC(1) PWM_POLARITY_NORMAL>; 53 ... 54 }; 55 56 The 'pwm_out_p{PORT}_{PIN}_ccu8{MODULE_IDX}_ch{CHANNEL_IDX}_{HIGH_LOW}' 57 format is used for CCU8 pinctrl nodes. 'MODULE_IDX' and 'CHANNEL_IDX' 58 refer to a specific 'pwm_ccu8x' module and channel, respectively. 59 'PORT/PIN' defines the GPIO that the channel connects to. 60 'HIGH_LOW' indicates whether the pin is for the high or low-side signal. 61 62 It's not necessary to specify both the high and low pinctrls. Only the low-side 63 signal can, for example, be used as PWM, but note that the duty cycle of the 64 low signal will be (1 - duty) as set via the API. 65 66 Note that a slice has two channels. Channels 0/1 are in slice 0, 67 channels 2/3 are in slice 1, and so on. Each channel can have its own 68 duty cycle and high/low dead times. But the pulse duration applies to 69 both channels. Thus, when using the PWM control api to modify the pulse width 70 on a channel 0, it will also be updated for channel 1 since they are 71 in the same slice. 72 73compatible: "infineon,xmc4xxx-ccu8-pwm" 74 75include: 76 - name: base.yaml 77 - name: pwm-controller.yaml 78 - name: pinctrl-device.yaml 79 80properties: 81 reg: 82 required: true 83 84 pinctrl-0: 85 required: true 86 87 pinctrl-names: 88 required: true 89 90 slice-prescaler: 91 type: array 92 required: true 93 description: | 94 Defines the clock divider for each slice. 95 The entry in the array will divide CCU clock by (2 << value). 96 The range for the prescaler values is [0, 15]. 97 Reducing prescaler value will improve resolution but decrease the maximum period. 98 99 slice-deadtime-prescaler: 100 type: array 101 required: true 102 description: | 103 Defines the clock divider for dead time counter for each slice. 104 The range for the values is [0, 3]. 105 Reducing prescaler value will improve dead time resolution but decrease the 106 maximum dead time. 107 108 channel-deadtime-high: 109 type: array 110 required: true 111 description: | 112 Defines the dead time in nanoseconds for the high-side PWM signal for each channel. 113 114 channel-deadtime-low: 115 type: array 116 required: true 117 description: | 118 Defines the dead time in nanoseconds for the low-side PWM signal for each channel. 119 120 "#pwm-cells": 121 const: 3 122 123pwm-cells: 124 - channel 125 - period 126 - flags 127