How to make spi work during uboot on Jetson TX1

Hi:

I want to make spi(pins G13 F13 F14 E14) works on Jetson TX1 during uboot, How can i do to accomplish it?

thanks!

Have a reference to below link

Hello:
I want to add the SPI driver to uboot, and configure the pins in u-boot\board\nvidia\p2371-2180\pinmux-config-p2371-2180.h, as follows:

static const struct tegra_gpio_config p2371_2180_gpio_inits[] = {
	/*        port, pin, init_val */
	GPIO_INIT(A,    5,   IN),
	GPIO_INIT(B,    0,   IN),
	GPIO_INIT(B,    1,   IN),
	GPIO_INIT(B,    2,   IN),
	GPIO_INIT(B,    3,   IN),
	GPIO_INIT(E,    4,   IN),
	GPIO_INIT(E,    5,   IN),
	GPIO_INIT(E,    6,   IN),
	GPIO_INIT(H,    0,   OUT0),
	GPIO_INIT(H,    1,   OUT0),
	GPIO_INIT(H,    2,   IN),
	GPIO_INIT(H,    3,   OUT0),
	GPIO_INIT(H,    4,   OUT0),
	GPIO_INIT(H,    5,   IN),
	GPIO_INIT(H,    6,   IN),
	GPIO_INIT(H,    7,   IN),
	GPIO_INIT(I,    0,   OUT0),
	GPIO_INIT(I,    1,   IN),
	GPIO_INIT(I,    2,   OUT0),
	GPIO_INIT(K,    4,   IN),
	GPIO_INIT(K,    5,   OUT0),
	GPIO_INIT(K,    6,   IN),
	GPIO_INIT(K,    7,   IN),
	GPIO_INIT(L,    1,   IN),
	GPIO_INIT(S,    4,   OUT0),
	GPIO_INIT(S,    5,   OUT0),
	GPIO_INIT(S,    6,   OUT0),
	GPIO_INIT(S,    7,   OUT0),
	GPIO_INIT(T,    0,   OUT0),
	GPIO_INIT(T,    1,   OUT0),
	GPIO_INIT(U,    2,   IN),
	GPIO_INIT(U,    3,   IN),
	GPIO_INIT(V,    1,   OUT0),
	GPIO_INIT(V,    2,   OUT0),
	GPIO_INIT(V,    3,   IN),
	GPIO_INIT(V,    5,   OUT0),
	GPIO_INIT(V,    6,   OUT0),
	GPIO_INIT(X,    0,   IN),
	GPIO_INIT(X,    1,   IN),
	GPIO_INIT(X,    2,   IN),
	GPIO_INIT(X,    3,   IN),
	GPIO_INIT(X,    4,   IN),
	GPIO_INIT(X,    5,   IN),
	GPIO_INIT(X,    6,   IN),
	GPIO_INIT(X,    7,   IN),
	GPIO_INIT(Y,    0,   IN),
	GPIO_INIT(Y,    1,   IN),
	GPIO_INIT(Z,    0,   IN),
	GPIO_INIT(Z,    2,   IN),
	GPIO_INIT(Z,    3,   OUT0),
	GPIO_INIT(BB,   0,   IN),
	GPIO_INIT(BB,   2,   OUT0),
	GPIO_INIT(BB,   3,   IN),
	GPIO_INIT(CC,   1,   IN),
};

