From nobody Sun Apr 12 13:54:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E08FC54EBD for ; Tue, 3 Jan 2023 23:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238388AbjACXfe (ORCPT ); Tue, 3 Jan 2023 18:35:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237771AbjACXf0 (ORCPT ); Tue, 3 Jan 2023 18:35:26 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13EBD165A6 for ; Tue, 3 Jan 2023 15:35:25 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id m6so37598347lfj.11 for ; Tue, 03 Jan 2023 15:35:24 -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=INGl8EC4lutAaxK7oytOrepZPv62csf4zgf/Dha7g08=; b=tUh9Qclbxwes1y19TozU8R6/M6yFHt0Tf/7Uk9vnG8eT3MKTfnZ5FPazeKrWpGZ/Zs FDHCXMqufboxBhsvccZNg7j44bIL/+rNLP0e+70HxzbS67f4vUXHkOdA5Xu5FdYxlegb o9SYgd7W1epIDogWkpbLTzQihLn16sHKSZAXrU9AjO4LQV47d63ABNKdaa+4pNhBMVhG Rd9wRbiao8kN0AZQX6BTdOQxwrfmAhr00DTDe3ra1H410N6socCrzWGi30Sz09qMVa42 pJp1lr6X8SfBhq+IueeYNKSdxR/3/E5Z60dCUmMUcUZet97rlLEZYSY+kiS1oHAkmJky zDLQ== 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=INGl8EC4lutAaxK7oytOrepZPv62csf4zgf/Dha7g08=; b=2yV5Fa29Y2grpoP6pxZd5HwJx/2x8TuK6U21yPbp5zLjeZdjQg+59hD/RdMwEBWECh CCbs88JqWBP6Fu1sPguCmkJOLrpsncNhwO/YasJhRtnQzLlvoB7uMikR/OxRQEhhw8ya Thw+OxkCb3E3GfVw2KOXzCkYdZ6/tK2ZI4tfP6EM24/PUWmfnrmW5V4JJSC2arRGL7sv 16pqyASfqmyPpQN+TDHOmXitpMjxP599q6NhCOwPjWikE1cAkajtjcwgoVjjD02EEGcb 6PbUOIkx5YM2xEBOnVpxkSm0zlBXX/2ObjdcMTIxuowtasMONUHoSJ/76Iw4yE9mIXGq vebg== X-Gm-Message-State: AFqh2kro0pkIiBkTsbROFWydxrF5Q3wvmdOw7jjvxImvqHETWuTJowBU FEPt9IuRztGAy7lYCNsWv4Cvjw== X-Google-Smtp-Source: AMrXdXvAhYJCpYRkWDTIDmckimmTS2x6TV9+jF5DsOMDB10ivmTBIrIyYglIf0/N5/eHOWrkh4XH1g== X-Received: by 2002:a05:6512:3ca9:b0:4b5:61c5:8927 with SMTP id h41-20020a0565123ca900b004b561c58927mr14359517lfv.42.1672788923444; Tue, 03 Jan 2023 15:35:23 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020a056512070b00b004a45edc1de2sm4939801lfs.239.2023.01.03.15.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 15:35:22 -0800 (PST) From: Linus Walleij Date: Wed, 04 Jan 2023 00:35:17 +0100 Subject: [PATCH 1/7] dt-bindings: usb: Correct and extend FOTG210 schema MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-gemini-fotg210-usb-v1-1-f2670cb4a492@linaro.org> References: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Vogt , Linus Walleij X-Mailer: b4 0.11.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It turns out that this IP block exists in at least two incarnations: FOTG200 and FOTG210. The one in the Gemini is FOTG200, so add the variants and rectify the binding for Gemini. This affects things such as the placement of certain registers. It remains to be seen how similar this block is to the third USB block from Faraday, FUSB220. Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/usb/faraday,fotg210.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/faraday,fotg210.yaml b/D= ocumentation/devicetree/bindings/usb/faraday,fotg210.yaml index 84b3b69256b1..12d4fc742f20 100644 --- a/Documentation/devicetree/bindings/usb/faraday,fotg210.yaml +++ b/Documentation/devicetree/bindings/usb/faraday,fotg210.yaml @@ -5,7 +5,7 @@ $id: http://devicetree.org/schemas/usb/faraday,fotg210.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# =20 -title: Faraday Technology FOTG210 HS OTG USB 2.0 controller +title: Faraday Technology FOTG200 series HS OTG USB 2.0 controller Bindings =20 maintainers: - Linus Walleij @@ -17,10 +17,11 @@ allOf: properties: compatible: oneOf: + - const: faraday,fotg200 - const: faraday,fotg210 - items: - const: cortina,gemini-usb - - const: faraday,fotg210 + - const: faraday,fotg200 =20 reg: maxItems: 1 @@ -66,7 +67,7 @@ examples: #include #include usb0: usb@68000000 { - compatible =3D "cortina,gemini-usb", "faraday,fotg210"; + compatible =3D "cortina,gemini-usb", "faraday,fotg200"; reg =3D <0x68000000 0x1000>; interrupts =3D <10 IRQ_TYPE_LEVEL_HIGH>; resets =3D <&syscon GEMINI_RESET_USB0>; --=20 2.38.1 From nobody Sun Apr 12 13:54:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB82BC3DA7D for ; Tue, 3 Jan 2023 23:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238417AbjACXfi (ORCPT ); Tue, 3 Jan 2023 18:35:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237900AbjACXf1 (ORCPT ); Tue, 3 Jan 2023 18:35:27 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25C0713E3C for ; Tue, 3 Jan 2023 15:35:26 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id bt23so31316572lfb.5 for ; Tue, 03 Jan 2023 15:35:26 -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=Fm8GAHA4wHOZ6aH5j10PuHm5s/aZ6TljNeVHuGhMRwk=; b=QTSUiaPpbGJceQRcTqfXW+fhAp/0bRlZ9/jR1kVkMF+m6O0/Jhj2v/E3CtGWtHhJTc fGUPGKXKsuxbDkIniisGJjvVwfpYAFdd1BMCkZyGe0WZPVJrV8vIvsSjZpmGrRfIDG4u Bq1I9EzxVDuFg3E1KO2iZjZCukYVUzG9h47QzdrWK60Bp/HUy8pxWGC4wC1hZvR4dRaM RMV8U/TRiXzw279/8nS29dYjLEBl8azTEBmpwtUWsZl+iYh+tjE8ZPKxST+ymIriz6Gb 9Ug0ED9JU3UPSPU8IbR7cJ7/mdS3pcAZ2cZturYPUU6RU90dWgUx53Z6NQrAIuvrpJRN vF6w== 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=Fm8GAHA4wHOZ6aH5j10PuHm5s/aZ6TljNeVHuGhMRwk=; b=trgR/zs6vYrwjfbdP63gPpzIOwBQPnKMTaZ31XHcVR6PMy3F/GcEkQCJUKS+NSbRa4 TkXvpcC90HDgMPm4WYPay8QRa/11xZF2B4DQUAy4KCwZPw1RI7uqZgs1/2eQ7bgcFIV0 wSmPc9x2RamRWgxyr6CqNLgDFPOjYVPyyxg7F5R1BHYP6/3ffQB5I016r8SkzaCeTycl 4Q2N5aBt8SzQXxVeKpK29+OxR93X84l991DPHaE0iMCQWpd9ZsJSsyT7mJCWBfEbrem8 Dbk6Ger24FReGezlrIhV++0Sdf1EIDUi7OjChCAYCg5TFOD2e3h1pwSE3DJeNtVTca/m JQog== X-Gm-Message-State: AFqh2kqoKy8SZdFSjp0/3mm/ipk8bxfXmhs2zQw6RgSJRHVzGDZ6Yia8 +zETPDV326bPrIXyUvVnWGV70g== X-Google-Smtp-Source: AMrXdXvUEMqhAGEePbJwzuMHSc4UTdEcNlNqP3IyR3XvRSGdbrV9sdapS0Q41zVldzt3iZHk82Lqfw== X-Received: by 2002:a05:6512:220f:b0:4bf:982f:f63b with SMTP id h15-20020a056512220f00b004bf982ff63bmr15779860lfu.21.1672788924538; Tue, 03 Jan 2023 15:35:24 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020a056512070b00b004a45edc1de2sm4939801lfs.239.2023.01.03.15.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 15:35:23 -0800 (PST) From: Linus Walleij Date: Wed, 04 Jan 2023 00:35:18 +0100 Subject: [PATCH 2/7] usb: fotg210: List different variants MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-gemini-fotg210-usb-v1-2-f2670cb4a492@linaro.org> References: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Vogt , Linus Walleij X-Mailer: b4 0.11.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are at least two variants of the FOTG: FOTG200 and FOTG210. Handle them in this driver and let's add more quirks as we go along. Signed-off-by: Linus Walleij --- drivers/usb/fotg210/fotg210-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg2= 10-core.c index 8a54edf921ac..cef12827e797 100644 --- a/drivers/usb/fotg210/fotg210-core.c +++ b/drivers/usb/fotg210/fotg210-core.c @@ -127,7 +127,9 @@ static int fotg210_remove(struct platform_device *pdev) =20 #ifdef CONFIG_OF static const struct of_device_id fotg210_of_match[] =3D { + { .compatible =3D "faraday,fotg200" }, { .compatible =3D "faraday,fotg210" }, + /* TODO: can we also handle FUSB220? */ {}, }; MODULE_DEVICE_TABLE(of, fotg210_of_match); --=20 2.38.1 From nobody Sun Apr 12 13:54:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2D3EC4708E for ; Tue, 3 Jan 2023 23:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238415AbjACXfl (ORCPT ); Tue, 3 Jan 2023 18:35:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238245AbjACXf3 (ORCPT ); Tue, 3 Jan 2023 18:35:29 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4952F165AA for ; Tue, 3 Jan 2023 15:35:27 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id bq39so40175699lfb.0 for ; Tue, 03 Jan 2023 15:35:27 -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=Rq0s4onjSRUwhmApDnZ8KEVauR86LqfQw7i8WlycEFs=; b=rJvaZkk57ZeoGjLTVPf6NQmvZfWeEFVlPJbGJ3wvMJ63Av0UjO5SAxDlXQPXVJjXHQ m3PBikfjuV6CMWTaalBoqNhftpinKPz/nk7SexZAYeM09eTnxslPgQ1eiAOwVNJ/cicV 0fHLNOZyGxMGZu2z5HgpmKd8dqztH7gH0rO3zgZqD6MwhMmr4unT8nCedyeeOytgFzzU Z1JKdzEqA3FL+H6BRqlwdth52gWQjWTAlM4Z46ZhAM20OuRzliT+0mlc0Yf39FlWvkVE ZA9sLIbS6DjEZy0Lu42PSiILujdPeA8wx6/h/RgYfB877zh5jTCrT2YgSUzF4EnWUsGJ xWvA== 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=Rq0s4onjSRUwhmApDnZ8KEVauR86LqfQw7i8WlycEFs=; b=0T4C1Wf8BvyDgw0eCn17B65SPAtVH06K9xOGmU3wOxZtM91ELDbF63RgAmwNA83OFk eQExRgtdux/SFOpmw4pDcb8tWcAEsGIw00naL2mglk1YwHp6qCYoXC8ORd3hc86ECpdE uW8mswxC9LAfgMNv7mBsozmOdulqCcG2N63hMcI6Lz12VFFMklnTKuL/mgh0j/LSK8zq q6NK3XNLSYmMzSlxnY3kQxcfcjrE/tMFKfYRATjiQoi9pKL+O8kN0T/CV6NP025iz378 OfIySxPrQ9K4EeUynJoX92s6Q2xRAJDJP+mJX2/7N/QGfK/Z/Gdd4jQV9OrcleoO2FdX L+1Q== X-Gm-Message-State: AFqh2kr9j5NZ+WuvUwbDZVZL2shVDDfJ2mIS+7VPDWk7ElOZxDJKh7Nk m30thP+n+gi+qlCltlaOi+DImj+CAMLd/tgv X-Google-Smtp-Source: AMrXdXutAAOkOUBIuK6T1E9JkbuwrOliPzDnYqRmT25gu1gXcfAdrJsGfjDYEORwXECwxCTU2UBEJw== X-Received: by 2002:a05:6512:3b22:b0:4a4:68b9:19e1 with SMTP id f34-20020a0565123b2200b004a468b919e1mr14446708lfv.9.1672788925655; Tue, 03 Jan 2023 15:35:25 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020a056512070b00b004a45edc1de2sm4939801lfs.239.2023.01.03.15.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 15:35:25 -0800 (PST) From: Linus Walleij Date: Wed, 04 Jan 2023 00:35:19 +0100 Subject: [PATCH 3/7] usb: fotg210: Acquire memory resource in core MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-gemini-fotg210-usb-v1-3-f2670cb4a492@linaro.org> References: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Vogt , Linus Walleij X-Mailer: b4 0.11.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The subdrivers are obtaining and mapping the memory resource separately. Create a common state container for the shared resources and start populating this by acquiring the IO memory resource and remap it and pass this to the subdrivers for host and peripheral. Signed-off-by: Linus Walleij --- drivers/usb/fotg210/fotg210-core.c | 29 ++++++++++++++++++++++------- drivers/usb/fotg210/fotg210-hcd.c | 15 +++++---------- drivers/usb/fotg210/fotg210-hcd.h | 1 + drivers/usb/fotg210/fotg210-udc.c | 16 +++------------- drivers/usb/fotg210/fotg210-udc.h | 1 + drivers/usb/fotg210/fotg210.h | 24 ++++++++++++++++++++---- 6 files changed, 52 insertions(+), 34 deletions(-) diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg2= 10-core.c index cef12827e797..4593120c02de 100644 --- a/drivers/usb/fotg210/fotg210-core.c +++ b/drivers/usb/fotg210/fotg210-core.c @@ -33,9 +33,10 @@ #define GEMINI_MISC_USB0_MINI_B BIT(29) #define GEMINI_MISC_USB1_MINI_B BIT(30) =20 -static int fotg210_gemini_init(struct device *dev, struct resource *res, +static int fotg210_gemini_init(struct fotg210 *fotg, struct resource *res, enum usb_dr_mode mode) { + struct device *dev =3D fotg->dev; struct device_node *np =3D dev->of_node; struct regmap *map; bool wakeup; @@ -47,6 +48,7 @@ static int fotg210_gemini_init(struct device *dev, struct= resource *res, dev_err(dev, "no syscon\n"); return PTR_ERR(map); } + fotg->map =3D map; wakeup =3D of_property_read_bool(np, "wakeup-source"); =20 /* @@ -55,6 +57,7 @@ static int fotg210_gemini_init(struct device *dev, struct= resource *res, */ mask =3D 0; if (res->start =3D=3D 0x69000000) { + fotg->port =3D GEMINI_PORT_1; mask =3D GEMINI_MISC_USB1_VBUS_ON | GEMINI_MISC_USB1_MINI_B | GEMINI_MISC_USB1_WAKEUP; if (mode =3D=3D USB_DR_MODE_HOST) @@ -64,6 +67,7 @@ static int fotg210_gemini_init(struct device *dev, struct= resource *res, if (wakeup) val |=3D GEMINI_MISC_USB1_WAKEUP; } else { + fotg->port =3D GEMINI_PORT_0; mask =3D GEMINI_MISC_USB0_VBUS_ON | GEMINI_MISC_USB0_MINI_B | GEMINI_MISC_USB0_WAKEUP; if (mode =3D=3D USB_DR_MODE_HOST) @@ -89,23 +93,34 @@ static int fotg210_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; enum usb_dr_mode mode; + struct fotg210 *fotg; int ret; =20 + fotg =3D devm_kzalloc(dev, sizeof(*fotg), GFP_KERNEL); + if (!fotg) + return -ENOMEM; + fotg->dev =3D dev; + + fotg->res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!fotg->res) + return -ENODEV; + + fotg->base =3D devm_ioremap_resource(dev, fotg->res); + if (!fotg->base) + return -ENOMEM; + mode =3D usb_get_dr_mode(dev); =20 if (of_device_is_compatible(dev->of_node, "cortina,gemini-usb")) { - struct resource *res; - - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); - ret =3D fotg210_gemini_init(dev, res, mode); + ret =3D fotg210_gemini_init(fotg, fotg->res, mode); if (ret) return ret; } =20 if (mode =3D=3D USB_DR_MODE_PERIPHERAL) - ret =3D fotg210_udc_probe(pdev); + ret =3D fotg210_udc_probe(pdev, fotg); else - ret =3D fotg210_hcd_probe(pdev); + ret =3D fotg210_hcd_probe(pdev, fotg); =20 return ret; } diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg21= 0-hcd.c index 51ac93a2eb98..15ba5b1618e1 100644 --- a/drivers/usb/fotg210/fotg210-hcd.c +++ b/drivers/usb/fotg210/fotg210-hcd.c @@ -5557,11 +5557,10 @@ static void fotg210_init(struct fotg210_hcd *fotg21= 0) * then invokes the start() method for the HCD associated with it * through the hotplug entry's driver_data. */ -int fotg210_hcd_probe(struct platform_device *pdev) +int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg) { struct device *dev =3D &pdev->dev; struct usb_hcd *hcd; - struct resource *res; int irq; int retval; struct fotg210_hcd *fotg210; @@ -5585,18 +5584,14 @@ int fotg210_hcd_probe(struct platform_device *pdev) =20 hcd->has_tt =3D 1; =20 - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); - hcd->regs =3D devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(hcd->regs)) { - retval =3D PTR_ERR(hcd->regs); - goto failed_put_hcd; - } + hcd->regs =3D fotg->base; =20 - hcd->rsrc_start =3D res->start; - hcd->rsrc_len =3D resource_size(res); + hcd->rsrc_start =3D fotg->res->start; + hcd->rsrc_len =3D resource_size(fotg->res); =20 fotg210 =3D hcd_to_fotg210(hcd); =20 + fotg210->fotg =3D fotg; fotg210->caps =3D hcd->regs; =20 /* It's OK not to supply this clock */ diff --git a/drivers/usb/fotg210/fotg210-hcd.h b/drivers/usb/fotg210/fotg21= 0-hcd.h index 0781442b7a24..13c9342982ee 100644 --- a/drivers/usb/fotg210/fotg210-hcd.h +++ b/drivers/usb/fotg210/fotg210-hcd.h @@ -182,6 +182,7 @@ struct fotg210_hcd { /* one per controller */ # define INCR(x) do {} while (0) #endif =20 + struct fotg210 *fotg; /* Overarching FOTG210 device */ /* silicon clock */ struct clk *pclk; }; diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg21= 0-udc.c index 66e1b7ee3346..034193592a36 100644 --- a/drivers/usb/fotg210/fotg210-udc.c +++ b/drivers/usb/fotg210/fotg210-udc.c @@ -1142,21 +1142,14 @@ int fotg210_udc_remove(struct platform_device *pdev) return 0; } =20 -int fotg210_udc_probe(struct platform_device *pdev) +int fotg210_udc_probe(struct platform_device *pdev, struct fotg210 *fotg) { - struct resource *res; struct fotg210_udc *fotg210 =3D NULL; struct device *dev =3D &pdev->dev; int irq; int ret =3D 0; int i; =20 - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - pr_err("platform_get_resource error.\n"); - return -ENODEV; - } - irq =3D platform_get_irq(pdev, 0); if (irq < 0) { pr_err("could not get irq\n"); @@ -1169,6 +1162,7 @@ int fotg210_udc_probe(struct platform_device *pdev) return -ENOMEM; =20 fotg210->dev =3D dev; + fotg210->fotg =3D fotg; =20 /* It's OK not to supply this clock */ fotg210->pclk =3D devm_clk_get(dev, "PCLK"); @@ -1207,11 +1201,7 @@ int fotg210_udc_probe(struct platform_device *pdev) goto err_alloc; } =20 - fotg210->reg =3D ioremap(res->start, resource_size(res)); - if (fotg210->reg =3D=3D NULL) { - dev_err(dev, "ioremap error\n"); - goto err_alloc; - } + fotg210->reg =3D fotg->base; =20 spin_lock_init(&fotg210->lock); =20 diff --git a/drivers/usb/fotg210/fotg210-udc.h b/drivers/usb/fotg210/fotg21= 0-udc.h index fadb57ca8d78..20335a38a410 100644 --- a/drivers/usb/fotg210/fotg210-udc.h +++ b/drivers/usb/fotg210/fotg210-udc.h @@ -236,6 +236,7 @@ struct fotg210_udc { unsigned long irq_trigger; =20 struct device *dev; + struct fotg210 *fotg; struct usb_phy *phy; struct usb_gadget gadget; struct usb_gadget_driver *driver; diff --git a/drivers/usb/fotg210/fotg210.h b/drivers/usb/fotg210/fotg210.h index ef79d8323d89..50436cc16538 100644 --- a/drivers/usb/fotg210/fotg210.h +++ b/drivers/usb/fotg210/fotg210.h @@ -2,13 +2,28 @@ #ifndef __FOTG210_H #define __FOTG210_H =20 +enum gemini_port { + GEMINI_PORT_NONE =3D 0, + GEMINI_PORT_0, + GEMINI_PORT_1, +}; + +struct fotg210 { + struct device *dev; + struct resource *res; + void __iomem *base; + struct regmap *map; + enum gemini_port port; +}; + #ifdef CONFIG_USB_FOTG210_HCD -int fotg210_hcd_probe(struct platform_device *pdev); +int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg); int fotg210_hcd_remove(struct platform_device *pdev); int fotg210_hcd_init(void); void fotg210_hcd_cleanup(void); #else -static inline int fotg210_hcd_probe(struct platform_device *pdev) +static inline int fotg210_hcd_probe(struct platform_device *pdev, + struct fotg210 *fotg) { return 0; } @@ -26,10 +41,11 @@ static inline void fotg210_hcd_cleanup(void) #endif =20 #ifdef CONFIG_USB_FOTG210_UDC -int fotg210_udc_probe(struct platform_device *pdev); +int fotg210_udc_probe(struct platform_device *pdev, struct fotg210 *fotg); int fotg210_udc_remove(struct platform_device *pdev); #else -static inline int fotg210_udc_probe(struct platform_device *pdev) +static inline int fotg210_udc_probe(struct platform_device *pdev, + struct fotg210 *fotg) { return 0; } --=20 2.38.1 From nobody Sun Apr 12 13:54:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59DDDC3DA7D for ; Tue, 3 Jan 2023 23:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234088AbjACXfp (ORCPT ); Tue, 3 Jan 2023 18:35:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238308AbjACXfa (ORCPT ); Tue, 3 Jan 2023 18:35:30 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6882F165AB for ; Tue, 3 Jan 2023 15:35:28 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id 1so47951652lfz.4 for ; Tue, 03 Jan 2023 15:35:28 -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=BtRN+qVRV1KbBnVSqhsl2L1Dw52l5PTGL9dlg3vRmSg=; b=L6pneSlfBV8hJroS5X7KCQsJcflcnd4ohQjKk25rbttOudOaeb8WzOjm86Y79S8dir wqEXKvigPHHUl063jpj6Y38z3agdhfftVLTd0xib2fe7pppM+cjhsFHnZewG5BPIu+sN Vh7vm9SrkiZEOGAAZAwXwo3seFAwO5plR1wYqtg7mvRiikmOVPSL9SaoXTtXUIgmdHu7 eBDc3wzFj2QA3UViFNklFifZ/Ntuy5cdCSfCbD7kVjaaUXdSOSKvM7dQBR63E0DQRmQW uOvLMSAAFRqpFvx0VGEBdDWD13MsNITli4UWWvkbtAeNRawH6VzY6YJf9Pg1XGfqdK/j Sl0Q== 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=BtRN+qVRV1KbBnVSqhsl2L1Dw52l5PTGL9dlg3vRmSg=; b=CDS7FdV0oUsFZ4aAahKrhAr3Ccnxv7r3RQuWhMu4Kz0yuZ2rrZDY0zVZAdas0bQIIa I0QhxaIPi4qfx+qkCHNfcs538XvmBNBNeEj+BMuImATOItscQ3cknAlW4QnLfkhlyVgu ibRx6WGhoA9G4eucKV6FvVeP3b1IHIQsUhtKN/IRQEAT0s5KdYB4MMAAW81PCP7+dG1I pXLnLd4fMEIX0gWdx4RAM6yK9ggeD0J6VU/bGw3beGKOBedj8tYWipwDV2IpxIcgqtOT +wkneDxQ4pNYEY/eJBX5vLpHR8OIrS/kAaBas2pOn7mEdNphKiJNWe3Cz/9Eq95VOQS1 hTXQ== X-Gm-Message-State: AFqh2krdlYRyecuZ5Gv4JNgE/4lJt/+XOb+RCORgyjEAaE2AWKw3WJif ZsmW47YinNvjWh14iHMuRy8fcg== X-Google-Smtp-Source: AMrXdXs2bS5QxeAPRgtcNR1L3O1x+4UzA3xGsphCQbmPF0U6qyLhfrjM1yHQng04wacz+B8EAg2dVg== X-Received: by 2002:a05:6512:31d1:b0:4b5:7925:8707 with SMTP id j17-20020a05651231d100b004b579258707mr15867129lfe.26.1672788926805; Tue, 03 Jan 2023 15:35:26 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020a056512070b00b004a45edc1de2sm4939801lfs.239.2023.01.03.15.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 15:35:26 -0800 (PST) From: Linus Walleij Date: Wed, 04 Jan 2023 00:35:20 +0100 Subject: [PATCH 4/7] usb: fotg210: Move clock handling to core MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-gemini-fotg210-usb-v1-4-f2670cb4a492@linaro.org> References: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Vogt , Linus Walleij X-Mailer: b4 0.11.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Grab the optional silicon block clock, prepare and enable it in the core before proceeding to prepare the host or peripheral driver. This saves duplicate code and also uses the simple devm_clk_get_optional_enabled() to do everything we really want to do. Signed-off-by: Linus Walleij --- drivers/usb/fotg210/fotg210-core.c | 5 +++++ drivers/usb/fotg210/fotg210-hcd.c | 33 ++------------------------------- drivers/usb/fotg210/fotg210-udc.c | 30 +++--------------------------- drivers/usb/fotg210/fotg210-udc.h | 1 - drivers/usb/fotg210/fotg210.h | 1 + 5 files changed, 11 insertions(+), 59 deletions(-) diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg2= 10-core.c index 4593120c02de..58d84747fb30 100644 --- a/drivers/usb/fotg210/fotg210-core.c +++ b/drivers/usb/fotg210/fotg210-core.c @@ -6,6 +6,7 @@ * driver. */ #include +#include #include #include #include @@ -109,6 +110,10 @@ static int fotg210_probe(struct platform_device *pdev) if (!fotg->base) return -ENOMEM; =20 + fotg->pclk =3D devm_clk_get_optional_enabled(dev, "PCLK"); + if (IS_ERR(fotg->pclk)) + return PTR_ERR(fotg->pclk); + mode =3D usb_get_dr_mode(dev); =20 if (of_device_is_compatible(dev->of_node, "cortina,gemini-usb")) { diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg21= 0-hcd.c index 15ba5b1618e1..7bd1e8f3080d 100644 --- a/drivers/usb/fotg210/fotg210-hcd.c +++ b/drivers/usb/fotg210/fotg210-hcd.c @@ -33,7 +33,6 @@ #include #include #include -#include =20 #include #include @@ -5594,44 +5593,22 @@ int fotg210_hcd_probe(struct platform_device *pdev,= struct fotg210 *fotg) fotg210->fotg =3D fotg; fotg210->caps =3D hcd->regs; =20 - /* It's OK not to supply this clock */ - fotg210->pclk =3D clk_get(dev, "PCLK"); - if (!IS_ERR(fotg210->pclk)) { - retval =3D clk_prepare_enable(fotg210->pclk); - if (retval) { - dev_err(dev, "failed to enable PCLK\n"); - goto failed_put_hcd; - } - } else if (PTR_ERR(fotg210->pclk) =3D=3D -EPROBE_DEFER) { - /* - * Percolate deferrals, for anything else, - * just live without the clocking. - */ - retval =3D PTR_ERR(fotg210->pclk); - goto failed_dis_clk; - } - retval =3D fotg210_setup(hcd); if (retval) - goto failed_dis_clk; + goto failed_put_hcd; =20 fotg210_init(fotg210); =20 retval =3D usb_add_hcd(hcd, irq, IRQF_SHARED); if (retval) { dev_err(dev, "failed to add hcd with err %d\n", retval); - goto failed_dis_clk; + goto failed_put_hcd; } device_wakeup_enable(hcd->self.controller); platform_set_drvdata(pdev, hcd); =20 return retval; =20 -failed_dis_clk: - if (!IS_ERR(fotg210->pclk)) { - clk_disable_unprepare(fotg210->pclk); - clk_put(fotg210->pclk); - } failed_put_hcd: usb_put_hcd(hcd); fail_create_hcd: @@ -5647,12 +5624,6 @@ int fotg210_hcd_probe(struct platform_device *pdev, = struct fotg210 *fotg) int fotg210_hcd_remove(struct platform_device *pdev) { struct usb_hcd *hcd =3D platform_get_drvdata(pdev); - struct fotg210_hcd *fotg210 =3D hcd_to_fotg210(hcd); - - if (!IS_ERR(fotg210->pclk)) { - clk_disable_unprepare(fotg210->pclk); - clk_put(fotg210->pclk); - } =20 usb_remove_hcd(hcd); usb_put_hcd(hcd); diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg21= 0-udc.c index 034193592a36..6a4b94d26951 100644 --- a/drivers/usb/fotg210/fotg210-udc.c +++ b/drivers/usb/fotg210/fotg210-udc.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include =20 @@ -1134,9 +1133,6 @@ int fotg210_udc_remove(struct platform_device *pdev) for (i =3D 0; i < FOTG210_MAX_NUM_EP; i++) kfree(fotg210->ep[i]); =20 - if (!IS_ERR(fotg210->pclk)) - clk_disable_unprepare(fotg210->pclk); - kfree(fotg210); =20 return 0; @@ -1164,34 +1160,17 @@ int fotg210_udc_probe(struct platform_device *pdev,= struct fotg210 *fotg) fotg210->dev =3D dev; fotg210->fotg =3D fotg; =20 - /* It's OK not to supply this clock */ - fotg210->pclk =3D devm_clk_get(dev, "PCLK"); - if (!IS_ERR(fotg210->pclk)) { - ret =3D clk_prepare_enable(fotg210->pclk); - if (ret) { - dev_err(dev, "failed to enable PCLK\n"); - goto err; - } - } else if (PTR_ERR(fotg210->pclk) =3D=3D -EPROBE_DEFER) { - /* - * Percolate deferrals, for anything else, - * just live without the clocking. - */ - ret =3D -EPROBE_DEFER; - goto err; - } - fotg210->phy =3D devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); if (IS_ERR(fotg210->phy)) { ret =3D PTR_ERR(fotg210->phy); if (ret =3D=3D -EPROBE_DEFER) - goto err_pclk; + goto err_free; dev_info(dev, "no PHY found\n"); fotg210->phy =3D NULL; } else { ret =3D usb_phy_init(fotg210->phy); if (ret) - goto err_pclk; + goto err_free; dev_info(dev, "found and initialized PHY\n"); } =20 @@ -1286,11 +1265,8 @@ int fotg210_udc_probe(struct platform_device *pdev, = struct fotg210 *fotg) err_alloc: for (i =3D 0; i < FOTG210_MAX_NUM_EP; i++) kfree(fotg210->ep[i]); -err_pclk: - if (!IS_ERR(fotg210->pclk)) - clk_disable_unprepare(fotg210->pclk); =20 -err: +err_free: kfree(fotg210); return ret; } diff --git a/drivers/usb/fotg210/fotg210-udc.h b/drivers/usb/fotg210/fotg21= 0-udc.h index 20335a38a410..22b72caf498c 100644 --- a/drivers/usb/fotg210/fotg210-udc.h +++ b/drivers/usb/fotg210/fotg210-udc.h @@ -231,7 +231,6 @@ struct fotg210_ep { struct fotg210_udc { spinlock_t lock; /* protect the struct */ void __iomem *reg; - struct clk *pclk; =20 unsigned long irq_trigger; =20 diff --git a/drivers/usb/fotg210/fotg210.h b/drivers/usb/fotg210/fotg210.h index 50436cc16538..4d0d4ae1a957 100644 --- a/drivers/usb/fotg210/fotg210.h +++ b/drivers/usb/fotg210/fotg210.h @@ -12,6 +12,7 @@ struct fotg210 { struct device *dev; struct resource *res; void __iomem *base; + struct clk *pclk; struct regmap *map; enum gemini_port port; }; --=20 2.38.1 From nobody Sun Apr 12 13:54:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDB32C4708E for ; Tue, 3 Jan 2023 23:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238245AbjACXfx (ORCPT ); Tue, 3 Jan 2023 18:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237008AbjACXfa (ORCPT ); Tue, 3 Jan 2023 18:35:30 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A312B1659C for ; Tue, 3 Jan 2023 15:35:29 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id m6so37598689lfj.11 for ; Tue, 03 Jan 2023 15:35:29 -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=LfqK6qBFH8YFyjUi0V5Pk9BV6gkDIZNht4kUj3nmxsk=; b=GsOXISdSRV97jTW19WaKqVcsFh59IOOCGNy41YNbhGo+zogwzgVgxTn2XYIFP5fy51 7OGzxjkJcgZ0iX9B24HlxuWH3BcnSk+RNZ7ss9XGYeF5GDkR0BxZaJcXAQ1Ty495VdZJ nawju/K7S1pBGKMb472tZDFEUxVwuHZsypI24Fw+hvhNo18BYfgLC/861nJOupbDHt19 yHoOh9qBUeiEelUa00crBmI9VpIr2nlgE45Kr/mKET81/5Z5k3oyki3Gor2O8eZmQKWK oAYvROqewlZPvxv02HMLdsLUp5p5zYIhbGt1dEVWoQ9ld7LmRFuKlka4IdT+QAFXchkR JLfA== 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=LfqK6qBFH8YFyjUi0V5Pk9BV6gkDIZNht4kUj3nmxsk=; b=HpZUdiJ3/7IGpwLCWhtGUqMXRcOemf/Y/axn4CP/wdfM1f66t5MBTDnvKfy4QC72PX EAzxVtnrSmSnJKtcCea/lNIpokx1bsdGIjL/0RUHxz5sbWTOfZQDGUVYa8JdC7mVPvAN a27HE2WHhUmxsumcxkKMn3MSaJ5LDkj+oG3fVnEI/O+QO8ArHIHT6EKjz4rr7yhvutt4 JVJPIiXydem2LU2N2kdihYW9bqfauLekweBGWKg9NwySd77gTzR+vuQxAaKypVdD8X1T gwozlBDFtMcaVBTQpevOgfALEyzDPjMn2J0P+WVd3ZkAqwTTBAufQ6AZlSNzMiAVTJ6P ma6A== X-Gm-Message-State: AFqh2krTBCwaeWWam0u9RtNKZKpUpg9eKoDxDVBdv3t3JZ/9W0uMpKVF rif1f48s78/TfACOpLl1AfRTpQ== X-Google-Smtp-Source: AMrXdXvGQS/bswxpe0igHUGcViNfV0w61Poc5iqZnUfTxEjT7Iz2j6FvCTfduAeRyTbqU3inECNbNw== X-Received: by 2002:ac2:4bd3:0:b0:4b4:a460:c995 with SMTP id o19-20020ac24bd3000000b004b4a460c995mr18141753lfq.5.1672788927892; Tue, 03 Jan 2023 15:35:27 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020a056512070b00b004a45edc1de2sm4939801lfs.239.2023.01.03.15.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 15:35:27 -0800 (PST) From: Linus Walleij Date: Wed, 04 Jan 2023 00:35:21 +0100 Subject: [PATCH 5/7] usb: fotg210: Check role register in core MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-gemini-fotg210-usb-v1-5-f2670cb4a492@linaro.org> References: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Vogt , Linus Walleij X-Mailer: b4 0.11.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Read the role register and check that we are in host/peripheral mode and issue warnings if we're not in the right role when probing respective driver. Signed-off-by: Linus Walleij --- drivers/usb/fotg210/fotg210-core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg2= 10-core.c index 58d84747fb30..013a1d0112fc 100644 --- a/drivers/usb/fotg210/fotg210-core.c +++ b/drivers/usb/fotg210/fotg210-core.c @@ -18,6 +18,11 @@ =20 #include "fotg210.h" =20 +/* Role Register 0x80 */ +#define FOTG210_RR 0x80 +#define FOTG210_RR_ID BIT(21) /* 1 =3D B-device, 0 =3D A-device */ +#define FOTG210_RR_CROLE BIT(20) /* 1 =3D device, 0 =3D host */ + /* * Gemini-specific initialization function, only executed on the * Gemini SoC using the global misc control register. @@ -95,6 +100,7 @@ static int fotg210_probe(struct platform_device *pdev) struct device *dev =3D &pdev->dev; enum usb_dr_mode mode; struct fotg210 *fotg; + u32 val; int ret; =20 fotg =3D devm_kzalloc(dev, sizeof(*fotg), GFP_KERNEL); @@ -122,10 +128,16 @@ static int fotg210_probe(struct platform_device *pdev) return ret; } =20 - if (mode =3D=3D USB_DR_MODE_PERIPHERAL) + val =3D readl(fotg->base + FOTG210_RR); + if (mode =3D=3D USB_DR_MODE_PERIPHERAL) { + if (!(val & FOTG210_RR_CROLE)) + dev_err(dev, "block not in device role\n"); ret =3D fotg210_udc_probe(pdev, fotg); - else + } else { + if (val & FOTG210_RR_CROLE) + dev_err(dev, "block not in host role\n"); ret =3D fotg210_hcd_probe(pdev, fotg); + } =20 return ret; } --=20 2.38.1 From nobody Sun Apr 12 13:54:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFB35C3DA7D for ; Tue, 3 Jan 2023 23:35:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234083AbjACXfs (ORCPT ); Tue, 3 Jan 2023 18:35:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237880AbjACXfa (ORCPT ); Tue, 3 Jan 2023 18:35:30 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C45213E3C for ; Tue, 3 Jan 2023 15:35:29 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id bt23so31316915lfb.5 for ; Tue, 03 Jan 2023 15:35:29 -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=tcCZcfMImVoguFifloAOWn9GN0CXlpPQ4S3kvfMhx2k=; b=LMzkaTaD9wctPIdbVm6QZUwZrtpXDiu7SaqEPqgdBxrAK6JScPBaGrLm/A0N01Lhiq /h0OmYwR4qgPuUZcg0MhoQMcXM8wZZxbV//ypdaaHphZ9dVEdqWMcg0FSCE80jX22uVM xIz43KghAFD0/iQECoyywpdcNddRH6WyU7KavDCrWnWEdv8Uh3MsXOJLcsh+tL9tr2Qq 4S6lhVTVH9sb1JCGSuu3LZHNAC3/sXJ2Mrugam+0yG0CSodv0QHEPfusOYoT/sI+v5sc IG9UxCWX31XmP//ZJvOvpfu9sS0HxngRJtp5PLWnbYfsLBE7Rq1Oye3utnjwW+o2tF9w 5r2w== 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=tcCZcfMImVoguFifloAOWn9GN0CXlpPQ4S3kvfMhx2k=; b=1dc+Z+YLgK1f9+591Y6FiwQdEwHxToo10/7gO2FY1rbmBokUysA8h7leD5hpzYt5uN GeOD7kiJHLGDLhyt1tLDTa2MVOf/eJE8k9qBb4a0IIJbD08KMsOVT/o1+qmdK1gq1Es8 Ps7MPBZ1r0Q/l/GDSJcderDxAPMUYKTl/svxH2Mh87GhxUsRuc6LOe4YczLfNs8ehcX7 /PCZa0PeYOXr+LuKBxECNg6qoVckugUBZCvBcKi/s9TUI0rJCQF07Fy3ED/0xpTDgDkT niy2HD5rW+U6BlpE3GXQ7Lnn5plyDRYYajv+M3tampwuzrJN2zSqPMo42UZfMxQLa2Ul TgKg== X-Gm-Message-State: AFqh2ko7l5Q58TC/0U+ixPdgPm8LXi/ZjVYUZEarIynj3khPAvb9xb7E hzKVc3aAa7YK38bJfmcdGXWTBA== X-Google-Smtp-Source: AMrXdXvLdlUsU1PT4CQcHXR+z585RdhI7YL7h5GGKY8TbquQG03EMAnBetUu1yFg0GrQv7/0XuJYMg== X-Received: by 2002:a05:6512:2393:b0:4a4:68b9:1a00 with SMTP id c19-20020a056512239300b004a468b91a00mr15548858lfv.40.1672788928996; Tue, 03 Jan 2023 15:35:28 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020a056512070b00b004a45edc1de2sm4939801lfs.239.2023.01.03.15.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 15:35:28 -0800 (PST) From: Linus Walleij Date: Wed, 04 Jan 2023 00:35:22 +0100 Subject: [PATCH 6/7] usb: fotg210-udc: Assign of_node and speed on start MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-gemini-fotg210-usb-v1-6-f2670cb4a492@linaro.org> References: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Vogt , Linus Walleij X-Mailer: b4 0.11.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Follow the example set by other drivers to assign of_node and speed to the driver when binding, also print bound info akin to other UDC drivers. Signed-off-by: Linus Walleij --- drivers/usb/fotg210/fotg210-udc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg21= 0-udc.c index 6a4b94d26951..4099e7453112 100644 --- a/drivers/usb/fotg210/fotg210-udc.c +++ b/drivers/usb/fotg210/fotg210-udc.c @@ -1015,6 +1015,10 @@ static int fotg210_udc_start(struct usb_gadget *g, /* hook up the driver */ driver->driver.bus =3D NULL; fotg210->driver =3D driver; + fotg210->gadget.dev.of_node =3D fotg210->dev->of_node; + fotg210->gadget.speed =3D USB_SPEED_UNKNOWN; + + dev_info(fotg210->dev, "bound driver %s\n", driver->driver.name); =20 if (!IS_ERR_OR_NULL(fotg210->phy)) { ret =3D otg_set_peripheral(fotg210->phy->otg, @@ -1071,6 +1075,7 @@ static int fotg210_udc_stop(struct usb_gadget *g) =20 fotg210_init(fotg210); fotg210->driver =3D NULL; + fotg210->gadget.speed =3D USB_SPEED_UNKNOWN; =20 spin_unlock_irqrestore(&fotg210->lock, flags); =20 --=20 2.38.1 From nobody Sun Apr 12 13:54:19 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 461DEC3DA7D for ; Tue, 3 Jan 2023 23:36:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238515AbjACXgA (ORCPT ); Tue, 3 Jan 2023 18:36:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238349AbjACXfb (ORCPT ); Tue, 3 Jan 2023 18:35:31 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A12EA165A5 for ; Tue, 3 Jan 2023 15:35:30 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id y25so47977324lfa.9 for ; Tue, 03 Jan 2023 15:35:30 -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=R0uvymsPrpGAEh2BG1RLD0dqjUm8ZCLGS+gXm8386eY=; b=HbM+7KVQBWYkGwSyHDDJwF3QRzIi3Ah0k5QjVzuEEmGnlYXJsCooNiQE9P7xijHOKs BExioI0Ana0mbpWq3NcBftE0EgTQRybRgsf+a1k03OSoIkpPN6Zy2UO2Xnd6HChfEg/X 89t0CMX5NrKXMApK1pnIlrbT9t4h3mQ7sXptbxkRL/o2skXc6SMBbA3jI3GYy+DeledN krz4AILKghp1B22uiSHnsyBra4nsVvKpZKD0KkWRygVQiNswC506OQv+ptsTUFcueoXz 2WouoFIJKXqWNSeOGK19kcp6RtJLrkMb8EulWOOw4fY3iC7NOn6Dl+n7uqZ6UeosvII8 TJ9g== 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=R0uvymsPrpGAEh2BG1RLD0dqjUm8ZCLGS+gXm8386eY=; b=W41NbrX7H7Tn3UXT2s9/NdeOzp4S67JbciIRDaOyIJ84kTYMkAGE/+rzQsWa9xwarb Y+w/ce435C9Y3wY1D3MkufQZ35g9Y6RFQPwSQ3YnimZaJEaOu1EB4ybQcFkEILF1Cr4H /uyNlF9IWH3Q/23roO3Hfp3LFgXIOCl+0EAqZnj0lDOT5vq4/l0HQqVVe+lsbtnxiDr5 alt2OhBfO5D0zoLfOo+mkJoyuq96W46emgUn8yexcfsZbYES3GscTOcKAJWQz2ufhYPp WmxHnuJPkRQ1Bl4MBlaXG6y/sF3iAkb0OwRTYpN7+uhLJ3ctGGT/mx7supItrD4JO9AZ bZwA== X-Gm-Message-State: AFqh2kqXN7svFkbi0h4izRALk8lFPUCh6aKAsFhdcdaOP7Kgcso4vC0G r0Np1Sre7Zh0mu4CE7M11t/33Q== X-Google-Smtp-Source: AMrXdXuWUOstb+6wkH9q+lI6gn2lg/hmvSWjds0SNBS4vzz8WVxEUOt+PJ81WQ4spuIcUGH5X0dYcw== X-Received: by 2002:a05:6512:3d9f:b0:4a4:68b7:f878 with SMTP id k31-20020a0565123d9f00b004a468b7f878mr19080201lfv.28.1672788930160; Tue, 03 Jan 2023 15:35:30 -0800 (PST) Received: from Fecusia.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020a056512070b00b004a45edc1de2sm4939801lfs.239.2023.01.03.15.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 15:35:29 -0800 (PST) From: Linus Walleij Date: Wed, 04 Jan 2023 00:35:23 +0100 Subject: [PATCH 7/7] usb: fotg210-udc: Implement VBUS session MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230103-gemini-fotg210-usb-v1-7-f2670cb4a492@linaro.org> References: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v1-0-f2670cb4a492@linaro.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Vogt , Linus Walleij X-Mailer: b4 0.11.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement VBUS session handling for FOTG210. This is mainly used by the UDC driver which needs to call down to the FOTG210 core and enable/disable VBUS, as this needs to be handled outside of the HCD and UDC drivers, by platform specific glue code. The Gemini has a special bit in a system register to turn VBUS on and off so we implement this in the FOTG210 core. Signed-off-by: Linus Walleij --- drivers/usb/fotg210/fotg210-core.c | 29 +++++++++++++++++++++++++++++ drivers/usb/fotg210/fotg210-udc.c | 17 +++++++++++++++++ drivers/usb/fotg210/fotg210.h | 2 ++ 3 files changed, 48 insertions(+) diff --git a/drivers/usb/fotg210/fotg210-core.c b/drivers/usb/fotg210/fotg2= 10-core.c index 013a1d0112fc..70d2ff5a2682 100644 --- a/drivers/usb/fotg210/fotg210-core.c +++ b/drivers/usb/fotg210/fotg210-core.c @@ -95,6 +95,35 @@ static int fotg210_gemini_init(struct fotg210 *fotg, str= uct resource *res, return 0; } =20 +/** + * fotg210_vbus() - Called by gadget driver to enable/disable VBUS + * @enable: true to enable VBUS, false to disable VBUS + */ +void fotg210_vbus(struct fotg210 *fotg, bool enable) +{ + u32 mask; + u32 val; + int ret; + + switch (fotg->port) { + case GEMINI_PORT_0: + mask =3D GEMINI_MISC_USB0_VBUS_ON; + val =3D enable ? GEMINI_MISC_USB0_VBUS_ON : 0; + break; + case GEMINI_PORT_1: + mask =3D GEMINI_MISC_USB1_VBUS_ON; + val =3D enable ? GEMINI_MISC_USB1_VBUS_ON : 0; + break; + default: + return; + } + ret =3D regmap_update_bits(fotg->map, GEMINI_GLOBAL_MISC_CTRL, mask, val); + if (ret) + dev_err(fotg->dev, "failed to %s VBUS\n", + enable ? "enable" : "disable"); + dev_info(fotg->dev, "%s: %s VBUS\n", __func__, enable ? "enable" : "disab= le"); +} + static int fotg210_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg21= 0-udc.c index 4099e7453112..754429553f61 100644 --- a/drivers/usb/fotg210/fotg210-udc.c +++ b/drivers/usb/fotg210/fotg210-udc.c @@ -1082,9 +1082,26 @@ static int fotg210_udc_stop(struct usb_gadget *g) return 0; } =20 +/** + * fotg210_vbus_session - Called by external transceiver to enable/disable= udc + * @_gadget: usb gadget + * @is_active: 0 if should disable UDC VBUS, 1 if should enable + * + * Returns 0 + */ +static int fotg210_vbus_session(struct usb_gadget *g, int is_active) +{ + struct fotg210_udc *fotg210 =3D gadget_to_fotg210(g); + + /* Call down to core integration layer to drive or disable VBUS */ + fotg210_vbus(fotg210->fotg, is_active); + return 0; +} + static const struct usb_gadget_ops fotg210_gadget_ops =3D { .udc_start =3D fotg210_udc_start, .udc_stop =3D fotg210_udc_stop, + .vbus_session =3D fotg210_vbus_session, }; =20 /** diff --git a/drivers/usb/fotg210/fotg210.h b/drivers/usb/fotg210/fotg210.h index 4d0d4ae1a957..c44c0afe2956 100644 --- a/drivers/usb/fotg210/fotg210.h +++ b/drivers/usb/fotg210/fotg210.h @@ -17,6 +17,8 @@ struct fotg210 { enum gemini_port port; }; =20 +void fotg210_vbus(struct fotg210 *fotg, bool enable); + #ifdef CONFIG_USB_FOTG210_HCD int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg); int fotg210_hcd_remove(struct platform_device *pdev); --=20 2.38.1