"""Find a VALID SwI2cRequest that the SMU accepts, before testing NumCmds bounds. Driver builds: port=1, speed=I2C_SPEED_FAST_400K(2), cmds[0]|=RESTART, cmds[n-1]|=STOP. READ commands only (READWRITE bit clear) -> nothing is written to any device. """ import time, struct from tinygrad import Device import tinygrad.runtime.autogen.am.smu_13_0_0 as smu d=Device["AMD"]; adev=d.iface.dev_impl TP=adev.smu.driver_table_paddr; SIZE=116 MSG=adev.mmMP1_SMN_C2PMSG_66; ARG=adev.mmMP1_SMN_C2PMSG_82; RESP=adev.mmMP1_SMN_C2PMSG_90 N={0:'BUSY',1:'OK',0xFF:'FAILED',0xFE:'UNKNOWN',0xFD:'BAD_PREREQ',0xFC:'REJ_BUSY',0xFB:'REJ_PREREQ'} def send(msg,param=0,tmo=2.0): RESP.write(0); ARG.write(param&0xffffffff); MSG.write(msg) t0=time.monotonic() while time.monotonic()-t00: b[5]|=RESTART b[5+2*(eff-1)]|=STOP for off in range(52,SIZE): b[off]=0xCC return bytes(b) print("=== find an accepted SwI2cRequest (READ cmds, no device writes) ===") for port in (0,1): for speed in (1,2): for slave in (0x50,0xA0,0x18): wr(build(2,port,speed,slave)) r,ms=send(smu.PPSMC_MSG_TransferTableDram2Smu,9) print(" port=%d speed=%d slave=%#04x n=2 -> %-8s %5.1fms"%(port,speed,slave,r,ms)) print() print("MEMSIZE:",hex(adev.rreg(0xde3)))