static const struct pmux_pingrp_config p2371_2180_pingrps[] = {
	/*     pingrp,               mux,        pull,   tri,      e_input, od,      e_io_hv */
	PINCFG(PEX_L0_RST_N_PA0,     PE0,        NORMAL, NORMAL,   OUTPUT,  DISABLE, HIGH),
	PINCFG(PEX_L0_CLKREQ_N_PA1,  PE0,        NORMAL, NORMAL,   INPUT,   DISABLE, HIGH),
	PINCFG(PEX_WAKE_N_PA2,       PE,         NORMAL, NORMAL,   INPUT,   DISABLE, HIGH),
	PINCFG(PEX_L1_RST_N_PA3,     PE1,        NORMAL, NORMAL,   OUTPUT,  DISABLE, HIGH),
	PINCFG(PEX_L1_CLKREQ_N_PA4,  PE1,        NORMAL, NORMAL,   INPUT,   DISABLE, HIGH),
	PINCFG(SATA_LED_ACTIVE_PA5,  DEFAULT,    UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(PA6,                  SATA,       NORMAL, NORMAL,   OUTPUT,  DISABLE, DEFAULT),
	PINCFG(DAP1_FS_PB0,          DEFAULT,    DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(DAP1_DIN_PB1,         DEFAULT,    DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(DAP1_DOUT_PB2,        DEFAULT,    DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(DAP1_SCLK_PB3,        DEFAULT,    DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI2_MOSI_PB4,        SPI2,       DOWN,   NORMAL,   OUTPUT,  DISABLE, DEFAULT),
	PINCFG(SPI2_MISO_PB5,        SPI2,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI2_SCK_PB6,         SPI2,       DOWN,   NORMAL,   OUTPUT,  DISABLE, DEFAULT),
	PINCFG(SPI2_CS0_PB7,         SPI2,       UP,     NORMAL,   OUTPUT,  DISABLE, DEFAULT),
	PINCFG(SPI2_CS1_PDD0,        SPI2,       UP,     NORMAL,   OUTPUT,  DISABLE, DEFAULT),
	PINCFG(SPI1_MOSI_PC0,        SPI1,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI1_MISO_PC1,        SPI1,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI1_SCK_PC2,         SPI1,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI1_CS0_PC3,         SPI1,       UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI1_CS1_PC4,         SPI1,       UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI4_SCK_PC5,         SPI4,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI4_CS0_PC6,         SPI4,       UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI4_MOSI_PC7,        SPI4,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI4_MISO_PD0,        SPI4,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(UART3_TX_PD1,         UARTC,      NORMAL, NORMAL,   OUTPUT,  DISABLE, DEFAULT),
	PINCFG(UART3_RX_PD2,         UARTC,      UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(UART3_RTS_PD3,        UARTC,      NORMAL, NORMAL,   OUTPUT,  DISABLE, DEFAULT),
	PINCFG(UART3_CTS_PD4,        UARTC,      UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(DMIC1_CLK_PE0,        I2S3,       NORMAL, NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(DMIC1_DAT_PE1,        I2S3,       NORMAL, NORMAL,   INPUT,   DISABLE, DEFAULT),
        ...
};

I am using SPI2. After running the driver, the SPI will not work. Is the pin multiplexing configuration correct? If not, how to configure it? thank you!

Could you try SPI1 first?

PINCFG(SPI1_MOSI_PC0,        SPI1,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI1_MISO_PC1,        SPI1,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI1_SCK_PC2,         SPI1,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI1_CS0_PC3,         SPI1,       UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),

Hello,
I am a bit uncertain about the address mapping relationship of SPI. The pin in “Jetson_TX1_Generic_Customer_Pinmux_Customer_Release.xlsm” is defined as follows:

Jetson TX1 Pin Name	Jetson TX1 Pin #	Ball Name	Unused	GPIO	SFIO0

SPI
						
SPI0_MOSI	F4	SPI4_MOSI	unused_SPI4_MOSI		SPI4A_DOUT	
SPI0_MISO	E4	SPI4_MISO	unused_SPI4_MISO		SPI4A_DIN	
SPI0_CLK	E3	SPI4_SCK	unused_SPI4_SCK		        SPI4A_SCK	
SPI0_CS0#	F3	SPI4_CS0	unused_SPI4_CS0		        SPI4A_CS0	
SPI1_MOSI	F13	SPI1_MOSI	unused_SPI1_MOSI   GPIO3_PC.00	SPI1A_DOUT	
SPI1_MISO	F14	SPI1_MISO	unused_SPI1_MISO   GPIO3_PC.01	SPI1A_DIN	
SPI1_CLK	G13	SPI1_SCK	unused_SPI1_SCK	   GPIO3_PC.02	SPI1A_SCK	
SPI1_CS0#	E14	SPI1_CS0	unused_SPI1_CS0	   GPIO3_PC.03	SPI1A_CS0	
SPI1_CS1#	E13	SPI1_CS1	unused_SPI1_CS1	   GPIO3_PC.04	SPI1A_CS1	
SPI2_MOSI	G15	SPI2_MOSI	unused_SPI2_MOSI		SPI2A_DOUT	
SPI2_MISO	H15	SPI2_MISO	unused_SPI2_MISO		SPI2A_DIN	
SPI2_CLK	H14	SPI2_SCK	unused_SPI2_SCK		        SPI2A_SCK	
SPI2_CS0#	G16	SPI2_CS0	unused_SPI2_CS0		        SPI2A_CS0	
SPI2_CS1#	F16	SPI2_CS1	unused_SPI2_CS1		        SPI2A_CS1

The address mapping relationship on page 21 in “Tegra_X1_TRM_DP07225001_v1.2p.pdf” is as follows:

SPI 2B-1    7000:d400     7000:d5ff    0000:d400    0000:d5ff    512 B
SPI 2B-2    7000:d600     7000:d7ff    0000:d600    0000:d7ff    512 B
SPI 2B-3    7000:d800     7000:d9ff    0000:d800    0000:d9ff    512 B
SPI 2B-4    7000:da00     7000:dbff    0000:da00    0000:dbff    512 B

I think SPI1’s address mapping is 0x7000d400, SPI2 address mapping is 0x7000d600, SPI4 address mapping is 0x7000da00, is this correct?
According to the above address mapping, SPI1 and SPI4 can work, but SPI2 can not work, SPI2 chip select is valid, how can we make SPI2 work? The following is the pin multiplexing of SPI2,thank you!

p2371_2180_pingrps[] = {
        ...
	PINCFG(SPI2_MOSI_PB4,        SPI2,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI2_MISO_PB5,        SPI2,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI2_SCK_PB6,         SPI2,       DOWN,   NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI2_CS0_PB7,         SPI2,       UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
	PINCFG(SPI2_CS1_PDD0,        SPI2,       UP,     NORMAL,   INPUT,   DISABLE, DEFAULT),
        ...
};

Hi:
After running the driver for different SPIs, I can measure the SCLK signals of SPI1 (0x7000d400) and SPI4 (0x7000da00), but I can’t measure the SCLK signal of SPI2 (0x7000d600). I compared the dts and Pinmux Registers, I found no difference. What else needs to be done to get SPI2 working properly? Thank you!