History

can: netlink: add PWM netlink interface

When the TMS is switched on, the node uses PWM (Pulse Width Modulation) during the data phase instead of the classic NRZ (Non Return to Zero) encoding. PWM is configured by three parameters: - PWMS: Pulse Width Modulation Short phase - PWML: Pulse Width Modulation Long phase - PWMO: Pulse Width Modulation Offset time For each of these parameters, define three IFLA symbols: - IFLA_CAN_PWM_PWM*_MIN: the minimum allowed value. - IFLA_CAN_PWM_PWM*_MAX: the maximum allowed value. - IFLA_CAN_PWM_PWM*: the runtime value. This results in a total of nine IFLA symbols which are all nested in a parent IFLA_CAN_XL_PWM symbol. IFLA_CAN_PWM_PWM*_MIN and IFLA_CAN_PWM_PWM*_MAX define the range of allowed values and will match the value statically configured by the device in struct can_pwm_const. IFLA_CAN_PWM_PWM* match the runtime values stored in struct can_pwm. Those parameters may only be configured when the tms mode is on. If the PWMS, PWML and PWMO parameters are provided, check that all the needed parameters are present using can_validate_pwm(), then check their value using can_validate_pwm_bittiming(). PWMO defaults to zero if omitted. Otherwise, if CAN_CTRLMODE_XL_TMS is true but none of the PWM parameters are provided, calculate them using can_calc_pwm().

Vincent Mailhol committed 11 months ago

Commit 46552321 parent 98923392 files · +215 −2Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/linux/can/netlink.h+25−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 * Definitions for the CAN netlink interface
66 *
77 * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
8+ * Copyright (c) 2021-2025 Vincent Mailhol <mailhol@kernel.org>
89 *
910 * This program is free software; you can redistribute it and/or modify
1011 * it under the terms of the version 2 of the GNU General Public License
@@ -147,6 +148,7 @@ enum { · 136 unmodified lines
147148 IFLA_CAN_XL_DATA_BITTIMING_CONST,
148149 IFLA_CAN_XL_DATA_BITRATE_CONST,
149150 IFLA_CAN_XL_TDC,
151+ IFLA_CAN_XL_PWM,
150152
151153 /* add new constants above here */
152154 __IFLA_CAN_MAX,
@@ -188,6 +190,29 @@ enum { · 35 unmodified lines
188190 IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1
189191 };
190192
193+/*
194+ * CAN FD/XL Pulse-Width Modulation (PWM)
195+ *
196+ * Please refer to struct can_pwm_const and can_pwm in
197+ * include/linux/can/bittiming.h for further details.
198+ */
199+enum {
200+ IFLA_CAN_PWM_UNSPEC,
201+ IFLA_CAN_PWM_PWMS_MIN, /* u32 */
202+ IFLA_CAN_PWM_PWMS_MAX, /* u32 */
203+ IFLA_CAN_PWM_PWML_MIN, /* u32 */
204+ IFLA_CAN_PWM_PWML_MAX, /* u32 */
205+ IFLA_CAN_PWM_PWMO_MIN, /* u32 */
206+ IFLA_CAN_PWM_PWMO_MAX, /* u32 */
207+ IFLA_CAN_PWM_PWMS, /* u32 */
208+ IFLA_CAN_PWM_PWML, /* u32 */
209+ IFLA_CAN_PWM_PWMO, /* u32 */
210+
211+ /* add new constants above here */
212+ __IFLA_CAN_PWM,
213+ IFLA_CAN_PWM_MAX = __IFLA_CAN_PWM - 1
214+};
215+
191216 /* u16 termination range: 1..65535 Ohms */
192217 #define CAN_TERMINATION_DISABLED 0
193218