A20: SPI Drivers

774 views
Skip to first unread message

bruce bushby

unread,
Jul 1, 2014, 5:47:39 PM7/1/14
to linux...@googlegroups.com
Hi

I wanted to ask if anybody has tried to build spi-sun7.c for mainline kernels?

I followed this excellent guide:


...but the compile fails with

drivers/spi/spi-sun7i.c:30:22: fatal error: mach/dma.h: No such file or directory
 #include <mach/dma.h>
                      ^
compilation terminated.
make[3]: *** [drivers/spi/spi-sun7i.o] Error 1
make[3]: *** Waiting for unfinished jobs....


I also noticed the Fedora 20 images doesn't support SPI for A20:
* SPI (as module, not supported on A20)


So now I'm a little worried as my entire project is built around 4 SPI devices on an A20-SOM :)

Any secret plans for full DMA + SPI in the works?


Bruce






Emilio López

unread,
Jul 1, 2014, 6:17:11 PM7/1/14
to linux...@googlegroups.com, bruce....@gmail.com
Hi there,

El 01/07/14 18:47, bruce bushby escribió:
> Hi
>
> I wanted to ask if anybody has tried to build spi-sun7.c for mainline
> kernels?
>
> I followed this excellent guide:
> http://will-tm.com/spi-on-the-cubieboard2/
>
>
> ...but the compile fails with
>
> drivers/spi/spi-sun7i.c:30:22: fatal error: mach/dma.h: No such file or
> directory
> #include <mach/dma.h>
> ^
> compilation terminated.
> make[3]: *** [drivers/spi/spi-sun7i.o] Error 1
> make[3]: *** Waiting for unfinished jobs....

SPI on mainline is already supported on A20 via the SPI_SUN4I kconfig
entry. It only supports PIO transfers for the moment.

> I also noticed the Fedora 20 images doesn't support SPI for A20:
> https://github.com/jwrdegoede/sunxi-fedora-scripts/blob/master/README
> * SPI (as module, not supported on A20)

This uses the linux-sunxi 3.4 kernel. I believe it has also recently
gained SPI support on A20.

> So now I'm a little worried as my entire project is built around 4 SPI
> devices on an A20-SOM :)
>
> Any secret plans for full DMA + SPI in the works?

As part of my work on DMA, I have worked on enabling DMA transfers on
SPI, so it should be supported on mainline in the nearby future. I'll be
sending a fresh second round of patches you can try really soon, so stay
tuned.

Cheers,

Emilio

sophi...@gmail.com

unread,
Jul 1, 2014, 10:52:12 PM7/1/14
to linux...@googlegroups.com
I can compile the driver successfully, May be you can cherry-pick this commit https://github.com/mmplayer/linux-sunxi/commit/82f7a2bda8a8adbbdca1850dfaf3df0f43ee2ee1

bruce bushby

unread,
Jul 4, 2014, 4:32:41 AM7/4/14
to linux...@googlegroups.com

What kernel version are you using? I created much the same (if not identicle) patches but I ran into:
drivers/spi/spi-sun7i.c:30:22: fatal error: mach/dma.h: No such file or directory

Any reason you're not using the sun4i spi drivers? 

I think I've made some progress, a "ps" listing shows:
   27 root     [spi0]
   28 root     [spi1]

and under "sys" I have:
# ls -l /sys/bus/platform/drivers/sun4i-spi
total 0
lrwxrwxrwx    1 root     root             0 Jan  8 05:15 1c06000.spi -> ../../../../devices/soc.3/1c06000.spi
lrwxrwxrwx    1 root     root             0 Jan  8 05:15 1c17000.spi -> ../../../../devices/soc.3/1c17000.spi



