Enable 3 (or more) SPI Ports on Colibri T30

I need to use at least 3 SPI ports on Colibri T30 in Linux. How can I enable them? In Linux it’s only enabled 1 port by default, which can be accessed via path /dev/spidev0.0.

I then tried modifying kernel file board-colibri_t30.c from this:

...
static struct spi_board_info tegra_spi_devices[] __initdata = {
	{
		.bus_num		= 0,		/* SPI1: Colibri SSP */
#if !defined(CONFIG_CAN_MCP251X) && !defined(CONFIG_CAN_MCP251X_MODULE)
		.chip_select		= 0,
#else /* !CONFIG_CAN_MCP251X & !CONFIG_CAN_MCP251X_MODULE */
		.chip_select		= 1,
#endif /* !CONFIG_CAN_MCP251X & !CONFIG_CAN_MCP251X_MODULE */
		.controller_data	= &spidev_controller_data,
		.irq			= 0,
		.max_speed_hz		= 50000000,
		.modalias		= "spidev",
		.mode			= SPI_MODE_0,
		.platform_data		= NULL,
	}
};
...
static struct platform_device *colibri_t30_spi_devices[] __initdata = {
    &tegra_spi_device1
};
...

into this:

...
static struct spi_board_info tegra_spi_devices[] __initdata = {
	{
		.bus_num		= 0,		/* SPI1: Colibri SSP */
//#if !defined(CONFIG_CAN_MCP251X) && !defined(CONFIG_CAN_MCP251X_MODULE)
		.chip_select		= 0,
//#else /* !CONFIG_CAN_MCP251X & !CONFIG_CAN_MCP251X_MODULE */
//		.chip_select		= 1,
//#endif /* !CONFIG_CAN_MCP251X & !CONFIG_CAN_MCP251X_MODULE */
		.controller_data	= &spidev_controller_data,
		.irq			= 0,
		.max_speed_hz		= 50000000,
		.modalias		= "spidev",
		.mode			= SPI_MODE_0,
		.platform_data		= NULL,
	},
	{
		.bus_num		= 1,		/* SPI1: Colibri SSP */
		.chip_select		= 0,
		.controller_data	= &spidev_controller_data,
		.irq			= 0,
		.max_speed_hz		= 50000000,
		.modalias		= "spidev",
		.mode			= SPI_MODE_0,
		.platform_data		= NULL,
	},
	{
		.bus_num		= 2,		/* SPI1: Colibri SSP */
		.chip_select		= 0,
		.controller_data	= &spidev_controller_data,
		.irq			= 0,
		.max_speed_hz		= 50000000,
		.modalias		= "spidev",
		.mode			= SPI_MODE_0,
		.platform_data		= NULL,
	}
};
...
static struct platform_device *colibri_t30_spi_devices[] __initdata = {
    &tegra_spi_device1,
    &tegra_spi_device2,
    &tegra_spi_device3
};
...

I configured the kernel with CAN MCP251X disabled and SPI enabled. It compiled and flashed successfully and I can get the dev paths shown: /dev/spidev0.0, /dev/spidev1.0, /dev/spidev2.0. But when I tested it with the spidev_test it would crash for the paths other than spidev0.0.

How to make it work? Thanks

Hi @m-rap,

After a deeper check, unfortunately the Colibri T30 does not support Device Tree configuration for the customization of system resources. So, my previous information was not correct and I apologize for that.

That said, you’ll have to enable and configure the additional SPI ports in the platform file, as you were doing initially.

And, as @marcel.tx said below, in addition to modifying the board platform data, you also need to adjust the respective pin muxing.

Best regards,
André Curvello

hi André.
What branch should I checkout on? I checked out on tag Colibri-T30_LXDE-Image_2.8b7.-20200610, the dts files you mentioned are missing.
I also tried checkout on tegra branch, but I couldn’t configure for colibri_t30_defconfig, it said:
Can’t find default configuration “arch/arm/configs/colibri_t30_defconfig”

In addition to modifying the board platform data you would also need to adjust resp. pin muxing here:

https://git.toradex.com/cgit/linux-toradex.git/tree/arch/arm/mach-tegra/board-colibri_t30-pinmux.c?h=tegra

Please note that the downstream T30 Linux kernel does not yet make use of a device tree.

Found the tegra30-colibri.dtsi file on origin/toradex_5.4.y, but failed when executing make colibri_t30_defconfig. The message: scripts/Kconfig.include:39: gold linker ‘arm-angstrom-linux-ld’ not supported

I’m sorry but that toradex_5.4.y branch is not officially supported for the Colibri T30.

can you explain more detail (maybe with example) about how to carefully edit the pin muxing? I don’t quite understand with the parameters and macro names used in that file. Thanks

Hi,

Yes, unfortunately the toradex_5.4.y branch is not officially supported.

In your case, you shall use:

  • BSP Version: 2.8.7
  • Branch: tegra
  • Kernel Config: colibri_t30_defconfig
  • Kernel File: arch/arm/boot/zImage

Best regards,
André Curvello

Hi,

For that I suggest you to start with the module datasheet, together with the Pinout Designer Tool, concerning what alternate functions to use in order to enable the other SPI ports.
Then, adapt the pinmux.c according to the new configuration of each pin.

Best regards,
André Curvello

thanks, I’ll try it out

hi @m-rap

Is your issue solved now?

Best regards,
Jaski

hi jaski,
yes it is solved. thank you very much.
sorry forgot to give an update

You are welcome. It would be nice if you can share your solution.

Best regards,
Jaski