Hi Mark, On Sun, 26 Sept 2021 at 14:53, Mark Kettenis <mark.kette...@xs4all.nl> wrote: > > > From: Simon Glass <s...@chromium.org> > > Date: Mon, 20 Sep 2021 19:11:25 -0600 > > Hi Simon, > > > [..] > > > > > > > +static int apple_dart_bind(struct udevice *dev) > > > > > +{ > > > > > + void *base; > > > > > + int sid, i; > > > > > + > > > > > + base = dev_read_addr_ptr(dev); > > > > > + if (!base) > > > > > + return -EINVAL; > > > > > + > > > > > + u32 params2 = readl(base + DART_PARAMS2); > > > > > + if (params2 & DART_PARAMS2_BYPASS_SUPPORT) { > > > > > + for (sid = 0; sid < 16; sid++) { > > > > > + writel(DART_TCR_BYPASS_DART | > > > > > DART_TCR_BYPASS_DAPF, > > > > > + base + DART_TCR(sid)); > > > > > + for (i = 0; i < 4; i++) > > > > > + writel(0, base + DART_TTBR(sid, i)); > > > > > + } > > > > > + } > > > > > > > > Not allowed hardware access in bind(). Can this more to probe() ? > > > > > > Well, I need to make sure that this happens before other drivers get > > > probed (in particular the xhci-dwc3 driver). Is there a better > > > mechanism to achieve that? > > > > If those drivers have something in the DT indicating that they need > > this, then you can add a uclass_get_device_by_phandle() in those > > drivers. > > Yes, there is an "iommus" property that points at the IOMMU. This is > a standard property and I think it would make sense to have the core > device probing code handle it in a way similar to how "power-domains" > is handled. That way we don't have to add IOMMU hooks into each and > every driver.
OK. > > > If not, then you can probe all the DART devices with uclass_probe_all(). > > > > Having said that, I see you are using UCLASS_MISC. I suspect this > > should have its own UCLASS_IOMMU. > > So here is a proof-of-concept diff to add UCLASS_IOMMU. This > deliberately does not yet introduce driver ops yet; coming up with > something sensible there needs a bit more thought. For USB support > all I need is for the probe function to put the IOMMU in bypass mode, > so that is what's implemented here. > > Does this look reasonable? I'll split this up eventually into a > commit that adds UCLASS_IOMMU and a commit that adds the apple_dart > driver. Yes from a quick look. Remember for the IOMMU uclass to add a sandbox test, even though for now it will only probe the driver since there are no ops. Also you don't need the #if in iommu-uclass.c as the linked will garbage-collect it. Regards, Simon