Lines Matching full:bt
9 void can_sjw_set_default(struct can_bittiming *bt) in can_sjw_set_default() argument
11 if (bt->sjw) in can_sjw_set_default()
15 bt->sjw = max(1U, min(bt->phase_seg1, bt->phase_seg2 / 2)); in can_sjw_set_default()
18 int can_sjw_check(const struct net_device *dev, const struct can_bittiming *bt, in can_sjw_check() argument
21 if (bt->sjw > btc->sjw_max) { in can_sjw_check()
23 bt->sjw, btc->sjw_max); in can_sjw_check()
27 if (bt->sjw > bt->phase_seg1) { in can_sjw_check()
30 bt->sjw, bt->phase_seg1); in can_sjw_check()
34 if (bt->sjw > bt->phase_seg2) { in can_sjw_check()
37 bt->sjw, bt->phase_seg2); in can_sjw_check()
49 static int can_fixup_bittiming(const struct net_device *dev, struct can_bittiming *bt, in can_fixup_bittiming() argument
53 const unsigned int tseg1 = bt->prop_seg + bt->phase_seg1; in can_fixup_bittiming()
68 if (bt->phase_seg2 < btc->tseg2_min) { in can_fixup_bittiming()
70 bt->phase_seg2, btc->tseg2_min); in can_fixup_bittiming()
73 if (bt->phase_seg2 > btc->tseg2_max) { in can_fixup_bittiming()
75 bt->phase_seg2, btc->tseg2_max); in can_fixup_bittiming()
79 can_sjw_set_default(bt); in can_fixup_bittiming()
81 err = can_sjw_check(dev, bt, btc, extack); in can_fixup_bittiming()
85 brp64 = (u64)priv->clock.freq * (u64)bt->tq; in can_fixup_bittiming()
92 bt->brp = (u32)brp64; in can_fixup_bittiming()
94 if (bt->brp < btc->brp_min) { in can_fixup_bittiming()
96 bt->brp, btc->brp_min); in can_fixup_bittiming()
99 if (bt->brp > btc->brp_max) { in can_fixup_bittiming()
101 bt->brp, btc->brp_max); in can_fixup_bittiming()
105 bt->bitrate = priv->clock.freq / (bt->brp * can_bit_time(bt)); in can_fixup_bittiming()
106 bt->sample_point = ((CAN_SYNC_SEG + tseg1) * 1000) / can_bit_time(bt); in can_fixup_bittiming()
107 bt->tq = DIV_U64_ROUND_CLOSEST(mul_u32_u32(bt->brp, NSEC_PER_SEC), in can_fixup_bittiming()
115 can_validate_bitrate(const struct net_device *dev, const struct can_bittiming *bt, in can_validate_bitrate() argument
123 if (bt->bitrate == bitrate_const[i]) in can_validate_bitrate()
128 bt->brp); in can_validate_bitrate()
133 int can_get_bittiming(const struct net_device *dev, struct can_bittiming *bt, in can_get_bittiming() argument
144 if (!bt->tq && bt->bitrate && btc) in can_get_bittiming()
145 return can_calc_bittiming(dev, bt, btc, extack); in can_get_bittiming()
146 if (bt->tq && !bt->bitrate && btc) in can_get_bittiming()
147 return can_fixup_bittiming(dev, bt, btc, extack); in can_get_bittiming()
148 if (!bt->tq && bt->bitrate && bitrate_const) in can_get_bittiming()
149 return can_validate_bitrate(dev, bt, bitrate_const, in can_get_bittiming()