2021-12-10
00:02jannauno, also if the controller has no method to set the cs timing: !spi->controller->set_cs_timing
00:03yuyichao has quit [Ping timeout: 480 seconds]
00:05bps has quit [Ping timeout: 480 seconds]
00:09marcandid you not hit the WARN_ON(fifo_flags & APPLE_SPI_FIFO_TXOVERFLOW); ? I would expect that to fire with the bad code
00:09rwhitby has joined #asahi-dev
00:09bps has joined #asahi-dev
00:11jannauI saw tx_overflow set in the spi trace I did not notice it in the kernel log but I was not really looking at it
00:39aidenfoxivey has joined #asahi-dev
01:17StupidYui has quit [Read error: Connection reset by peer]
01:30yuyichao has joined #asahi-dev
01:39rwhitby has quit [Quit: rwhitby]
03:12phiologe has joined #asahi-dev
03:16PhilippvK has quit [Ping timeout: 480 seconds]
06:10vx^ has quit [Ping timeout: 480 seconds]
06:10marcanin principle we can run the HV in UP mode (or just filter out one CPU, might add an option for that) and then throw the gpiola on that one and see what linux does
06:18jannauI suppose j`ey was using something very similar to https://github.com/jannau/linux/tree/exp/spi-keyboard except for the random delays which fix it somewhat on bare metal
06:18marcanjust plain HV should have relatively little performance impact, mostly the timer IRQ spam
06:21marcanwe definitely want to rewrite that as a HID transport properly (and someone else can add the bits to make it work with ACPI laptops too and then we can deprecate applespi in the future)
06:26jannautouchpad seems to need more delay than I currently have. broken both with bare metal and hv without tracing
06:33kettenisthere are some packets that get sent early one that I haven't been able to give a meaning to
06:41marcan[ 14.081273] applespi spi1.0: Received corrupted packet (invalid message length 8 - num-fingers 0, tp-len 48)
06:41marcan[ 14.089493] applespi spi1.0: Received corrupted packet (invalid message length 8 - num-fingers 0, tp-len 48)
06:56kettenisso is it correct that the M1 models use the 24MHz refclk and the M1 Pro/Max models a 200MHz clock?
07:14marcanmaybe they actually forgot to initialize that clock in iBoot (but it works anyway because the spi driver does the right thing wrt divider)
07:18ketteniswell, if the input frequency isn't 24MHz but 200MHz the actual SPI clock frequency won't be what I think it is
07:20marcanbut the clock being 5x faster by accident on j293 would explain why it's breaking for people
07:20kettenisspi-max-frequency is the max frequency the spi device can run at if my understanding is correct
07:21marcanyes, and if your clock provider is claiming the controller is clocked at 24 when it's actually at 120, then you're driving the device at 10MHz instead of 2MHz
07:28marcanthe CS pin is specified in the ADT, I guessed it was nearby pins. that worked for spi3 but not spi1, for spi1 I spammed the RegMonitor during a SPI transaction until I saw something change
07:29marcanyou could also just trace, like, all pins in groups of 32 (the analyzer supports up to 32)
07:32kettenisthe adt doesn't actually provide the equivalent of spi-max-frequency for the spi devices isn't it?
07:44marcan[GPIOTracer@/arm-io/gpio] Pin-49 W 0x876220 (GROUP=7, CFG_DONE=1, PERIPH=1, CONFIG=0, VALUE=0)
07:44marcanthis is wrong, it's setting the CS pin to hardware control but then the spi node is being told to use software CS
07:52marcannot sure about X, I need to figure out why that breaks the touchpad, but I get the feeling that's an applespi problem, not a SPI problem
07:55marcanbut then you need the pinconfig; without that it tries to use software CS control while the hardware is the one actually owning the pin
08:03marcanI'll go back to t6k since that's where I have a root partition for X, but hopefully those DT changes were the only difference that matters on t8103
08:05kettenisso the 24/120MHz difference suggests that we can actually use a 10MHz spi-max-frequency on t8103-j293
08:06jannauI'm not sure how much time we should spend on applespi. I'll work on the spi hid transport this weekend
08:17marcanfirst write a HID transport that can do the keyboard/mouse bits via the standard HID framework
08:17marcanthen break up the bcm5974 driver into a core that sets up the input device and parses reports, and a transport layer
08:18marcanif both drivers are enabled the SPI/HID transport thing knows to switch modes and delegate to bcm5974 for that part
08:20kettenisso my driver has some weird delays in it; it would be nice to get a better understanding of those
08:24kettenisbut maybe the hardware will assert the GPIO that is used for interrupts when it is ready
08:33Glanzmannmarcan / jannau: I can test on macbook air if you tell me which tree I should use and what patch I should apply to the dtb.
08:39kettenisI think that is just a packet with a different layout that isn't handled by the current code
08:46j`eymarcan: I dont want to distract, but I'm confused now if m1air uses a 24mhz or 120mhz clock?
08:59Andre[m]1 has joined #asahi-dev
08:59marcanbut now that things are starting to come together I do want to test stuff on all of them and fix whatever's broken :)
09:23marcan/System/Library/AssetsV2/com_apple_MobileAsset_SFRSoftwareUpdate/e1e322bee87acc15973794a58f6e551734c82adf.asset/AssetData/boot/Firmware/J293_Multitouch.im4p for one... but surely it doesn't get it from there
09:25FireFox317apple really do like firmware, doesnt it
10:12aleasto has joined #asahi-dev
10:15marcanu32 unk, clock_period, flags, word_delay, cs_delay, cs_preamble_delay, cs_postamble_delay
10:18marcanso not only are they tying their SPI device abstraction to ARM platforms only, they define it in the kitchen sink driver
10:19marcanseriously, people need to give us credit, the stuff we come up with is way cleaner than macOS :p
10:20marcanalso the controller driver is called AppleSamsungSPI so I was right that it's somehow a relative of Samsung stuff
10:23sventhere's also the entire gpu iommu node that's just used to create a small shim driver that just calls back to the main gpu driver
10:26marcanlooks like the preamble/postamble ones are cs to data and data to cs, and take effect if cs_delay is zero
10:28marcanthe four flag bytes I think are clock_polarity, flags (I think only bit 0 does something), some other bool, and bits per word
10:30j`eymarcan: either that 120MHZ clock fixed it.. or the change I made to use gpio instead of hw-cs /me reverts back to hw-cs and checks
10:33aidenfoxivey has quit [Quit: aidenfoxivey]
10:33aidenfoxivey has joined #asahi-dev
11:02gladiac is now known as Guest8136
11:02gladiac has joined #asahi-dev
11:03bps has quit [Ping timeout: 480 seconds]
11:08Guest8136 has quit [Ping timeout: 480 seconds]
11:52bps2 has joined #asahi-dev
12:40the_lanetly_052__ has joined #asahi-dev
12:41marcanit sets it to 3, which for 24MHz would be 8MHz under that interpretation (I had it as divisor - 1 instead which would give 6MHz)
12:42marcanwonder if I can get the gpiotracer accurate enough to test that... probably measuring the entire transfer with auto-cs
13:05aleasto has quit [Remote host closed the connection]
13:19Gaspare has joined #asahi-dev
13:31j`eyIm getting what seems to be recursive exceptions when trying to use linux.py, anyone else seeing this?
14:05yuyichao has quit [Ping timeout: 480 seconds]
14:24aleasto has joined #asahi-dev
14:25yuyichao has joined #asahi-dev
14:39kgarrington has joined #asahi-dev
14:40kgarrington has quit [Remote host closed the connection]
14:41yuyichao has quit [Ping timeout: 480 seconds]
14:45mini_ has joined #asahi-dev
14:47marcanok, got gpiola running on the hypervisor while running linux; I can't see the signals accurately at 8MHz, but I can tell the CS to clock delay isn't being correctly implemented
14:49the_lanetly_052___ has joined #asahi-dev
14:52mini_ has quit [Quit: ZNC closing...]
14:53marcan... because applespi calls applespi_setup_read_txfrs before applespi_setup_spi, which is what sets the cs delay value
14:55the_lanetly_052__ has quit [Ping timeout: 480 seconds]
14:57marcanunless I dropped it while rebasing at some point, but I don't think so? at least not intentionally
14:58marcaneither way obviously the way that driver is doing things is wrong; instead of that delay message it should be setting up a cs_hold
15:02j`eyhttps://gitlab.arm.com/linux-arm/linux-jg/-/commit/1c07a8fb8148224d8dbb51082d46bf0c98b9e1d3 I wrote this a while ago
15:03marcanwe need https://gitlab.arm.com/linux-arm/linux-jg/-/commit/4ccf359849ce709f4bf0214b4b5b8b6891d38770 back
15:08marcanthe spi core needs some code to call it during transfer setup passing in spi_device values
15:17Gaspare has quit [Quit: Gaspare]
15:44Gaspare has joined #asahi-dev
15:53balrog has quit [Quit: Bye]
15:59balrog has joined #asahi-dev
16:08Dcow_ has joined #asahi-dev
16:08Dcow has quit [Remote host closed the connection]
16:08Gaspare has quit [Quit: Gaspare]
16:31aidenfoxivey has quit [Quit: aidenfoxivey]
16:31aidenfoxivey has joined #asahi-dev
17:08Gaspare has joined #asahi-dev
17:13bps2 has quit [Ping timeout: 480 seconds]
18:10Glanzmann has quit [Quit: leaving]
18:34bpye has quit [Quit: The Lounge - https://thelounge.chat]
18:39Gaspare has quit [Quit: Gaspare]
18:51the_lanetly_052___ has quit [Ping timeout: 480 seconds]
19:35zimsneexh has joined #asahi-dev
22:27kumoko has joined #asahi-dev
22:29kumoko has quit []
23:04slicey has joined #asahi-dev
23:35ted[m] has left #asahi-dev [#asahi-dev]