Zephyr: Implement Microchip SAM family CAN controller driver

Created on 29 Apr 2020  路  12Comments  路  Source: zephyrproject-rtos/zephyr

Summary

A number of Microchip (formerly, Atmel) SAM family SoCs include a CAN 2.0A/B and CAN-FD capable host controller peripheral.

In order to take advantage of this, it is necessary to implement a driver for it, that can interface to the existing Zephyr CAN protocol stack.

Target Devices

The following Microchip SAM family devices implement the "Microchip CAN Controller" peripheral:

  • SAM C21
  • SAM E51/E54
  • SAM E70
  • SAM V70/V71

Note that the following (old generation) Atmel SAM family devices also include a CAN controller peripheral, but this is completely different from the "Microchip CAN Controller" and therefore incompatible; this issue does not propose to support them:

  • SAM 3X
  • SAM 4E
Feature CAN Drivers ATMEL

Most helpful comment

FYI: those Microchip (formerly Atmel) products implement Bosch M_CAN IP. The same IP is used by ST (FDCAN) and TI (TCAN4550) so there may be value in having a generic driver.

All 12 comments

Is anyone already working on this by any chance?

cc @benpicco @nandojve @mnkp @aurel32 @karstenkoenig @alexanderwachter

Not that I know off.
Do you plan to work on that driver by any chance?

Not that I know off.
Do you plan to work on that driver by any chance?

Not anytime soon, but it is in my long-term backlog for now.

I'm not working...happy to read that!

FYI: those Microchip (formerly Atmel) products implement Bosch M_CAN IP. The same IP is used by ST (FDCAN) and TI (TCAN4550) so there may be value in having a generic driver.

I just implemented the driver for STM32G4 (FDCAN) #22832

FYI: those Microchip (formerly Atmel) products implement Bosch M_CAN IP. The same IP is used by ST (FDCAN) and TI (TCAN4550) so there may be value in having a generic driver.

@DarrylGamroth Comparing the CAN FD register maps of the SAM and STM32 SoCs, I can see that is indeed the case. Thanks for the very useful info!

I just implemented the driver for STM32G4 (FDCAN) #22832

@alexanderwachter It looks like it would be possible to support the Atmel SAM series just by refactoring your "STM32" CAN FD driver in that PR :)

Not working on any CAN drivers lately :-(

@DarrylGamroth Oh wow thanks for pointing that out! I knew the TCAN4550 standalone controller had a bosch m_can ip but not that it's also what's in the STs FDCAN. The TCAN4550 looked really sweet, but the price of that evaluation board is just a bit much...

@DarrylGamroth thanks for pointing this out!
I鈥榣l rename the driver then!

I separated the generic part of the M_CAN module. Some functions need to be implemented for every platform, like all clock related stuff. Unfortunately, the STM FDCAN is not 100% compatible with M_CAN. It misses some registers, and the size of the message RAM differs. There will be some #ifdefs in the code.

Nice!

Could the message RAM definition be defined in Devicetree similar to the Linux dts then use DT_REG_ADDR_BY_NAME(DT_INST(0, bosch_m_can), message_ram) to get the base and DT_REG_SIZE_BY_NAME(DT_INST(0, bosch_m_can), message_ram) for the size?

I might be wrong with the correct DT macro usage but you get the general idea.

Sure, it is not finished yet. There are some other things, especially in the init, that need to be changed.

Was this page helpful?
0 / 5 - 0 ratings