Repository navigation
Rpi 4.4.y spi aux - #1295
Rpi 4.4.y spi aux#1295frasersdev wants to merge 3 commits into
Conversation
These will be used for enabling UART1, SPI1, and SPI2. Signed-off-by: Eric Anholt <eric@anholt.net> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Michael Turquette <mturquette@baylibre.com>
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 <eric@anholt.net> Signed-off-by: Michael Turquette <mturquette@baylibre.com> 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? |
After creating a dm device, then user can reload such dm with itself, and dead loop will be triggered because dm keep looking up to itself. Test procedures: 1) dmsetup create test --table "xxx sda", assume dm-0 is created 2) dmsetup suspend test 3) dmsetup reload test --table "xxx dm-0" 4) dmsetup resume test Test result: BUG: TASK stack guard page was hit at 00000000736a261f (stack is 000000008d12c88d..00000000c8dd82d5) stack guard page: 0000 [#1] PREEMPT SMP CPU: 29 PID: 946 Comm: systemd-udevd Not tainted 6.1.0-rc3-next-20221101-00006-g17640ca3b0ee raspberrypi#1295 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014 RIP: 0010:dm_prepare_ioctl+0xf/0x1e0 Code: da 48 83 05 4a 7c 99 0b 01 41 89 c4 eb cd e8 b8 1f 40 00 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 41 57 48 83 05 a1 5a 99 0b 01 <41> 56 49 89 d6 41 55 4c 8d af 90 02 00 00 9 RSP: 0018:ffffc90002090000 EFLAGS: 00010206 RAX: ffff8881049d6800 RBX: ffff88817e589000 RCX: 0000000000000000 RDX: ffffc90002090010 RSI: ffffc9000209001c RDI: ffff88817e589000 RBP: 00000000484a101d R08: 0000000000000000 R09: 0000000000000007 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000005331 R13: 0000000000005331 R14: 0000000000000000 R15: 0000000000000000 FS: 00007fddf9609200(0000) GS:ffff889fbfd40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffc9000208fff8 CR3: 0000000179043000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> dm_blk_ioctl+0x50/0x1c0 ? dm_prepare_ioctl+0xe0/0x1e0 dm_blk_ioctl+0x88/0x1c0 dm_blk_ioctl+0x88/0x1c0 ......(a lot of same lines) dm_blk_ioctl+0x88/0x1c0 dm_blk_ioctl+0x88/0x1c0 blkdev_ioctl+0x184/0x3e0 __x64_sys_ioctl+0xa3/0x110 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fddf7306577 Code: b3 66 90 48 8b 05 11 89 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e1 88 8 RSP: 002b:00007ffd0b2ec318 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00005634ef478320 RCX: 00007fddf7306577 RDX: 0000000000000000 RSI: 0000000000005331 RDI: 0000000000000007 RBP: 0000000000000007 R08: 00005634ef4843e0 R09: 0000000000000080 R10: 00007fddf75cfb38 R11: 0000000000000246 R12: 00000000030d4000 R13: 0000000000000000 R14: 0000000000000000 R15: 00005634ef48b800 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]--- RIP: 0010:dm_prepare_ioctl+0xf/0x1e0 Code: da 48 83 05 4a 7c 99 0b 01 41 89 c4 eb cd e8 b8 1f 40 00 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 41 57 48 83 05 a1 5a 99 0b 01 <41> 56 49 89 d6 41 55 4c 8d af 90 02 00 00 9 RSP: 0018:ffffc90002090000 EFLAGS: 00010206 RAX: ffff8881049d6800 RBX: ffff88817e589000 RCX: 0000000000000000 RDX: ffffc90002090010 RSI: ffffc9000209001c RDI: ffff88817e589000 RBP: 00000000484a101d R08: 0000000000000000 R09: 0000000000000007 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000005331 R13: 0000000000005331 R14: 0000000000000000 R15: 0000000000000000 FS: 00007fddf9609200(0000) GS:ffff889fbfd40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffc9000208fff8 CR3: 0000000179043000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Kernel panic - not syncing: Fatal exception in interrupt Kernel Offset: disabled ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]--- Fix the problem by forbidding a disk to create link to itself. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20221115141054.1051801-11-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
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