You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone,
I am working on a driver for AUX SPI1. I used @joan2937 userspace code for AUX SPI as a reference.
It's pretty simple currently, but I hope to get it into a proper state soon.
If there is any advice or suggestion regarding this driver I would be happy to hear it.
Here is my code: https://github.com/vlad-zakharov/rpi-spi1, now it's very simple and just a kernel module. @msperl@notro@joan2937 what do you think?
note that a quick look at your patch shows that you are not using the latest "recommended" interface for new drivers - you should have used the transfer_one interface and not the transfer interface...
please try the patch - it should work when you use the correct device-tree!
@msperl , Can you give me an advice how to add your patch to the kernel? And you wrote about the correct device-tree, what did you mean? I added to file linux/arch/arm/boot/dts/bcm2708.dtsi next lines from your patch:
Driver requiers that you set cs-gpios with the chipselects to use and you also have to set the correct alt functions for the miso, mosi and sck pins as well as setting Chipselects pins as output not alt!!!
Please consider this a thumbnail sketch - I'm guessing a bit at the chip select support, but I'm sure @msperl will correct me if I'm wrong.
Since we are using GPIO chip selects you can have any number you like and use any pins you like, but this example mirrors the pins used by the three native chip selects for SPI1. If you need fewer you can shrink the sp1_cs_pins section accordingly.
I hope this is at least a pointer in the right direction.
[ P.S. @msperl The upstreamed documentation patch looks wrong:
gpio-cs: the gpio-cs (native cs is NOT supported)
Shouldn't that be cs-gpio ?
And it would be helpful if the example included the cs-gpio/gpio-cs usage. ]
@pelwell I have done changes you adviced, but I still have no results. May be the problem I have isn't in the device tree? Do I have to change some configuration files? When building kernel and modules I don't get any message about spi-bcm2835-aux. @msperl, May be you can push your code with this patch on GitHub?
Well, the first version did not get accepted, so I am about to push a version 3 that makes use of the sysconf framework for access to the enable register.
If this is accepted, then we can starting to merge it.
@msperl I'd like to test yout driver. Please, let me know when new version would be available. It would be great if you could upload it on Github somewhere.
...so...
I notice the spi1aux module is in the kernel (4.4.y / 4.5.y) and I would like to try and get it going.
I've built it on a rPi2 (note I had to change the spi Kconfig for it to show up in menuconfig)
The module loads,
However it doesn't show up in sys/class etc, no log entries nothing.
I'm guessing thats a absence of device tree definition issue.
I'm new to device trees so I may need a little help here,
I can see the SPI module needs to be defined to 2 places to work,
bcm2708_common.dtsi
bcm2???-rpi-*.dts (one for each type of rPi board)
Is there anywhere else?
Once I've made the changes can I use the device-tree-compiler package in jessie to compile it?
There is a note from a few years ago that the package was too old but is this still the case?
When I compile the dtb using the jessie package I get an error
$ dtc -I dts -O dtb -o bcm2709-rpi-2-b.dtb bcm2709-rpi-2-b.dts
Error: bcm2709-rpi-2-b.dts:3.1-9 syntax error
FATAL ERROR: Unable to parse input tree
Which I think is telling me syntax error is on line 3, characters 1-9 -> the '#include' ?
I'm getting close now. For the record here is what I have had to do (if this is not the right place for this then I apologise in advance)
Edit ./drivers/spi/Kconfig and change the config SPI_BCM2835AUX depends on line to depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709 || COMPILE_TEST
Edit ./arch/arm/boot/dts/bcm2708_common.dtsi and add to aliases spi1 = &spi1;
and then add to soc:
You will typically also need the auxiliar clock driver installed (as only then the clock gate is enabled - but that is also upstream only).
But that should only impact functionality not configuration
Please share dmesgwhen you have loaded the module (maybe put the module on the blacklist first) as well as the corresponding section for spi1 from dtc -Ifs /proc/device-tree
Note that you may see some conflicts on the GPIOs with the default configs - especially when you have i2s drivers loaded - but these would show up in dmesg
As said: you will need a clock-driver that will bring up the clock-gate.
The clk-bcm2835-aux driver that does this should come along in 4.5.
Then it should be possible to use that one directly on a downstream kernel - maybe still with a fixed clock behind it instead of the new clock framework for now...
The osc clock you use is running at 19.2MHz which is definitely wrong and will result in unexpected results - i.e: the SPI clock will be much to fast (by a factor of 13.3)! It needs to be the VPU/core clock running (typically) at 250MHz!
If you are willing you can also just poke 0x00000007 into register 0x7e215004 and then the clock gates for spi1/2 and uart1 are also enabled.
sorry, I don't understand what you mean
I have been using this kernel https://github.com/raspberrypi/linux/tree/rpi-4.5.y as it contains both the spi1aux and clkaux
I rebuilt the kernel with clk-bcm2835-aux enabled for the bcm2709 architecture
fraser@rpi:~/kernel/linux $ make -j4 zImage modules dtbs
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
CHK include/generated/timeconst.h
CHK include/generated/bounds.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CHK kernel/config_data.h
CC drivers/clk/bcm/clk-bcm2835.o
CC drivers/clk/bcm/clk-bcm2835-aux.o
LD drivers/clk/bcm/built-in.o
LD drivers/clk/built-in.o
LD drivers/built-in.o
LINK vmlinux
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SORTEX vmlinux
SYSMAP System.map
OBJCOPY arch/arm/boot/Image
Building modules, stage 2.
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/Image is ready
GZIP arch/arm/boot/compressed/piggy.gzip
AS arch/arm/boot/compressed/piggy.gzip.o
MODPOST 1455 modules
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
...
fraser@rpi:~/kernel/linux $ sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img
[sudo] password for fraser:
Version: Linux version 4.5.0-rc3-v7+ (fraser@rpi) (gcc version 4.9.2 (Raspbian 4.9.2-10) ) #2 SMP Tue Feb 16 19:15:09 AEDT 2016
I am running that kernel
$ uname -a
Linux rpi 4.5.0-rc3-v7+ #2 SMP Tue Feb 16 19:15:09 AEDT 2016 armv7l GNU/Linux
One tiny tiny little problem but I'll look at that tomorrow - when I compiled the dtb is didn't recognise the define (BCM2835_AUX_CLOCK_SPI1) but worked fine if I substituted the value (1). So this file: include/dt-bindings/clock/bcm2835-aux.h needs to be referenced somehow.
anyway, thanks again for your help.
I'm going to put spi1 through its paces now and see how it holds up
FYI I have submitted a pull request which if nothing else neatly wraps up the changes I needed to make.
The pull request is for kernel 4.4 as it has been raised as a LTS kernel so figured that now is a good time to mull over making the auxiliary SPI devices available.
Activity
msperl commentedon Jun 24, 2015
there is a post of a patch going upstream already (posted yesterday):
http://permalink.gmane.org/gmane.linux.kernel.spi.devel/20770
http://permalink.gmane.org/gmane.linux.kernel.spi.devel/20769
msperl commentedon Jun 24, 2015
as soon as it got accepted into the tree of linux I was planning to ask to merge/cherry-pick it downstream...
vlad-zkhr commentedon Jun 24, 2015
Oh, wow! Such a coincidence:)
That's great, I look forward to seeing it upstream.
msperl commentedon Jun 24, 2015
note that a quick look at your patch shows that you are not using the latest "recommended" interface for new drivers - you should have used the transfer_one interface and not the transfer interface...
please try the patch - it should work when you use the correct device-tree!
vlad-zkhr commentedon Jun 30, 2015
@msperl , Can you give me an advice how to add your patch to the kernel? And you wrote about the correct device-tree, what did you mean? I added to file linux/arch/arm/boot/dts/bcm2708.dtsi next lines from your patch:
but anything happened. What I'm doing wrong?
msperl commentedon Jun 30, 2015
Driver requiers that you set cs-gpios with the chipselects to use and you also have to set the correct alt functions for the miso, mosi and sck pins as well as setting Chipselects pins as output not alt!!!
pelwell commentedon Jun 30, 2015
I think you need to create children of the gpio node that look like this:
and then reference them from the spi1 node:
Things to bear in mind:
I hope this is at least a pointer in the right direction.
[ P.S. @msperl The upstreamed documentation patch looks wrong:
Shouldn't that be cs-gpio ?
And it would be helpful if the example included the cs-gpio/gpio-cs usage. ]
vlad-zkhr commentedon Jul 1, 2015
@pelwell I have done changes you adviced, but I still have no results. May be the problem I have isn't in the device tree? Do I have to change some configuration files? When building kernel and modules I don't get any message about spi-bcm2835-aux.
@msperl, May be you can push your code with this patch on GitHub?
msperl commentedon Jul 6, 2015
Well, the first version did not get accepted, so I am about to push a version 3 that makes use of the sysconf framework for access to the enable register.
If this is accepted, then we can starting to merge it.
vlad-zkhr commentedon Jul 6, 2015
@msperl I'd like to test yout driver. Please, let me know when new version would be available. It would be great if you could upload it on Github somewhere.
frasersdev commentedon Feb 15, 2016
...so...
I notice the spi1aux module is in the kernel (4.4.y / 4.5.y) and I would like to try and get it going.
I've built it on a rPi2 (note I had to change the spi Kconfig for it to show up in menuconfig)
The module loads,
However it doesn't show up in sys/class etc, no log entries nothing.
I'm guessing thats a absence of device tree definition issue.
I'm new to device trees so I may need a little help here,
I can see the SPI module needs to be defined to 2 places to work,
bcm2708_common.dtsi
bcm2???-rpi-*.dts (one for each type of rPi board)
Is there anywhere else?
Once I've made the changes can I use the device-tree-compiler package in jessie to compile it?
There is a note from a few years ago that the package was too old but is this still the case?
When I compile the dtb using the jessie package I get an error
Which I think is telling me syntax error is on line 3, characters 1-9 -> the '#include' ?
Any guidance would be much appreciated.
frasersdev commentedon Feb 15, 2016
I'm getting close now. For the record here is what I have had to do (if this is not the right place for this then I apologise in advance)
Edit ./drivers/spi/Kconfig and change the config SPI_BCM2835AUX depends on line to
depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709 || COMPILE_TESTEdit ./arch/arm/boot/dts/bcm2708_common.dtsi and add to aliases
spi1 = &spi1;and then add to soc:
Edit ./arch/arm/boot/dts/bcm2709-rpi-2-b.dts (I'm using a PI2) and add to gpio:
then add a spi1 node (i'm not sure of this bit):
Finally add an override
spi_aux = <&spi1>,"status";run make menuconfig, pick the aux spi driver, build the kernel, install the kernel, reboot
add
dtparam=spi_aux=onto /boot/config.txt and reboot.This gives me:
However
msperl commentedon Feb 15, 2016
You will typically also need the auxiliar clock driver installed (as only then the clock gate is enabled - but that is also upstream only).
But that should only impact functionality not configuration
Please share
dmesgwhen you have loaded the module (maybe put the module on the blacklist first) as well as the corresponding section for spi1 fromdtc -Ifs /proc/device-treeNote that you may see some conflicts on the GPIOs with the default configs - especially when you have i2s drivers loaded - but these would show up in dmesg
1 remaining item
pelwell commentedon Feb 15, 2016
clk_spidoesn't exist - the <0xdeadbeef> is an unresolved symbol. I think you wantclk_core.frasersdev commentedon Feb 15, 2016
real close now
but sending a message fails, config (ioctl's) work though
==> indicates a clock issue?
FYI spi1 is using the following clock now
So this is tomorrows challenge:
msperl commentedon Feb 15, 2016
As said: you will need a clock-driver that will bring up the clock-gate.
The clk-bcm2835-aux driver that does this should come along in 4.5.
Then it should be possible to use that one directly on a downstream kernel - maybe still with a fixed clock behind it instead of the new clock framework for now...
msperl commentedon Feb 15, 2016
The osc clock you use is running at 19.2MHz which is definitely wrong and will result in unexpected results - i.e: the SPI clock will be much to fast (by a factor of 13.3)! It needs to be the VPU/core clock running (typically) at 250MHz!
If you are willing you can also just poke 0x00000007 into register 0x7e215004 and then the clock gates for spi1/2 and uart1 are also enabled.
Or you add this:
But for clocks choose a different clock that is available downstream - not osc, but maybe :
<&clk_core>frasersdev commentedon Feb 17, 2016
well I have got it working
But try as I might I just could enable the aux clock gate with via the device tree.
I'm new to device trees so perhaps I have made a mistake. This has been added to bcm2708_common.dtsi in the 'soc' section
and its there
But I just could not work out how to enable to aux clock properly...
NOTE I needed to update this kernel makefile: https://github.com/raspberrypi/linux/blob/rpi-4.5.y/drivers/clk/bcm/Makefile as it was only building the bcm clocks for CONFIG_ARCH_BCM2835 where the rPI2 is CONFIG_ARCH_BCM2709 and all other rPis are CONFIG_ARCH_BCM2708
frasersdev commentedon Feb 17, 2016
oh - I should add I got the SPi1 module going by poking 0x7 into 0x7e215004
msperl commentedon Feb 17, 2016
as said: you will need to enable the clk-bcm2835-aux driver (which is by default not enabled for the downstream architecture 270x, but only for 283X).
Note that it may get enabled with a 4.5 kernel as it will be included there...
frasersdev commentedon Feb 17, 2016
sorry, I don't understand what you mean
I have been using this kernel https://github.com/raspberrypi/linux/tree/rpi-4.5.y as it contains both the spi1aux and clkaux
I rebuilt the kernel with clk-bcm2835-aux enabled for the bcm2709 architecture
I am running that kernel
I have got this in the bcm2708_common.dtsi
Is there something else I need to do to enable clk-bcm2835-aux?
msperl commentedon Feb 17, 2016
did you now use the aux clock in spi1/spi2?
should look like this:
Because only then the aux clock is used and enables the gate.
if the building does not work with the above include (because the foundation kernel has not moved to #includes yet), you can also replace:
and it should work as well
frasersdev commentedon Feb 17, 2016
that was it! 👍
Obvious once its pointed out...
One tiny tiny little problem but I'll look at that tomorrow - when I compiled the dtb is didn't recognise the define (BCM2835_AUX_CLOCK_SPI1) but worked fine if I substituted the value (1). So this file: include/dt-bindings/clock/bcm2835-aux.h needs to be referenced somehow.
anyway, thanks again for your help.
I'm going to put spi1 through its paces now and see how it holds up
frasersdev commentedon Feb 20, 2016
FYI I have submitted a pull request which if nothing else neatly wraps up the changes I needed to make.
The pull request is for kernel 4.4 as it has been raised as a LTS kernel so figured that now is a good time to mull over making the auxiliary SPI devices available.
#1295
chaosjug commentedon Apr 5, 2016
4.6rc1 contains some fixes for the auxiliary SPI driver.
It would be nice to include those as well.
frasersdev commentedon Apr 21, 2016
Hi,
I've created a pull request for the aux clock fix in 4.6
#1423
Ruffio commentedon Aug 16, 2016
@vlad-zakharov has your issue been resolved? If so, please close this issue. Thanks.