2021-11-28
00:33squags has quit [Ping timeout: 480 seconds]
00:45opticron has joined #asahi-dev
00:59squags has joined #asahi-dev
03:10PhilippvK has joined #asahi-dev
03:13phiologe has quit [Ping timeout: 480 seconds]
03:17squags has quit [Ping timeout: 480 seconds]
03:21squags has joined #asahi-dev
03:50kov has quit [Quit: Coyote finally caught me]
07:18user982492_ has joined #asahi-dev
07:18user982492 has quit [Read error: Connection reset by peer]
07:29the_lanetly_052___ has quit [Remote host closed the connection]
07:29the_lanetly_052 has joined #asahi-dev
07:43uartman_ has joined #asahi-dev
07:45uartman_ has quit []
07:47kov has joined #asahi-dev
08:13user982492_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
10:01the_lanetly_052 has quit [Remote host closed the connection]
10:01the_lanetly_052 has joined #asahi-dev
11:01Dcow has joined #asahi-dev
11:05Dcow_ has quit [Ping timeout: 480 seconds]
13:23j_eyso I put a branch here with my new SPI driver, if anyone is using the keyboard patches and wants to test it out https://gitlab.arm.com/linux-arm/jg-open/-/commits/spi/dev/
13:26j_eyjannau: would be nice if you could try it out at some point. I seem to still get data from the tracpkad even after pressing capslock. (I dont have x11 or anything, but I put a pr_err in applespi_got_data and im at least getting prints when using the tracpkad)
14:39svenj_ey: it's a bit weird that the irq is started by setting REG_CONFIG_IE_TXEMPTY but never stopped. does that happen automatically?
14:39svenand do you know why you need to read and then write REG_STATUS? does that ack an irq or something?
14:42j_eysven: it's stopped here https://gitlab.arm.com/linux-arm/jg-open/-/commit/799eac917c9dc1b358641725238a634245b21250#64e032c3d47a1edda1e3ae6be8b8f1d1be4464b6_0_98
14:43j_eythe status thing is cargo culted from corellium, will add it to the list of things to check
14:44j_eyI found that I don't even need to set: config |= REG_CONFIG_IE_RXRDY;, seems to work fine without it
14:45svenfeel free to squash in https://f.svpe.de/4eae0bf083999e3028280f7e374b2fd1ca02a915e730cc802b9c1d00fdf4106c_0001-spi-review.patch untested, but compiles and should work
14:47svenmaybe also add a check to apple_spimc_irq to ensure there actually is an xfer in progress and return IRQ_NONE otherwise
14:49the_lanetly_052__ has joined #asahi-dev
14:49the_lanetly_052 has quit [Read error: Connection reset by peer]
14:53svenhrm, spi is also technically full duplex but i dunno how that works with the spi subssytem or that driver
14:54j_eyif you mean the calls inside apple_spimc_transfer_one to apple_spimc_drain_rx and apple_spimc_fill_tx
14:55j_eyright, but this fills the FIFO for rx and tx, i assume the controller then takes data from the FIFO and does the right thing
14:56svenit maybe works because at first the RX fifo will always be empty but then the call to apple_spimc_drain_rx is probably not required?
14:59the_lanetly_052__ has quit [Read error: Connection reset by peer]
14:59the_lanetly_052 has joined #asahi-dev
15:00j_eyI also wonder if I should remove that 'early return' https://gitlab.arm.com/linux-arm/jg-open/-/commit/799eac917c9dc1b358641725238a634245b21250#64e032c3d47a1edda1e3ae6be8b8f1d1be4464b6_0_139
15:00j_eythe packets from the keyboard/touchpad are 256 bytes, so we know theyre never going to be sent in one go..
15:01sveni dunno how this hardware works but SPI is probably slow i'd expect that at first you just fill the TX fifo, start the xfer and then wait for an interrupt
15:02svenand then in the interrupt probably first see if you can read from the RX fifo and then try to fill the TX fifo again
15:02svenand the xfer would be complete if you read from the RX fifo and don't have any more bytes to send
15:03j_eythis seems to match up what I learnt about SPI from watching one Ben Eater video about it lol
15:08j_eythere is this bit REG_STATUS_COMPL.. but I think because I disable the interrurpts.. it seems to be set at the start of every new transfer
15:11j_eyI think I can just ignore it, since Im keeping track of when the transfer is going to be cmplete anyway
15:15j_eyi started to try write a spi.py.. but realised I didnt want to deal with getting the actual HID protocol right to properly get packets
15:17sventhough at this point it actually wouldn't have been that bad. for some reason i assumed that nvme was going to be much more complex than it actually is
15:18sventwo more weeks of work and my xmas vacation starts. i should be able to just get it done then :-)
15:34jannauj_ey: I get "applespi spi0.0: Received corrupted packet (invalid message length 0 - expected 4294967286)" every second
15:56j_eythe only way I could think of figuring it out is to just slowly add back in some of the register that corellium set, that I didnt
16:07j_eyjannau: are you willing to try figure out whats missing, if not maybe marcan or someone else can help
16:12marcanspi seems to fit the "so simple figuring it out from scratch is probably easier than figuring out what corellium did wrong" bill so...
16:13marcanand it might give me an excuse to disassemble that second Mini if I need to pull out the scope
16:15marcan(at least in this context; in global context I just came back from band practice today, I promise I'm not *literally* wasting my time :p)
16:25j_eyoverall it's pretty simple to have a basic SPI driver, you just need a to provide a transfer_one, and you return 0 from that if the transfer finished and 1 if there is more to send
16:27j_eyyou also want master->use_gpio_descriptors = true;, so the core gets the cs from the DT for you
16:56ethanr has joined #asahi-dev
17:37jannauj_ey: sure, do you a suspicion to what it might be? just to be sure, it should work with an unchanged dtb?
17:37aleasto has joined #asahi-dev
17:39j_eyjannau: no I dont have any real suspicions.. but it seems like markan might take over, so Im just going to park it for now
17:39ethanr_ has joined #asahi-dev
17:45j_eysven: openbsd starts with RX first too.. https://github.com/openbsd/src/blob/master/sys/arch/arm64/dev/aplspi.c#L216
17:45ethanr has quit [Ping timeout: 480 seconds]
17:48kettenisit reads the fifo level register and the rx level should be 0 at the start of a transfer
17:50j_eyjannau: you could also try: writel_relaxed(0, spi->base + REG_CLKIDLE);, just before the writel_relaxed(REG_CLKCFG_ENABLE, spi->base + REG_CLKCFG);
17:51jannaucommenting apple_spimc_drain_rx doesn't help, all adding all the register writes in _prepare/_clock except the draining doesn't fisx it either
17:53marcanI highly encourage everyone to work out how the hardware works first, over stumbling over drivers written by people who haven't done so :-)
17:54marcanremember, Corellium do VMs that run *one* OS; they don't need to understand how the hardware works, they just need to make that OS happy. you can get away with a ton of nonsense/misunderstandings when you only need to make one piece of code work.
17:55marcanit's been evident throughout this entire thing that they have never sat down and actually poked at any of this hardware to understand how it works; they just read macOS drivers
17:57marcan(that entire thing is *designed* as a testing and understanding framework precisely for this purpose!)
17:58marcanyou should be able to "single-step" through the hardware handling and observe the registers change and exactly what effect each action has (RegMonitor is your friend etc)
18:00marcanand yes, IRQ support should follow naturally from a polled implementation; the only thing that should need working out for IRQs to work is the flags/masks/whatever, everything else should come from an existing understanding of the hardware
18:00marcanthe rest of the IRQ complexity is in the kernel/driver side to handle things properly asynchronously, not in hardware understanding
18:02kettenismy understanding of how it works is still incomplete, but heck of a lot better than whoever write the corellium driver ;)
18:02marcanthere will always be gaps, but it's important to get the core concepts right or else the thing will fall apart even if it appears to work at first
18:03marcanthey all have the same compatible and I think this probably also dates to the dark ages of iPhones
18:07kettenisOpenBSD won't run on the M1 pro/max until I have a working u-boot and a driver for the new AIC version
18:11marcanas long as you don't create dependency issues, linux will power down everything that needs powering down anyway
18:11marcanand in general the default state is/should be things powered up (which is why driver probe functions are called after domains are powered up)
18:16the_lanetly_052 has quit [Ping timeout: 480 seconds]
18:16marcanonce I catch up on getting decent versions of all these kernel bits and pieces merged, I want to finally put together a shippable boot stack, and I definitely want it to work on t6000 :)
18:22marcansgtm, I imagine if I get to this point and you haven't gotten around to it yet, it shouldn't be a huge issue to take a crack at :)
18:38Dcow has quit [Ping timeout: 480 seconds]
18:53user982492 has joined #asahi-dev
19:15ethanr_ has quit [Quit: Leaving]
19:20loki_val has quit [Ping timeout: 480 seconds]
19:23squags has quit [Ping timeout: 480 seconds]
19:32squags has joined #asahi-dev
19:40squags has quit [Ping timeout: 480 seconds]
19:48squags has joined #asahi-dev
20:35aleasto has quit [Remote host closed the connection]
21:14ethanr has joined #asahi-dev
21:16ethanr has quit []
21:17ethanr has joined #asahi-dev
21:25DarkShadow44 has quit [Quit: ZNC - https://znc.in]
21:26DarkShadow44 has joined #asahi-dev
21:28Mary has quit [Quit: Ping timeout (120 seconds)]
21:28Mary has joined #asahi-dev
21:54alonetogether[m] has joined #asahi-dev
21:58ethanr has quit [Quit: Leaving]
22:00alonetogether[m] is now known as petermlyon[m]
22:08squags has quit [Ping timeout: 480 seconds]
22:10jannauexcept for reads and writebacks of 0x150, 0x154, 0x160, and 0x168 I don't see a difference in the register writes
22:16squags has joined #asahi-dev
22:24squags has quit [Ping timeout: 480 seconds]
22:33squags has joined #asahi-dev
22:41squags has quit [Ping timeout: 480 seconds]
22:44kenzie41 has quit []
22:44kenzie41 has joined #asahi-dev
22:47kenzie41 has quit []
22:49squags has joined #asahi-dev
22:59Dcow has joined #asahi-dev
23:00yrlf has quit [Quit: The Lounge - https://thelounge.chat]
23:01jannauseems ok, although the common spi code actually does extra cs deassrt/assert requested by applespi
23:03jannaumaybe the clock programming between transfers vs. once per message and with cs already low causes problems
23:14user982492 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
23:16yrlf has joined #asahi-dev
23:21mrbatmanface[m] has joined #asahi-dev
23:24j_eyjannau: thanks again for looking into it more (if nothing else, will be useful info if markan ends up redoing the driver)
23:30ethanr has joined #asahi-dev
23:58ethanr has quit [Ping timeout: 480 seconds]
23:58squags has quit [Ping timeout: 480 seconds]