LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   SPI interface in mpc83xx (http://www.linuxquestions.org/questions/linux-kernel-70/spi-interface-in-mpc83xx-4175438895/)

NishaK 11-27-2012 05:52 AM

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

Mara 12-01-2012 03:21 PM

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.

NishaK 12-06-2012 06:38 AM

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

Mara 12-06-2012 02:20 PM

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.

iMonk 12-07-2012 05:17 AM

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?

NishaK 02-28-2013 05:49 AM

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>;
};
};


All times are GMT -5. The time now is 12:04 AM.