From 9079f7d230679a07c1d5d63bab779cde9e111751 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 1 Jun 2024 22:28:09 +0000 Subject: [PATCH] dts: bindings: can: rename bus-speed/bus-speed-data properties 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. (cherry picked from commit 695e704b5dc30ae1863373cc8f31f62219710051) Original-Signed-off-by: Henrik Brix Andersen GitOrigin-RevId: 695e704b5dc30ae1863373cc8f31f62219710051 Change-Id: I0f6cd7085ced0ef7fc651ecb6b95bd8782ee0cf6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5602006 Tested-by: ChromeOS Prod (Robot) Commit-Queue: Fabio Baltieri Reviewed-by: Fabio Baltieri --- doc/hardware/peripherals/can/shell.rst | 2 +- doc/releases/migration-guide-3.7.rst | 8 ++++++-- drivers/can/Kconfig | 4 ++-- dts/bindings/can/can-controller.yaml | 8 ++++++++ dts/bindings/can/can-fd-controller.yaml | 8 ++++++++ include/zephyr/drivers/can.h | 7 ++++--- samples/modules/canopennode/src/main.c | 5 +++-- tests/drivers/can/host/README.rst | 2 +- 8 files changed, 33 insertions(+), 11 deletions(-) diff --git a/doc/hardware/peripherals/can/shell.rst b/doc/hardware/peripherals/can/shell.rst index ed36379c55f..0457203438d 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 b18522722e1..ce867152581 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 df1bf5f7f6c..5aa956353dc 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 55322b50a21..e2825b6e676 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 9efc7823f94..ea357b83224 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 bf3af29ede2..8dbf7c89e48 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 60c3ebaa6df..e741f569466 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 7f8b15936af..bc1dca4d73c 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).