SocketCAN and TJA1145 Transceiver

cancel
Showing results for 
Search instead for 
Did you mean: 

SocketCAN and TJA1145 Transceiver

449 Views
paul_katarzis
Contributor III

I am working on a custom board with an IMX8QXP and would like to get CAN working. This board is using a TJA1145 for the CAN transceiver. I am a bit lost on how to proceed. I can see that there is a SocketCAN based FLEXCAN driver provided by NXP. However, it seems that all SocketCAN based drivers that are part of the mainline kernel are written for devices that have an internal PHY. The FLEXCAN module is only a protocol engine, which is why the TJA1145 transceiver is needed. The complexity of the TJA1145 seems to require its own driver but I don't think NXP has one available. If I write a driver for the TJA1145, do I treat it as a PHY driver like what is done with Ethernet network devices? Is this not supported by the SocketCAN framework? Do I need to modify the FLEXCAN driver to control the transceiver directly?

Tags (3)
0 Kudos
4 Replies

305 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Paul

I think you are right, one can develop such driver like what is done with Ethernet network devices.

As starting point one can look at:

meta-sitec-score/1005-misc-tja1145-Initial-commit.patch at master · sitec-systems/meta-sitec-score ·... 

flexcan.c\can\net\drivers - linux-imx - i.MX Linux kernel 

Driver description in Linux Manual included in linux documentation on

i.MX Software and Development Tools | NXP 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

305 Views
paul_katarzis
Contributor III

Hello Igor,

I included that TJA1145 driver into my kernel (there are multiple patches that need to be put together), but it doesn't seem to work. Within the probe function is a call to check the device ID by reading the identification register over SPI. Based on the TJA1145 documentation it should either return 0x70 or 0x74. When I try to read this register it returns 0x00. In fact it seems all reads return 0x00. The TJA1145 chip is definitely powered, so I think there is something wrong with the SPI configuration in my device tree.

The board I am using has the TJA1145 connected to SPI1. The following is my device tree configuration for SPI1 and the TJA1145:

lpspi1: lpspi@5a010000 {
compatible = "fsl,imx7ulp-spi";
reg = <0x0 0x5a010000 0x0 0x10000>;
interrupts = <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>;
interrupt-parent = <&gic>;
clocks = <&clk IMX8QXP_SPI1_CLK>,
<&clk IMX8QXP_SPI1_IPG_CLK>;
clock-names = "per", "ipg";
assigned-clocks = <&clk IMX8QXP_SPI1_CLK>;
assigned-clock-rates = <20000000>;
power-domains = <&pd_dma_lpspi1>;
status = "disabled";
};

pinctrl_lpspi1: lpspi1grp {
fsl,pins = <
SC_P_SAI0_TXD_ADMA_SPI1_SDO 0x00000041
SC_P_SAI0_RXD_ADMA_SPI1_CS0 0x02000061
SC_P_SAI0_TXC_ADMA_SPI1_SDI 0x00000041
SC_P_SAI0_TXFS_ADMA_SPI1_SCK 0x00000061
>;
};

&lpspi1 {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpspi1>;
status = "okay";

tja1145: tja1145@0 {
compatible = "nxp,tja1145";
reg = <0>;
spi-max-frequency = <1000000>;
spi-cpha;
};
};

The TJA1145 has an internal pull up resistor on the chip select line and an internal pull down resistor on the clock line. The minimum clock frequency for SPI in the TJA1145 data sheet is 4 MHz. The SPI timing diagram in the TJA1145 data sheet shows that CPOL=0 and CPHA=1 with chip select active low. Is there something wrong with my device tree settings?

Edit: I tried using the configuration 0x0600004c for all of the pins since I saw another node in a sample device tree do this, but it also did not work. I have also changed the spi-max-frequency field to 1 MHz since I misinterpreted the data sheet. A clock rate of 4 MHz is the maximum, not the minimum. However, I still can't read anything.

0 Kudos

305 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Paul

may be suggested to proceed with help of Commercial Support and Engineering Services | NXP 

Reasons:

1. TJA1145 & SocketCan are not officially supported in nxp bsps, Supported features

are listed in Release Notes document included in linux documentation on

i.MX Software and Development Tools | NXP 

2. i.MX8QXP is not publicly released yet, it is marked as "PREPRODUCTION" as shown below

and also has not full support.

pastedImage_3.jpg

Best regards
igor

0 Kudos

305 Views
paul_katarzis
Contributor III

Hello Igor,

I will look into that. Thank you for your help!

0 Kudos