# cd 1c17000.spi
# ls -l
total 0
lrwxrwxrwx    1 root     root             0 Jan  8 05:15 driver -> ../../../bus/platform/drivers/sun4i-spi
-r--r--r--    1 root     root          4096 Jan  8 05:15 modalias
drwxr-xr-x    2 root     root             0 Jan  8 05:15 power
drwxr-xr-x    3 root     root             0 Jan  8 05:15 spi_master
lrwxrwxrwx    1 root     root             0 Jan  8 05:15 subsystem -> ../../../bus/platform
-rw-r--r--    1 root     root          4096 Jan  8 05:15 uevent
# find .
.
./power
./power/control
./power/runtime_active_time
./power/autosuspend_delay_ms
./power/runtime_status
./power/runtime_suspended_time
./spi_master
./spi_master/spi1
./spi_master/spi1/power
./spi_master/spi1/power/control
./spi_master/spi1/power/runtime_active_time
./spi_master/spi1/power/autosuspend_delay_ms
./spi_master/spi1/power/runtime_status
./spi_master/spi1/power/runtime_suspended_time
./spi_master/spi1/device
./spi_master/spi1/subsystem
./spi_master/spi1/uevent
./modalias
./driver
./subsystem
./uevent


However, I still don't have anything in "/dev/*spi*  :(

jons...@gmail.com

unread,
Jul 4, 2014, 8:52:27 AM7/4/14
to linux-sunxi
Isn't SPI already working in Emilio's kernel?



--
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 linux-sunxi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jon Smirl
jons...@gmail.com

bruce bushby

unread,
Jul 4, 2014, 9:07:08 AM7/4/14
to linux...@googlegroups.com

Jon... looks like you are correct. I've been somewhat blinded hacking away on stock mainline, will give Emilio's kernel a run this evening.

Thanks!


--
You received this message because you are subscribed to a topic in the Google Groups "linux-sunxi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/linux-sunxi/3Ybi8DQ37O0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to linux-sunxi...@googlegroups.com.

Maxime Ripard

unread,
Jul 4, 2014, 9:10:05 AM7/4/14
to linux...@googlegroups.com
On Fri, Jul 04, 2014 at 08:52:25AM -0400, jons...@gmail.com wrote:
> Isn't SPI already working in Emilio's kernel?

SPI is actually working on every kernel since 3.15 (without DMA
though).

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
signature.asc

bruce bushby

unread,
Jul 4, 2014, 9:27:33 AM7/4/14
to linux...@googlegroups.com

Maxime: Many gratitude's for all your A20 dts contributions. Hoping I could ask about the 4 SPI controllers (SPI0-SPI3) 

I was wanting to better understand how people put dts files together so started reading the A20 Users Manual looking for addresses that I recognize in the dts files.....when I noticed on page 241 (1.19.2 Port Configuration Table)  that the 4 pins for SPI3 (PA5 - PA8)  *can* also be used for GTXD.... (emac)

emac_pins_a: emac0@0 {
allwinner,pins = "PA0", "PA1", "PA2",
"PA3", "PA4", "PA5", "PA6",
"PA7", "PA8", "PA9", "PA10",
"PA11", "PA12", "PA13", "PA14",
"PA15", "PA16";
allwinner,function = "emac";
allwinner,drive = <0>;
allwinner,pull = <0>;
};


Does this mean that it's not possible to have SPI0-SPI3 + ethernet working at the same time?


Thanks
Bruce


jons...@gmail.com

unread,
Jul 4, 2014, 10:14:39 AM7/4/14
to linux-sunxi
On Fri, Jul 4, 2014 at 9:27 AM, bruce bushby <bruce....@gmail.com> wrote:
>
>
> Maxime: Many gratitude's for all your A20 dts contributions. Hoping I could ask about the 4 SPI controllers (SPI0-SPI3)
>
> I was wanting to better understand how people put dts files together so started reading the A20 Users Manual looking for addresses that I recognize in the dts files.....when I noticed on page 241 (1.19.2 Port Configuration Table) that the 4 pins for SPI3 (PA5 - PA8) *can* also be used for GTXD.... (emac)
>
> emac_pins_a: emac0@0 {
> allwinner,pins = "PA0", "PA1", "PA2",
> "PA3", "PA4", "PA5", "PA6",
> "PA7", "PA8", "PA9", "PA10",
> "PA11", "PA12", "PA13", "PA14",
> "PA15", "PA16";
> allwinner,function = "emac";
> allwinner,drive = <0>;
> allwinner,pull = <0>;
> };
>
>
> Does this mean that it's not possible to have SPI0-SPI3 + ethernet working at the same time?

