Dear NXP fellows,
In our development board based on S32G399ARDB3 we are using 6 TJA1145ATK/FD CAN transceiver connected to DSPI1 pins of the S32G399A microcontroller:
We are using the LLCE_CAN interface for accessing these CAN transceivers.
Differently from the original TJA1153, the TJA1145 uses SPI communication for Partial Networking state transition (OFF - STANDBY - SLEEP - ACTIVE modes):
But what I don't understand is how to use SPI to control these state changes.
Do I need to provide a Linux driver for TJA1145?
Can someone provide me a basic walkthrough on how to enable this CAN transceiver on S32G399A LLCE_CAN interface?
Thank you very much for the support.
Best regards,
Guilherme
Hello,
Just to update. I found the Linux kernel patches for supporting TJA1145 here:
And that allowed me to build the tja1145.c into the Kernel (5.15.153-rt).
Added the following line to the drivers/net/can/Makefile:
obj-$(CONFIG_TJA1145) += tja1145.oAdded the following entry to drivers/net/can/Kconfig:
config TJA1145
tristate "TJA1145 CAN-Transceiver driver"
select REGMAP_SPI
depends on SPI_MASTER
help
Say Y here if you want to use the TJA1145 CAN Transceiver. TODO advanced description. Added the following entry to arch/arm64/configs/s32cc_defconfig:
CONFIG_TJA1145=yAdded the following Device Tree node to arch/arm64/boot/dts/freescale/s32g399a-rdb3.dtsi
&spi1 {
pinctrl-names = "default";
pinctrl-0 = <&dspi1_pins>;
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
spidev0: spidev@0 {
spi-max-frequency = <1000000>;
reg = <0>;
spi-cpha;
compatible = "nxp,tja1145";
};
};And then I successfully enabled CAN communication with the TJA1145.
Thanks for your support,
Best regards,
Guilherme
Hello, @GuilhermeS32G
You are welcome.
If any other issues, welcome to submit new ticket on the board, we are happy to support.
BR
Chenyin
Hello @chenyin_h ,
Ok, I understand now.
Thank you for clarifying.
Best regards,
Guilherme
Hello, @GuilhermeS32G
Sorry that I do not think there are document related since it is very specific case and should be disigned by the user.
What I mean for the sequence is that you may need to put a spi operation before loading the LLCE-CAN driver according to your own requirements, when resuming from STR, you may have to also confirm that the SPI operation is done before reloading the LLCE driver.
Again, thanks for @XD 's valuable input.
BR
Chenyin
Hello @chenyin_h ,
Thank you for the feedback.
In this case, what is the correct way of configuring the driver loading sequence? Is there a document that specifies this operation?
Best regards,
Guilherme
Hi @XD ,
Thank you for your help. Following your advice, I have enabled spidev on the spi1 interface and now I can see that /dev/spidev1.0 is available.
The next step is to write this user-space program for accessing the correct registers and writing the required changes to the specific addresses. I will be working on it.
Best regards,
Guilherme
Hello, @GuilhermeS32G
Thanks for sharing the schematic, I could understand your point.
You may use the spi to firstly switch the state, and then to load the llce-can driver, but you may be careful with the driver loading sequence while the system resumed from STR.
I agree with @XD 's valuable input, the spidev interface is useful for accessing the spi devices in Linux.
BR
Chenyin
Hi @GuilhermeS32G ,
Our customized board uses a similar partial network transceiver but from a different vendor. Unfortunately, the board hasn’t returned yet, so I haven’t been able to verify this process. Here’s what I plan to do, just for your reference:
Device Tree Entry:
Add your CAN transceiver to the device tree under the relevant DSPI entry. For SPI access, you can use compatible = "spidev"; This should allow you to interact with the transceiver via /dev/spidevX.X, where X.X is the SPI bus and chip select.
Driver Requirement:
You may not need a dedicated kernel driver. Instead, you can control the CAN transceiver directly from user space. For example, you can modify the transceiver's registers to switch its mode from standby to normal using a simple user-space program. You can refer to tools/spi/spidev_test.c in the kernel source as an example for how to interact with SPI devices.
Thanks,
XD
Hello @chenyin_h ,
Thank you for your response,
So, just for clarifying. Our board has 16 CAN transceivers in total, being:
All 16 transceivers are using LLCE_CAN interfaces. I was able to enable LLCE_CAN feature and include all the required firmware files in the built Yocto image.
What happens is that the TJA1057 is a simple CAN transceiver, it does not support standby or sleep mode, so the communication on these transceiver is occurring normally.
However, the TJA1145 supports Partial Networking, and it required the SPI communication for state transition. Whenever I try to set any of these llcecan interfaces connected to TJA1145 up, I get an error:
Failed the transition to LLCE_CAN_T_START stateThis is due to the lack of a driver for controlling the state changes via SPI.
Here is a picture of one of these CAN transceivers from our schematic:
As you can see, the RXD and TXD are connected to LLCE_CAN3, and the pins concerning state transition are connected to DSPI1.
Does that mean that if I can provide a driver for TJA1145 it may work properly?
Is there any specific change to be made in LLCE_CAN configuration?
Thank you for the support,
Best regards,
Guilherme
Hello, @GuilhermeS32G
Thanks for your post.
From my experience, if so, a Linux device driver may be needed(whether it is a kenel driver or user space driver).
I do not see such reference code from the latest BSP, but I ever know that someone has done something with a iMX platform via socketcan:
https://community.nxp.com/t5/i-MX-Processors/SocketCAN-and-TJA1145-Transceiver/m-p/1008601
However, the link from this thread is invalid.
The TJA1145 connected to the board via SPI, not LLCE-CAN, for using the LLCE-CAN from Linux, it is detailed described under chapter 11 of BSP41 UM, you may directly use the llce-canx interface to send/receive frames once finished the settings.
BR
Chenyin