Skip to content

Commit

Permalink
dts: bindings: can: rename bus-speed/bus-speed-data properties
Browse files Browse the repository at this point in the history
Deprecate the CAN controller bus-speed/bus-speed-data properties and rename
them to bitrate/bitrate-data to match the terminology used in other CAN
devicetree properties and the CAN subsystem API.

Signed-off-by: Henrik Brix Andersen <[email protected]>
  • Loading branch information
henrikbrixandersen authored and fabiobaltieri committed Jun 5, 2024
1 parent 23b4706 commit 695e704
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/hardware/peripherals/can/shell.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ stopping the processing of CAN frames.
.. note::
The CAN controller mode and timing can only be changed while the CAN controller is stopped, which
is the initial setting upon boot-up. The initial CAN controller mode is set to ``normal`` and the
initial timing is set according to the ``bus-speed``, ``sample-point``, ``bus-speed-data``, and
initial timing is set according to the ``bitrate``, ``sample-point``, ``bitrate-data``, and
``sample-point-data`` :ref:`devicetree` properties.

Timing
Expand Down
8 changes: 6 additions & 2 deletions doc/releases/migration-guide-3.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ Controller Area Network (CAN)
=============================

* Removed the following deprecated CAN controller devicetree properties. Out-of-tree boards using
these properties need to switch to using the ``bus-speed``, ``sample-point``, ``bus-speed-data``,
and ``sample-point-data`` devicetree properties for specifying the initial CAN bitrate:
these properties can switch to using the ``bitrate``, ``sample-point``, ``bitrate-data``, and
``sample-point-data`` devicetree properties (or rely on :kconfig:option:`CAN_DEFAULT_BITRATE` and
:kconfig:option:`CAN_DEFAULT_BITRATE_DATA`) for specifying the initial CAN bitrate:

* ``sjw``
* ``prop-seg``
Expand All @@ -259,6 +260,9 @@ Controller Area Network (CAN)
* ``phase-seg1-data``
* ``phase-seg1-data``

The ``bus-speed`` and ``bus-speed-data`` CAN controller devicetree properties have been
deprecated.

(:github:`68714`)

* Support for manual bus-off recovery was reworked (:github:`69460`):
Expand Down
4 changes: 2 additions & 2 deletions drivers/can/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ config CAN_DEFAULT_BITRATE
default 125000
help
Default initial CAN bitrate in bits/s. This can be overridden per CAN controller using the
"bus-speed" devicetree property.
"bitrate" devicetree property.

config CAN_DEFAULT_BITRATE_DATA
int "Default CAN data phase bitrate"
default 1000000
depends on CAN_FD_MODE
help
Default initial CAN data phase bitrate in bits/s. This can be overridden per CAN controller
using the "bus-speed-data" devicetree property.
using the "bitrate-data" devicetree property.

config CAN_SHELL
bool "CAN shell"
Expand Down
8 changes: 8 additions & 0 deletions dts/bindings/can/can-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ include: base.yaml

properties:
bus-speed:
type: int
deprecated: true
description: |
Deprecated. This property has been renamed to bitrate.
Initial bitrate in bit/s. If this is unset, the initial bitrate is set to
CONFIG_CAN_DEFAULT_BITRATE.
bitrate:
type: int
description: |
Initial bitrate in bit/s. If this is unset, the initial bitrate is set to
Expand Down
8 changes: 8 additions & 0 deletions dts/bindings/can/can-fd-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ include: can-controller.yaml

properties:
bus-speed-data:
type: int
deprecated: true
description: |
Deprecated. This property has been renamed to bitrate-data.
Initial data phase bitrate in bit/s. If this is unset, the initial data phase bitrate is set
to CONFIG_CAN_DEFAULT_BITRATE_DATA.
bitrate-data:
type: int
description: |
Initial data phase bitrate in bit/s. If this is unset, the initial data phase bitrate is set
Expand Down
7 changes: 4 additions & 3 deletions include/zephyr/drivers/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,12 @@ struct can_driver_config {
.phy = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(node_id, phys)), \
.min_bitrate = DT_CAN_TRANSCEIVER_MIN_BITRATE(node_id, _min_bitrate), \
.max_bitrate = DT_CAN_TRANSCEIVER_MAX_BITRATE(node_id, _max_bitrate), \
.bus_speed = DT_PROP_OR(node_id, bus_speed, CONFIG_CAN_DEFAULT_BITRATE), \
.bus_speed = DT_PROP_OR(node_id, bitrate, \
DT_PROP_OR(node_id, bus_speed, CONFIG_CAN_DEFAULT_BITRATE)), \
.sample_point = DT_PROP_OR(node_id, sample_point, 0), \
IF_ENABLED(CONFIG_CAN_FD_MODE, \
(.bus_speed_data = DT_PROP_OR(node_id, bus_speed_data, \
CONFIG_CAN_DEFAULT_BITRATE_DATA), \
(.bus_speed_data = DT_PROP_OR(node_id, bitrate_data, \
DT_PROP_OR(node_id, bus_speed_data, CONFIG_CAN_DEFAULT_BITRATE_DATA)), \
.sample_point_data = DT_PROP_OR(node_id, sample_point_data, 0),)) \
}

Expand Down
5 changes: 3 additions & 2 deletions samples/modules/canopennode/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
LOG_MODULE_REGISTER(app);

#define CAN_INTERFACE DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus))
#define CAN_BITRATE (DT_PROP_OR(DT_CHOSEN(zephyr_canbus), bus_speed, \
CONFIG_CAN_DEFAULT_BITRATE) / 1000)
#define CAN_BITRATE (DT_PROP_OR(DT_CHOSEN(zephyr_canbus), bitrate, \
DT_PROP_OR(DT_CHOSEN(zephyr_canbus), bus_speed, \
CONFIG_CAN_DEFAULT_BITRATE)) / 1000)

static struct gpio_dt_spec led_green_gpio = GPIO_DT_SPEC_GET_OR(
DT_ALIAS(green_led), gpios, {0});
Expand Down
2 changes: 1 addition & 1 deletion tests/drivers/can/host/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Zephyr end of the CAN fixture can be configured as follows:
* The CAN controller to be used is set using the ``zephyr,canbus`` chosen devicetree node.
* The CAN bitrates are set using :kconfig:option:`CONFIG_CAN_DEFAULT_BITRATE` and
:kconfig:option:`CONFIG_CAN_DEFAULT_BITRATE_DATA`, but can be overridden on a board level using
the ``bus-speed`` and ``bus-speed-data`` CAN controller devicetree properties if needed. Default
the ``bitrate`` and ``bitrate-data`` CAN controller devicetree properties if needed. Default
bitrates are 125 kbits/s for the arbitration phase/CAN classic and 1 Mbit/s for the CAN FD data
phase when using bitrate switching (BRS).

Expand Down

0 comments on commit 695e704

Please sign in to comment.