This is pin control. Look at the section in the dtsi file for the CPU
and the pin control driver in the kernel.

In SOCs most pins can take on three or four different roles. You have
to choose which group of peripherals you want to use given the
constraints on what pins can be mapped.

In the kernel tree look at:
Documentation/pinctrl.txt
Documentation/devicetree/bindings/pinctrl




>
>
> Thanks
> Bruce
>
>
>
>
> On Fri, Jul 4, 2014 at 2:08 PM, Maxime Ripard <maxime...@free-electrons.com> wrote:
>>
>> On Fri, Jul 04, 2014 at 08:52:25AM -0400, jons...@gmail.com wrote:
>> > Isn't SPI already working in Emilio's kernel?
>>
>> SPI is actually working on every kernel since 3.15 (without DMA
>> though).
>>
>> --
>> Maxime Ripard, Free Electrons
>> Embedded Linux, Kernel and Android engineering
>> http://free-electrons.com
>
>

Maxime Ripard

unread,
Jul 4, 2014, 10:25:14 AM7/4/14
to linux...@googlegroups.com
On Fri, Jul 04, 2014 at 02:27:32PM +0100, bruce bushby wrote:
> Does this mean that it's not possible to have SPI0-SPI3 + ethernet
> working at the same time?

It is. The EMAC pins are also routed in the PH bank. So if your board
uses the relevant PA pins for the SPI controllers, and the PH pins for
the EMAC, it's fine.

If you're using the PA pins for the EMAC, you're screwed, at least for
SPI3.

Maxime
signature.asc

bruce bushby

unread,
Jul 4, 2014, 11:28:07 AM7/4/14
to linux...@googlegroups.com
 Got it, I wanted to make sure there wasn't some multiplexing voodoo which I had never heard about. I remember the Beaglebone had the omap pin mux ....so figured pin control was similar.

Fortunately I don't need ethernet, but looking at the Olimex A20-SOM I'm not sure all the SPI devices are available anyway.

Just purchased Device Tree for Dummies which should help things along.

Thanks for the help!

bruce bushby

unread,
Jul 4, 2014, 12:18:02 PM7/4/14
to linux...@googlegroups.com
*downloaded.....rather then purchased:

Maxime: Thanks for the link!

bruce bushby

unread,
Jul 5, 2014, 9:14:46 AM7/5/14
to linux...@googlegroups.com

update: I added spi0 to my dts file and everything appears to build and boot smoothly.....however I still don't see anything under "/dev/*spi*"  ......perhaps something simple as a missing udev rule or mknod script. I'm not sure who or what should create the "/dev/*spi*" device(s).

I've tried a couple of things now, thought I would post my results for any other newbies playing with the same board (Olimex_A20-SOM)
 

I use buildroot to build my images and I'm using "sunxi_defconfig" + SPI configs:

[bruce@core a20-som]$ pwd
/disk/software/drone/buildroot/board/olimex/a20-som
[bruce@core a20-som]$ grep SPI sunxi_defconfig
CONFIG_SPI=y
CONFIG_SPI_SUN4I=y
CONFIG_SPI_SUN6I=y
CONFIG_SPI_MASTER=y
CONFIG_SPI_SPIDEV=y
[bruce@core a20-som]$ 




My buildroot kernel config:

