From patchwork Thu Jun 8 19:56:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 1792568 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=F2tzoYQp; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QcZjt4Yj2z20QH for ; Fri, 9 Jun 2023 05:57:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D539C8598A; Thu, 8 Jun 2023 21:56:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="F2tzoYQp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C4D8F8582C; Thu, 8 Jun 2023 21:56:49 +0200 (CEST) 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,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 E1E018598A for ; Thu, 8 Jun 2023 21:56:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=cfsworks@gmail.com Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-777a78739ccso50687439f.3 for ; Thu, 08 Jun 2023 12:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686254204; x=1688846204; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D7w94SVsyT16TWCuJUtlnb37YIBoY3zYlWBiie8dC9g=; b=F2tzoYQpu5550TliFshe27o272CQTTgGmWqfv7QYSpzCo0oEJy7QHKYewAdqbXUlU9 OETOXXcGApB+OruSp/VfBnomCd921bd/Aa6Ctm6d87uETuhHbl51AxI6gZtAviAZ7CfL y2Rw2YE4y2TMSQKt7p2IVB/puxs3RWaYUv0rqv3ncLDHT31o3lKD2lR+GPHt7Xd9Nr1k Onx56/CbnpP+BWM46UoBOaoTAwAAo2zjnAn9j7ELVJnF4ZC/z1XZS6yligMEqw4N92Ta V4DZT+Shd6zWHrO+vD8m7bzxaFBXa9KigNgmdnGglULkyAC+NNDHeQ4bU5ZaWfE3gj7N 4SgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686254204; x=1688846204; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D7w94SVsyT16TWCuJUtlnb37YIBoY3zYlWBiie8dC9g=; b=a/yySGRN161t7nbdZg+uLUSe0EuM+417rxXTdusy6kkZ4zWIyz4vyr6p6g3FOE8cmK 9hjjm1IrSCDgLb8dhgcqIGbpe4Fdy40aXUcy4JLc5zv3oZ6CpFBnWLm+bYDRbheHrxnK TNI5Pcwqe2ELsY8AM6ZztXwGADSPKwT7lQ61BdOcbBPa9MWG9XqjQDtJVyNInmfYwS1f fSJdtoe50TFeVoX1RMjD9IHYqrmPeXX3kYpvXWeYyVDzxC/kiUq6PLiNtxO+ZqkZtHtZ fDxEmozut9cyxNY0qnlKpvUzCWnxGurCCpfFuVMfSudJ9oOBUDO465qZ6jmLJ4t7LYh5 YJeg== X-Gm-Message-State: AC+VfDxvsGm844L11qgPdatpVIqBOxy4uslOuJN7rsYbACyNQLwxvKES NurZPO+h/P1X9pRkcbU44FWM9bWhCSknPo9d X-Google-Smtp-Source: ACHHUZ4J2MJfmTT8EOMqa3S7LExRubJLvaI9rvOVEE1nvC6+oMsjqHw06d2zzUXYZ35YRUqpmXnchQ== X-Received: by 2002:a5e:a611:0:b0:777:a970:b382 with SMTP id q17-20020a5ea611000000b00777a970b382mr13436045ioi.18.1686254204224; Thu, 08 Jun 2023 12:56:44 -0700 (PDT) Received: from celestia.nettie.lan ([2001:470:42c4:101:48b2:a45a:f2d2:c155]) by smtp.gmail.com with ESMTPSA id d16-20020a6b6e10000000b0077acb3225e0sm573874ioh.7.2023.06.08.12.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:56:43 -0700 (PDT) From: Sam Edwards X-Google-Original-From: Sam Edwards To: u-boot@lists.denx.de Cc: Andre Przywara , Jagan Teki , Marek Vasut , Sam Edwards Subject: [PATCH v2 1/2] usb: musb-new: sunxi: remove unwanted printfs Date: Thu, 8 Jun 2023 13:56:30 -0600 Message-Id: <20230608195631.55364-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230608195631.55364-1-CFSworks@gmail.com> References: <20230608195631.55364-1-CFSworks@gmail.com> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Per Marek's feedback, unconditional printfs in the probe function of this USB controller driver should be removed. This patch also slightly tidies up the return path, in preparation for DM support. Signed-off-by: Sam Edwards Cc: Marek Vasut --- drivers/usb/musb-new/sunxi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index c1c0087f7d..510b254f7d 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -494,19 +494,15 @@ static int musb_usb_probe(struct udevice *dev) if (!host->host) return -EIO; - ret = musb_lowlevel_init(host); - if (!ret) - printf("Allwinner mUSB OTG (Host)\n"); + return musb_lowlevel_init(host); #else pdata.mode = MUSB_PERIPHERAL; host->host = musb_register(&pdata, &glue->dev, base); if (IS_ERR_OR_NULL(host->host)) return -EIO; - printf("Allwinner mUSB OTG (Peripheral)\n"); + return 0; #endif - - return ret; } static int musb_usb_remove(struct udevice *dev) From patchwork Thu Jun 8 19:56:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Edwards X-Patchwork-Id: 1792570 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=JrD2MfzL; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QcZk75TRmz20X9 for ; Fri, 9 Jun 2023 05:57:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8345A860C3; Thu, 8 Jun 2023 21:56:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="JrD2MfzL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BC068598A; Thu, 8 Jun 2023 21:56:50 +0200 (CEST) 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,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) (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 88E36860BC for ; Thu, 8 Jun 2023 21:56:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=cfsworks@gmail.com Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-77865f63473so46809339f.3 for ; Thu, 08 Jun 2023 12:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686254205; x=1688846205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ogS0Rf1QlsoWiazbleDDuN4Zdbc7DUKEqVQDO/iRis4=; b=JrD2MfzLAPiXSwEekDa7gYlYcy8pwLZ2BLWxNRjq1n04Y74PVqPeLeBv08ZiL9lDm+ itTyrLeGOr2CgAonG4fMeAtr6tQPOaZKEAGPOBEoyQ8DkfiGgGby/tJ3VfMTfTDCFsBj He0X1SjmWZk1KsHFqqYhEbFTgAaMmajc6HovsUVOro8oU4To1MB6wG1fq4+NL1YS/dUT MyJgyUNG85Ak9zzXpjEP1fjUXR/c2UNJo5LDkYFFT1a6OgGMyPc43mDTIcAzGGVOCOv+ 16C4mlYvWjqnGvLTT8HU9p7Vv3sbGeGFaqCtpsqY5LugjFHh6GYEM8XD3IKdWMvdT++X H4XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686254205; x=1688846205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ogS0Rf1QlsoWiazbleDDuN4Zdbc7DUKEqVQDO/iRis4=; b=kCN2WM2RmVjdFyvDIYtbYcaKvOV8ASBIaxWO+GLkd/5XbjK8/KS7ab4FUZQlw/KNlv n/TdBsLuCfrjJNwjcj7K9VN9ZlATgjOGcA5OH150VzeYWSmXOXV4rD6ehDZc9ni8FtIx SPH5Io9in7Ks29KnbdqkqAVEwLgPBCzX63X/tA/yuBt9Vc5/de9NyUQcyMkeTytd8QJJ Eqx43cyOEXpn0qy/RbL+r98lEu/2q9lW2QuyyLugValZIat3Jt1XVnH2YkZEUi207udA OzWHBjb1LkZtZDTEJ+/CxOd7/9t8MnY/pejcN+o+BFVrknoOAZsIrcf1DchO3O3/zrtl YGow== X-Gm-Message-State: AC+VfDw+PTFffWJ/oohECkJQyKpfX1hbfJybnh4ZJTqT1mWAygK47KlC mSHISwyEF2++s4EotKfpU4sba4xBS5pUTr5k X-Google-Smtp-Source: ACHHUZ6cZ1Unc1eRl27qgSXJ6ngUN5k5v5iiLuEn59agxCBPZ/x+EQrH23TLrr4zyUCh/OKg9QKrnQ== X-Received: by 2002:a6b:d818:0:b0:774:9af9:f45e with SMTP id y24-20020a6bd818000000b007749af9f45emr9612116iob.11.1686254205000; Thu, 08 Jun 2023 12:56:45 -0700 (PDT) Received: from celestia.nettie.lan ([2001:470:42c4:101:48b2:a45a:f2d2:c155]) by smtp.gmail.com with ESMTPSA id d16-20020a6b6e10000000b0077acb3225e0sm573874ioh.7.2023.06.08.12.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 12:56:44 -0700 (PDT) From: Sam Edwards X-Google-Original-From: Sam Edwards To: u-boot@lists.denx.de Cc: Andre Przywara , Jagan Teki , Marek Vasut , Sam Edwards Subject: [PATCH v2 2/2] usb: musb-new: sunxi: make compatible with UDC/DM gadget model Date: Thu, 8 Jun 2023 13:56:31 -0600 Message-Id: <20230608195631.55364-3-CFSworks@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230608195631.55364-1-CFSworks@gmail.com> References: <20230608195631.55364-1-CFSworks@gmail.com> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Since many sunxi boards do not implement a `board_usb_init`, it's better if we just make the sunxi USB driver compatible with the DM gadget model, as many other musb-new variants already are. This change has been verified working on a T113s. Signed-off-by: Sam Edwards --- drivers/usb/musb-new/sunxi.c | 50 +++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 510b254f7d..6658cd995d 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -444,6 +444,16 @@ static struct musb_hdrc_config musb_config_h3 = { .ram_bits = SUNXI_MUSB_RAM_BITS, }; +#if CONFIG_IS_ENABLED(DM_USB_GADGET) +int dm_usb_gadget_handle_interrupts(struct udevice *dev) { + struct sunxi_glue *glue = dev_get_priv(dev); + struct musb_host_data *host = &glue->mdata; + + host->host->isr(0, host->host); + return 0; +} +#endif + static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); @@ -452,10 +462,6 @@ static int musb_usb_probe(struct udevice *dev) void *base = dev_read_addr_ptr(dev); int ret; -#ifdef CONFIG_USB_MUSB_HOST - struct usb_bus_priv *priv = dev_get_uclass_priv(dev); -#endif - if (!base) return -EINVAL; @@ -486,23 +492,31 @@ static int musb_usb_probe(struct udevice *dev) pdata.platform_ops = &sunxi_musb_ops; pdata.config = glue->cfg->config; -#ifdef CONFIG_USB_MUSB_HOST - priv->desc_before_addr = true; + if (IS_ENABLED(CONFIG_USB_MUSB_HOST)) { + struct usb_bus_priv *priv = dev_get_uclass_priv(dev); + priv->desc_before_addr = true; - pdata.mode = MUSB_HOST; - host->host = musb_init_controller(&pdata, &glue->dev, base); - if (!host->host) - return -EIO; + pdata.mode = MUSB_HOST; + host->host = musb_init_controller(&pdata, &glue->dev, base); + if (!host->host) + return -EIO; - return musb_lowlevel_init(host); -#else - pdata.mode = MUSB_PERIPHERAL; - host->host = musb_register(&pdata, &glue->dev, base); - if (IS_ERR_OR_NULL(host->host)) - return -EIO; + return musb_lowlevel_init(host); + } else if (CONFIG_IS_ENABLED(DM_USB_GADGET)) { + pdata.mode = MUSB_PERIPHERAL; + host->host = musb_init_controller(&pdata, &glue->dev, base); + if (!host->host) + return -EIO; - return 0; -#endif + return usb_add_gadget_udc(&glue->dev, &host->host->g); + } else { + pdata.mode = MUSB_PERIPHERAL; + host->host = musb_register(&pdata, &glue->dev, base); + if (IS_ERR_OR_NULL(host->host)) + return -EIO; + + return 0; + } } static int musb_usb_remove(struct udevice *dev)