at91sam9x35 spidev error

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

nmmane
Posts: 10
Joined: Mon Aug 14, 2017 9:36 am

at91sam9x35 spidev error

Mon Aug 14, 2017 11:46 am

Dear all,

I have at91sam9x35 based custom board and want to use spi (spidev) from user space. For the same i have edited at91sam9x35.dtsi as follows .


at91sam9x35.dtsi

Code: Select all

spi0: spi@f0000000 {
				#address-cells = <1>;
				#size-cells = <0>;
				compatible = "atmel,at91sam9x5-spi";
				reg = <0xf0000000 0x100>;
				interrupts = <13 4 3>;
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_spi0>;
				dma-mask = <0xffffffff>;
				dma = <&dma0 0x10002212>;
				status = "okay";				
				//also checked with spi-num-chipselects = <1>
				cs-gpios = <&pioA 14 0>;
				spidev@0 {
				compatible = "linux,spidev";
				spi-max-frequency = <10000000>;
				reg = <0>;
				}; 
				
			};

spi0 {
					pinctrl_spi0: spi0-0 {
						atmel,pins =
							<0 11 0x1 0x0	/* PA11 periph A SPI0_MISO */
							 0 12 0x1 0x0	/* PA12 periph A SPI0_MOSI */
							 0 13 0x1 0x0	/* PA13 periph A SPI0_SPCK */
							 0 14 0x1 0x0>;	/* PA14 periph A SPI0_NPCS0 */
					};
				};

But at the time of booting device cant get registered successfully.
it shows following error.

atmel_spi f0000000.spi: Using dma0chan1 (tx) and dma0chan2 (rx) for DMA transfers
atmel_spi f0000000.spi: Atmel SPI Controller at 0xf0000000 (irq 17)
atmel_spi f0000000.spi: master is unqueued, this is deprecated
atmel_spi f0000000.spi: chipselect 0 already in use
spi_master spi32766: spi_device register error /ahb/apb/spi@f0000000/m25p80@0

Still the devise listed under /dev but no any output signal on spi port when i write to .

Code: Select all

# ls /dev/spidev*
/dev/spidev32766.0

I have 3.6.9 kernel. as i am new to device tree concept, i am unable to understand where did i wrong?
blue_z
Location: USA
Posts: 1550
Joined: Thu Apr 19, 2007 10:15 pm

Re: at91sam9x35 spidev error

Tue Aug 15, 2017 10:58 pm

nmmane wrote:For the same i have edited at91sam9x35.dtsi as follows .
Either that's a big edit to at91sam9x35.dtsi, or you actually edited at91sam9x5.dtsi and are misreporting what you did.

Obviously you cannot modify the SoC itself, and yet you are modifying the Device Tree files that describe that SoC.
Instead your edits should be applied to your board-level DT file(s), and the SoC-level files should be left as generic descriptions.
nmmane wrote:But at the time of booting device cant get registered successfully.
...
Still the devise listed under /dev but no any output signal on spi port when i write to .
You seem to be referring to a single "device", when in fact there are several SPI devices.
Study the Linux kernel documentation for SPI, especially the spi-summary,

The salient log messages are:
atmel_spi f0000000.spi: chipselect 0 already in use
spi_master spi32766: spi_device register error /ahb/apb/spi@f0000000/m25p80@0
Even though you write that you have a "custom" board, you seem to be (blindly) reusing Device Tree definitions for the AT91SAM9X35-EK board.
You have two SPI slave devices configured to the first CS of the SPI master.

Regards
nmmane
Posts: 10
Joined: Mon Aug 14, 2017 9:36 am

Re: at91sam9x35 spidev error

Wed Aug 16, 2017 8:49 am

Either that's a big edit to at91sam9x35.dtsi, or you actually edited at91sam9x5.dtsi and are misreporting what you did.
sorry, i have put wrong file name before data it was at91sam9x5.dtsi


now I have put the spidev tag in core9x35ek.dts file and it removes chip select error.

Code: Select all

spi0: spi@f0000000 {
				status = "okay";				
				cs-gpios = <&pioA 14 0>;
				spidev@0 {							
				compatible = "linux,spidev";				
				spi-max-frequency = <10000000>;
				reg = <0>;
				};
			};
now output is

Code: Select all

atmel_spi f0000000.spi: Using dma0chan1 (tx) and  dma0chan2 (rx) for DMA transfers
atmel_spi f0000000.spi: Atmel SPI Controller at 0xf0000000 (irq 17)
atmel_spi f0000000.spi: master is unqueued, this is deprecated
m25p80 spi32766.0: unrecognized JEDEC id ffffff
reusing Device Tree definitions for the AT91SAM9X35-EK board.
my core board is CORE9x53 and base board is custom board.

Code: Select all

