-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Rpi 4.4.y spi aux #1295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rpi 4.4.y spi aux #1295
Conversation
These will be used for enabling UART1, SPI1, and SPI2. Signed-off-by: Eric Anholt <[email protected]> Acked-by: Rob Herring <[email protected]> Signed-off-by: Michael Turquette <[email protected]>
There are a pair of SPI masters and a mini UART that were last minute additions. As a result, they didn't get integrated in the same way as the other gates off of the VPU clock in CPRMAN. Signed-off-by: Eric Anholt <[email protected]> Signed-off-by: Michael Turquette <[email protected]> Needed to manually merge drivers/clk/bcm/Makefile to preserve the architecture condition for drivers/clk/bcm/clk-bcm2835.c
Activate and provision the SPI auxiliaries.
Can this be dropped, it just confuses by indicating that 3 chip selects are mandatory: + cs-gpios = <0>, <0>, <0>; I suggest putting the spi1/2 setup into overlays instead of the board files: spi1-spidev-overlay.dts Not everyone wants 3 chip selects. Maybe we can have 3 chip select nodes in the overlay which enables 1, 2 or 3 chip selects: @pelwell Is there a way to to use an overlay parameter to tell which spi bus to use (ie. which spi bus node to attach a device to)? Even better if we could set the gpio for a variable number of cs-gpios (including pinmux): |
@notro: this goes back to the discussion about indexes and the fact that one overlay can only get loaded once - not different times with different parameters. Otherwise you could run this:
if you could also parametric the name it could even become:
|
FWIW I agree with @notro about making the SPI configuration configurable with overlays & dtparams. I have a working example: frasersdev@5d4a4a1 So three overlays, one each for 1,2,3 CS lines. Each CS line can be mapped to a gpio by a user and also the spi device node can be disabled. Its not the neatest solution having a few overlays per spi device but if I understand @msperl properly then that compromise may not be avoidable. Example usage: spin up spi1 with 2 cs lines. use pin 30 for cs0 and & 31 for cs1. only create a /dev/spidev1.0 node this sets up spi1 like so:
So is that heading in the right direction? |
@msperl is quite right about the limitations of the overlay mechanism. I've had a back-burner project since last year to extend the syntax to allow names to be parameterised along with some more radical changes, but the challenges are:
There is also a tension between wanting to get something out soon that at least manages renaming nodes, and wanting to minimise the number of iterations, or at least not to miss out on future opportunities by insufficient planning. @notro was kind enough to give me some feedback on a early draft which led to several improvements, but then my ideas grew along with my other challenges. The implementations so far have all been fairly straightforward - the what is much harder than the how - so if there's an appetite for progress in this area then I may create an issue here and invite comments from those interested and knowledgeable in the field. Until then, @frasersdev I think your approach is the best you can do under the circumstances. If you add descriptions into the README and create a pull-request I'll happily merge it. |
@pelwell: maybe it would be better if we started using the device-tree overlays in kernles and find some way to feed the experience we see/have into that - worsted case by having a DTS-overlay translator or similar that runs only in user-space (also for backwards compatiblity support) I guess this would make all our lives easier in the long run - especially for yours, as the support for DT-overlays in the firmware goes away... |
@pelwell sure will do. A question while everyone is here - the spi-max-frequency for spi0 is 500khz which is a bit on the low side (i.e. for driving lcd screens or SD cards). I've see the hardware successfully used up to 10Mz and beyond. I'm unaware of the history behind the speed limit for spi0 and so cannot determine if it also applies spi1/2 or not. Is there any harm is bumping that up a bit for spi1/2 in the dtoverlays I'm going to submit? say 10Mhz? |
I don' think this matters much when using spidev since there's an ioctl to set the speed (SPI_IOC_WR_MAX_SPEED_HZ) but I could be wrong, haven't seen many spidev-using programs. |
@notro I guess this pull request can be closed now then? |
Hi,
As per this post https://www.raspberrypi.org/forums/viewtopic.php?p=909123#p909123 I am submitting a pull request to enable the SPI1 & 2 'Auxiliaries' in kernel 4.4 for the purpose of establishing it if could be applied. Note that it requires back porting of the auxiliary clock. This pull request also resolves this issue #1034
The first two commits are the back porting of the auxiliary clock from 4.5 along with associated documentation and bindings. The third commit is the changes needed to build the code for rPI hardware and make these SPI auxiliaries available to end users via device tree configuration. To enable add 'dtparam=spi1_aux=on' or 'dtparam=spi2_aux=on' (compute module) into the /boot/config.txt
Apart from the obvious there are some items that might be worth discussing:
Naming convention - even broadcom is inconsistent with the naming of these two SPI devices. I have elected for spi1_aux and spi2_aux.
uart1 clock - this probably needs to be looked at as it can probably be reconfigured to use the aux clock.
Configuration is based on header availability:
I do not have a PI A+/B+/Zero/compete module so this hardware is untested
I have however tested the SPI1 driver on a rPI2 B.
Loopback test on spi1.1
Reading a MCP3202 via spi1.0