[bruce@core buildroot]$ pwd
/disk/software/drone/buildroot
[bruce@core buildroot]$ cat configs/olimex_a20-som_defconfig | grep KERNEL
BR2_LINUX_KERNEL_PATCH="board/olimex/a20-som/kernel-headers"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/torvalds/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="77c4cf17ae867ba93233b3832bda3de7adaae326"
BR2_LINUX_KERNEL_VERSION="master"
BR2_LINUX_KERNEL_PATCH="board/olimex/a20-som/kernel/"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/olimex/a20-som/sunxi_defconfig"
BR2_LINUX_KERNEL_UIMAGE_LOADADDR="0x40008000"
BR2_LINUX_KERNEL_APPENDED_UIMAGE=n
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_APPENDED_DTB=n
BR2_LINUX_KERNEL_USE_INTREE_DTS=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="sun7i-a20-som"
[bruce@core buildroot]$


The build runs through ok, I boot and can see the following spi kernel procs and devices:
# ps -ef | grep -i spi
   28 root     [spi0]
   29 root     [spi1]
   30 root     [spi2]
   91 root     grep -i spi



# find /sys -iname "*spi*"
/sys/bus/spi
/sys/bus/spi/drivers/spidev
/sys/bus/platform/devices/1c05000.spi
/sys/bus/platform/devices/1c06000.spi
/sys/bus/platform/devices/1c17000.spi
/sys/bus/platform/drivers/sun4i-spi
/sys/bus/platform/drivers/sun4i-spi/1c05000.spi
/sys/bus/platform/drivers/sun4i-spi/1c06000.spi
/sys/bus/platform/drivers/sun4i-spi/1c17000.spi
/sys/bus/platform/drivers/sun6i-spi
/sys/devices/soc@01c00000/1c05000.spi
/sys/devices/soc@01c00000/1c05000.spi/spi_master
/sys/devices/soc@01c00000/1c05000.spi/spi_master/spi0
/sys/devices/soc@01c00000/1c06000.spi
/sys/devices/soc@01c00000/1c06000.spi/spi_master
/sys/devices/soc@01c00000/1c06000.spi/spi_master/spi1
/sys/devices/soc@01c00000/1c17000.spi
/sys/devices/soc@01c00000/1c17000.spi/spi_master
/sys/devices/soc@01c00000/1c17000.spi/spi_master/spi2
/sys/class/spi_master
/sys/class/spi_master/spi0
/sys/class/spi_master/spi1
/sys/class/spi_master/spi2
/sys/class/spidev
/sys/firmware/devicetree/base/soc@01c00000/spi@01c05000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c06000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c17000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c1f000
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi0@0
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi1@0
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi2@0
/sys/firmware/devicetree/base/aliases/spi0
/sys/firmware/devicetree/base/aliases/spi1
/sys/firmware/devicetree/base/aliases/spi2
/sys/module/spidev





Then I changed my buildroot config file to test Emilio's kernel:

BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://bitbucket.org/emiliolopez/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="f97f72ee433f4b5c1ee1ba78abcec588cbe9565b"
BR2_LINUX_KERNEL_VERSION="sunxi-dma"


The build runs through and boots to login....this time I don't see any "spi" processes, but I do see spi messages in dmesg and I can see some spi stuff in "/proc/devices" and "/sys":
# ps -ef | grep -i spi
   81 root     grep -i spi
