Skip to content

Commit

Permalink
aop/exp: Bringup AOP ASC (audioep doesnt work yet)
Browse files Browse the repository at this point in the history
Works up til aop.audioep.ready on j293ap 13.5

Notably endpoints 0x20-0x22 must be started before asc boots. This means
the asc api has got to change. Thus we are currently writing to the CPU
control directly which is undesirable. The 3 endpoints are spu, accel,
and gyro respectively. I'm not sure if the Macs even have accel/gyro? Or
they are iDevice vestiges (hence they have to be "turned on" before).

Only after asc boots the lower sys endpoints (0x0-0x8) and the endpoints
0x24-0x28 are then started. 0x24 is LAS (lid angle something; but I
thought that was DCP?), 0x25 is wake hint, 0x26 is unk (might be ALS),
0x27 is audioep which is not yet working and I now get to do, and 0x28
is voice trigger ep.

After booting asc we get this, which is identical as macOS. First in
inbox is voicetriggerep which is as expected:
```
0x24a400000+000044 CPU_CONTROL = 0x10 (RUN=1)
0x24a400000+000048 CPU_STATUS = 0xd (IDLE=0, FIQ_NOT_PEND=1, IRQ_NOT_PEND=1, STOPPED=0, RUNNING=1)
0x24a400000+008110 INBOX_CTRL = 0x26601 (FIFOCNT=0x0, OVERFLOW=0, EMPTY=1, FULL=0, RPTR=0x6, WPTR=0x6, ENABLE=1)
0x24a400000+008114 OUTBOX_CTRL = 0x100101 (FIFOCNT=0x1, OVERFLOW=0, EMPTY=0, FULL=0, RPTR=0x0, WPTR=0x1, ENABLE=1)
0x24a400000+008800 INBOX0 = 0x80000000000000 ()
0x24a400000+008808 INBOX1 = 0x28 (EP=0x28)
0x24a400000+008830 OUTBOX0 = 0x100000000c000c ()
0x24a400000+008838 OUTBOX1 = 0x10010000000000 (OUTCNT=0x1, INCNT=0x0, OUTPTR=0x0, INPTR=0x1, EP=0x0)
```

Signed-off-by: Eileen Yoon <[email protected]>
  • Loading branch information
eiln committed Jan 15, 2024
1 parent c51ab4d commit a46d023
Showing 1 changed file with 48 additions and 61 deletions.
109 changes: 48 additions & 61 deletions proxyclient/experiments/aop.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@

from m1n1.setup import *
from m1n1.shell import run_shell
from m1n1.hw.dart import DART, DARTRegs
from m1n1.hw.dart import DART
from m1n1.fw.asc import StandardASC, ASCDummyEndpoint
from m1n1.fw.asc.base import *
from m1n1.fw.aop import *
from m1n1.fw.aop.ipc import *
from m1n1.fw.afk.rbep import *
from m1n1.fw.afk.epic import *

w32 = p.write32
r32 = p.read32

# Set up a secondary proxy channel so that we can stream
# the microphone samples
p.usb_iodev_vuart_setup(p.iodev_whoami())
p.iodev_set_usage(IODEV.USB_VUART, USAGE.UARTPROXY)

p.pmgr_adt_clocks_enable("/arm-io/aop")
p.pmgr_adt_clocks_enable("/arm-io/dart-aop")

adt_dc = u.adt["/arm-io/aop/iop-aop-nub/aop-audio/dc-2400000"]
Expand Down Expand Up @@ -72,6 +76,7 @@ class AFKEP_Hello_Ack(AFKEPMessage):

class EPICEndpoint(AFKRingBufEndpoint):
BUFSIZE = 0x1000
VERBOSE = True

