-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: can: add support for minimum supported bitrates #69533
drivers: can: add support for minimum supported bitrates #69533
Conversation
e095e60
to
99aed69
Compare
e4e60fc
to
2160751
Compare
2160751
to
7880feb
Compare
Rebased to resolve merge conflict in |
@str4t0m PTAL |
Some CAN transceivers have a lower limit on their supported bitrate. Add an optional "min-bitrate" for specifying this limit via devicetree. Signed-off-by: Henrik Brix Andersen <[email protected]>
The NXP TJA1050 supports bitrates from 60kbit/s up to 1Mbit/s. Signed-off-by: Henrik Brix Andersen <[email protected]>
Add support for getting the minimum supported bitrate of a CAN transceiver. Signed-off-by: Henrik Brix Andersen <[email protected]>
Add tests for DT_CAN_TRANSCEIVER_MIN_BITRATE() and DT_INST_CAN_TRANSCEIVER_MIN_BITRATE(). Signed-off-by: Henrik Brix Andersen <[email protected]>
Add support for specifying the minimum bitrate supported by a CAN controller in CAN_DT_DRIVER_CONFIG_GET() and CAN_DT_DRIVER_CONFIG_INST_GET(). Signed-off-by: Henrik Brix Andersen <[email protected]>
Allow frontend drivers based on the SJA1000 backend to specify a minimum supported bitrate. The ESP32 TWAI supports bitrates from 25kbit/s to 1Mbit/s. Signed-off-by: Henrik Brix Andersen <[email protected]>
Add a new CAN controller API function can_get_min_bitrate() for getting the minimum supported bitrate of a CAN controller/transceiver combination. Signed-off-by: Henrik Brix Andersen <[email protected]>
Add test for validating the CAN controller bitrate limits. Signed-off-by: Henrik Brix Andersen <[email protected]>
Take the minimum supported bitrate into consideration when validating the bitrate. Signed-off-by: Henrik Brix Andersen <[email protected]>
Enable testing of all bitrates for all drivers and report which bitrates are not supported by the CAN controller under test. Signed-off-by: Henrik Brix Andersen <[email protected]>
Add release notes related to the added support for minimum supported CAN transceiver/controller bitrates. Signed-off-by: Henrik Brix Andersen <[email protected]>
7880feb
to
86fdff4
Compare
Rebased to resolve merge conflict in |
@@ -363,7 +366,7 @@ int z_impl_can_set_bitrate(const struct device *dev, uint32_t bitrate) | |||
return ret; | |||
} | |||
|
|||
if ((max_bitrate > 0) && (bitrate > max_bitrate)) { | |||
if ((bitrate < min_bitrate) || (((max_bitrate > 0) && (bitrate > max_bitrate)))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is the check for max_bitrate of zero needed here? It is marked as required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing! Currently, it is needed. It will go away in a future revision.
Some CAN controllers and CAN transceivers have a lower limit for which bitrates they support.
In-tree examples:
This patch series adds:
can_get_min_bitrate()
API function (+ tests) for getting the minimum supported bitrate for a given CAN controller/transceiver combo.