# dmesg | grep -i spi
[    0.820043] sun4i-spi 1c05000.spi: Unable to acquire DMA channel TX
[    0.826621] sun4i-spi 1c06000.spi: Unable to acquire DMA channel TX
[    0.833164] sun4i-spi 1c17000.spi: Unable to acquire DMA channel TX
# grep -i spi /proc/devices
153 spi
# find /sys -iname "*spi*"
/sys/bus/spi
/sys/bus/spi/drivers/spidev
/sys/bus/platform/devices/1c05000.spi
/sys/bus/platform/devices/1c06000.spi
/sys/bus/platform/devices/1c17000.spi
/sys/bus/platform/drivers/sun4i-spi
/sys/bus/platform/drivers/sun6i-spi
/sys/devices/soc@01c00000/1c05000.spi
/sys/devices/soc@01c00000/1c06000.spi
/sys/devices/soc@01c00000/1c17000.spi
/sys/class/spi_master
/sys/class/spidev
/sys/firmware/devicetree/base/soc@01c00000/spi@01c05000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c06000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c17000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c1f000
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi0@0
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi1@0
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi2@0
/sys/firmware/devicetree/base/aliases/spi0
/sys/firmware/devicetree/base/aliases/spi1
/sys/firmware/devicetree/base/aliases/spi2
/sys/module/spidev
#
# ls -l /dev/*spi*
ls: /dev/*spi*: No such file or directory


Perhaps I need to add "dma" attributes in my "sun7i-a20-som.dts" (sun7i-a20.dtsi  already has dma configured for spi devices) 

Perhaps everything is all working and I've been starring at it for so long I've forgotten some simple udev/mknod step?

As always....any tips or questions appreciated!

Thanks
Bruce












jons...@gmail.com

unread,
Jul 5, 2014, 10:01:18 AM7/5/14
to linux-sunxi
All of the sunxi 3.16 trees that I have tried are broken in various
ways. In general early -rc releases of kernels don't work very well.

I pushed my current 3.15 build here:
https://github.com/jonsmirl/lpc31xx/tree/jds-merge
copy /config to .config and build

It has the user space SPI driver enabled. This is using Emilio's DMA
driver for SPI.

root@linaro-developer:~# ls /dev/*spi*
/dev/spidev32766.2

I have no clue if it works, I am not using SPI in the audio code. But
it builds and the correct device appears.

Look in Documentation/spi for an example of how to use it.

Maxime Ripard

unread,
Jul 5, 2014, 4:00:05 PM7/5/14
to linux...@googlegroups.com
On Sat, Jul 05, 2014 at 02:14:44PM +0100, bruce bushby wrote:
> update: I added spi0 to my dts file and everything appears to build and
> boot smoothly.....however I still don't see anything under "/dev/*spi*"
> ......perhaps something simple as a missing udev rule or mknod script. I'm
> not sure who or what should create the "/dev/*spi*" device(s).

/dev/spi* is handled by a driver called spidev. If this driver is not
both loaded and probed, you'll never see a /dev/spi* file, even though
the controller driver is working fine.
signature.asc

Maxime Ripard

unread,
Jul 5, 2014, 4:05:05 PM7/5/14
to linux...@googlegroups.com
On Sat, Jul 05, 2014 at 10:01:16AM -0400, jons...@gmail.com wrote:
> All of the sunxi 3.16 trees that I have tried are broken in various
> ways.

Such as? It would be great if you wouldn't keep these breakages to
yourself and share them. That way, they'll get fixed (and it's
actually the only way!)
signature.asc

bruce bushby

unread,
Jul 5, 2014, 5:04:37 PM7/5/14
to linux...@googlegroups.com
Well Jon kindly pointed me to his repo which is confirmed to have spidev working on A20.  I used his repo and his .config file .....with the same results ...which I guess is a good thing as it means my previous attempts were probably all working and I just need to find what crucial step I am missing.

Here you can see both spi kernel processes running
# ps -ef | grep -i spi
   46 root     [spi0]
   47 root     [spi1]
  152 root     grep -i spi


I changed spidev to be a kernel module....and it loads without any problems
# lsmod
Module                  Size  Used by    Not tainted
spidev                  5471  0 



The /sys filesystem is aware of the spi devices: 
# find /sys -iname "*spi*"
/sys/bus/spi
/sys/bus/spi/drivers/spidev
/sys/bus/platform/devices/1c06000.spi
/sys/bus/platform/devices/1c17000.spi
/sys/bus/platform/drivers/sun4i-spi
/sys/bus/platform/drivers/sun4i-spi/1c06000.spi
/sys/bus/platform/drivers/sun4i-spi/1c17000.spi
/sys/bus/platform/drivers/sun6i-spi
/sys/devices/soc@01c00000/1c06000.spi
/sys/devices/soc@01c00000/1c06000.spi/spi_master
/sys/devices/soc@01c00000/1c06000.spi/spi_master/spi0
/sys/devices/soc@01c00000/1c17000.spi
/sys/devices/soc@01c00000/1c17000.spi/spi_master
/sys/devices/soc@01c00000/1c17000.spi/spi_master/spi1
/sys/class/spi_master
/sys/class/spi_master/spi0
/sys/class/spi_master/spi1
/sys/class/spidev
/sys/firmware/devicetree/base/soc@01c00000/spi@01c05000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c06000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c17000
/sys/firmware/devicetree/base/soc@01c00000/spi@01c1f000
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi0@0
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi1@0
/sys/firmware/devicetree/base/soc@01c00000/pinctrl@01c20800/spi2@0
/sys/firmware/devicetree/base/aliases/spi0
/sys/firmware/devicetree/base/aliases/spi1
/sys/module/spidev
/sys/module/spidev/drivers/spi:spidev

I have added "udev" (eudev) to my build
# /etc/init.d/S10udev stop
# /etc/init.d/S10udev start
Populating /dev using udev: [ 1242.412281] udevd[164]: starting version 1.7
done
#



Wondering if I need:
1. An actual spi device connected 
2. An "spiddev node" ....or "spidev" as a "childnode" of spi1


Also noticed I don't see any SPI messages from dmesg....which I guess is a hint I'll follow soon








bruce bushby

unread,
Jul 5, 2014, 5:16:27 PM7/5/14
to linux...@googlegroups.com

Looking much better:
# ls -l /dev/*spi*
crw-------    1 root     root      153,   0 Jan 10 13:51 /dev/spidev0.0


I added an spidev childnode to my spi1 node like so:

                spi1: spi@01c06000 {
                        pinctrl-names = "default";
                        pinctrl-0 = <&spi1_pins_a>;
                        status = "okay";
                        spidev@0 {
                                compatible = "linux,spidev";
                                reg = <0>;
                                spi-max-frequency = <1000000>;
                        };
                };



Rebuild, reboot and what would you know...... I have " /dev/spidev0.0" 

Really can't thank you guys enough for all the help, much appreciated!!!!

next stop.....connecting an SPI  device ....hopefully without too many sparks :) 

I'm connecting an MPU9250:

Guessing the "compatible" string will just be spi?






Koen Kooi

unread,
Jul 7, 2014, 2:39:38 AM7/7/14
to linux...@googlegroups.com

Op 5 jul. 2014, om 23:16 heeft bruce bushby <bruce....@gmail.com> het volgende geschreven:

>
> Looking much better:
> # ls -l /dev/*spi*
> crw------- 1 root root 153, 0 Jan 10 13:51 /dev/spidev0.0
> #
>
>
> I added an spidev childnode to my spi1 node like so:
>
> spi1: spi@01c06000 {
> pinctrl-names = "default";
> pinctrl-0 = <&spi1_pins_a>;
> status = "okay";
> spidev@0 {
> compatible = "linux,spidev";
> reg = <0>;
> spi-max-frequency = <1000000>;
> };
> };
>
>
>
> Rebuild, reboot and what would you know...... I have " /dev/spidev0.0"

Note that spidev is a userspace 'driver' and a hack, not something you'd use longterm.

> Really can't thank you guys enough for all the help, much appreciated!!!!
>
> next stop.....connecting an SPI device ....hopefully without too many sparks :)
>
> I'm connecting an MPU9250:
> http://www.drotek.fr/shop/421-1256-large_dm/mpu9250-gyro-accelerometer-magnetometer.jpg
>
> Guessing the "compatible" string will just be spi?

iirc the MPU6050 has a driver already, to get that working replace the spidev entry with the 6050 one.

regards,

Koen

bruce bushby

unread,
Jul 7, 2014, 4:13:44 PM7/7/14
to linux...@googlegroups.com

Thanks Koen! I think I'm starting to understand a little more now ....at least enough to have a go learning how to do it. MPU6050 is interesting .... led me to "iio" which is also interesting. Main issue is that it's i2c and doesn't offer all 9 axis.....then agaain I could be talking about my a!ss so  :)

I found this:

Which has been somewhat ported into:

Which is close....but it's C++ and it's more Middleware then a device driver ....so I'm thinking that with all the above examples and the "spidev.c" skeleton, I would have a go at copying/porting/writing an MPU9250 SPI device driver. 

I'm guessing:
Interrupt wakes up processor, reads 9 axis values into a binary string and outputs to device "/dev/mpu9250" 

Now to find my old copy of "The C Programming language" :)



  


You received this message because you are subscribed to a topic in the Google Groups "linux-sunxi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/linux-sunxi/3Ybi8DQ37O0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to linux-sunxi...@googlegroups.com.

Maxime Ripard

unread,
Jul 8, 2014, 3:35:04 AM7/8/14
to linux...@googlegroups.com
On Mon, Jul 07, 2014 at 09:13:42PM +0100, bruce bushby wrote:
> Thanks Koen! I think I'm starting to understand a little more now ....at
> least enough to have a go learning how to do it. MPU6050 is interesting
> .... led me to "iio" which is also interesting. Main issue is that it's i2c
> and doesn't offer all 9 axis.....then agaain I could be talking about my
> a!ss so :)

Yeah, it looks like it's only supporting i2c at the moment.

> I found this:
> https://mbed.org/users/kylongmu/code/MPU9250_SPI/
>
> Which has been somewhat ported into:
> https://github.com/emlid/Navio/blob/master/Navio/MPU9250.cpp
>
> Which is close....but it's C++ and it's more Middleware then a device
> driver ....so I'm thinking that with all the above examples and the
> "spidev.c" skeleton, I would have a go at copying/porting/writing an
> MPU9250 SPI device driver.

Or extending the current MPU6050 driver, if the sensors are similar
(which is often the case)

> I'm guessing:
> Interrupt wakes up processor, reads 9 axis values into a binary string and
> outputs to device "/dev/mpu9250"

Or just the IIO interface that allows to do pretty much every thing
you might need, plus has some userspace library to handle all that,
documentation, and so on... (and it will probably turn out to be
easier if you're extending the current driver)

Maxime
signature.asc

Koen Kooi

unread,
Jul 8, 2014, 7:02:16 AM7/8/14
to linux...@googlegroups.com

Op 8 jul. 2014, om 09:30 heeft Maxime Ripard <maxime...@free-electrons.com> het volgende geschreven:

> On Mon, Jul 07, 2014 at 09:13:42PM +0100, bruce bushby wrote:
>> Thanks Koen! I think I'm starting to understand a little more now ....at
>> least enough to have a go learning how to do it. MPU6050 is interesting
>> .... led me to "iio" which is also interesting. Main issue is that it's i2c
>> and doesn't offer all 9 axis.....then agaain I could be talking about my
>> a!ss so :)
>
> Yeah, it looks like it's only supporting i2c at the moment.

I wonder if SPI support can be done with regmap.

> I found this:
>> https://mbed.org/users/kylongmu/code/MPU9250_SPI/
>>
>> Which has been somewhat ported into:
>> https://github.com/emlid/Navio/blob/master/Navio/MPU9250.cpp
>>
>> Which is close....but it's C++ and it's more Middleware then a device
>> driver ....so I'm thinking that with all the above examples and the
>> "spidev.c" skeleton, I would have a go at copying/porting/writing an
>> MPU9250 SPI device driver.
>
> Or extending the current MPU6050 driver, if the sensors are similar
> (which is often the case)

The MPU9000 series is a 6000 series with an extra sensor on the internal i2c bus and a "motion processor". The motion processor is snake oil, but there are commands to query all the sensors at once instead of iterating over them.

The ardupilot linux port should have a userspace spidev version of this.

regards,

Koen
Reply all
Reply to author
Forward
0 new messages