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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DB8C9C3DA78 for ; Tue, 17 Jan 2023 09:43:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20D3A850CC; Tue, 17 Jan 2023 10:43:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="07S/KP1m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC6EB83E5D; Tue, 17 Jan 2023 10:43:23 +0100 (CET) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (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 182A0850CC for ; Tue, 17 Jan 2023 10:43:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mkorpershoek@baylibre.com Received: by mail-wr1-x42b.google.com with SMTP id b7so3946951wrt.3 for ; Tue, 17 Jan 2023 01:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=DH1nIgiRCOR4y1RKzEzTfXVa13g1IH+s/b48+91yyhs=; b=07S/KP1m9L8Xa9L4UfuKBPzprhsETyywOQwMlz1535JsyGDIhEIalxQMptEMpoQMX1 QseSka8/jBvGTBmyZKeP/XawhQwPrSGo2yg3417IE3i2Od39b8tGiPiJl4sthE/28nTi pw4AcyhSW/lwZYwxkymYZBimL5U7NHkefQtOl9h2/3eGktqSW0AJyC8rLBDCh3S/d89o m+0+zFJzqckgesxL0/LKzooF4e1647QgjzZ7kdVzuUBU41a90OaJWf82TPvSsTOfY40L GNc310pA0xeMDmJ6wCAoBvdNU2CIoevJpVZeeRtbzJu5PuBIa1sxocpzlNMufAOy2X35 O8Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DH1nIgiRCOR4y1RKzEzTfXVa13g1IH+s/b48+91yyhs=; b=6FqkDx4/x+bybUaOMY8dZaBubIZQvUcLpa+j4SXGjgOfntSdm6PiBLr2n7ZubP6z2z GFJRUz3xf1AHAj5W25K5MnqywHWLydDo8Nsp7WXiCyI2MZk3shf6k0cYbUU8AmdvU/qg +c53yg6xminzCXtKUYs9tT9iFQtNbyakykyGsACsjoLqPgTFbxLINZnv3XNYsxxvTIFk c9B8W2JATC6DQnas6Ki0KnQM7am/ZLhpsI5zuWMqIALQqXJ5QIdXMr7YB/0pDNohYyys aiQ9cysThQpeTg5GJ55WbJ+6IaMFgZvFdEcPNmgm3lnwkydHC35s7J1nA7MfF14quTap VAuQ== X-Gm-Message-State: AFqh2kpAgJxTXfeOEPXQcNIU54M7aqM+OvGo+68aW1Qrhwv+ZilN0l21 uhlNFhsUsCt6r32l9sQLSmwhfw== X-Google-Smtp-Source: AMrXdXsc7seZqiy6k8FtepKpaklsWKb+EAOUxgaodD+IL7oLQiDPX9AHhYFXSGCOXr+gChprLj/+Gg== X-Received: by 2002:adf:b604:0:b0:2bd:f35f:1b5e with SMTP id f4-20020adfb604000000b002bdf35f1b5emr2571480wre.4.1673948599387; Tue, 17 Jan 2023 01:43:19 -0800 (PST) Received: from localhost ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id bu3-20020a056000078300b002bbe7efd88csm23642939wrb.41.2023.01.17.01.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 01:43:19 -0800 (PST) From: Mattijs Korpershoek To: Neil Armstrong , Marek Vasut , Vyacheslav Bocharov Cc: u-boot-amlogic@groups.io, u-boot@lists.denx.de, Neil Armstrong Subject: Re: [PATCH 1/2] usb: dwc3-meson-gxl: force mode on child add/removal In-Reply-To: <20230117-u-boot-usb-gxl-otg-dm-v1-1-2853f6d75b06@linaro.org> References: <20230117-u-boot-usb-gxl-otg-dm-v1-0-2853f6d75b06@linaro.org> <20230117-u-boot-usb-gxl-otg-dm-v1-1-2853f6d75b06@linaro.org> Date: Tue, 17 Jan 2023 10:43:17 +0100 Message-ID: <87tu0pmr7u.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean On Tue, Jan 17, 2023 at 10:11, Neil Armstrong wrote: > arch/mach-meson has some custom usb logic, in particular: > * on board_usb_init(), we force USB_DR_MODE_PERIPHERAL > * on board_usb_cleanup(), we force USB_DR_MODE_HOST > > With DM_USB_GADGET=y, board_usb_init/cleanup() are no > longer used when we call usb_gadget_initialize(). > Instead, the generic (from udc-uclass) initialization/release is > called, which itself calls the controller driver's probe()/remove(). > > Therefore, enabling DM_USB_GADGET=y will mean that this mode > switching will break. > > To prepare for enabling DM_USB_GADGET, perform the mode switching > when the "amlogic,meson-g12a-usb" (dwc2) driver is > probed()/removed() instead. > > This is achieved via the glue driver, which gets notified each time one > of its children is probed()/removed. > > Note: this change should be harmless without DM_USB_GADGET=y > because the amlogic-g12a-usb driver is not probed via driver model. > > Thanks for Mattijs for the original work at [1]. > > [1] https://lore.kernel.org/all/20221024-meson-dm-usb-v1-1-2ab077a503b9@baylibre.com/ > > Signed-off-by: Neil Armstrong Thank you for mentioning me, I appreciate it. Reviewed-by: Mattijs Korpershoek > --- > drivers/usb/dwc3/dwc3-meson-gxl.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/usb/dwc3/dwc3-meson-gxl.c b/drivers/usb/dwc3/dwc3-meson-gxl.c > index 6c6d463203..d56f2747b6 100644 > --- a/drivers/usb/dwc3/dwc3-meson-gxl.c > +++ b/drivers/usb/dwc3/dwc3-meson-gxl.c > @@ -408,6 +408,22 @@ static int dwc3_meson_gxl_remove(struct udevice *dev) > return dm_scan_fdt_dev(dev); > } > > +static int dwc3_meson_gxl_child_pre_probe(struct udevice *dev) > +{ > + if (ofnode_device_is_compatible(dev_ofnode(dev), "amlogic,meson-g12a-usb")) > + return dwc3_meson_gxl_force_mode(dev->parent, USB_DR_MODE_PERIPHERAL); > + > + return 0; > +} > + > +static int dwc3_meson_gxl_child_post_remove(struct udevice *dev) > +{ > + if (ofnode_device_is_compatible(dev_ofnode(dev), "amlogic,meson-g12a-usb")) > + return dwc3_meson_gxl_force_mode(dev->parent, USB_DR_MODE_HOST); > + > + return 0; > +} > + > static const struct udevice_id dwc3_meson_gxl_ids[] = { > { .compatible = "amlogic,meson-axg-usb-ctrl" }, > { .compatible = "amlogic,meson-gxl-usb-ctrl" }, > @@ -421,6 +437,8 @@ U_BOOT_DRIVER(dwc3_generic_wrapper) = { > .of_match = dwc3_meson_gxl_ids, > .probe = dwc3_meson_gxl_probe, > .remove = dwc3_meson_gxl_remove, > + .child_pre_probe = dwc3_meson_gxl_child_pre_probe, > + .child_post_remove = dwc3_meson_gxl_child_post_remove, > .plat_auto = sizeof(struct dwc3_meson_gxl), > > }; > > -- > 2.34.1