From patchwork Fri Dec 16 16:29:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 34012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1066523wrn; Fri, 16 Dec 2022 08:31:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XntX6jj6U8hEaWUM7WBYYBFMosxKakj+1BiIbVQuHnN8M1g5AJ7divGh2TmUWRNX22wiN X-Received: by 2002:a05:6402:f0b:b0:46f:fe45:ed68 with SMTP id i11-20020a0564020f0b00b0046ffe45ed68mr19217586eda.26.1671208281347; Fri, 16 Dec 2022 08:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671208281; cv=none; d=google.com; s=arc-20160816; b=H86XNUQkBvn9LN4Bw4TdVuhkoljPGi4VZJTPrbzLfiwtwohXUlTLGpIp2mNVsQvUwd jPgVY2zRbj44PXMMc5UAYvRd7hKaQEO4Qt1pNbvGZOZtVX0zdYSQXwKxnPhkctCdIoQJ y23SCoIVYFghCjhR/t6pixVISaxV1GV1AyB3GVRBVlFG12pak7lldOruUfR3uIMBiyNz nWo65P8jDON2dja/eocFriiy2hLTfc3poYDDvVE+qLxR6Eeg0oSkIemymhRuUiSApOWe JRYvAed9eEkrcSj0oNyU/rLUA/U3y15yxdXYkiAOvSjHn99Fx+Tzxuv0Y/3FkAKRmvHe NRlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6fUA8B1qmBJl9/cqy+fWN9zwNnL1+u3p9XpPCV7kSy4=; b=zUrPSE/poJhkFKmMLdMqtTKCVQOQ224ZCfWms2as6GHV2rUIdJprY/tLH0Ls+GVwIR Jxmx5s6LEuno/jbGCzYHG67kcZZJFVXnyEC6OJyMs6z5RtR0/6uk9tO9LjGKyDuiRIXJ UKugyPL8njFKMbNDtt1zvTA50OubkDp3F79k1I5mZX/vQDflntEDZ9pSz5TWOWAUA4rP Jgz4eC8lG2FEH3qV54FhQF8kK1vjk+XmCC4qWHLZJRwQFEvnpYTpUSLxqQ42kpH27kfE R9PdIjRF3atj1Px/DMsoduMhp2ZgV5UNMeBv17r9crKAKJ/u+yB4yiSD1M1PRMKSLKVQ H+kQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a05640227cb00b0046ae912ff2asi2983327ede.397.2022.12.16.08.30.58; Fri, 16 Dec 2022 08:31:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231409AbiLPQaX (ORCPT + 99 others); Fri, 16 Dec 2022 11:30:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbiLPQaL (ORCPT ); Fri, 16 Dec 2022 11:30:11 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12B905D6AC; Fri, 16 Dec 2022 08:30:09 -0800 (PST) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 26CC0E000F; Fri, 16 Dec 2022 16:30:05 +0000 (UTC) From: Quentin Schulz To: Minas Harutyunyan , Greg Kroah-Hartman Cc: Quentin Schulz , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Bin Yang , Quentin Schulz Subject: [PATCH v2 1/2] usb: dwc2: allow platforms to prevent core phy initialisation Date: Fri, 16 Dec 2022 17:29:28 +0100 Message-Id: <20221206-dwc2-gadget-dual-role-v2-1-0de821615dd3@theobroma-systems.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206-dwc2-gadget-dual-role-v2-0-0de821615dd3@theobroma-systems.com> References: <20221206-dwc2-gadget-dual-role-v2-0-0de821615dd3@theobroma-systems.com> MIME-Version: 1.0 X-Mailer: b4 0.11.0-dev-141d4 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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?1752388894995929836?= X-GMAIL-MSGID: =?utf-8?q?1752388894995929836?= From: Quentin Schulz Some USB PHYs need to be controlled dynamically on some platforms. Let's allow platforms to define whether they should prevent core PHY initialization by providing a "shadow" value to HCD's skip_phy_initialization flag before HCD is actually created (e.g. from a dwc2_set_*_params callback). Signed-off-by: Quentin Schulz --- drivers/usb/dwc2/core.h | 6 ++++++ drivers/usb/dwc2/hcd.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 40cf2880d7e5..6aa9aeb374eb 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -423,6 +423,10 @@ enum dwc2_ep0_state { * 0 - No * 1 - Yes * + * @hcd_skip_phy_initialization: Shadow value of HCD skip_phy_initialization + * flag. + * See include/linux/usb/hcd.h for documentation. + * * The following parameters may be specified when starting the module. These * parameters define how the DWC_otg controller should be configured. A * value of -1 (or any other out of range value) for any parameter means @@ -499,6 +503,8 @@ struct dwc2_core_params { u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; bool change_speed_quirk; + + unsigned hcd_skip_phy_initialization:1; }; /** diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 657f1f659ffa..e2fa9a491cab 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -5315,6 +5315,8 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) if (!IS_ERR_OR_NULL(hsotg->uphy)) otg_set_host(hsotg->uphy->otg, &hcd->self); + hcd->skip_phy_initialization = hsotg->params.hcd_skip_phy_initialization; + /* * Finish generic HCD initialization and start the HCD. This function * allocates the DMA buffer pool, registers the USB bus, requests the