Commit Graph

18 Commits

Author SHA1 Message Date
Gerard Marull-Paretas 178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Henrik Brix Andersen 180cdc105e drivers: can: add start and stop CAN controller API functions
Up until now, the Zephyr CAN controller drivers set a default bitrate (or
timing) specified via devicetree and start the CAN controller in their
respective driver initialization functions.

This is fine for CAN nodes using only one fixed bitrate, but if the bitrate
is set by the user (e.g. via a DIP-switch or other HMI which is very
common), the CAN driver will still initialise with the default
bitrate/timing at boot and use this until the application has determined
the requested bitrate/timing and set it using
can_set_bitrate()/can_set_timing().

During this period, the CAN node will potentially destroy valid CAN frames
on the CAN bus (which is using the soon-to-be-set-by-the-application
bitrate) by sending error frames. This causes interruptions to the ongoing
CAN bus traffic when a Zephyr-based CAN node connected to the bus is
(re-)booted.

Instead, require all configuration (setting bitrate, timing, or mode) to
take place when the CAN controller is stopped. This maps nicely to entering
"reset mode" (called "configuration mode" or "freeze mode" for some CAN
controller implementations) when stopping and exiting this mode when
starting the CAN controller.

Fixes: #45304

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-09-13 16:06:50 +00:00
Henrik Brix Andersen bb08e4251a drivers: can: add API for getting supported capabilities
Add API function for getting the supported capabilities of a CAN
controller. This allows for writing portable CAN applications.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-07-13 10:13:56 +02:00
Henrik Brix Andersen 2f7c01ba21 drivers: can: rename API functions from timing_*_data to timing_data_*
Rename the CAN data phase API functions to timing_data_* for consistency:
- can_get_timing_min_data() -> can_get_timing_data_min()
- can_get_timing_max_data() -> can_get_timing_data_max()
- .timing_min_data -> timing_data_min
- .timing_max_data -> timing_data_max

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 18890828b8 drivers: can: split CAN classic and CAN-FD syscalls
Split CAN classic and CAN-FD syscalls into two:
- can_set_timing() -> can_set_timing() + can_set_timing_data()
- can_set_bitrate() -> can_set_bitrate() + can_set_bitrate_data()

Fixes: #45303

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen ebbb4b67b9 drivers: can: sam: use UPLL clock instead of PLLA clock
Use the UPLLCK clock for the CAN controller as recommended by the Atmel SAM
E70 data sheet.

Move the configuration of the clock prescaler from Kconfig to devicetree
and limit it to the values recommended by the SAM E70 datasheet.

Fixes: #45012

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-05-09 09:27:40 +02:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Henrik Brix Andersen 41a77be91c drivers: can: mcan: add shared initializer macros
Add shared initializer macros for struct can_mcan_config and struct
can_mcan_data.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-03 09:36:34 +02:00
Henrik Brix Andersen 5b3712a9ac drivers: can: mcan: refactor to get rid of wrapper functions
Refactor the Bosch M_CAN shared driver functions to get rid of the
front-end driver wrapper functions.

This requires flipping the relationship between shared config/data
structs and front-end config/data structs. Front-end drivers can now
store a pointer to their custom config/data structs in the .custom
fields of the can_mcan_config and can_mcan_data data structures.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-03 09:36:34 +02:00
Henrik Brix Andersen e0aaaea473 drivers: can: mcan: fix compiler warning
Fix compiler warning with CONFIG_CAN_AUTO_BUS_OFF_RECOVERY=y.

Fixes: 4e41d89c7b

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 18:11:13 -04:00
Henrik Brix Andersen 99964fab45 drivers: can: add missing static keywords
Add missing static keywords for functions internal to the drivers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 10:31:37 +02:00
Henrik Brix Andersen 4e41d89c7b drivers: can: mcan: fix bus recovery functions
Fix the signature of the CAN bus recovery functions in the Bosch M_CAN
driver frontends.

Fixes: #44345

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-31 10:31:15 +02:00
Gerson Fernando Budke d7c37d1f12 drivers: can: Update sam canfd driver to use pinctrl
This update Atmel sam canfd driver to use pinctrl driver and API. It
updates all boards with new pinctrl groups format. In addition this
add missing entries to run automated tests for can/canfd drivers.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2022-03-24 15:45:37 -07:00
Henrik Brix Andersen 5fd079bd68 drivers: can: mcan: add generic support for can_get_max_filters()
Add generic support for can_get_max_filters() to the Bosch M_CAN
base driver and use it in all driver frontends.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-18 16:14:40 -04:00
Henrik Brix Andersen d8e88b61eb drivers: can: mcan: add transceiver support
Add support for CAN transceivers to the Bosch M_CAN CAN drivers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-15 14:32:29 -05:00
Henrik Brix Andersen de45e8ec72 drivers: can: use separate log modules for each driver
Use separate log modules for each CAN driver similar to other
sub-systems/driver classes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-02-22 10:34:04 -05:00
Henrik Brix Andersen 2aed5a1237 drivers: can: remove CAN_BUS_UNKNOWN CAN controller state
The CAN_BUS_UNKNOWN CAN controller state is only used to indicate that
the current CAN controller state could not be read.

Remove it and change the signature of the can_get_state() API function
to return an integer indicating success or failure.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-28 10:05:29 +01:00
Alexander Wachter 6e5c8a339d drivers: can: Add frontend for Atmel SAM M_CAN controller
This commit adds a frontend for the generic Bosch m_can driver
for Atmel SAM series.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2022-01-18 10:39:55 -05:00