mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-05 00:04:34 -04:00
can: dev: make can_get_relative_tdco() FD agnostic and move it to bittiming.h
can_get_relative_tdco() needs to access can_priv->fd making it specific to CAN FD. Change the function parameter from struct can_priv to struct data_bittiming_params. This way, the function becomes CAN FD agnostic and can be reused later on for the CAN XL TDC. Now that we dropped the dependency on struct can_priv, also move can_get_relative_tdco() back to bittiming.h where it was meant to belong to. Signed-off-by: Vincent Mailhol <mailhol@kernel.org> Link: https://patch.msgid.link/20250923-canxl-netlink-prep-v4-2-e720d28f66fe@kernel.org Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
cc470fcf1d
commit
7208385df7
@@ -160,6 +160,35 @@ int can_get_bittiming(const struct net_device *dev, struct can_bittiming *bt,
|
||||
const unsigned int bitrate_const_cnt,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
||||
/*
|
||||
* can_get_relative_tdco() - TDCO relative to the sample point
|
||||
*
|
||||
* struct can_tdc::tdco represents the absolute offset from TDCV. Some
|
||||
* controllers use instead an offset relative to the Sample Point (SP)
|
||||
* such that:
|
||||
*
|
||||
* SSP = TDCV + absolute TDCO
|
||||
* = TDCV + SP + relative TDCO
|
||||
*
|
||||
* -+----------- one bit ----------+-- TX pin
|
||||
* |<--- Sample Point --->|
|
||||
*
|
||||
* --+----------- one bit ----------+-- RX pin
|
||||
* |<-------- TDCV -------->|
|
||||
* |<------------------------>| absolute TDCO
|
||||
* |<--- Sample Point --->|
|
||||
* | |<->| relative TDCO
|
||||
* |<------------- Secondary Sample Point ------------>|
|
||||
*/
|
||||
static inline s32 can_get_relative_tdco(const struct data_bittiming_params *dbt_params)
|
||||
{
|
||||
const struct can_bittiming *dbt = &dbt_params->data_bittiming;
|
||||
s32 sample_point_in_tc = (CAN_SYNC_SEG + dbt->prop_seg +
|
||||
dbt->phase_seg1) * dbt->brp;
|
||||
|
||||
return (s32)dbt_params->tdc.tdco - sample_point_in_tc;
|
||||
}
|
||||
|
||||
/*
|
||||
* can_bit_time() - Duration of one bit
|
||||
*
|
||||
|
||||
@@ -85,35 +85,6 @@ static inline bool can_fd_tdc_is_enabled(const struct can_priv *priv)
|
||||
return !!(priv->ctrlmode & CAN_CTRLMODE_FD_TDC_MASK);
|
||||
}
|
||||
|
||||
/*
|
||||
* can_get_relative_tdco() - TDCO relative to the sample point
|
||||
*
|
||||
* struct can_tdc::tdco represents the absolute offset from TDCV. Some
|
||||
* controllers use instead an offset relative to the Sample Point (SP)
|
||||
* such that:
|
||||
*
|
||||
* SSP = TDCV + absolute TDCO
|
||||
* = TDCV + SP + relative TDCO
|
||||
*
|
||||
* -+----------- one bit ----------+-- TX pin
|
||||
* |<--- Sample Point --->|
|
||||
*
|
||||
* --+----------- one bit ----------+-- RX pin
|
||||
* |<-------- TDCV -------->|
|
||||
* |<------------------------>| absolute TDCO
|
||||
* |<--- Sample Point --->|
|
||||
* | |<->| relative TDCO
|
||||
* |<------------- Secondary Sample Point ------------>|
|
||||
*/
|
||||
static inline s32 can_get_relative_tdco(const struct can_priv *priv)
|
||||
{
|
||||
const struct can_bittiming *dbt = &priv->fd.data_bittiming;
|
||||
s32 sample_point_in_tc = (CAN_SYNC_SEG + dbt->prop_seg +
|
||||
dbt->phase_seg1) * dbt->brp;
|
||||
|
||||
return (s32)priv->fd.tdc.tdco - sample_point_in_tc;
|
||||
}
|
||||
|
||||
static inline u32 can_get_static_ctrlmode(struct can_priv *priv)
|
||||
{
|
||||
return priv->ctrlmode & ~priv->ctrlmode_supported;
|
||||
|
||||
Reference in New Issue
Block a user