From patchwork Wed Jan 18 07:09:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 45056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199469wrn; Tue, 17 Jan 2023 23:50:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXuxn6r1KQ+PL064aZPb64w0j2oJOsIPDELWe2Djh+XykIQKV0Kyd/AIx5y24LhgGu21Z55k X-Received: by 2002:a17:907:8dcb:b0:871:ca62:5666 with SMTP id tg11-20020a1709078dcb00b00871ca625666mr7162426ejc.10.1674028207677; Tue, 17 Jan 2023 23:50:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674028207; cv=none; d=google.com; s=arc-20160816; b=qo+hL/ihei97s1+suwSafGCLrXte57J4Ju7EKB0EogI7YHh1f1/0PJCMgtlZP/xa/l AeYQy0KbYNFs9ai4zyU7rY2t9j79zQWeh9W/1rxPxXqbCAzMMEwef0e9gMQACFTFmP56 EDsToiAxuGaeuID8Xiu0nm8/nLb0Qy1J9GNcsIqr+5PyZDGD0xn5yW2XytsaSJQiDAJc Gsk8YXnA1qtOOarx71CS+ap8JLynmN6IAb2LX1YpCwrZFK4SmG1P2pjzU7uiNAEpBhPy /GbsuwGJ/N8GDrReUK3yCIoXQmUtu/VoOeVjVWPpj+RdzsyY4yBHtwF6G5mfMH3s9FYi qJcA== 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=tz/0Vx6eDg0DiBO/TaaOaa2oRiAZoQpqzz9GXBsd0QI=; b=t9fKIjHrglkfACAnMFJ6YAUUgC3uDrxmL5DWFHyc32ktertk5pBGFzEtoEAvlEzEvy XhrRRPeSJRlWzrKlnYA022qSYNXHp7Gs7l/ZzdgmLlr7ClWqGX/OsGjhxKGXavAzis6n 6ANy6f3WlMY0VQTB8cEqs1U0EghOcY9P91TdWxkX/bCtqaY5zG0lIAiXTGN0CqyRkXnS 5TsSlRyOVyL9geDhcgdI8r7tTrbeiLtNVsl0WutwBIz19zJqGakwgIhODo/OWDBTi8t6 odUq5UlGDF09QJlSd8sqxgq3VX4VD2V2T+/4VhA+S1rfUWzoqJysMPWHZy8G7zOTfNmw tLSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BOmgKM0Z; 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 dr7-20020a170907720700b008775c01f763si1436133ejc.539.2023.01.17.23.49.43; Tue, 17 Jan 2023 23:50:07 -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=BOmgKM0Z; 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 S229640AbjARHqE (ORCPT + 99 others); Wed, 18 Jan 2023 02:46:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbjARHop (ORCPT ); Wed, 18 Jan 2023 02:44:45 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 459B361D63 for ; Tue, 17 Jan 2023 23:09:33 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id z11so48368475ede.1 for ; Tue, 17 Jan 2023 23:09:33 -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=tz/0Vx6eDg0DiBO/TaaOaa2oRiAZoQpqzz9GXBsd0QI=; b=BOmgKM0ZDO1zyDLyzTQDcxlUBStdroCvk+RDaDQ/lnIrEIpNzUZ8LhHH497vVWux0C lUInWZVL2l+49/noO6Kr/fJXPJ2QzISh2921HrIvaqfnHQUKxyvcNH7/MZy/ZTT3XLoL YmDQcT8cVo1wWxud4qZolFXblmCWHxw6mxM5vjbXCetXdYipM1Uvl36Qxgyqrx1AD/2X unfn9T8iEQ28UpQge+cj8q/+/59hV+ii7noq2IAYbnOBZICU1yxqd+K0V3E1KS7jq8Oo aF3tDoDuQac/ObCPPrSE1Xlpu8AIq+rhFqOH39hdNXUZdwB7w09kXQcs5vT+OtAm+m2h TwQw== 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=tz/0Vx6eDg0DiBO/TaaOaa2oRiAZoQpqzz9GXBsd0QI=; b=HAaD+1e4CN7F1mwjJv6kcb0/EnMKJafnR2LPtLZCy427o9iJ0wNSX0byQMVShvDVXQ /lmjC83Ll3U0o6JLMjMWYv7Qqoqz4X0foE+V30wbQWum/0pgy5Ynzx3kicRbipmGif0d OK2bnqi2H0xc3a5e+kgd6sVpyV/XgYjiddv8Ny54upq4JD3HNXdUcU74OzUe6af7pgtd qGnF3TC7VNgEbm+r2KJDNkDhABmsTnOO+gKUZixhmsL/SR+v31FtmRc48Iu1IF0U7Gij qL+nnQdk9uL3Dl0jN5K0glyx2+U+LLy2ZzGMqkGGXAyL61SucdiKdwlf/uOQ7hvg1T7C XiaQ== X-Gm-Message-State: AFqh2koZupCRpud390NSDgOp+nVvVZGIeqBxyCgNX5LPV8JNK3qBSdDJ ZErY1ZDX8xhl2W6bEV+ZEv/NpdBNEI9kjpKc X-Received: by 2002:aa7:d887:0:b0:499:1ed2:6461 with SMTP id u7-20020aa7d887000000b004991ed26461mr5812989edq.17.1674025771805; Tue, 17 Jan 2023 23:09:31 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bt16-20020a0564020a5000b00482e0c55e2bsm13596984edb.93.2023.01.17.23.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:09:31 -0800 (PST) From: Linus Walleij Date: Wed, 18 Jan 2023 08:09:15 +0100 Subject: [PATCH v2 1/7] dt-bindings: usb: Correct and extend FOTG210 schema MIME-Version: 1.0 Message-Id: <20230103-gemini-fotg210-usb-v2-1-100388af9810@linaro.org> References: <20230103-gemini-fotg210-usb-v2-0-100388af9810@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v2-0-100388af9810@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?1755345802307407279?= X-GMAIL-MSGID: =?utf-8?q?1755345802307407279?= 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 Reviewed-by: Krzysztof Kozlowski --- ChangeLog v1->v2: - Drop stray word "bindings" in description --- 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..3fe4d1564dfe 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 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 Wed Jan 18 07:09:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 45055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199417wrn; Tue, 17 Jan 2023 23:49:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXvCr1cIR7S6MWdjazDo26F5f8Omy59J1dHX04AdDJonKpFnf7Uoc1mowvNLRORb95uStFUO X-Received: by 2002:a05:6402:1ad1:b0:460:5706:d1fa with SMTP id ba17-20020a0564021ad100b004605706d1famr6114268edb.18.1674028197545; Tue, 17 Jan 2023 23:49:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674028197; cv=none; d=google.com; s=arc-20160816; b=Y8qQ8bGBgwjbA10a0mtHz+TVy9IdUnEDYEf0Cha0ANaE9iGCF0PSXXZI46aFH4W0Yl /4ocbP39t71RPHWKt1MUVfmZs453fTAARNlhC53UKtM4R53RGZ4fGvKH+Q89zhtTexe+ kcvT0i0FOvVD9FGineKILmLWJP3tPIETFUwhj7wzjmPatV539pJQh00H53BJoSB/H8Hw LKQqoVJu5iZvYfFtPw9ZaS6n+0NzBpOd2wWdsKif0+4YO8u0gIsBjIL3Hqz2aulLzA67 JPFF0pheekrRfhUN3UifKkZPx6vh26Y0SJT/WcqMPuWyNRMUB2sXMCsR+28X8sgsS7SN 5O9g== 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=W+ByaNjNMsFVHh2+86A0e94ppJsulN3YnOrh35qT8wE=; b=vD5FIWyJfPZJAOmePbc9HontoRXxOJCpf3MhVBvAFgg5iaYUXIHl6yMw5DqQHLolYU e9Ym07mjRDBTGZH1VDIe0/ft27RvODgMWrrOXNvkvLYaVLLb8N4Lfv0032NrMEdPJXz1 ZPMqh9Fy0xfkuIJLn/RwgCh0n1kf1iRo1eOMuBpZg2v6F95n2K881UtU9gRyDlb3u3EF is/9HrAAa2Ar0Hnfj61ycGW34kpg4B4DwkPz9VkpGHjcBZ+V3tIKDS64be2HNDd+22bU sRazk0eQ59RLcDVsLatdL/GY+kijHjTIzhAH/yw/erRmBYDFwwMGtDbiIkFbpqo2cR/U /CeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j2OAqho3; 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 m20-20020a056402511400b0045a1dbedd92si40464353edd.35.2023.01.17.23.49.33; Tue, 17 Jan 2023 23:49:57 -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=j2OAqho3; 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 S229999AbjARHpv (ORCPT + 99 others); Wed, 18 Jan 2023 02:45:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbjARHor (ORCPT ); Wed, 18 Jan 2023 02:44:47 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 871F9470B1 for ; Tue, 17 Jan 2023 23:09:34 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id 18so48329114edw.7 for ; Tue, 17 Jan 2023 23:09:34 -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=W+ByaNjNMsFVHh2+86A0e94ppJsulN3YnOrh35qT8wE=; b=j2OAqho3+opiA5EDso1N0iVJ8/kZBW3beSDtZYYdS3aPzzUkwS3SAm8pEm7EOhJvHj bD9M4bDvOyqr18y7V47tHmJBYuZdk/OE+ASdFx8OmVeX3tCGCwQwdhGNbvJehuQk0eAF 0aTsmD0w6JuhPMalUOQNiq9ehLy1eaIo106sCXsThKMH4jcNTgIyOSRrDplzzzF66K0K 4yemZrWlRo9tZ57LkQ4UQd3h80UZnLR/2cYO8eOEz2frQGffpIIghK/BFw83SpRLYJB3 TxJqHDt0v6cvvaG1pCCZZzFis3R22em/z0VT2pjChkvDO1lYdLVCQYkLm7XavJPKiP4n 3I4g== 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=W+ByaNjNMsFVHh2+86A0e94ppJsulN3YnOrh35qT8wE=; b=TVYW7GVA6a/E35qIhYHtBkS/A4Tx9uiakO7elcgnp6eQG/9AN+Jgu006VO3PnQ7rme yT4RXmISMwmHhQ2WNkLLh7pcH8NzEe2uf7NPXv7KEXTViosARGQIiIusJ1EGObmlHjpd A+OU46xlMQFV+hLaCf/mQY8obKG1CkL1ttEr7sV0eHmbdmprCEMjztudtRcdDmRY8lgx wVbBuE0yAqpZQBGNCTspQWvjIHq6U7MrhMGXAAeBeFglxd8DkDcPCUhse1+FGeRX1Cju BVS9LCMJ2+N+DwL8cYxggEN+9UyFQH138rfiXymnur5kKyCa4nXc3TVHsosEY3jfgluS EgyQ== X-Gm-Message-State: AFqh2krN/QOGt7Lbu6TQPQ4BjHkCzfa57wEIIbkQUMQcsvY8PEQgKLrr h45VaLeK3iTe2IHRscCY2m+Acw== X-Received: by 2002:a05:6402:524f:b0:490:47c3:3d7f with SMTP id t15-20020a056402524f00b0049047c33d7fmr8255387edd.2.1674025773120; Tue, 17 Jan 2023 23:09:33 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bt16-20020a0564020a5000b00482e0c55e2bsm13596984edb.93.2023.01.17.23.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:09:32 -0800 (PST) From: Linus Walleij Date: Wed, 18 Jan 2023 08:09:16 +0100 Subject: [PATCH v2 2/7] usb: fotg210: List different variants MIME-Version: 1.0 Message-Id: <20230103-gemini-fotg210-usb-v2-2-100388af9810@linaro.org> References: <20230103-gemini-fotg210-usb-v2-0-100388af9810@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v2-0-100388af9810@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?1755345791278898619?= X-GMAIL-MSGID: =?utf-8?q?1755345791278898619?= 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 Wed Jan 18 07:09: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: 45054 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199314wrn; Tue, 17 Jan 2023 23:49:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXufh9uIdBMPF9t42ThZAq6Xve/wTS5pNl0acHoCW9Acri3ZeWQAPlHKAwc3guWZcgMv31+h X-Received: by 2002:a17:907:d50e:b0:877:5b9d:2f9a with SMTP id wb14-20020a170907d50e00b008775b9d2f9amr1295788ejc.25.1674028177085; Tue, 17 Jan 2023 23:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674028177; cv=none; d=google.com; s=arc-20160816; b=geSBKjH1huXydUH7y1Mb9XsHsN9qyQsG8S+QdBgLBbZdNnWodF7GRRjUiSyVFSPjA4 8VjTxL3OQfHaZ2+FLbEV8YMWxdDp1S3kvrUBXgPEzLBNjOhZ7OwbGCe4xOTNA1aGxWQX PjDF1jFppBOftEKdoJcl+GRV1s/t3ck/oXy+VAJBhlqQAAeGSSjRUEVsfCHIfVarPnbS nMoxYT8Ftqo1ICHNly+oLhWbTsO+w4/k4HYp/WSqp0vabOExkZvKZ5wFGpKclWL+YImJ J93Wg9te8GZPwjOs/fS4hKOwJzUB6WUPwP9Tjy3ISdGTnAa31fffcreUouLz838QbjEE G5lA== 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=a3+Ki3jVLQ0LRVXvgBC5LvGWwpzkotK4uxgJyLKL2bM=; b=MW3W78Xnd65McB+dpj+roLrUMWFswPmoa4l7uA5BKht8YSWd6hFy0H0UZR29SK6wU3 iIC72HTrOIpzKfWcwF2N86+Cab0I3JPL/jEJ65vY112InQEnsNvV16sO4jY3t+0KAGKw 1gmaeSXOoKhXoCafGzfD4BOANeql4h81emnxeQeRZUSwzaTPGXRzqz30wP0LvVVRd1CA H7jli++dJzeGXKtf07tNQuKnZ91TCVRoUID9ma2At+o0xp4Jc7vzTGjTJ274ZD80DNBh HxqEiap9G8WvPUBrNF7K24ESgenjjmB9DczCDeDE9Mlz+DexHxT8EQuGsfmImX+4Hl1w lpxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vewduD/j"; 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 gb21-20020a170907961500b008722ef50e42si6086838ejc.277.2023.01.17.23.49.13; Tue, 17 Jan 2023 23:49:37 -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="vewduD/j"; 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 S229964AbjARHp0 (ORCPT + 99 others); Wed, 18 Jan 2023 02:45:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbjARHox (ORCPT ); Wed, 18 Jan 2023 02:44:53 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF10063E06 for ; Tue, 17 Jan 2023 23:09:35 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id v30so48343641edb.9 for ; Tue, 17 Jan 2023 23:09:35 -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=a3+Ki3jVLQ0LRVXvgBC5LvGWwpzkotK4uxgJyLKL2bM=; b=vewduD/jVKEMwZZFSWQzb5JyBn0POCggM/Ke8wGza2mC4TKmzBy1Z1t3tZNYC19JtS KPh+e3siB+GMgsJNYMKhkxYy7Do59VzaRxc68cLGHuG3OkiHmCQSpJjTWoNptd1VeRiU w4CXy6HsR1cjLwjGWMDytBzspLv/DJaf9cR4f02nLusa9Xj+iQ/GIWqd3aw8aYcsDAfs hsEBP7gW8j2S148wXY3HmgBKk4PJAkLcU5+O32vFRuULVNl/HRGkoIy2yuYGkrHb/KA1 9SsaDhI9Plff56ltuIR3YInh1aJNhP7kxWuoztFSLszGZBxEyJJETT2EZb3zDgtn3rML /qjg== 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=a3+Ki3jVLQ0LRVXvgBC5LvGWwpzkotK4uxgJyLKL2bM=; b=TVilVMFlFUCNykM18vloTOn2BSeHvJhGcB8gDZAfrFGmUBh9G9wjWwHyp1fNc4das8 IMOkwAhL5/DQmc/KzXMdhbwzUvUaHS+v70lV19rSYtYEMG9YpxSqRNJYGA69dys6JEUY ZSDh41+stdwhRJWgJEkzQ1cRKGG/pFPgOKwa26KT0/U+Ei2+Td7Ik7qOz/aICLQCp7TI SVcIJtEV7PGAX0fMfeLORMROZowCqnzbWRNXzg2yVxZ2yUABvlc4BzetAXXlaOYbQS0y h1Km0NuxdreTAcF/4N76F+r2ex5zYQd4nDoT49B5QyzNZJ3Y4ubFyJ0E3Ac3Y9G6aqLN JmCg== X-Gm-Message-State: AFqh2krePo3EUml8RV28CznPOJURT41G7F5Sg6bcqeGSxKq6yXsnNa23 C6+VDNPssJX0fabGecjYztsHUQ== X-Received: by 2002:aa7:c91a:0:b0:48e:c0c3:796f with SMTP id b26-20020aa7c91a000000b0048ec0c3796fmr5705818edt.28.1674025774347; Tue, 17 Jan 2023 23:09:34 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bt16-20020a0564020a5000b00482e0c55e2bsm13596984edb.93.2023.01.17.23.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:09:34 -0800 (PST) From: Linus Walleij Date: Wed, 18 Jan 2023 08:09:17 +0100 Subject: [PATCH v2 3/7] usb: fotg210: Acquire memory resource in core MIME-Version: 1.0 Message-Id: <20230103-gemini-fotg210-usb-v2-3-100388af9810@linaro.org> References: <20230103-gemini-fotg210-usb-v2-0-100388af9810@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v2-0-100388af9810@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?1755345770003118484?= X-GMAIL-MSGID: =?utf-8?q?1755345770003118484?= 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 Wed Jan 18 07:09: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: 45057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199634wrn; Tue, 17 Jan 2023 23:50:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXuAQXI/SeGzyjPFUNbKqNf4o7SYxMRaLgWuBIRkRffOD6cZpacBFQ3H/CiA9VAu5NfrmyrJ X-Received: by 2002:a17:907:397:b0:844:5d1f:95cc with SMTP id ss23-20020a170907039700b008445d1f95ccmr2196387ejb.15.1674028238837; Tue, 17 Jan 2023 23:50:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674028238; cv=none; d=google.com; s=arc-20160816; b=ndrHe373NdTukjW3d4XS/oZOCqVnkUgXI/s6kEp27CUgDJ3qR2Bx+a4RJn6+GZaM6r 8ihXWu7Hv7IL9MKu06n4D/i1mpoLnL5q8JvUYRL3HYFpM1h7ske9Y188ZpaxzQk4J7M9 vUZXLO0C2wxJwqX6wRjVhMYcFEo5MR8YECGFoWMfLx/r/c2v5lv2ekLCybzBgWTskQlT U0kYU1uJmc3szOD5sIRcqVUd9Z/zF6aZwOSc6oiJWJBaRiTARKJee9hjE7bs2Wa8MlPh 813MCh+CUEmVjH2lA4iMaYnwkc2muAcCxpHRyXJaawBLJODKapcRdqysHXVgSgJ2VggO d8uA== 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=MPfoISQ8yjAy6Kx331RQfusK05V745Ciii+y5Z5oDqY=; b=iyixdqPG7/PkMJ15nlomYp4nMqiiyGqs3y/CeJTaazbyx2/+YNE4ou3wgEq5dAz3hL pRyynZ4z1rbRLDPTkOIi76BWDGOA5iSVscsdsnJdz6ThGY3XBs9lZdOlyOYaqXJbRt2x w/6+IGWxZedI2EQ8s2Tp0QDCvKLiJrVrEKOjh5ppdWIvPyE2rLY84cEwHYh6AMSSsAlE wllmt2XGUGWEbj6H9soW4sUbJ6PVFquIrURlCTQPm9IILvmM62VRdHlJNil3Vq6bkO58 C4w/GVkTeh19XJEW/4B6ZpXSwbA4Q8F//TElBjgUwix82HIuq1US/mE7wfoe811q3/43 MdsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wmBctA3n; 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 gs7-20020a1709072d0700b0087752be1da1si2096138ejc.791.2023.01.17.23.50.14; Tue, 17 Jan 2023 23:50:38 -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=wmBctA3n; 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 S229789AbjARHqN (ORCPT + 99 others); Wed, 18 Jan 2023 02:46:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbjARHoz (ORCPT ); Wed, 18 Jan 2023 02:44:55 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEF3861D6B for ; Tue, 17 Jan 2023 23:09:36 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id x36so13684182ede.13 for ; Tue, 17 Jan 2023 23:09:36 -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=MPfoISQ8yjAy6Kx331RQfusK05V745Ciii+y5Z5oDqY=; b=wmBctA3n37PE/Qp9VALE9hvyzokhZGhVlRNSBMG/pR54HplM0ADaFZtoQFMksmipEH BEjNgVhJHaYD3m+ygGntHKc58L/3ykSpeavTFyxZz5O1leoe+/DM+ePod4CBmWLxwAgV IK/YQT7ilfTtVzQixBiKdyVxImzjpGhkmtXPc8yb+SBpOGtbx7SbrcKelgEtejFs0fiI S/fiNx6xMaezZ+IZRpe437F8EYrB3ovmHkKIaLrs4eqHLEAx1jJYPMU3xHWsNd8VWcDH Xk0mrBequEd/CuuXL/cIoB//DRWRvUA84Emwn1so7JKoE+EEmgr784BZHZp4+5zaHZa5 nJkw== 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=MPfoISQ8yjAy6Kx331RQfusK05V745Ciii+y5Z5oDqY=; b=uxBzAGYEzlNOm130ttoBdTWRJwWx6J6OBY1pJvQriJ9ovmJBU2oXsRwQL/MjoG8fDW 9Xft4hC581W8gavTyFti7rZc/ONCJ3ATYSTon3TAJ6tt/cTIiAfBBTam/zB/6LvhL7OC 61Onex72ha0xoxrA7Y0Q4vevjIPa52j366Uu/ITaje+AXFzyCcN/XqvwKcqT7pieNlRf SYC+T+kig8QQDFMJ6CMGhvVwWfBxxH1w16y6B+97fY5eY4IjoD6O2RsckK3cRD3icEor +j+l0AtzTIvZK/bTd8kP34gKAwF0/VHTWNi/1/wJZodqRdjMfWnBfPQcOuHVGxLJrtTa m2ZA== X-Gm-Message-State: AFqh2kqDdfLtpm3LaFhokIyf2KjBODa7s5mBcQJssecIlaxxi9X+slx/ iiZmTyuD1GbJv9O7sDW2LyGffT7Dy5GNS7T6 X-Received: by 2002:a05:6402:14d0:b0:498:1995:ac54 with SMTP id f16-20020a05640214d000b004981995ac54mr5288614edx.40.1674025775533; Tue, 17 Jan 2023 23:09:35 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bt16-20020a0564020a5000b00482e0c55e2bsm13596984edb.93.2023.01.17.23.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:09:35 -0800 (PST) From: Linus Walleij Date: Wed, 18 Jan 2023 08:09:18 +0100 Subject: [PATCH v2 4/7] usb: fotg210: Move clock handling to core MIME-Version: 1.0 Message-Id: <20230103-gemini-fotg210-usb-v2-4-100388af9810@linaro.org> References: <20230103-gemini-fotg210-usb-v2-0-100388af9810@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v2-0-100388af9810@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?1755345834516914330?= X-GMAIL-MSGID: =?utf-8?q?1755345834516914330?= 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 Wed Jan 18 07:09: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: 45058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199675wrn; Tue, 17 Jan 2023 23:50:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXtzRbTgFQnHLTCC6UQCQdu+uErHdjOL2cRtkPJF72FdXyiUUiYk+zTjxoM3R0Fz73fGIsZF X-Received: by 2002:a17:906:e13:b0:870:f0c8:8187 with SMTP id l19-20020a1709060e1300b00870f0c88187mr5469233eji.24.1674028250190; Tue, 17 Jan 2023 23:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674028250; cv=none; d=google.com; s=arc-20160816; b=ZfEgGUb+jKuXIunoDGLmF2S2GJ5hcw1zQl0GkvmPtt7Y5MLcqEkwZojnQ9Dda+SzXB 8u752qxceuVUe8Ejobv0KIgsnJ0viPg6a/LiDgviJJrUhn+J/BVVUkOBKns+YLp1BV+v 4esz3N+lFR7sSOIemrNm0nJ3wC1Z6nRadsjcjuZ4dySynlSm98r7n9r1u/svpqfYJOol xAd3B8vzwuGuMInRwmxm/8reIRArU0SQMFE6GqZ/3RGin9jU4UOY8iNIlas7d/F+hKfd /j+7bw/TbF9k81mXla+6ljmMftU124VrLOQTVMUhbF0w5UpVspO2AvcBiJPGe24GMRv/ tv6w== 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=sResmjpkOst92em2xHEqCRKaDl2VpyxVgJORb+VfbaQ=; b=eka3W+ih7fn/m+iOz/zsnvu4erzkBEzNb8AoX9tQiygoUBJh50UgEd4rdIPquMmCfP S9AQaixbMxALLnhJ8sLbRmBFZ8b6XlyFa2j2x8VSrGC+DzwvC0sfz8stLQMgx3SI7lQT /EnbtrVOtOGE/ELJul3G+/vYOd5TrMWtlrnYumsBrH6FyuiGmerJ1XOrdfflKmtcDqXW ix4NfftNJiUsQ3GQ+7eRPwEzq1IqRU0Mh6QqlH6gLAVKhNGr6vNc3frv4sxBoV4aTfC0 uqfe00QqqhFIHBJUnbnIRmTVaX8yFQts81rgKggY7VU6eLy6y16+ZMtZaX2hG2Ee21F9 2/1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YemzCb/q"; 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 l6-20020aa7c306000000b0048475139291si11534857edq.590.2023.01.17.23.50.25; Tue, 17 Jan 2023 23:50:50 -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="YemzCb/q"; 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 S229626AbjARHqn (ORCPT + 99 others); Wed, 18 Jan 2023 02:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbjARHoz (ORCPT ); Wed, 18 Jan 2023 02:44:55 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23AD463E11 for ; Tue, 17 Jan 2023 23:09:37 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id b4so28839131edf.0 for ; Tue, 17 Jan 2023 23:09:37 -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=sResmjpkOst92em2xHEqCRKaDl2VpyxVgJORb+VfbaQ=; b=YemzCb/qx1iRfYzhK9MKaNtuiANnVfC1Abut0sC2esnXr2/e+4FpPdrNk8mYkAQWoM BZENHwcZvGshPwQWDz5EjDBnHW6zY9Iqe5ziDE4GUICXxQid/AKpK87Ukj32x1c/MJqp HzqWrCB0q6TxjbFtDi/h6W5e6HtSLqVkd2EzLgiBGM/kYJUSuLQbdm8Kd+bclLgn26M4 B07WtxWgeNeXX+pvGTXdTfICy0GIo46l/iHWM4TyjR1Dn4DxnQAw7utgEKARMSkYfwLn Ka7ZGRQjc676jd5oTl7XYr24IintPyUY/ADOlTXsBKxdZhQsT/9KgqjEzc8noOj8MDxk hJuA== 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=sResmjpkOst92em2xHEqCRKaDl2VpyxVgJORb+VfbaQ=; b=0Y1EBpewCnNzreJDFNrOfx/JlUL9/Gls9OwOTfkQRIG2W84BoNLtiJlqW+AidqtDw6 6tLhm47KUB7laSarWkUvocnqWrhzGasuL6xLYpuAxkdlgHwN/l3LzVpmT7EjanzThWA3 r+pSPexPieh0MRVOrzENziQddBbhjRX2UFR4TEYN8zJKKg2Ib1ZZK75IbBuG7nj1NG+I ijzV1oywwc1tMP/xWrlW6zVWJ6rXcQkwGdATavRQYzPHY5Z7fFc0nMcwqGbe9enAd6zn qnuLhW1xsJ2WMC8h9yqytmwRYyagpaiEX2JDvUv+/Rq+MTgMoF9X06DmY+J9z86k6s6+ 5oOQ== X-Gm-Message-State: AFqh2kr9IeNE4qccKkNuwE5DGtsQGxra5SZNY8Kz3SzZDknaH9trDrVw e5df1n0nEO9hd9iMl0vgOio74A== X-Received: by 2002:a05:6402:4025:b0:49b:67c3:39ae with SMTP id d37-20020a056402402500b0049b67c339aemr6608930eda.33.1674025776660; Tue, 17 Jan 2023 23:09:36 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bt16-20020a0564020a5000b00482e0c55e2bsm13596984edb.93.2023.01.17.23.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:09:36 -0800 (PST) From: Linus Walleij Date: Wed, 18 Jan 2023 08:09:19 +0100 Subject: [PATCH v2 5/7] usb: fotg210: Check role register in core MIME-Version: 1.0 Message-Id: <20230103-gemini-fotg210-usb-v2-5-100388af9810@linaro.org> References: <20230103-gemini-fotg210-usb-v2-0-100388af9810@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v2-0-100388af9810@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?1755345846778973492?= X-GMAIL-MSGID: =?utf-8?q?1755345846778973492?= 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 Wed Jan 18 07:09: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: 45059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199715wrn; Tue, 17 Jan 2023 23:51:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXv2Ce1VVmWEYcIs+jf6REIO96QuvtZIfI0mSt/zS1uVyb2hCE61GDr0tr26wosz9q3KG1Uq X-Received: by 2002:a17:906:a24f:b0:873:4ebb:94cd with SMTP id bi15-20020a170906a24f00b008734ebb94cdmr4557666ejb.10.1674028261130; Tue, 17 Jan 2023 23:51:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674028261; cv=none; d=google.com; s=arc-20160816; b=tAZuQqs8TlU3iRd4SUcFKTdeq4F7YgqkrRN20TNtYiY9FWeHLBCFoEqO52A80VWMFL bbD2aml1LGLvsuuZkPlhZgVVM32TO7vpNM3TvjY6peCYPSx2/lp2JFElxRi80+yx2SPc NfMZ9muIEGTW+6jqujaV5Hh31w/Ur2WKPLq6rTrTezA+1z4MscN3+LAhBTVNWyJT95kC jZHG6XwiB3mWa0bAZkDnXJHC7p2YvE7SpTvlGT4EANwjaTqs5kDBTeZaiDz12bcrL2oG +47W66/odlUSrzykdmIcxJhFXswQ7+d3MzAOjxqtQ9UJtDi10fBz2io3joZ7xtbp5R+7 lz4w== 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=BGi6nevtBEvlgNue4HrSz3FnhFRGHNrkieQvtpQFYHc=; b=01AFSGqiQxeVLkn0vdPgGhUgulrdYpZqD8hp1PqTjmjfTJprtQQzQ0OYmZxzwa3lFi 324NQ1rPf/vyR2Y27wLhpbaI6JUR10DTFC5bj0lQTzkrbKo+6Jz72z74iXHFQHjc841b znOLXHWL8f6m9Hb99m106/uwhTqf3wb9/HRmSs9GyexBPSZwb01uLc9f5b7MnsK/Iu22 lSnjPIrJ0duLjvvlqP+8VdTAfpVwXvIpxTpDkgGuwAGXiGgSn+1L2ccZjwS/dOgHNMjp xdl2e5aWTh1/6fZ8qvSg1uKXV6wouRs2V15W0ehzNpbMiDgVpImF7LKzQVwUfGUo6di1 AQUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YtWCclO1; 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 e6-20020a17090658c600b007a953d421bbsi39531629ejs.322.2023.01.17.23.50.37; Tue, 17 Jan 2023 23:51: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=YtWCclO1; 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 S229685AbjARHrD (ORCPT + 99 others); Wed, 18 Jan 2023 02:47:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbjARHo6 (ORCPT ); Wed, 18 Jan 2023 02:44:58 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2480963E2E for ; Tue, 17 Jan 2023 23:09:38 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id v6so48278817edd.6 for ; Tue, 17 Jan 2023 23:09:38 -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=BGi6nevtBEvlgNue4HrSz3FnhFRGHNrkieQvtpQFYHc=; b=YtWCclO174QhyaMA5EVNNQLEWZVxz+9FPz49LoHxX2km/CLtESfB+9DI3Ioq/2Axmz ZIdzk2YypknjThU/8BJSCfqmXhoEtefbk2or5M0kiK0rhsMybkXbKV92/dpwpewYjKMe ZW8gR0PdnL1d6aDKso6qqZKbCSYwjg5Ay2BQxN93YOG2scLrRlPBe9oYcWi02CteNDPK rJiAPrxMv1jqH8YvB4R/0C8J3dBUHG2xj7Y072Bm/LyyBCa4jiK4ztQnApC012ubxC1G PA3j01E5IQ+lkOUrNXKe6E0ppjHgCXo99HP3+/2YXjJsTgIMHjEf7Em9bbIcITNwnd9w 1pUQ== 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=BGi6nevtBEvlgNue4HrSz3FnhFRGHNrkieQvtpQFYHc=; b=idxpseY55+v1W3Md8pVLjD7ettCWg3TAdMcD9TysfA8cmIIGO39DV/7kK12Pw7wNvF GRAweSK4YtP2wDGmQqCWJnkTyT9d1BeJWyNOOm0TZDaOx6dOPm0+/mE6TyE5oPcD68Q2 Yt1haYtOUe4knGtuwMOq/fml679UY3/lnZPRZk+CSGwYW+pGN9kLM6o8y39iqmADFmxi tDaoDfTZgUbvtZSzNnEP3rozvqx3qkiTwTz2bxnK4Z2AAGYG9EaU/uv9D7uO5ejUkp1f 1B6yfvaDaS3oWZPGTAoGi4BoSaUZ+AeH+jrVC63CV6nm3JulQZT/7yJqvzYupDM6B5k3 QymA== X-Gm-Message-State: AFqh2kp9VfE2SMnNeiKFpNsMNEjPT6qA8ieAHEb2+MMqb06fX9G4zmDj cKV62FPdOj8TS2INW/iufuZ2ZQ== X-Received: by 2002:a05:6402:3226:b0:498:1ca:80d0 with SMTP id g38-20020a056402322600b0049801ca80d0mr7193209eda.28.1674025777745; Tue, 17 Jan 2023 23:09:37 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bt16-20020a0564020a5000b00482e0c55e2bsm13596984edb.93.2023.01.17.23.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:09:37 -0800 (PST) From: Linus Walleij Date: Wed, 18 Jan 2023 08:09:20 +0100 Subject: [PATCH v2 6/7] usb: fotg210-udc: Assign of_node and speed on start MIME-Version: 1.0 Message-Id: <20230103-gemini-fotg210-usb-v2-6-100388af9810@linaro.org> References: <20230103-gemini-fotg210-usb-v2-0-100388af9810@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v2-0-100388af9810@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?1755345857803714478?= X-GMAIL-MSGID: =?utf-8?q?1755345857803714478?= 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 Wed Jan 18 07:09: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: 45060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2199858wrn; Tue, 17 Jan 2023 23:51:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXuE/epYjtiDDlv6lh1ePBU+teldIL1j9sp3IuRZ5Cw5L213z0eHRWuH3VIp074Mc30xqtPu X-Received: by 2002:aa7:dbc4:0:b0:47c:445b:b4f with SMTP id v4-20020aa7dbc4000000b0047c445b0b4fmr6013067edt.32.1674028288876; Tue, 17 Jan 2023 23:51:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674028288; cv=none; d=google.com; s=arc-20160816; b=fM8/IF2wlF0ljifdS+IiBo1K3PFx5Zu/bTJVBV5CRbSXNiIdjVLMBeu7KLSJqNIPxK 8x2rQsQtpV557UmmjZ1S3LnK1XRAyB8WLzKov9N0X5UIOMwgyCUkaVf78NZlKCoU+rED CToZhEZpNmzeD9xeGPCsP3iA0ynmMQfzcYF53ChKzC2L9nOXLRyfsFllWlVj4Ypv0wEI AXQI68JPnmbNYwibB+v8nVmPMAq/Y4bcxvBP4SOlYIF8WSZB7H6jULjecumLZHA5gMmK U3A2aIElFr9qoYi/alBm6VELMEPu7mTFwgdsm3UuGDfKFHtEAIgzuqm2AKCKEgpPw19m 13kg== 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=ERUzW2NTS0HSKxHZgJkhNmc/Fre4SMT/MoW1Mr8mzQ4=; b=pdP0t2HJ75q+jDdjsFcVBwuBxmb+XWiKCowy/R13srZ1/MCS7/CIOUr6lruhMee0Qk 7vDWq1ySkFlrh85Dkz/s7KagASU018hFQpEWtFyDAMj/jZz+8R0EkKv9Iz7mt/M9wxf3 LbTH+fCdEerH5gY3EC9mcWftrihakZHdmYtV2FW5v+hrI8TcX0PmuF9FP0jFFWqUEPm5 6lfbywDNUCFmJSjj3j/NQvSXyKlI1DCpxbXnuLziNOBk/yYUz3rtm1AxfYDSob996mnv C5ONKzbCvJWL1lAKPmqxKsE/Rtuds5tEm9M2zSYDWcDEA4mwlCtyKph0/reYPNor/ReI udQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zQwd7J7H; 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 gb21-20020a170907961500b008722ef50e42si6086838ejc.277.2023.01.17.23.51.05; Tue, 17 Jan 2023 23:51:28 -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=zQwd7J7H; 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 S229807AbjARHr2 (ORCPT + 99 others); Wed, 18 Jan 2023 02:47:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230165AbjARHpK (ORCPT ); Wed, 18 Jan 2023 02:45:10 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF5906468B for ; Tue, 17 Jan 2023 23:09:40 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id v6so37928609ejg.6 for ; Tue, 17 Jan 2023 23:09:40 -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=ERUzW2NTS0HSKxHZgJkhNmc/Fre4SMT/MoW1Mr8mzQ4=; b=zQwd7J7HLRznjgSFM9pKJya0EuA8lZun8bi0lci+/+J+INOZCIV9Q3HPoKn/H2t7EZ jGeRwvaXEEWwexTNs3th+4lE4e2mfsFiw/zpJ3Z2FAhlJ8oZ4NPzOPm3JmLPTx3MBNFa w+ISOMSy7RMkJTr+lHArjUK0VmYFRNOdUPFojbNu8WS85Fhi/m+b4tZShv0heXwB4nZ+ OaD6sQhZ5YawH9Zq9fKNUcFXqrmF8AdLX7z3wvO56SfZWRMkcpGeS2cMRP2lbeOTxsxi Riltb4cI1zp2s3bCg92Y1AWH58vCLH83S015+aG7gcRb/BeKW1MbD21VA3x+OJyB4tLM uKuQ== 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=ERUzW2NTS0HSKxHZgJkhNmc/Fre4SMT/MoW1Mr8mzQ4=; b=MSB4KBJnXbcfjPVp4qadTQa8zdqyEkIyvyKoLWa6AX7MhXoyam/Hy5DxF/8g0gppF4 Vx+EY5h7vytSqb7jGCBUOwO2b/Zw1FGevp66m534gKir4Vppa6Dh/Lx2KfZyVNJ2WB2/ 4dUWBMh/Y8nDKvqLT7EgoAV7oKwbhngXysZN1NV34X7MPdX6F06yZ8q1wcw+brCcstf2 ts+lAbOS36+KN16bXfbq6RNdRvpXZD15pzRAyOvnW4UaQ+GcNtLdQFqICi97tjvNT5aH 2vu4uM69dKXfDNK3GBG5J3xesCLOSVHE5uTUxktJrwPbkbr9qezBJkpnrzphmuT43YS/ cwwg== X-Gm-Message-State: AFqh2koOqQD1FVyzqY2c25Y74Yl9w4Yr5EY+rr4oz8Z3w59GkDzEhT8l uGFYWCLFLYGOymDNirWFdyT2Gg== X-Received: by 2002:a17:907:b9da:b0:872:21b2:9a1f with SMTP id xa26-20020a170907b9da00b0087221b29a1fmr5931576ejc.58.1674025778843; Tue, 17 Jan 2023 23:09:38 -0800 (PST) Received: from fedora.local (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id bt16-20020a0564020a5000b00482e0c55e2bsm13596984edb.93.2023.01.17.23.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 23:09:38 -0800 (PST) From: Linus Walleij Date: Wed, 18 Jan 2023 08:09:21 +0100 Subject: [PATCH v2 7/7] usb: fotg210-udc: Implement VBUS session MIME-Version: 1.0 Message-Id: <20230103-gemini-fotg210-usb-v2-7-100388af9810@linaro.org> References: <20230103-gemini-fotg210-usb-v2-0-100388af9810@linaro.org> In-Reply-To: <20230103-gemini-fotg210-usb-v2-0-100388af9810@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?1755345887064702481?= X-GMAIL-MSGID: =?utf-8?q?1755345887064702481?= 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);