jetson tk1 spi flash

I have cross compiled and tested spidev_test application from linux kernel.
Output is always 00 00 00.
Has anyone faced similar issue?
How to resolve it?

shell@jetson:/ # /data/spidev_test
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00
shell@jetson:/ #

Ideally output should be:
FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D

Hi,
Did you check the activity (scope) on the SPI bus ?
You can also try to use sspi command from u-boot ?
Below a link about spi & tegra:
http://neurorobotictech.com/Community/Blog/tabid/184/ID/11/Using-the-Jetson-TK1-SPI--Part-1-Why-is-SPI-important.aspx
BR,
Greg

If you know your SPI flash device part number, you can just add it into
Linux/drivers/mtd/devices/m25p80.c

Enable Memroy Technology Devices (MTD) in the config and rebuild the kernel.

Add the device definition to the device tree

The memory device should just appear in /dev/spidev

Hi GE_Chen,
I have updated device tree as follows:
spi@7000da00 {
status = “okay”;
spi-max-frequency = <25000000>;
spi-flash@0 {
compatible = “m25p80”;
reg = <0>;
spi-max-frequency = <20000000>;
};
};

Also enabled MTD.
So now I can get logs about m25p80.

<7>[ 5.423903] spi-tegra114 spi-tegra114.3: registered master spi3
<7>[ 5.424355] spi spi3.0: setup 8 bpw, ~cpol, ~cpha, 20000000Hz
<7>[ 5.424368] spi spi3.0: child node ‘controller-data’ not found
<7>[ 5.424425] spi spi3.0: setup mode 0, 8 bits/w, 20000000 Hz max → 0
<7>[ 5.424640] spi-tegra114 spi-tegra114.3: The def 0x40408000 and written 0x40608827
<7>[ 5.424699] spi-tegra114 spi-tegra114.3: The def 0x40408000 and written 0x40609027
<4>[ 5.424791] m25p80 spi3.0: found w25q32dw, expected m25p80
<6>[ 5.430305] m25p80 spi3.0: w25q32dw (4096 Kbytes)
<7>[ 5.435577] spi-tegra114 spi-tegra114.3: registered child spi3.0

  1. Do you think “spi spi3.0: child node ‘controller-data’ not found” is to be worried about?
  2. I don’t get /dev/spi3.0 entry in file system.

You are in luck, a colleague has asked me to get the SPI Flash device working again.

We are using a spansion S25FL132K device.

In the DeviceTree source I have :

spi4: spi@7000dc00 {
		compatible = "nvidia,tegra114-spi";
		reg = <0x0 0x7000dc00 0x0 0x200>;
		interrupts = <0x0 0x5e 0x4>;
		nvidia,dma-request-selector = <0x7 0x1b>;
		nvidia,memory-clients = <0xe>;
		#address-cells = <0x1>;
		#size-cells = <0x0>;
		clocks = <0xc 0x68>;
		status = "okay";
		dmas = <0x7 0x1b 0x7 0x1b>;
		dma-names = "rx", "tx";

		eeprom@0 {
			compatible = "a25fl132k";
			spi-max-frequency = <100000000>;
			reg = <0>;
			addr-size = <2>;
			page-size = <256>;
			eeprom-size = <1024>;
			eeprom-name = "johnsat25";
		};
	};

Strickly speaking, the description is wrong - it is not an EEPROM but all that is important is the device id.

The deivce id must be added to a driver. The driver is
kernel/drivers/mtd/devices/m25p80.c

Find the table of devices :

static const struct spi_device_id m25p_ids[] = {

For device S25FL132K add :

//      INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)    
         { "a25fl132k",  INFO(0x014016,      0,  16 *  256, 1024, 0) },

Finally, in the default config file, add :

CONFIG_SPI=y
CONFIG_SPI_TEGRA114=y
CONFIG_SPI_MASTER=y
CONFIG_SPI_SPIDEV=y
CONFIG_MTD_M25P80=y
CONFIG_MTD=y
CONFIG_MTD_JEDECPROBE=m
CONFIG_MTD_GEN_PROBE=m
CONFIG_MTD_PHYSMAP=m
CONFIG_MTD_CHAR=y
CONFIG_MTD_BLOCK=y

Compile, download and boot up the Jetson.
The SPI flash should appear as
/dev/mtd0
It is a char device.

You have not actually said what SPI device you are trying to interface to?
SPI is just a low level protocol to talk to devices - you need to know what you are talking to.
The device may have a protocol on top of the SPI.

I am reading/writing the SPI boot rom (winbond w25q32dw) on the jetson TK1 board. As per schematic it is connected to SPI4. This is present in the kernel:

{ "w25q32dw", INFO(0xef6016, 0, 64 * 1024,  64, SECT_4K) }

I hope boot ROM is accessible normally :)

I have same config as you mentioned except following are not set.

CONFIG_MTD_JEDECPROBE=m
CONFIG_MTD_GEN_PROBE=m
CONFIG_MTD_PHYSMAP=m
CONFIG_MTD_CHAR=y
CONFIG_MTD_BLOCK=y

One more thing, if I use following dts then I get /dev/spi3.0

spi@7000da00 {
		status = "okay";
		spi-max-frequency = <25000000>;
		spi@0 {
				compatible = "spidev";
				reg = <0>;
				spi-max-frequency = <25000000>;
		};
};