#
…

2021-09-13

00:34quarkyalice has joined #asahi-re
01:26riker77_ has joined #asahi-re
01:31riker77 has quit [Ping timeout: 480 seconds]
01:31riker77_ is now known as riker77
02:55phiologe has joined #asahi-re
02:59PhilippvK has quit [Ping timeout: 480 seconds]
04:39quarkyalice has quit [Ping timeout: 480 seconds]
05:16quarkyalice has joined #asahi-re
05:33marcansven: even if it were a separate i2c bus to expose to other drivers, that could just be provided by the dcp node
05:33marcanthe rtkit node is about us having multiple *drivers* (potentially different modules) bind to rtkit directly
05:33marcanI don't think we have a good reason to do that; all the endpoints can be bundled together in dcp.ko
05:34marcanit can still expose whatever zillion interfaces we feel like to userspace or other drivers
05:34marcannothing terribly wrong with a monolithic driver like that, and considering how many hacks Apple has in their model, if we tried to modularize it we'd probably have a bunch of abstraction breaks anyway...
05:34marcanI do expect us to expose i2c to userspace; people want that for monitor control
05:35marcanre 2 i2c buses, I saw two exposed externally via those debug PD modes and now I wonder if they're those two
05:37quarkyalice has quit [Ping timeout: 480 seconds]
05:54svenand yeah, i guess it would make sense if they exposed the two busses that way
05:55sveni'm fairly sure at this point the secondary bus of those usb pd chips is connected to the smc directly
06:04akemin_dayo has joined #asahi-re
07:13marcanthat would make a lot of sense, yeah
07:13marcanand then we just need to make sure we don't mask the wrong IRQs
07:16svenyeah. i'll have to fix the linux driver a bit anyway because right now it also treats IntMask1 and IntMask2 the same.
07:16svenand change the irq numbers to what apple uses. they don't seem to line up with the TI ones :/
07:20svenand then ofc see if there's a sane way to forward usb connected interrupts to the phy driver (possibly just a virtual irq chip) so that usb hotplug finally works
07:28marcancould be a gpio thing too, perhaps
07:28marcanI assume this hasn't been done before for other USB PHYs?
07:28marcanI imagine some systems have a separate VBUS GPIO and the like
07:30sventhere's also this whole extcon thing that seems to be somehow related to usb which also seems to have some kind of notification system
07:32svendunno, just need to read more code and see what the right thing to use is
07:33marcanbut this sounds like something generally useful for Type C, except I assume Linux already has some Type C shenanigans?
07:33marcanwe should look into how thunderbolt/etc muxing is done
07:34marcanmaybe this *is* the thing to use? but if so, shouldn't the TI driver already be using it?
07:35sventhere's also some typec_ api but at first glance that's mostly about notifying userspace i think (https://www.kernel.org/doc/html/v5.0/driver-api/usb/typec.html)
07:35marcanvarious PHYs support using this API to get the state
07:35svenjust requires to spend some time to read more code :)
07:36marcanincluding some dwc3 wrappers
07:36svenyeah, that's how i found it
07:41marcansven: have you seen Documentation/devicetree/bindings/connector/usb-connector.yaml ?
07:41marcanthe one existing dt user of the TI chips uses that to link to dwc3
07:41svenyes, just need to read that all in detail
07:42sventhis is not a hard problem, it just requires some reading :D
07:42marcanwell, I'm just wondering if this is one of "there are two competing ways to do this in linux" cases
07:42marcanit sure sounds like the typec stuff and extcon overlap
07:42marcansome typec drivers do extcon, but not this one
07:42svenpossibly
07:45marcanI'm getting the feeling very few drivers actually *use* those connector relationships
07:48marcansee also include/linux/usb/role.
07:48svenyeah, i know
07:48sveni already have a reading list
07:49marcanok ok :)
07:49j_eysven: reading list: **/*
07:49svenmarcan: i mean, feel free to take over if you want to :D
07:49marcanj_ey: zsh user \o/
07:50marcansven: I already took over the power management stuff, I should probably stay here for a while :>
07:52marcansven: I found a thing though
07:52svena thing?
07:53marcanthat role switch stuff, dwc3 uses it, see CONFIG_USB_ROLE_SWITCH and dwc3_usb_role_switch_set
07:53marcanhowever, it just does some lame default mode thing on disconnect
07:53marcanif the typec controller correctly sets the role to none on disconnect, and dwc3 correctly uses that trigger to reset itself, I bet that'd work
07:53svenin gadget mode we don't even get disconnect events fwiw
07:53marcanwell, we should
07:54marcanvbus presence should be somewhere
07:54marcanbut the mode should be automatic anyway
07:54marcanthat's what this role switch stuff is for
07:54svenno, i mean, dwc3 doesn't trigger an interrupt for disconnects. not even in m1n1
07:54marcanand that should be enough to get hotplug to work
07:54sven(in gadget mode. i think in host mode it does)
07:54marcansure, but I mean
07:54marcanthe call path is ti -> dwc3
07:55marcandwc3 is a role switch provider (see dwc3_setup_role_switch)
07:55svenok, now i get what you mean
07:55marcanand tipd calls it (see tps6598x_set_data_role)
07:55marcanso if all the right configs and DT links are set up, that should all already work
07:55marcanand it should just be a matter of making sure it actually works as intended, and that dwc3 can use the HOST -> NONE -> HOST transition to reset itself
07:56svenyeah, that could work once the interrupt stuff in the TI code is adapted
07:56marcanthis is probably the least friction way, since it's an existing subsystem
07:56marcanI don't know if anyone else actually relies on the roleswitch for hotplugs within a mode, but well
07:56marcanit's there
07:56marcanmight as well use it with a smallish patch and move on :p
07:56sveneventually we may or may not need to do more thanks to thunderbolt (ugh) but this might work for now
07:57marcanand displayport
07:57marcanI'm guessing there are no devicetrees with thunderbolt, seeing as, well, intel monopolized that and it's ACPI-mediated...
07:57marcanbut displayport alt mode should already be a thing
07:57j_eytps6598x_interrupt -> tps6598x_disconnect -> tps6598x_set_data_role
07:57marcanand on paper should be handled the same way
07:58svenso it sounds like you're volunteering for thunderbolt to me? :>
07:58marcanI'm volunteering for displayport *if* I get power to work :p
07:58marcan desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
07:58marcanlol the ti driver
07:58marcanthough those are just audio/debug
07:59marcanwhere are altmodes in this thing...
07:59sventhe ti driver is pretty minimal
07:59sventhe interrupt handling is also broken. it requests a shared interrupt but always returns IRQ_HANDLED
07:59svennot a big deal and a quick fix, but i guess apple is the first one to use two of these chips on the same irq line
08:01marcanheh yeah
08:03marcan port@2:
08:03marcan $ref: /schemas/graph.yaml#/properties/port
08:03marcan description: Sideband Use (SBU), present in USB-C. This describes the
08:03marcan alternate mode connection of which SBU is a part.
08:03marcanthere can be multiple of these
08:03marcanwho made this binding
08:03marcansven: current conclusion: this is all made of fail for altmodes and we need to fix core code :p
08:03svenso you'll upstream power/clocks first and then fix the core code? :>
08:04marcanno promises on how long power/clocks will take though... that could be a rabbit hole
08:04svenso i guess a week or so for you then? :P
08:09marcansven: fwiw, rk3399 is a good model for this
08:09marcanthe dp/usb/phy/tcpm model is the same as what we have
08:09marcanwe're just going to have another one for TB
08:09svenah, nice
08:09marcanright now we don't do USB3 at all, right?
08:09svennot really
08:10sventhat requires a real phy driver
08:10sven(aka bunch of magic pokes and possibly tunables)
08:10marcanand the acio stuff presumably, or at least the atc switching
08:10marcanso that's when we'll have to look at that
08:10sveni think acio is only for thunderbolt
08:10marcanfor now, if you can get USB2 to work with the hs port0, that's good enough
08:10svennot sure though
08:10marcanI think acio handles tb, yeah
08:10marcannot sure if it has a hand in dp mode switching though
08:11svenyeah, no idea. all i know how is how to boot that thing so far
08:11marcananyway, this all looks reasonable
08:11marcansee if you can get hotplug to work by using that roleswap stuff
08:11marcanand just define the port0 (hs) link
08:11marcanand we can expand from there
08:11sven(and then reset the whole machine 2 minutes later because i probably skipped all the phy init and some internal state dies but those are details :-P)
08:12svenbut yeah, that's my plan. first get usb2 hot plug working and then take it from there
11:17alyssa08:09 <@marcan> sven: fwiw, rk3399 is a good model for this
11:17alyssa08:09 <@marcan> the dp/usb/phy/tcpm model is the same as what we have
11:18alyssatbf type-c on rk3399 is only mostly broken 🤷
11:18sveni think marcan volunteered to fix that as well!
11:18alyssasven: ADT suggests acio is a prerequisite for HDMI audio
11:18svenuhhhh... that sounds weird. but then again, this is apple
11:19alyssaer might be mixing up with sio
11:19alyssathe funny DMA thing
11:19svenyeah, that's sio
11:19alyssatoo many acronyms
11:20sveni *think* cio only needs to be booted when you want to tunnel pcie over thunderbolt
11:20svenbecause the moment i disconnect my thunderbolt dock macos shuts cio down again
11:20alyssawhat do you even use thunderbolt for lol
11:21svenuh, i have a thunderbolt dock to connect all my peripherals to my macbook air
11:23alyssa(I have a type-C to type-A + HDMI cable that's tunnelling displayport internally .. I don't think that's tbolt though right?)
11:24svendon't think so
11:25alyssawas going to say i didn't think rk3399 could do tbolt
11:25svenmy dock does usb-c to uhh... displayport,ethernet,like 10 or so usb3 ports, sound and a sd card slot for some reason
11:26j_eyswiss army dock
12:19svenmarcan: have you ever dumped the firmware running on those PD chips btw?
12:29X-Scale has joined #asahi-re
13:08marcansven: not on the M1 ones
13:08marcanit's one of those ROM + patch things
13:08marcanI have the patch set for some x86 macs with the same ones
13:08marcanbut for the ROM I think you need to start poking at SWD
13:09marcanalyssa: I have an offer from a dock company to send me over some free ones to bring this up :>
13:09marcanI'll probably take them up on that soonish
13:26jbowen has quit [Quit: leaving]
13:26jbowen has joined #asahi-re
13:51yuyichao has quit [Ping timeout: 480 seconds]
16:39riker77 has quit [Quit: Quitting IRC - gone for good...]
16:50riker77 has joined #asahi-re
17:54austriancoder has quit []
17:54austriancoder has joined #asahi-re
18:30yuyichao has joined #asahi-re
18:30mindfreeze has quit []
18:30mindfreeze has joined #asahi-re
19:00quarkyalice has joined #asahi-re
19:01quarkyalice has quit [Remote host closed the connection]
20:47nsklaus_ has joined #asahi-re
20:53nsklaus has quit [Ping timeout: 480 seconds]
23:18yuyichao_ has joined #asahi-re
23:22yuyichao has quit [Ping timeout: 480 seconds]
23:55DarkShadow4444 has joined #asahi-re
23:56DarkShadow4444 has quit []
…