Hi

I've been wanting to write an SPI skeleton driver to learn the basics. I'm 
hoping a driver guru could offer some guidance. 

The idea is to write a skeleton driver that simply prints the chip id

Kernel: stock standard mainline 3.16.0-rc7 kernel on Olimex A20-SOM (EVK)
Device: MPU9250 Break out board

My thinking so far:

1. DTS
Add an SPI slave device to my DTS file.

I will connect the Break out board to the second SPI bus .... so need to 
add the slave device to SPI1

Existing SPI1 device (from dts file)

        spi1: spi@01c06000 {
            pinctrl-names = "default";
            pinctrl-0 = <&spi1_pins_a>;
            status = "okay";
        };


Adding SPI1 slave device:

        spi1: spi@01c06000 {
            pinctrl-names = "default";
            pinctrl-0 = <&spi1_pins_a>;
            status = "okay";
 
                        mpu9250@0 {
                                 compatible = "mpu9250";
                                 reg = <0>;
                                 spi-max-frequency = <1000000>;
                                 ???? interrupt pin .... gpio ???????
                         };

        };
2. The driver will create an entry in "sysfs" and a "corresponding" entry 
in /dev. Catting the device " /dev/mpu9250 " will return the device id.

Then the driver will be a standard Linux kernel module with support for SPI
....
#include <linux/module.h> 
#include <linux/spi/spi.h>
....

struct spi_driver
spi_register_driver  (struct device dev;   dictates the name of the device)
spi_alloc_device
spi_add_device



Am I on the right track? Any similar simple examples floating about?


Thanks
Bruce



















-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to