LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-27-2012, 05:52 AM   #1
NishaK
LQ Newbie
 
Registered: Feb 2012
Location: Chennai
Distribution: Fedora
Posts: 7

Rep: Reputation: Disabled
SPI interface in mpc83xx


Hi everyone,

I have to write an application in linux-3.0.36 for ADC/DAC that has connected using SPI interface. Processor im using is mpc8379 and chip select signal to SPI has given using processor gpio. Problem is i dont know where to start.

I know the register details of spi. In kernel im not getting the code flow and how gpio interacts with with the spi driver code.

Finally i just want to know the SPI implementation flow in kernel code and User Space Support for SPI.

Thanks in advance.

-Nisha K

Last edited by NishaK; 11-27-2012 at 07:00 AM.
 
Old 12-01-2012, 03:21 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Can you try spidev: http://www.kernel.org/doc/Documentation/spi/spidev ?

It is from user space, so should be easier to use than the direct accesses to the driver.
 
Old 12-06-2012, 06:38 AM   #3
NishaK
LQ Newbie
 
Registered: Feb 2012
Location: Chennai
Distribution: Fedora
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks mara. Ive already read that document.

After analyzing the code, Now i have some knowledge about SPI interface in Kernel. Now my problem is adding a slave device in kernel.

It has given in documentation spi-summary to register the slave device using spi_register_board_info. Is there any other way add? like device-tree.

And GPIO in processor has control of chip-select to the slave device. How to implement this?
Once again my processor is powerpc with 83xx platform

Thanks in advance
-Nisha K
 
Old 12-06-2012, 02:20 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
The device tree allows you to find out where your device is connected and how it is configured. However, you need to tell your driver to get that, and not the other device. You should be able to get all the ifnormation from the device tree, if you have it for your board.
 
Old 12-07-2012, 05:17 AM   #5
iMonk
LQ Newbie
 
Registered: Nov 2011
Location: Bangalore
Distribution: CentOS 6
Posts: 2

Rep: Reputation: Disabled
Post

1. There is a way to add it in device tree file. You can refer to arch/PowerPC/boot/dts/mpc8313erdb.dts
spi@7000{
cell-index = <0>;
compatible = "fsl,spi";
reg = <0x7000 0x1000>;
interrupts = <16 0x8>;
interrupt-parent = <&ipic>;
mode = "cpu";
};

2. For mpc8xxx series, you need to configure one of the GPIO as SPICS signal. You can refer to the datasheet of the spi slave. Here you can get whether the
Chip Select signal is active high or active low. Based on this, you can set gpio line as 1/0 before doing any SPI transfer.


What kind of spi slave are you using?
 
1 members found this post helpful.
Old 02-28-2013, 05:49 AM   #6
NishaK
LQ Newbie
 
Registered: Feb 2012
Location: Chennai
Distribution: Fedora
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thumbs up Solved

Thanks iMonk.

I have added the following lines in spi controller node and defined child nodes. It worked.

spi@7000 {
#address-cells = <1>;
#size-cells = <0>;
cell-index = <0>;
compatible = "fsl,spi";
reg = <0x7000 0x1000>;
interrupts = <16 0x8>;
interrupt-parent = <&ipic>;
mode = "cpu";
gpios = <&gpio1 4 0
&gpio1 5 0>;

dev1@0 {
compatible = "spidev";
reg = <0>;
spi-max-frequency = <10000000>;
};
dev2@1 {
compatible = "spidev";
reg = <1>;
spi-max-frequency = <10000000>;
};
};
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to interface ade7758 to at91sam9261 using spi raulapati Linux - Embedded & Single-board computer 6 10-26-2010 01:17 AM
how to interface ade7758 to at91sam9261 by SPI protocol raulapati Linux - Hardware 1 10-11-2010 07:45 AM
SPI interface with AT91SAM9261 sunr2007 Linux - Embedded & Single-board computer 0 08-03-2009 03:43 AM
ALPS touchpad with SPI interface can not work in relative mode!!! fromker Linux - Embedded & Single-board computer 0 02-24-2009 09:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration