Hi!
I’m looking for some guidance on how to correctly enable the required clocks for running the CAN block from the SPE. I’ve had some success but I don’t think I’m quite there yet.
So let’s begin with what I have so far.
I’ve modified the firewall to allow the SPE to control the relevant registers in the CAR.
reg@2125 { /* CAR, CLK_RST_CONTROLLER_AON_SCR_CAN_0 */
exclusion-info = <3>;
value = <0x30001410>;
};
I’m then setting up, what i think is the CAN1 core-clock, from the SPE with the same values as the BPMP writes when running the regular Linux kernel module. (figured by just reading back these registers after the ttcan kernel module has been inserted). 0xb10000 comes from arclk_rst.h in the SPE firmware repo.
reg_wr(0x20b11000, 3); // CAN1_CLK_OUT ?
reg_wr(0x20b13000, 2); // CAN1_CLK_SRC ?
I can then make the CAN block drop out of reset with:
reg_wr(0x20b10000, 0);
I’m also setting COK in the M_TTCAN_CONTROL_REGISTER0_0
After this I can read/write to the CAN registers but the CAN bus-status stays in synchronizing state and it keeps complaining about various errors and also the read-error-counter keeps increasing and pegs to 127.
I’m also writing the exact same value (0x0000230c) as the kernel module in the NBTP register.
I’ve only tried receiving frames so far, not transmitted. But it seems like the clocks are not configured correctly.
The BPMP and TRM mentions three (different ?) clocks:
/** @brief output of mux controlled by CLK_RST_CONTROLLER_CLK_SOURCE_CAN1 */
#define TEGRA234_CLK_CAN1 9U
/** @brief output of gate CLK_ENB_CAN1_HOST */
#define TEGRA234_CLK_CAN1_HOST 10U
/** @brief CLK_RST_CONTROLLER_CAN1_CORE_RATE divider output */
#define TEGRA234_CLK_CAN1_CORE 284U
and (TRM chapter 9.4.2.1.1)
The following table has the frequency ranges for CAN.
Clock Minimum Maximum
CCLK 8 MHz 80 MHz
HCLK (always N*CCLK, N=1,2,3,4) 8 MHz 320 MHz
PCLK (System Dependent) N/A N/A
Are all these configured from the CAR 0x20b1xxxx register section or am I missing something here?
I’ve made sure the ttcan kernel module is not loaded and the relevant can sections are set to disabled in the kernel/bootloader device-tree. (I’ve also tried without booting Linux at all, same results)
Any advice would be much appreciated.
Thanks.