diff --git a/doc/hardware/peripherals/can/shell.rst b/doc/hardware/peripherals/can/shell.rst index ed36379c55ffe6..0457203438d7e9 100644 --- a/doc/hardware/peripherals/can/shell.rst +++ b/doc/hardware/peripherals/can/shell.rst @@ -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 diff --git a/doc/releases/migration-guide-3.7.rst b/doc/releases/migration-guide-3.7.rst index b18522722e1b11..ce86715258151e 100644 --- a/doc/releases/migration-guide-3.7.rst +++ b/doc/releases/migration-guide-3.7.rst @@ -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`` @@ -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`): diff --git a/drivers/can/Kconfig b/drivers/can/Kconfig index df1bf5f7f6c57f..5aa956353dc21c 100644 --- a/drivers/can/Kconfig +++ b/drivers/can/Kconfig @@ -28,7 +28,7 @@ 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" @@ -36,7 +36,7 @@ config CAN_DEFAULT_BITRATE_DATA 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" diff --git a/dts/bindings/can/can-controller.yaml b/dts/bindings/can/can-controller.yaml index 55322b50a21e9d..e2825b6e6763b8 100644 --- a/dts/bindings/can/can-controller.yaml +++ b/dts/bindings/can/can-controller.yaml @@ -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 diff --git a/dts/bindings/can/can-fd-controller.yaml b/dts/bindings/can/can-fd-controller.yaml index 9efc7823f94fd4..ea357b832240e3 100644 --- a/dts/bindings/can/can-fd-controller.yaml +++ b/dts/bindings/can/can-fd-controller.yaml @@ -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 diff --git a/include/zephyr/drivers/can.h b/include/zephyr/drivers/can.h index bf3af29ede29e7..8dbf7c89e48e97 100644 --- a/include/zephyr/drivers/can.h +++ b/include/zephyr/drivers/can.h @@ -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),)) \ } diff --git a/samples/modules/canopennode/src/main.c b/samples/modules/canopennode/src/main.c index 60c3ebaa6dfe6f..e741f569466aee 100644 --- a/samples/modules/canopennode/src/main.c +++ b/samples/modules/canopennode/src/main.c @@ -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}); diff --git a/tests/drivers/can/host/README.rst b/tests/drivers/can/host/README.rst index 7f8b15936afce3..bc1dca4d73c05d 100644 --- a/tests/drivers/can/host/README.rst +++ b/tests/drivers/can/host/README.rst @@ -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).