m25p80 spi32766.0: unrecognized JEDEC id ffffff
what dose it means?
blue_z
Location: USA
Posts: 1550
Joined: Thu Apr 19, 2007 10:15 pm

Re: at91sam9x35 spidev error

Fri Aug 18, 2017 1:40 am

nmmane wrote:

Code: Select all

m25p80 spi32766.0: unrecognized JEDEC id ffffff
what dose it means?
Apparently you still have a leftover definition from the AT91SAM9X35-EK board.
"m25p80" is the label for the SPI serial flash chip on some SAM9x5 SoMs (aka "computer module" or CM).
The Corewind SoM that you're using does not have any SPI serial flash.
So you have not properly gone through the Device Tree files that you copied and are now using, and verified that the active devices actually exist.

Regards
nmmane
Posts: 10
Joined: Mon Aug 14, 2017 9:36 am

Re: at91sam9x35 spidev error

Wed Aug 23, 2017 6:51 am

I did not found any m25p80 device added in dt files. Is there any other way to find .
blue_z
Location: USA
Posts: 1550
Joined: Thu Apr 19, 2007 10:15 pm

Re: at91sam9x35 spidev error

Thu Aug 24, 2017 9:02 pm

nmmane wrote:I did not found any m25p80 device added in dt files. Is there any other way to find .
What did you look for, and where did you look?

Code: Select all

$ find arch/arm/boot/dts -name "at91*" | xargs grep m25p80
arch/arm/boot/dts/at91sam9n12ek.dts:				m25p80@0 {
arch/arm/boot/dts/at91sam9x5cm.dtsi:				m25p80@0 {
$
nmmane
Posts: 10
Joined: Mon Aug 14, 2017 9:36 am

Re: at91sam9x35 spidev error

Sat Aug 26, 2017 12:31 pm

Thank You So much :D

I have't seen in 'at91sam9x5cm.dtsi' , as i searched manually. Now i removed this section and now my spidev32766.0 mounded successfully.

do you know any detailed document to study device tree structure and working for beginners.

But still i cant get output signals on CLK/CS/MOSI :( .
Any idea about how to trace why there is no signal on output lines.

Code: Select all

spi0: spi@f0000000 {
				#address-cells = <1>;
				#size-cells = <0>;
				compatible = "atmel,at91sam9x5-spi";
				reg = <0xf0000000 0x100>;
				interrupts = <13 4 3>;
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_spi0>;
				dma-mask = <0xffffffff>;
				dma = <&dma0 0x10002212>;
				status = "disabled";
			};

Code: Select all

spi0 {
					pinctrl_spi0: spi0-0 {
						atmel,pins =
							<0 11 0x1 0x0	/* PA11 periph A SPI0_MISO */
							 0 12 0x1 0x0	/* PA12 periph A SPI0_MOSI */
							 0 13 0x1 0x0	/* PA13 periph A SPI0_SPCK */
							 0 14 0x1 0x0>;	/* PA14 periph A SPI0_NPCS0 */
					};
				};

Code: Select all

spi0: spi@f0000000 {
				cs-gpios = <&pioA 14 0>;
				spidev@0 {							
				compatible = "linux,spidev";				
				spi-max-frequency = <10000000>;
				reg = <0>;
				};				
			};

Code: Select all

spi0: spi@f0000000 {
				status = "okay";
			};
blue_z
Location: USA
Posts: 1550
Joined: Thu Apr 19, 2007 10:15 pm

Re: at91sam9x35 spidev error

Tue Aug 29, 2017 12:29 am

nmmane wrote:I have't seen in 'at91sam9x5cm.dtsi' , as i searched manually. Now i removed this section and now my spidev32766.0 mounded successfully.
A "manual search" should have involved every #include file.
A filesystem is mounted. Device nodes are created. spidev32766.0 is not a filesystem, but a device node.
nmmane wrote:do you know any detailed document to study device tree structure and working for beginners.
https://events.linuxfoundation.org/site ... ummies.pdf
nmmane wrote:But still i cant get output signals on CLK/CS/MOSI :( .
Any idea about how to trace why there is no signal on output lines.
Don't use Linux (especially with an unproven configuration) to debug your hardware.
Use a baremetal program (e.g. Atmel Software Package) or/and U-Boot to debug hardware.

Regards
nmmane
Posts: 10
Joined: Mon Aug 14, 2017 9:36 am

Re: at91sam9x35 spidev error

Thu Sep 07, 2017 1:23 pm

After Debugging spi driver i found in spi-atmel.c

Code: Select all

if (xfer->speed_hz)
          return -ENOPROTOOPT;
causing spi transfer error
so i replace this line with

Code: Select all

if (xfer->speed_hz < spi->max_speed_hz)
return -ENOPROTOOPT; 
So Cant allowed to lower tarnsfer speed than max speed.

now i got everything fine , i have tested upto 133MHz spi clk.

Thanks for Help :D .

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 0 guests