Sama5d33-ek SPI0 problem

Discussion around products based on ARM Cortex-A5 core.

Moderator: nferre

ekarlsson
Posts: 3
Joined: Wed Apr 02, 2014 4:31 pm

Sama5d33-ek SPI0 problem

Wed Apr 02, 2014 4:45 pm

Hello! I'm using the sama5d-ek and trying to use the SPI0 peripheral. The chip select SPI0_NPCS0 is always low (active), and I have tried to the other chip select but nothing happens. If I use SPI1, then something happens. The datasheet says something about the SPI0 is used in the boot sequence (flash boot). My feeling is that something is occupying the SPI0, because  SPI0_NPCS0 is always low (active). The processor is running linux (yocto and poky). The user space program is using the SPIDEV driver.
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: Sama5d33-ek SPI0 problem

Thu Apr 03, 2014 8:43 am

ekarlsson wrote:The datasheet says something about the SPI0 is used in the boot sequence (flash boot).
That something is the RomBOOT sequence of scanning for a boot program.
The Atmel EK boards typically install a DataFlash or serial Flash chip at SPI0_NPCS0 to illustrate this capability.
ekarlsson wrote: I have tried to the other chip select but nothing happens.
What do you you mean by "tried"?
What version of the Linux kernel?
Have you performed any Device Tree changes before you "tried" to use SPI0?


Regards
ekarlsson
Posts: 3
Joined: Wed Apr 02, 2014 4:31 pm

Re: Sama5d33-ek SPI0 problem

Thu Apr 03, 2014 11:40 am

Thank you for helping.
I'm using a user space program and spidev to use the spi unit and I'm measuring on the pins (SPI0 not connected to anything) with my oscilloscope. Nothing is happening on the pins. If I change to SPI1 that is connected to the screen, I can measure for example the clock pin is doing something.
The linux version is based on the linux4sam linux-3.10-at91 branch. With the stable tree for 3.10.30 updates included and some small custom changes to the display driver.

The device tree looks like this:

Code: Select all

/*
 * sama5d33ek.dts - Device Tree file for SAMA5D33-EK board
 *
 *  Copyright (C) 2013 Atmel,
 *                2013 Ludovic Desroches <ludovic.desroches@atmel.com>
 *
 * Licensed under GPLv2 or later.
 */
/dts-v1/;
#include "sama5d3xcm.dtsi"

/ {
	model = "test1";
	compatible = "test,scone", "atmel,sama5d33ek", "atmel,sama5d3xmb", "atmel,sama5d3xcm", "atmel,sama5d3", "atmel,sama5";

	ahb {
		apb {
			spi0: spi@f0004000 {
				status = "okay";
				cs-gpios = <&pioD 13 0>, <&pioD 14 0>, <&pioD 15 0>, <&pioD 16 0>;
				fimu0: fimu@0 {
					reg = <3>;
					spi-max-frequency = <1000000>;
					compatible = "test,sc1-fimu";
				};
			};
			spi1: spi@f8008000 {
				status = "okay";
				cs-gpios = <0>, <0>, <0>, <&pioC 28 0>;
				backlight0: backlight@3 {
					reg = <3>;
					spi-max-frequency = <2000000>;
					compatible = "samsung,ams369fg06";
				};
			};

			lcd_bus@f0030000 {
				status = "okay";
				lcd@f0030000 {
					status = "okay";
				};
				lcdovl1@f0030140 {
					status = "okay";
				};
				lcdovl2@f0030240 {
					status = "okay";
				};
				lcdheo1@f0030340 {
					status = "okay";
				};
			};
			ssc0: ssc@f0008000 {
				status = "okay";
			};

			i2c0: i2c@f0014000 {
				status = "okay";
			};
			i2c1: i2c@f0018000 {
				status = "okay";
			};
			macb0: ethernet@f0028000 {
				status = "okay";
			};
			dbgu: serial@ffffee00 {
				status = "okay";
			};
			watchdog@fffffe40 {
				status = "okay";
			};
			pinctrl@fffff200 {
				arrowkeys {
					pinctrl_arrowkeys: arrowkeys-0 {
						atmel,pins = <AT91_PIOA 16 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_DOWN
							      AT91_PIOA 17 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_DOWN
							      AT91_PIOA 18 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_DOWN
							      AT91_PIOA 19 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_DOWN>;
					};
				};
				board {
					pinctrl_usba_vbus: usba_vbus {
						atmel,pins =
							<AT91_PIOD 29 AT91_PERIPH_GPIO AT91_PINCTRL_DEGLITCH>; /* PD29 GPIO with deglitch */
					};
				};
			};
		};
		usb0: gadget@00500000 {
			atmel,vbus-gpio = <&pioD 29 GPIO_ACTIVE_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_usba_vbus>;
			status = "okay";
		};
		usb1: ohci@00600000 {
			num-ports = <3>;
			atmel,vbus-gpio = <&pioD 25 GPIO_ACTIVE_HIGH
					   &pioD 26 GPIO_ACTIVE_LOW
					   &pioD 27 GPIO_ACTIVE_LOW
					  >;
			status = "okay";
		};
		usb2: ehci@00700000 {
			status = "okay";
		};
	};
	arrowkeys {
		compatible = "gpio-keys";
		#address-cells = <1>;
		#size-cells = <0>;
		autorepeat;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_arrowkeys>;

		button@21 {
			label = "GPIO Key LEFT";
			linux,code = <105>;
			gpios = <&pioA 16 GPIO_ACTIVE_HIGH>;
		};
		button@22 {
			label = "GPIO Key DOWN";
			linux,code = <108>;
			gpios = <&pioA 17 GPIO_ACTIVE_HIGH>;
		};
		button@23 {
			label = "GPIO Key UP";
			linux,code = <103>;
			gpios = <&pioA 18 GPIO_ACTIVE_HIGH>;
		};
		button@24 {
			label = "GPIO Key RIGHT";
			linux,code = <106>;
			gpios = <&pioA 19 GPIO_ACTIVE_HIGH>;
		};
	};
	leds {
		d3 {
			label = "d3";
			gpios = <&pioE 24 GPIO_ACTIVE_HIGH>;
		};
	};




	sound {
		status = "okay";
	};
};

/* Uncomment following line will enable ISI support */
/* /include/ "sama5d3xmb_isi.dtsi" */
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: Sama5d33-ek SPI0 problem

Fri Apr 04, 2014 5:01 am

ekarlsson wrote:I'm using a user space program and spidev to use the spi unit
Okay, but then your code has:
ekarlsson wrote:

Code: Select all

				fimu0: fimu@0 {
					reg = <3>;
					spi-max-frequency = <1000000>;
					compatible = "test,sc1-fimu";
				};
			};
What driver has an id of sc1-fimu, and what does it do?

If you're using spidev.c as the SPI protocol driver, then this compatible name needs to match the id that is in the device driver, namely:

Code: Select all

static const struct of_device_id spidev_dt_ids[] = {
        { .compatible = "rohm,dh2228fv" },
        {},
};
Regards
ekarlsson
Posts: 3
Joined: Wed Apr 02, 2014 4:31 pm

Re: Sama5d33-ek SPI0 problem

Fri Apr 04, 2014 2:35 pm

Ok the problem is solved. Turns out that on the sama5d3x-ek board, the SPI0 pins are not connected to the PIO headers by default and I was measuring on the PIO header pins. R6,R51,R50,R120 are 'DEFAULT NO POPULATED'. Thank you blue_z for helping!

Return to “SAMA5D Cortex-A5 MPU”

Who is online

Users browsing this forum: No registered users and 1 guest