From patchwork Tue Jan 3 23:35:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4868817wrt; Tue, 3 Jan 2023 15:36:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXs7NlwudnQgrfbT2WDz4EwzPPnkxgVQU5vm1A1ACzJp0YTJuTqpKdpvAH/SsybRO/m9fKfb X-Received: by 2002:a17:902:b414:b0:186:748e:9383 with SMTP id x20-20020a170902b41400b00186748e9383mr44090519plr.46.1672788973821; Tue, 03 Jan 2023 15:36:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672788973; cv=none; d=google.com; s=arc-20160816; b=iEk7ZmuIWW4eiBVQK0kIpJgk4p6NTq8haCqoxrzO0PO+Sn7Jc/AMuxJsemY49CPnQa mqH+5nRmZIqg84Q7I73nNb0mSbN26dJYqTKWW3CTbVUu9pCZoror4aX8wk7jQ0cuHUGu 6rHpvqv5jbHy6+wXAfQHrSxVt5AviZiCoqSlKXe1vVbkUJFHiFMw4wRmpQYGg4FzItvY 6kb/JXSLangDLW0kVvVWJfKjZ1+LBOSxnJoLfIqHlc0HvfSJTX7T++m9OwzTs/iLjatk 6C81XlNXgTy3QDQUN89ynsRdwLS4YhWGCtrrDI0kgQQ92sglVaOF45L6uHjbDYK9ZXhh H8GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=INGl8EC4lutAaxK7oytOrepZPv62csf4zgf/Dha7g08=; b=D133h+2r5ZKUTOR4zj4HhlyDcWOScGf6DGM90TLgFn9OnSlxxDigeVO1brapDmPhW6 62Gwdwik8igoo+9d1sh2TFUGa0FH5nJPtUeXhUyWUZ5U62F+BvCDljEy/e0Y08X4s1L9 cH2XD2TDfk8bBSVSNxa0rL4uRlD2P4Msisl7QCp/GgaglnvxjP1fZEWCja3hsRKLuXGY R9pHpdVE8aAmfhQ5dhp9qer2Wd+tT9R7gVlmus1Ks/6HCi53MR9/e3Vga7jPZ4AYXs3q zVxs+iZTk2exNSXDkBIR/roEh3G2wzvEv/dz3HxYIayRJD9F8lhbV41+pWPOU9Rc+4dM YJ0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tUh9Qclb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020a170902e3c100b00188a915034bsi30006788ple.340.2023.01.03.15.36.00; Tue, 03 Jan 2023 15:36:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tUh9Qclb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233600AbjACXfc (ORCPT + 99 others); Tue, 3 Jan 2023 18:35:32 -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-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 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754046371260392596?= X-GMAIL-MSGID: =?utf-8?q?1754046371260392596?= 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/Documentation/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# -title: Faraday Technology FOTG210 HS OTG USB 2.0 controller +title: Faraday Technology FOTG200 series HS OTG USB 2.0 controller Bindings 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 reg: maxItems: 1 @@ -66,7 +67,7 @@ examples: #include #include usb0: usb@68000000 { - compatible = "cortina,gemini-usb", "faraday,fotg210"; + compatible = "cortina,gemini-usb", "faraday,fotg200"; reg = <0x68000000 0x1000>; interrupts = <10 IRQ_TYPE_LEVEL_HIGH>; resets = <&syscon GEMINI_RESET_USB0>; From patchwork Tue Jan 3 23:35:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4869396wrt; Tue, 3 Jan 2023 15:38:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXuZzToE3OG9T3FHg1Ydhs+2OXnEjgV3bQ/lzh4MaEibWqqzDpgkU2yO63i87rmAIylruHkb X-Received: by 2002:a05:6a21:3294:b0:9d:efbe:a122 with SMTP id yt20-20020a056a21329400b0009defbea122mr70670265pzb.50.1672789081784; Tue, 03 Jan 2023 15:38:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672789081; cv=none; d=google.com; s=arc-20160816; b=NPVNhAsuLQReoz4LZ21K5huR7MWh3s8PA1NdvyfqvAkFwW0UWLlcsVpyyZDkDBu/qA qjKx8gLFvzZKRaWQcSryH/qn8WeoF4SYiqI4eJTTVCFasUMq6LKZpz8H4GlN5nMzA7/T Rxnv0JLvqqZD9mcpbRh1DDp2gVXAsSz7YGt5KRZEEbnZ2LZG3WNhUtm9UGO5CnyXwS/7 gJNxpj0AmLySc0F+MMbKKUDqBvWOYD6oV0lC3/ApoxR7/6yPLE+GPfaj0xsmRKThMTPe zu37mAQmUNa0qDG1ssowr4PmTx1oOWuZ73SsaU3k18FzEOS6cE9/SAipBLyIvtwUiysp IjpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Fm8GAHA4wHOZ6aH5j10PuHm5s/aZ6TljNeVHuGhMRwk=; b=ZFnRmH/6mKfEBJqf9BtAE9Nba6usl7gCb6Am6faS47HjBl/17N32PSVyF1IkkzkXn0 d0rRBsAOLacXed+4seeqJoyQC/g1ESaexwOVB6EHMITjFEunRodPHLkoF4F8wwsWDcCl qFGdknKmqlRVR+EHD1wUBfYDKJae+G3eCxNT0KgKxfe3ATumIJdM0cCNi/HM/CmIeIfm 018wZ8o3O7e6Vh1ervO8e+WUSyv5/b8IxP+AjXBsRbT9yTBKSDfdNBwz40b0c9EaVXo/ +/li+KyEwoklPZfet21mOuvdXRicKWLXaW3UAw2BtMdNR3RvGeodfS2iVxkOBupHXD5I JGng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QTSUiaPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a631941000000b00477810a445asi32286160pgz.589.2023.01.03.15.37.49; Tue, 03 Jan 2023 15:38:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QTSUiaPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233461AbjACXfg (ORCPT + 99 others); Tue, 3 Jan 2023 18:35:36 -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-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 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754046484532501298?= X-GMAIL-MSGID: =?utf-8?q?1754046484532501298?= 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/fotg210-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) #ifdef CONFIG_OF static const struct of_device_id fotg210_of_match[] = { + { .compatible = "faraday,fotg200" }, { .compatible = "faraday,fotg210" }, + /* TODO: can we also handle FUSB220? */ {}, }; MODULE_DEVICE_TABLE(of, fotg210_of_match); From patchwork Tue Jan 3 23:35:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4869151wrt; Tue, 3 Jan 2023 15:37:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXtg5e9dByPLv+c7MgTLSQQNGzSK36muqHjmLRyC9v1QuOfVNuMtKx7BGBOppTPAbT4dwQyP X-Received: by 2002:a17:902:b402:b0:191:2b76:612c with SMTP id x2-20020a170902b40200b001912b76612cmr44162611plr.62.1672789034415; Tue, 03 Jan 2023 15:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672789034; cv=none; d=google.com; s=arc-20160816; b=iNFNRkCIYWTTEuOekPOcnEZwf6HyhCoXd3UrnVE6TZL51QBoExsYHqEjtR51eXmwTq nHB0Gx+jcLs1hODtSaZvmcRfrNyuPF9E3HnOWIMcuyvAr5YNYPyr570sGP2AzgBtn45o rZlBYkzo7NZo3Sc3XYcO7zc9wlAtNvFY4kD8VIKQJDjFwSHGugJD+N+X2BbYJMVW0Puj RF+Zxe8SuJ5O1hDu9vwKiiSoGMdxqfGEqBAJtcUBIT6yfQx8lpZ4OZozAHkbxXaRcjt6 xIQqfNwcVjqFiD8EX41VUXTeVlY7HRkK605yhiSK7+HhKcjt+oPHR1wVj/Y7KYlJYD+s W6WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Rq0s4onjSRUwhmApDnZ8KEVauR86LqfQw7i8WlycEFs=; b=KvVrOyPHv2RbE04/0e8BVoiWzaPlWtNGYMUzdduFQAKIwmeSNNRDpbIhDIIOnIrK/T vwSB5v+1YJd3P0UrvR0h/lOLkDHlIHbfyh6gCfLLSTuf6+axRmL8rFgYbuqkX2pV8F26 EJk9on/kBkGa6rxj7SucGqRgCv78yCXnQjJX9+0jJk+nV1tEpnSDfF0l1kCBiUIh+Pff 0yJNAD4rDVv4ewdXmJchI6UTE049CXU14XqLi6TPi8xUV2OIyp8Txc9if4tsgJwn2hxE QpNTqGaPHY981dni27XIDVFMybhBazNBHe+IME0XFHBS/CUiOjL2bbt8ybMqyFxPWrKJ VEgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rJvaZkk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a170902ce8700b00192827eabb3si25091431plg.346.2023.01.03.15.37.02; Tue, 03 Jan 2023 15:37:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rJvaZkk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238427AbjACXfk (ORCPT + 99 others); Tue, 3 Jan 2023 18:35:40 -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-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 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754046434632935802?= X-GMAIL-MSGID: =?utf-8?q?1754046434632935802?= 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/fotg210-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) -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 = fotg->dev; struct device_node *np = 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 = map; wakeup = of_property_read_bool(np, "wakeup-source"); /* @@ -55,6 +57,7 @@ static int fotg210_gemini_init(struct device *dev, struct resource *res, */ mask = 0; if (res->start == 0x69000000) { + fotg->port = GEMINI_PORT_1; mask = GEMINI_MISC_USB1_VBUS_ON | GEMINI_MISC_USB1_MINI_B | GEMINI_MISC_USB1_WAKEUP; if (mode == USB_DR_MODE_HOST) @@ -64,6 +67,7 @@ static int fotg210_gemini_init(struct device *dev, struct resource *res, if (wakeup) val |= GEMINI_MISC_USB1_WAKEUP; } else { + fotg->port = GEMINI_PORT_0; mask = GEMINI_MISC_USB0_VBUS_ON | GEMINI_MISC_USB0_MINI_B | GEMINI_MISC_USB0_WAKEUP; if (mode == USB_DR_MODE_HOST) @@ -89,23 +93,34 @@ static int fotg210_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; enum usb_dr_mode mode; + struct fotg210 *fotg; int ret; + fotg = devm_kzalloc(dev, sizeof(*fotg), GFP_KERNEL); + if (!fotg) + return -ENOMEM; + fotg->dev = dev; + + fotg->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!fotg->res) + return -ENODEV; + + fotg->base = devm_ioremap_resource(dev, fotg->res); + if (!fotg->base) + return -ENOMEM; + mode = usb_get_dr_mode(dev); if (of_device_is_compatible(dev->of_node, "cortina,gemini-usb")) { - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - ret = fotg210_gemini_init(dev, res, mode); + ret = fotg210_gemini_init(fotg, fotg->res, mode); if (ret) return ret; } if (mode == USB_DR_MODE_PERIPHERAL) - ret = fotg210_udc_probe(pdev); + ret = fotg210_udc_probe(pdev, fotg); else - ret = fotg210_hcd_probe(pdev); + ret = fotg210_hcd_probe(pdev, fotg); return ret; } diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-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 *fotg210) * 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 = &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) hcd->has_tt = 1; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hcd->regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(hcd->regs)) { - retval = PTR_ERR(hcd->regs); - goto failed_put_hcd; - } + hcd->regs = fotg->base; - hcd->rsrc_start = res->start; - hcd->rsrc_len = resource_size(res); + hcd->rsrc_start = fotg->res->start; + hcd->rsrc_len = resource_size(fotg->res); fotg210 = hcd_to_fotg210(hcd); + fotg210->fotg = fotg; fotg210->caps = hcd->regs; /* It's OK not to supply this clock */ diff --git a/drivers/usb/fotg210/fotg210-hcd.h b/drivers/usb/fotg210/fotg210-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 + struct fotg210 *fotg; /* Overarching FOTG210 device */ /* silicon clock */ struct clk *pclk; }; diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-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; } -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 = NULL; struct device *dev = &pdev->dev; int irq; int ret = 0; int i; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - pr_err("platform_get_resource error.\n"); - return -ENODEV; - } - irq = 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; fotg210->dev = dev; + fotg210->fotg = fotg; /* It's OK not to supply this clock */ fotg210->pclk = devm_clk_get(dev, "PCLK"); @@ -1207,11 +1201,7 @@ int fotg210_udc_probe(struct platform_device *pdev) goto err_alloc; } - fotg210->reg = ioremap(res->start, resource_size(res)); - if (fotg210->reg == NULL) { - dev_err(dev, "ioremap error\n"); - goto err_alloc; - } + fotg210->reg = fotg->base; spin_lock_init(&fotg210->lock); diff --git a/drivers/usb/fotg210/fotg210-udc.h b/drivers/usb/fotg210/fotg210-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; 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 +enum gemini_port { + GEMINI_PORT_NONE = 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 #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; } From patchwork Tue Jan 3 23:35:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4868968wrt; Tue, 3 Jan 2023 15:36:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXvPSc513Qt94DQ9XoZACBk50zDm5XCLHGciXaP12Bb4m6YeCCPXgRibqGmQldOtDilApCja X-Received: by 2002:a17:902:7409:b0:192:6019:a3d7 with SMTP id g9-20020a170902740900b001926019a3d7mr38349713pll.41.1672788999394; Tue, 03 Jan 2023 15:36:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672788999; cv=none; d=google.com; s=arc-20160816; b=Tt8bNmxn+L79PJr+E9rR8khA3Fs05xRuB+Fi00nx4AJnWUUHtnIEV8JpdCIk6Rv+5p klX7YpXBdBLKcb46xXxh8UiFfWmHXdfb+HpI4dAQQS+fZP19AGvxm6mN2SAa/CYtLXCd PeWuqvIzsRsZIcLiX1fu2uIE6VSv3YxhxIuE+c7lq1K2tyombLYO3/+9bmx8XLKu4qPn lD+LgYC/Gd0c1yXHGMDL/NVEMDhp/ZOtitL8VeZPyhZ+ri3KIa0IR2jRo3MzquoxD9lN L5JqfOuNuOxzU64twwL4Tge48dyxA2pij0xVDFCrGg7+Be1ESay4wIJs1EXRbF2kHV/o 1pxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=BtRN+qVRV1KbBnVSqhsl2L1Dw52l5PTGL9dlg3vRmSg=; b=L13qLuE9BBrpNuN+da+covPZFegVMfGvVqh4mBBJrkP5Kr7ZWQVfdIS6ZBCZJxlyc8 NjYk4Ahj8I++NygPJgZqxn8rrdJjHqsEGYELobrx+cNtBDmOHiXufYi68+u/rXxjkrvS vA0RwUFdjCWzkgTClVXpcY2Fo9EByci46LxUje8AUwaaORV/M7G8HUwMUIWrudrIRkWV mENVME4h19yjNSl4+jh/HVasNogZV/ZNbqS/MC/0R4ySlJtY+u7Xrhl6VTaCCMaTAqVI /Y1IvcRm35nF8OPM9F084v4yRhyHIkabFoNWFbTlEqc0Wlavr6L+xyX1tbZ/bqLVcki1 6GDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L6pneSlf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a170902cec400b00178b95aa01fsi37233263plg.614.2023.01.03.15.36.27; Tue, 03 Jan 2023 15:36:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L6pneSlf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233699AbjACXfn (ORCPT + 99 others); Tue, 3 Jan 2023 18:35:43 -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-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 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754046397749808042?= X-GMAIL-MSGID: =?utf-8?q?1754046397749808042?= 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/fotg210-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; + fotg->pclk = devm_clk_get_optional_enabled(dev, "PCLK"); + if (IS_ERR(fotg->pclk)) + return PTR_ERR(fotg->pclk); + mode = usb_get_dr_mode(dev); if (of_device_is_compatible(dev->of_node, "cortina,gemini-usb")) { diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-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 #include #include @@ -5594,44 +5593,22 @@ int fotg210_hcd_probe(struct platform_device *pdev, struct fotg210 *fotg) fotg210->fotg = fotg; fotg210->caps = hcd->regs; - /* It's OK not to supply this clock */ - fotg210->pclk = clk_get(dev, "PCLK"); - if (!IS_ERR(fotg210->pclk)) { - retval = 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) == -EPROBE_DEFER) { - /* - * Percolate deferrals, for anything else, - * just live without the clocking. - */ - retval = PTR_ERR(fotg210->pclk); - goto failed_dis_clk; - } - retval = fotg210_setup(hcd); if (retval) - goto failed_dis_clk; + goto failed_put_hcd; fotg210_init(fotg210); retval = 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); return retval; -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 = platform_get_drvdata(pdev); - struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); - - if (!IS_ERR(fotg210->pclk)) { - clk_disable_unprepare(fotg210->pclk); - clk_put(fotg210->pclk); - } usb_remove_hcd(hcd); usb_put_hcd(hcd); diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-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 @@ -1134,9 +1133,6 @@ int fotg210_udc_remove(struct platform_device *pdev) for (i = 0; i < FOTG210_MAX_NUM_EP; i++) kfree(fotg210->ep[i]); - if (!IS_ERR(fotg210->pclk)) - clk_disable_unprepare(fotg210->pclk); - kfree(fotg210); return 0; @@ -1164,34 +1160,17 @@ int fotg210_udc_probe(struct platform_device *pdev, struct fotg210 *fotg) fotg210->dev = dev; fotg210->fotg = fotg; - /* It's OK not to supply this clock */ - fotg210->pclk = devm_clk_get(dev, "PCLK"); - if (!IS_ERR(fotg210->pclk)) { - ret = clk_prepare_enable(fotg210->pclk); - if (ret) { - dev_err(dev, "failed to enable PCLK\n"); - goto err; - } - } else if (PTR_ERR(fotg210->pclk) == -EPROBE_DEFER) { - /* - * Percolate deferrals, for anything else, - * just live without the clocking. - */ - ret = -EPROBE_DEFER; - goto err; - } - fotg210->phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); if (IS_ERR(fotg210->phy)) { ret = PTR_ERR(fotg210->phy); if (ret == -EPROBE_DEFER) - goto err_pclk; + goto err_free; dev_info(dev, "no PHY found\n"); fotg210->phy = NULL; } else { ret = usb_phy_init(fotg210->phy); if (ret) - goto err_pclk; + goto err_free; dev_info(dev, "found and initialized PHY\n"); } @@ -1286,11 +1265,8 @@ int fotg210_udc_probe(struct platform_device *pdev, struct fotg210 *fotg) err_alloc: for (i = 0; i < FOTG210_MAX_NUM_EP; i++) kfree(fotg210->ep[i]); -err_pclk: - if (!IS_ERR(fotg210->pclk)) - clk_disable_unprepare(fotg210->pclk); -err: +err_free: kfree(fotg210); return ret; } diff --git a/drivers/usb/fotg210/fotg210-udc.h b/drivers/usb/fotg210/fotg210-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; unsigned long irq_trigger; 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; }; From patchwork Tue Jan 3 23:35:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4868988wrt; Tue, 3 Jan 2023 15:36:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXICsf+2dL16e1UYM+qgzYtmCogkCv8hBuTL7gTZPdQvJBGaN8Jc+OS5f6D4wzqsH+KNUZ X-Received: by 2002:a17:902:7284:b0:190:d273:38a9 with SMTP id d4-20020a170902728400b00190d27338a9mr49058368pll.14.1672789003103; Tue, 03 Jan 2023 15:36:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672789003; cv=none; d=google.com; s=arc-20160816; b=UBGiuv6NAj9qM+ZmYZBQM1tk83oILCJD6K0ZndaHy1GaOoueLtXWg2PDC3JBm42HxN /8MPoE2+3LO12M28YwIJ4qUQSKqGMrYFswHGUiuc1td7vEXjveY0Gw+yjThEPEHDYI7o MFVX91eS9uDgUap2+RroufKR1tO5UE/Rgt5Efm/EhHQiIrHAQErArALhpn8zMPEwnhSW bu23wbP0PpUsk+PHHduErGsrAX++KYCUhtf35i/9rmfYArlenHHUhliGzysESaLDCzB+ r+HjgyLAdE35N1V5d9QImQ1Ajr0XW9zvmIS3CnnA0kV0ixac9KHwQIX1Hu1IwpuPSkdo Q+5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=LfqK6qBFH8YFyjUi0V5Pk9BV6gkDIZNht4kUj3nmxsk=; b=KJt3F0jF4bsMhLl2cL7IU8UJ6NEF/JjhLwYS1dMxRMPL/5vnaPHQO7qXZIgyHMiGu0 HxMwW+PclUfIloRxocReZuDcHOc6v5JDQOHJa/EiRFaVqfBKLGp5Xz1PabyUZjqzZiI8 6+2C2s0EsXdQGQVoDYoBjNaw+YMz9C4Js2ZBSQre7ngnNowQh1eCFSKkkZM4h7xceSRK z9j8XN/Bgd/SLbZdCz2qyVM2Oz9veJm/Ea/DC0RduNmIsIQylK1CwPhHB+3IaXaZv4ce 1TkP68PjBlMkr8vEf5qjzZXCguGG7jk/RXwiYclQBoVrwIAEZeWMrO1oUOh9x4NmEPAC CNVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GsOXISdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a170902ba8900b0018725c072a3si31293095pls.539.2023.01.03.15.36.30; Tue, 03 Jan 2023 15:36:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GsOXISdS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238474AbjACXfv (ORCPT + 99 others); Tue, 3 Jan 2023 18:35:51 -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-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 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754046401693094234?= X-GMAIL-MSGID: =?utf-8?q?1754046401693094234?= 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/fotg210-core.c index 58d84747fb30..013a1d0112fc 100644 --- a/drivers/usb/fotg210/fotg210-core.c +++ b/drivers/usb/fotg210/fotg210-core.c @@ -18,6 +18,11 @@ #include "fotg210.h" +/* Role Register 0x80 */ +#define FOTG210_RR 0x80 +#define FOTG210_RR_ID BIT(21) /* 1 = B-device, 0 = A-device */ +#define FOTG210_RR_CROLE BIT(20) /* 1 = device, 0 = 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 = &pdev->dev; enum usb_dr_mode mode; struct fotg210 *fotg; + u32 val; int ret; fotg = devm_kzalloc(dev, sizeof(*fotg), GFP_KERNEL); @@ -122,10 +128,16 @@ static int fotg210_probe(struct platform_device *pdev) return ret; } - if (mode == USB_DR_MODE_PERIPHERAL) + val = readl(fotg->base + FOTG210_RR); + if (mode == USB_DR_MODE_PERIPHERAL) { + if (!(val & FOTG210_RR_CROLE)) + dev_err(dev, "block not in device role\n"); ret = fotg210_udc_probe(pdev, fotg); - else + } else { + if (val & FOTG210_RR_CROLE) + dev_err(dev, "block not in host role\n"); ret = fotg210_hcd_probe(pdev, fotg); + } return ret; } From patchwork Tue Jan 3 23:35:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4869214wrt; Tue, 3 Jan 2023 15:37:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXvGGHaof1/WbPl6zJpv1849N9OEI+rbFjr36/VI0PUKo3d1zR0i2HZFdmPmT5GvpvE9r1Bg X-Received: by 2002:a05:6a20:7b25:b0:a2:e391:f8f3 with SMTP id s37-20020a056a207b2500b000a2e391f8f3mr61352146pzh.34.1672789043400; Tue, 03 Jan 2023 15:37:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672789043; cv=none; d=google.com; s=arc-20160816; b=O+Yyq3d0FRHCYt5ltSc1Pwoo6Pm7frKnDJAOPoKatBdzu/79udq2IQZgKJrFQFeV5Z 8H0OjGnGlSWK+BpmNCo0PqlyVeCVB2SoJEt+Eo8oqFbV0KJh2WzpTNngeb5RJVfHpJa+ DY4I2A8HLP7mkikJ5XmxrPdf934c4S5S0sjxaDgr+VEvFRasLi567puFOe6pH/mKfSDv 9U7m4f0kWmt5TckRblnnYkK9qqNdL20ofIMd6srb38cbhNNSiGgFfeIoaYvYmENNiPTv LRK4wVgh4N1pQ4iHJ2KVlUe1LCBW1nPlobdLMlSKwA7liIeDdZIhohBBMa19xpg1oxmC pFmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=tcCZcfMImVoguFifloAOWn9GN0CXlpPQ4S3kvfMhx2k=; b=F0cMRxuH+u73UJwZwpXpnUSdamufoRbXXCRGKzEO7KZaJxXNI5rjCjTmHY6X91Kp8D eJVWUypV9VJvqAD6RJG+ruBJBb+0pn9Doj/TspqkVmXUhadiN+7IQPi4/7UtL2gpA3je 13Hjgrvcok5tabBpZrFgNXBabOO0zJq0QpTnH2sxl5txqOpTiFB1CQ9rSp2NLOtR35+H qsMneyOne6Fitr5D/VNJ6dluGXpPXLxje9mYGrH0P7cq3QDiSF6B0QKWjVer+fTqvr4e 8gmQ73NWwPk/v3ZOvvR2SjltKTF2iT4tp3W4PrGy7KGZGgSGlhIqPai/v4wpU8AdkE84 hGhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LMzkaTaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020a656410000000b00476de006c26si32909382pgv.52.2023.01.03.15.37.10; Tue, 03 Jan 2023 15:37:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LMzkaTaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233936AbjACXfr (ORCPT + 99 others); Tue, 3 Jan 2023 18:35:47 -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-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 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754046444239969743?= X-GMAIL-MSGID: =?utf-8?q?1754046444239969743?= 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/fotg210-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 = NULL; fotg210->driver = driver; + fotg210->gadget.dev.of_node = fotg210->dev->of_node; + fotg210->gadget.speed = USB_SPEED_UNKNOWN; + + dev_info(fotg210->dev, "bound driver %s\n", driver->driver.name); if (!IS_ERR_OR_NULL(fotg210->phy)) { ret = otg_set_peripheral(fotg210->phy->otg, @@ -1071,6 +1075,7 @@ static int fotg210_udc_stop(struct usb_gadget *g) fotg210_init(fotg210); fotg210->driver = NULL; + fotg210->gadget.speed = USB_SPEED_UNKNOWN; spin_unlock_irqrestore(&fotg210->lock, flags); From patchwork Tue Jan 3 23:35:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4869011wrt; Tue, 3 Jan 2023 15:36:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXtnHZNkZYica1MIDulACvuGWNMfVTq+uWNlU86rR1xna5wU/7J6uG3NKQx5E2BZv/Dwv/Xz X-Received: by 2002:a17:902:e54b:b0:191:24d1:8af6 with SMTP id n11-20020a170902e54b00b0019124d18af6mr71672881plf.42.1672789006051; Tue, 03 Jan 2023 15:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672789006; cv=none; d=google.com; s=arc-20160816; b=n5eQLgoRDbtwCWfen+OhAJJcOOaEi+wTFUlBAfEm0RuI+VRrsUqHxA4zzS+tT9f/0t rbZMofQLLwG4brWSIQGDhYVyKUreDO7H2BvBtb5kGgVdY8s0AHYZwpZQcloHbN8N3gDO +RStMEMTuKR8UbmwLsDp2kUzyF5dU+UDA+bL2u9rySrxWwunJaH/ZQ6mvdDhRuX3zxeP 8Tyai+3UT7FVx6RUVQE2pJPFQ1aGFW7ryqsX47k0CtaCM2SAXuMBuhJE8PSZt6hLjRDS ZMa4zmrO0ry9tqSHa9Hl4LpXHKTprCSRdBSAjbpdUQAmnHuVfuewCdPYetHITW7lYuBJ sKnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=R0uvymsPrpGAEh2BG1RLD0dqjUm8ZCLGS+gXm8386eY=; b=wWbYikWbF1sDdpORaqGswKko0qQw0DPYnbAX/sFp7VF4xWYzETLzAy4VppOpd9wwyx Q+ujnLVvSmaXlhuB7mcPzqRvFyqdP4lm/gGcbMGhvurODSDK37ZhmzPLxDaFopGEWr19 M/TwMTsc9ZCEczx5b1iBXmz1fD2oeOjmMevNJCpZwmv1hadS17qjEhP2izWZ8IGeISB7 xkMNvL2diTlL5Vd2O7Dflkj4jzfaraKfmtmSw4sa5sNfqbSYGcgkD3CUx7NNOwMxVgC5 XbUssFnaXDVrrfX/Y3ySxgyUHoc3CdULeRre4yI7od5lrSfqHwd5EsnmCpRMbFTJrZqw t2FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HbM+7KVQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a170902c60a00b0018954d84f0dsi30864571plr.431.2023.01.03.15.36.33; Tue, 03 Jan 2023 15:36:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HbM+7KVQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233962AbjACXgA (ORCPT + 99 others); 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-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 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754046405070434064?= X-GMAIL-MSGID: =?utf-8?q?1754046405070434064?= 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/fotg210-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, struct resource *res, return 0; } +/** + * 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 = GEMINI_MISC_USB0_VBUS_ON; + val = enable ? GEMINI_MISC_USB0_VBUS_ON : 0; + break; + case GEMINI_PORT_1: + mask = GEMINI_MISC_USB1_VBUS_ON; + val = enable ? GEMINI_MISC_USB1_VBUS_ON : 0; + break; + default: + return; + } + ret = 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" : "disable"); +} + static int fotg210_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-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; } +/** + * 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 = 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 = { .udc_start = fotg210_udc_start, .udc_stop = fotg210_udc_stop, + .vbus_session = fotg210_vbus_session, }; /** 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; }; +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);