def __init__(self, *args, **kwargs):
self.seq = 0x0
Expand Down Expand Up @@ -168,32 +173,6 @@ def roundtrip(self, call, chan=0x1000000d, timeout=0.3,

return call

class SPUAppEndpoint(EPICEndpoint):
SHORT = "SPUAppep"

class AccelEndpoint(EPICEndpoint):
SHORT = "accelep"

class GyroEndpoint(EPICEndpoint):
SHORT = "gyroep"

class UNK23Endpoint(EPICEndpoint):
SHORT = "unk23ep"

class LASEndpoint(EPICEndpoint):
SHORT = "lasep"
#VERBOSE = True # <--- uncomment to see lid angle measurements

class WakehintEndpoint(EPICEndpoint):
SHORT = "wakehintep"

class UNK26Endpoint(EPICEndpoint):
SHORT = "unk26ep"

class AudioEndpoint(EPICEndpoint):
SHORT = "audioep"


class OSLogMessage(Register64):
TYPE = 63, 56

Expand All @@ -218,76 +197,84 @@ def Init(self, msg):
return True


class SPUEndpoint(EPICEndpoint): # SPUApp.t / i2c.pp.t
SHORT = "spuep"

class AccelEndpoint(EPICEndpoint):
SHORT = "accelep"

class GyroEndpoint(EPICEndpoint):
SHORT = "gyroep"

class LASEndpoint(EPICEndpoint): # als.hint
SHORT = "lasep"
VERBOSE = True # <--- uncomment to see lid angle measurements # are we sure it's LAS not ALS?

class WakehintEndpoint(EPICEndpoint):
SHORT = "wakehintep"

class UNK26Endpoint(EPICEndpoint):
SHORT = "unk26ep"

class AudioEndpoint(EPICEndpoint):
SHORT = "audioep"

class VoiceTriggerEndpoint(EPICEndpoint): # aop-voicetrigger
SHORT = "voicetriggerep"


class AOPClient(StandardASC, AOPBase):
ENDPOINTS = {
8: AOPOSLogEndpoint,

0x20: SPUAppEndpoint,
0x8: AOPOSLogEndpoint,
0x20: SPUEndpoint,
0x21: AccelEndpoint,
0x22: GyroEndpoint,
0x23: UNK23Endpoint,
#0x23: UNK23Endpoint,
0x24: LASEndpoint,
0x25: WakehintEndpoint,
0x26: UNK26Endpoint,
0x27: AudioEndpoint,
0x28: EPICEndpoint,
0x29: EPICEndpoint,
0x2a: EPICEndpoint,
0x2b: EPICEndpoint
0x28: VoiceTriggerEndpoint,
}

def __init__(self, u, adtpath, dart=None):
node = u.adt[adtpath]
self.base = node.get_reg(0)[0]

AOPBase.__init__(self, u, node)
super().__init__(u, self.base, dart)

p.dapf_init_all()

dart = DART.from_adt(u, "/arm-io/dart-aop", iova_range=(0x2c000, 0x10_000_000))
dart.initialize()
dart.regs.TCR[0].set(BYPASS_DAPF=0, BYPASS_DART=0, TRANSLATE_ENABLE=1)
dart.regs.TCR[7].set(BYPASS_DAPF=0, BYPASS_DART=0, TRANSLATE_ENABLE=1)
dart.regs.TCR[15].val = 0x20100

aop = AOPClient(u, "/arm-io/aop", dart)

aop.update_bootargs({
'p0CE': 0x20000,
# 'laCn': 0x0,
# 'tPOA': 0x1,
'laCn': 0x0,
'tPOA': 0x1,
"gila": 0x80,
})

aop.verbose = 4

def set_aop_audio_pstate(devid, pstate):
audep.roundtrip(SetDeviceProp(
devid=devid,
modifier=202,
data=Container(
devid=devid,
cookie=1,
target_pstate=pstate,
unk2=1,
)
)).check_retcode()
p.dapf_init_all()
w32(0x24a408114, 0x20001) # OUTBOX_CTRL

try:
aop.boot()
for epno in range(0x20, 0x2c):
for epno in [0x20, 0x21, 0x22]: # must be started before aop asc boots
aop.start_ep(epno)
w32(0x24a400044, 0x10) # CPU_CONTROL (RUN=1); aop.start()
for epno in [0x0, 0x1, 0x2, 0x4, 0x8, # must start after asc boot except 0x8
0x24, 0x25, 0x26, 0x27, 0x28]:
aop.start_ep(epno)
aop.asc.dump_regs()

timeout = 10
timeout = 5
while (not aop.audioep.ready) and timeout:
aop.work_for(0.1)
timeout -= 1

if not timeout:
raise Exception("Timed out waiting on audio endpoint")

print("Finished boot")

audep = aop.audioep

audep.roundtrip(AttachDevice(devid='pdm0')).check_retcode()
Expand Down

0 comments on commit a46d023

Please sign in to comment.