From patchwork Tue Jan 17 09:11:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 643396 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1050370pvb; Tue, 17 Jan 2023 01:12:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXtivhe/InxrR49JDNZcF1GJhDdDpVE10rur4reUG4MymRodAGtPsj/eMpqy6qDtlmY9v9CW X-Received: by 2002:aca:41c5:0:b0:365:3e3:c8d6 with SMTP id o188-20020aca41c5000000b0036503e3c8d6mr845639oia.9.1673946735311; Tue, 17 Jan 2023 01:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673946735; cv=none; d=google.com; s=arc-20160816; b=0a4jQTDhfrYDx6FVcEZQsDtZhH5iILaQmUbqeOxZW7IRsyzI2LacFt3Ab55VLLf22x 4uXc0ozkSIKcGPt2VmTEPhAs24he+Tjn8DJSDU1FHZl1Xs+47Z9Vz+3wRuv1G5jAyxF6 VWwFzpcJ+H5hd6Y8P369JAMBlgwilljVxHuxpvxBcpO9Xirsg6q9AMJnLgW/N2D0nJ7t jIc/GjwGvSFL1lGQJyYV8idS/a30RUkb6ktmJLtIB7oBNmvvgUoCNF/+mMl0xo2o6J04 jFR6FWjrIsg+WcuI5vlE8PDDT6QUVvi/j08WnForGnLTqTs+99Evs9Y0Qo/jcGeH8BaY yMbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=5eDO8coD4YDnAYZyi8dwFLbs2H58cSViybgQ0P3IFyQ=; b=Rjsd4XUMb0PLLKC/i1L39B5Qolg2GVARljRcLVpCsY51a+6LWCgFX1BEe7QLOd9VK6 HQHMaL5pXIlW7c8Ac+ZbYtb/wg0TAt2Vt4nLhJ+4yMrm7mWgMzXs7z1e8rQu/1QrWjxa g0LAoiemqoS1zd0HK5Eg1LQWb6SSzfOF4Rgwm8MAVImOwXQyXNRqRO59j8yU7NWczCFb aV9qWtkRG78n12KMmeKXrXcZgLdNjXp2KxFi/mjP2fnBvU1YadX2RAK6Pg2wdR5nYBSL q0gcxwH3vedB3/coV2lAiSSxbr4EO8ClAl6xSsuJ/26MtcHetPNy8vaX6v+cY4zitb9O w8mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o0S1gx3o; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id h64-20020aca3a43000000b00364550964f9si12949083oia.259.2023.01.17.01.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 01:12:15 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o0S1gx3o; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CFFAC85527; Tue, 17 Jan 2023 10:11:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="o0S1gx3o"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B327381BBF; Tue, 17 Jan 2023 10:11:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (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 F237D8555D for ; Tue, 17 Jan 2023 10:11:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x336.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so20465830wma.1 for ; Tue, 17 Jan 2023 01:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5eDO8coD4YDnAYZyi8dwFLbs2H58cSViybgQ0P3IFyQ=; b=o0S1gx3oBv3Mi9H5rDrMVYzHcVq5bJehpHmQUx2UGepHVLI56GLHIGLJtPMwxu3CJJ N2GvkQbbZepBaIlrh9OH/IyQ3cGGgmqSs/QW9jLknCu4ECBWZVx3V8kBKsfQYDfkDiPM 4lDy74G8dO9dgihPRsVvDHGtTCyHnkMb+rI64SIRSVia9G28PbgT/HUlUXrNsGVknGKL xeKG+aOxNCnpA4Em8i2PDUkGIvAWufYAMl72Ugxwg34vwdcpR6LzWkjFBchGy2KErXQV H1/hAQ/WkZv5/x1q+nstKbkPNmI/1MXMa4a8EsDPvD4Zk/T2QDIJdlDGCLXQXDOplRGF 8lJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5eDO8coD4YDnAYZyi8dwFLbs2H58cSViybgQ0P3IFyQ=; b=U3tw7lcmR7hmYBDLhGFgxmip98wp1m+aW2YXKH7CRiTqGDLjiPmEBRlypBINRaeWy7 p0fpav4mBJhgSt3NwgjhCORDFIpOF62gtcHBN4P9gMo3zfPLELV2/CxDFZK+UpM+mnBp NePwNl3mEysszA/U80ijn5ftvIId3lS92QfgVgeKzF59tQhGSZkeek/pj/ehERafqiC8 qWKm34UelOx5Kt5USxKhEESzq275ZWHpt62LcRJUKLL1BxmjR9BH9f+l6xUDl0KYjzQ5 3EhvQ4FrLriXegmWvN+zPHkBheRFThJGk5T2XQmMyWVpfCPXv8fw0V+rxn0DpWZQRNIa U5LQ== X-Gm-Message-State: AFqh2ko2BhhMxk2iiyHY0HULNAlaPbhP+Mle12pTOYrxPX1vKl1qW0HJ DGcC8S/EIlx764TTvkmmUNTQzPvGELy82zQO X-Received: by 2002:a05:600c:1c02:b0:3d2:3b8d:21e5 with SMTP id j2-20020a05600c1c0200b003d23b8d21e5mr2304367wms.14.1673946709535; Tue, 17 Jan 2023 01:11:49 -0800 (PST) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id u21-20020a7bc055000000b003d9aa76dc6asm47969334wmc.0.2023.01.17.01.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 01:11:49 -0800 (PST) From: Neil Armstrong Date: Tue, 17 Jan 2023 10:11:45 +0100 Subject: [PATCH 1/2] usb: dwc3-meson-gxl: force mode on child add/removal MIME-Version: 1.0 Message-Id: <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> In-Reply-To: <20230117-u-boot-usb-gxl-otg-dm-v1-0-2853f6d75b06@linaro.org> To: Marek Vasut , Vyacheslav Bocharov Cc: u-boot-amlogic@groups.io, u-boot@lists.denx.de, Mattijs Korpershoek , Neil Armstrong X-Mailer: b4 0.11.1 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 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 Reviewed-by: Mattijs Korpershoek Reviewed-by: Marek Vasut --- 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), };