MCPcopy Create free account
hub / github.com/tinygrad/tinygrad / __init__

Method __init__

tinygrad/runtime/support/usb.py:191–207  ·  view source on GitHub ↗
(self, usb:USB3|None=None)

Source from the content-addressed store, hash-verified

189
190class CustomASM24Controller:
191 def __init__(self, usb:USB3|None=None):
192 if not usb:
193 devs = USB3.list_devices(0xADD1, 0x0001)
194 assert len(devs), "no ASM24 controller found"
195 self.usb = USB3(devs[0][0], 0x81, 0x83, 0x02, 0x04, use_bot=True)
196 else: self.usb = usb
197 self._pci_cacheable: list[tuple[int, int]] = []
198 self._pci_cache: dict[int, int|None] = {}
199
200 self._f0_out_buf, self._f0_out_mv = alloc_cbuffer(0x1000) # for f0 and e4, allocate big enough for e4
201 self._f0_in_buf, _ = alloc_cbuffer(8)
202
203 # Custom firmware now boots with PCIe off. Power it on before probing the link.
204 ltssm = self.read(0xB450, 1)[0]
205 if ltssm != 0x78: self.set_pcie_power(True)
206 ltssm = self.read(0xB450, 1)[0]
207 if ltssm != 0x78: raise RuntimeError(f"PCIe link not up (LTSSM=0x{ltssm:02X}), custom firmware not ready")
208
209 def set_pcie_power(self, enabled:bool, timeout:int=10000):
210 checked(libusb.libusb_control_transfer,

Callers

nothing calls this directly

Calls 5

readMethod · 0.95
set_pcie_powerMethod · 0.95
USB3Class · 0.90
alloc_cbufferFunction · 0.85
list_devicesMethod · 0.45

Tested by

no test coverage detected