From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52EEFC433F5 for ; Mon, 27 Sep 2021 20:15:41 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6DE3D60EC0 for ; Mon, 27 Sep 2021 20:15:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6DE3D60EC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92DFF82BE5; Mon, 27 Sep 2021 22:15:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ESTKp8dP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 800A382DA7; Mon, 27 Sep 2021 22:15:17 +0200 (CEST) Received: from mail-vk1-xa30.google.com (mail-vk1-xa30.google.com [IPv6:2607:f8b0:4864:20::a30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5993582952 for ; Mon, 27 Sep 2021 22:15:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-vk1-xa30.google.com with SMTP id t186so7508758vkd.3 for ; Mon, 27 Sep 2021 13:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MmDMXIi0rg4q7fEL+Ia2NfcjB9h+X3LjcluBhuex07s=; b=ESTKp8dPUbS7E/yCkEBfTN+32Wjml+GD+N5Wkmm/0G2N0vW1HuOfhSppVf+VaX67ku YLU8d+JwN3LY8GTwAuwO1RrcLszr3sD+4EKmkWp/Is/1M0/k5IlISg/3qLROrWqx7SUU OcjWYFYi+E/4ueKoNzP/Pr7+67bKAPMnYcsgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MmDMXIi0rg4q7fEL+Ia2NfcjB9h+X3LjcluBhuex07s=; b=asXioLxo4bST8apJmldPMOMGlosx2vgdeIqmkmxRy2SDWd9vofTAsCbRqVqUnnLmV4 Pn0WoV0SHh0JZyv0w4EmgDGQgx6rcZUSi/1wCAj3OjP9e7vXmuaWjOIvsZef2xcakZPL Xd8poVw00jW4U7IWxYmctSi9n1hxmHDGb7hzciR0OkGTwSSJK6C9UENss757GKDO5ltC XfZ4H0URZpGIgWamTO/ImDBNpdHz4Qw1UR9eMjFsDMqBa+/qT2kVqPZ/P1pDUzsO6lU/ QmBxE0JDY5gs/c1apnL9MrzpPeTuLmQevHhE7MEEJDynFpDc5wX06labl53JNhujIqb3 DL2g== X-Gm-Message-State: AOAM530KOyAJhOTWBxi2NkepvtpEWjytVUQNZxUiP0tRNfZF3UPzfzsR ro60RkWWVGEZYalBOk2x3jc3QmhMTPklbgs1FQwCjQ== X-Google-Smtp-Source: ABdhPJx7dBSwbckhFpWxXPgeM0bOJULsu77GNcU0MyKd19Y/m6IYNibmx8ua7F+ehyAWuCZaGdM4Lgh5WfyOuTJD0JE= X-Received: by 2002:a1f:1841:: with SMTP id 62mr2109185vky.26.1632773705388; Mon, 27 Sep 2021 13:15:05 -0700 (PDT) MIME-Version: 1.0 References: <20210918135437.36667-1-kettenis@openbsd.org> <20210918135437.36667-4-kettenis@openbsd.org> <56146d936d16f96c@bloch.sibelius.xs4all.nl> <561488006734eda7@bloch.sibelius.xs4all.nl> In-Reply-To: <561488006734eda7@bloch.sibelius.xs4all.nl> From: Simon Glass Date: Mon, 27 Sep 2021 14:14:54 -0600 Message-ID: Subject: Re: [PATCH 3/5] misc: Add Apple DART driver To: Mark Kettenis Cc: Mark Kettenis , U-Boot Mailing List , Oliver Graute , Stephan Gerhold , Masami Hiramatsu , Priyanka Jain , Leo Liang , Padmarao Begari , Michael Walle , Kishon Vijay Abraham I , Heinrich Schuchardt , Bin Meng , Asherah Connor , Michal Simek , Wasim Khan , Heiko Schocher , Igor Opaniuk , Ye Li , Stefan Roese , AKASHI Takahiro , Weijie Gao , Vabhav Sharma , Andy Shevchenko , Pratyush Yadav Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Mark, On Sun, 26 Sept 2021 at 14:53, Mark Kettenis wrote: > > > From: Simon Glass > > 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