Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

can: bittiming: add PWM parameters

In CAN XL, higher data bit rates require the CAN transceiver to switch
its operation mode to use Pulse-Width Modulation (PWM) transmission
mode instead of the classic dominant/recessive transmission mode.

The PWM parameters are:

- PWMS: pulse width modulation short phase
- PWML: pulse width modulation long phase
- PWMO: pulse width modulation offset

CiA 612-2 specifies PWMS and PWML to be at least 1 (arguably, PWML
shall be at least 2 to respect the PWMS < PWML rule). PWMO's minimum
is expected to always be zero. It is added more for consistency than
anything else.

Add struct can_pwm_const so that the different devices can provide
their minimum and maximum values.

When TMS is on, the runtime PWMS, PWML and PWMO are needed (either
calculated or provided by the user): add struct can_pwm to store
these.

TDC and PWM can not be used at the same time (TDC can only be used
when TMS is off and PWM only when TMS is on). struct can_pwm is thus
put together with struct can_tdc inside a union to save some space.

The netlink logic will be added in an upcoming change.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://patch.msgid.link/20251126-canxl-v8-8-e7e3eb74f889@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Vincent Mailhol and committed by
Marc Kleine-Budde
f6ccc2b2 6df01533

+39 -2
+39 -2
include/linux/can/bittiming.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 2 /* Copyright (c) 2020 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de> 3 - * Copyright (c) 2021 Vincent Mailhol <mailhol.vincent@wanadoo.fr> 3 + * Copyright (c) 2021-2025 Vincent Mailhol <mailhol@kernel.org> 4 4 */ 5 5 6 6 #ifndef _CAN_BITTIMING_H ··· 120 120 u32 tdcf_max; 121 121 }; 122 122 123 + /* 124 + * struct can_pwm - CAN Pulse-Width Modulation (PWM) parameters 125 + * 126 + * @pwms: pulse width modulation short phase 127 + * @pwml: pulse width modulation long phase 128 + * @pwmo: pulse width modulation offset 129 + */ 130 + struct can_pwm { 131 + u32 pwms; 132 + u32 pwml; 133 + u32 pwmo; 134 + }; 135 + 136 + /* 137 + * struct can_pwm - CAN hardware-dependent constants for Pulse-Width 138 + * Modulation (PWM) 139 + * 140 + * @pwms_min: PWM short phase minimum value. Must be at least 1. 141 + * @pwms_max: PWM short phase maximum value 142 + * @pwml_min: PWM long phase minimum value. Must be at least 1. 143 + * @pwml_max: PWM long phase maximum value 144 + * @pwmo_min: PWM offset phase minimum value 145 + * @pwmo_max: PWM offset phase maximum value 146 + */ 147 + struct can_pwm_const { 148 + u32 pwms_min; 149 + u32 pwms_max; 150 + u32 pwml_min; 151 + u32 pwml_max; 152 + u32 pwmo_min; 153 + u32 pwmo_max; 154 + }; 155 + 123 156 struct data_bittiming_params { 124 157 const struct can_bittiming_const *data_bittiming_const; 125 158 struct can_bittiming data_bittiming; 126 159 const struct can_tdc_const *tdc_const; 127 - struct can_tdc tdc; 160 + const struct can_pwm_const *pwm_const; 161 + union { 162 + struct can_tdc tdc; 163 + struct can_pwm pwm; 164 + }; 128 165 const u32 *data_bitrate_const; 129 166 unsigned int data_bitrate_const_cnt; 130 167 int (*do_set_data_bittiming)(struct net_device *dev);