From patchwork Fri May 22 10:32:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B23F3739 for ; Fri, 22 May 2020 10:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 957A420757 for ; Fri, 22 May 2020 10:32:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Og5qSi6B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728809AbgEVKcx (ORCPT ); Fri, 22 May 2020 06:32:53 -0400 Received: from mail-eopbgr50047.outbound.protection.outlook.com ([40.107.5.47]:48672 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728489AbgEVKcw (ORCPT ); Fri, 22 May 2020 06:32:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BV7uY51bkk7GTE9+Hc8/MHRTjEj7MShSkI7kcGgqFIdH/elmeBg3aC3CubWwpq9vSUTDvw+Aff7W+Nsbmtmkrjg7eIu8QwHkfajt21lV+hCn8UarEhSd8gzE+zl6f6WgenuUmFYxXIwQ/iD5eEKzfkZe/6kezaSHIU3pQGQmOXYj5rPU2ANwesUXtQnKhvuqQA5osx2lKejS2ku2ROfJazL9vM50twzPu44KPJ7FsH5o+bMFGjND/48ttpE6xvgT2N9xqn1VcSeabgA6sdflTQzUYwPdpnzzjLiVnd68bNOsnmK79b9Q1PctVwEozYaPveOz9xc4FIBKLciu1MSM9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jWxAKQiZlWT2as0dNVObnYfurRtCPh6FYbJM5rpI/wg=; b=IwSL3Fn1jNZTAKaO6lWs7JlmFX2N50w9w8AMMTG+VMQgkuH12ae/EoYsOqpjI9I5Sly1I/k4Q+VMClTOtNAKecPqqWmyGen0EOEnFmlfrjxbV7E6zRzYlNT0+cA3VYbGvSkm9wQudASwG/xJ5YQomeBE2yFUEUDfeGnBvmyRecuiP1JWN2/YI4tS5Ah2rUIvHov+aOn0uNGxNyYNKVVyKO+IbhhPcfEn9avr5VcQJuU4Vk2/VQ91i3AyEP08INoTPCkPjePxM0ZVuBqNmmC9K7f20PM1v+pSqKCNGYWKRQlmezaKj+sMn2FCj3qjMwfUfCYfjvS70ny7Kt3GxZHTXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jWxAKQiZlWT2as0dNVObnYfurRtCPh6FYbJM5rpI/wg=; b=Og5qSi6BhvWayDhLkpRMdW3+4G5cOvqjFPGm5RZZytIs1osT3qOQQGamPocNq+az4QON5s75x+dJKzK3NzNYX+yJvCwFlySdWcXG4umDu8THdDBzoaWHcIiPLkoU8jhWlu/43jdqXRPXd0uOJnO780Bq3rHAwmpRjvsM++PmkUk= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB7111.eurprd04.prod.outlook.com (2603:10a6:20b:118::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24; Fri, 22 May 2020 10:32:48 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:32:47 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 1/8] usb: cdns3: add runtime PM support Date: Fri, 22 May 2020 18:32:49 +0800 Message-Id: <20200522103256.16322-2-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:32:44 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 935571b7-23c3-4d5a-9018-08d7fe3b7884 X-MS-TrafficTypeDiagnostic: AM7PR04MB7111: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LKAl3xfJz7xtc7B2xGxKtPk7czZbXsnKC859MJ/eY5seyFR2CoCcCditFNsoNNPgJmwdoR2lN3TO18SFeNKsM1z/c50xwlAcu5J//7kA/b667AFxx2KJ3JdzsR0eEvZwq7jNi3lC057EssEtrgJhLPOQn8MD3qnCxndmBP+6d9UDdvrBjxJOCFmBYtdbFaG/aQbU1v9dM9K4vjnobxNl8mZoZydmgT7al+MYACNR6b+Bv+rkOlyFgiayjGWlVtDLtT97WCkJL1v+9ew+7LbcRx40Cl/I/VX0e2GuGP77m8gPiHVJm20Nkv+flADTxcToMimrw1u3zT3tiFRRRZrrGA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(346002)(136003)(376002)(396003)(39860400002)(8676002)(6506007)(1076003)(52116002)(26005)(6512007)(5660300002)(16526019)(86362001)(8936002)(66476007)(66556008)(36756003)(66946007)(186003)(6486002)(2616005)(44832011)(2906002)(478600001)(956004)(316002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MqpsWpF5aFcwu9QlybDxsVgz4xv4/hUMBlLLWcK1T3CVQEfrSxnhBwvozyKJDD5oX+IPv9d8vN8AFahncfaU3WlSQd7Wru20DQ/PLOyNpQDhypnJkbcdM3jCADQIjdPxQ4h8bYNnr7FjX1opDO1HY6PSm8Z422kGlkXDi2t7sphiiatjA5ypu6YF1oxtZELUyeTYIGd/HCQdEtWhyAakYLA7uLKcV+uCHxZ4U88zfRn9dyxK2wh7Hhso0Ag8ZqN6iSd9+b5o2YP0IVQDXkBzHjPESkJYfsAw99zI3NqDZbVCZ/AVKsaBuN2pfABCA+XExPh4S4oZ/tR1asUbemaSbzOY1B6wXkOrwP9DiAWF3s0G35MIBtrbneaIydJZWGO8Qob3R6b1Pw62VzDmd1/DVx/xPZGcxnyhBQb3dhxXUpdyCYQviXin7dugpz/oM92vXZTETH1/Nk4eqY6RALYYWrmckDnNOEtadaF/1id9eRo= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 935571b7-23c3-4d5a-9018-08d7fe3b7884 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:32:47.8556 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vnYEiD/hFgI8SpbUn/16M0fkTDEppI7HPGMpF7/qmz+TZyVD+BnV/hnAP2So/JeJjC82p1FbU+CaIDLs8b5a7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7111 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Introduce runtime PM and wakeup interrupt handler for cdns3, the runtime PM is default off since other cdns3 has not implemented glue layer support for runtime PM. When the controller is in low power mode, the lpm flag will be set. The interrupt triggered later than lpm flag is set considers as wakeup interrupt and handled at cdns_drd_irq. Once the wakeup occurs, it first disables interrupt to avoid later interrupt occurrence since the controller is in low power mode at that time, and access registers may be invalid at that time. At wakeup handler, it will call pm_runtime_get to wakeup controller, and at runtime resume handler, it will enable interrupt again. The API platform_suspend is introduced for glue layer to implement platform specific PM sequence. Signed-off-by: Peter Chen --- drivers/usb/cdns3/core.c | 119 +++++++++++++++++++++++++++++++------ drivers/usb/cdns3/core.h | 14 +++++ drivers/usb/cdns3/drd.c | 7 +++ drivers/usb/cdns3/gadget.c | 4 ++ drivers/usb/cdns3/host.c | 7 +++ 5 files changed, 134 insertions(+), 17 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index bfd09aa98c12..5221c1306e64 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -432,6 +432,7 @@ static int cdns3_probe(struct platform_device *pdev) return -ENOMEM; cdns->dev = dev; + cdns->pdata = dev_get_platdata(dev); platform_set_drvdata(pdev, cdns); @@ -525,9 +526,11 @@ static int cdns3_probe(struct platform_device *pdev) if (ret) goto err4; + spin_lock_init(&cdns->lock); device_set_wakeup_capable(dev, true); pm_runtime_set_active(dev); pm_runtime_enable(dev); + pm_runtime_forbid(dev); /* * The controller needs less time between bus and controller suspend, @@ -574,52 +577,134 @@ static int cdns3_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP +#ifdef CONFIG_PM -static int cdns3_suspend(struct device *dev) +static int cdns3_set_platform_suspend(struct device *dev, + bool suspend, bool wakeup) +{ + struct cdns3 *cdns = dev_get_drvdata(dev); + int ret = 0; + unsigned long flags; + + spin_lock_irqsave(&cdns->lock, flags); + if (cdns->pdata && cdns->pdata->platform_suspend) + ret = cdns->pdata->platform_suspend(dev, suspend, wakeup); + + spin_unlock_irqrestore(&cdns->lock, flags); + + return ret; +} + +static int cdns3_controller_suspend(struct device *dev, pm_message_t msg) { struct cdns3 *cdns = dev_get_drvdata(dev); + bool wakeup; unsigned long flags; - if (cdns->role == USB_ROLE_HOST) + if (cdns->in_lpm) return 0; - if (pm_runtime_status_suspended(dev)) - pm_runtime_resume(dev); + if (PMSG_IS_AUTO(msg)) + wakeup = true; + else + wakeup = false; - if (cdns->roles[cdns->role]->suspend) { - spin_lock_irqsave(&cdns->gadget_dev->lock, flags); - cdns->roles[cdns->role]->suspend(cdns, false); - spin_unlock_irqrestore(&cdns->gadget_dev->lock, flags); - } + cdns3_set_platform_suspend(cdns->dev, true, wakeup); + cdns3_set_phy_power(cdns, false); + spin_lock_irqsave(&cdns->lock, flags); + cdns->in_lpm = true; + spin_unlock_irqrestore(&cdns->lock, flags); return 0; } -static int cdns3_resume(struct device *dev) +static int cdns3_controller_resume(struct device *dev, pm_message_t msg) { struct cdns3 *cdns = dev_get_drvdata(dev); + int ret; unsigned long flags; - if (cdns->role == USB_ROLE_HOST) + if (!cdns->in_lpm) return 0; - if (cdns->roles[cdns->role]->resume) { - spin_lock_irqsave(&cdns->gadget_dev->lock, flags); + ret = cdns3_set_phy_power(cdns, true); + if (ret) + return ret; + + cdns3_set_platform_suspend(cdns->dev, false, false); + + spin_lock_irqsave(&cdns->lock, flags); + if (cdns->roles[cdns->role]->resume && !PMSG_IS_AUTO(msg)) cdns->roles[cdns->role]->resume(cdns, false); - spin_unlock_irqrestore(&cdns->gadget_dev->lock, flags); + + cdns->in_lpm = false; + spin_unlock_irqrestore(&cdns->lock, flags); + if (cdns->wakeup_int) { + cdns->wakeup_int = false; + if (cdns->role == USB_ROLE_HOST) { + /* Trigger xhci-plat.c runtime runtime */ + pm_runtime_get(&cdns->host_dev->dev); + pm_runtime_mark_last_busy(&cdns->host_dev->dev); + pm_runtime_put_autosuspend(&cdns->host_dev->dev); + /* balence the pm_runtime_get at cdns3_drd_irq */ + pm_runtime_mark_last_busy(cdns->dev); + pm_runtime_put_autosuspend(cdns->dev); + } + + enable_irq(cdns->otg_irq); + } + + return ret; +} + +static int cdns3_runtime_suspend(struct device *dev) +{ + return cdns3_controller_suspend(dev, PMSG_AUTO_SUSPEND); +} + +static int cdns3_runtime_resume(struct device *dev) +{ + return cdns3_controller_resume(dev, PMSG_AUTO_RESUME); +} +#ifdef CONFIG_PM_SLEEP + +static int cdns3_suspend(struct device *dev) +{ + struct cdns3 *cdns = dev_get_drvdata(dev); + unsigned long flags; + + if (pm_runtime_status_suspended(dev)) + pm_runtime_resume(dev); + + if (cdns->roles[cdns->role]->suspend) { + spin_lock_irqsave(&cdns->lock, flags); + cdns->roles[cdns->role]->suspend(cdns, false); + spin_unlock_irqrestore(&cdns->lock, flags); } + return cdns3_controller_suspend(dev, PMSG_SUSPEND); +} + +static int cdns3_resume(struct device *dev) +{ + int ret; + + ret = cdns3_controller_resume(dev, PMSG_RESUME); + if (ret) + return ret; + pm_runtime_disable(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); - return 0; + return ret; } -#endif +#endif /* CONFIG_PM_SLEEP */ +#endif /* CONFIG_PM */ static const struct dev_pm_ops cdns3_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(cdns3_suspend, cdns3_resume) + SET_RUNTIME_PM_OPS(cdns3_runtime_suspend, cdns3_runtime_resume, NULL) }; #ifdef CONFIG_OF diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h index 1ad1f1fe61e9..9eb8aeea2d20 100644 --- a/drivers/usb/cdns3/core.h +++ b/drivers/usb/cdns3/core.h @@ -38,6 +38,12 @@ struct cdns3_role_driver { }; #define CDNS3_XHCI_RESOURCES_NUM 2 + +struct cdns3_platform_data { + int (*platform_suspend)(struct device *dev, + bool suspend, bool wakeup); +}; + /** * struct cdns3 - Representation of Cadence USB3 DRD controller. * @dev: pointer to Cadence device struct @@ -62,6 +68,10 @@ struct cdns3_role_driver { * This field based on firmware setting, kernel configuration * and hardware configuration. * @role_sw: pointer to role switch object. + * @in_lpm: indicate the controller is in low power mode + * @wakeup_int: wakeup interrupt occurs + * @pdata: platform data from glue layer + * @lock: spinlock structure */ struct cdns3 { struct device *dev; @@ -89,6 +99,10 @@ struct cdns3 { struct mutex mutex; enum usb_dr_mode dr_mode; struct usb_role_switch *role_sw; + bool in_lpm; + bool wakeup_int; + struct cdns3_platform_data *pdata; + spinlock_t lock; }; int cdns3_hw_role_switch(struct cdns3 *cdns); diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 58089841ed52..292ea248c0ec 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -278,6 +278,13 @@ static irqreturn_t cdns3_drd_irq(int irq, void *data) struct cdns3 *cdns = data; u32 reg; + if (cdns->in_lpm) { + disable_irq_nosync(irq); + cdns->wakeup_int = true; + pm_runtime_get(cdns->dev); + return IRQ_HANDLED; + } + if (cdns->dr_mode != USB_DR_MODE_OTG) return ret; diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index a6723f46d509..2cee12195978 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -1766,9 +1766,13 @@ static void cdns3_check_usb_interrupt_proceed(struct cdns3_device *priv_dev, static irqreturn_t cdns3_device_irq_handler(int irq, void *data) { struct cdns3_device *priv_dev = data; + struct cdns3 *cdns = dev_get_drvdata(priv_dev->dev); irqreturn_t ret = IRQ_NONE; u32 reg; + if (cdns->in_lpm) + return ret; + /* check USB device interrupt */ reg = readl(&priv_dev->regs->usb_ists); if (reg) { diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index ad788bf3fe4f..b579ef15f4e0 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -13,11 +13,13 @@ #include "core.h" #include "drd.h" #include "host-export.h" +#include static int __cdns3_host_init(struct cdns3 *cdns) { struct platform_device *xhci; int ret; + struct usb_hcd *hcd; cdns3_drd_switch_host(cdns, 1); @@ -43,6 +45,11 @@ static int __cdns3_host_init(struct cdns3 *cdns) goto err1; } + /* Glue needs to access xHCI region register for Power management */ + hcd = platform_get_drvdata(xhci); + if (hcd) + cdns->xhci_regs = hcd->regs; + return 0; err1: platform_device_put(xhci); From patchwork Fri May 22 10:32:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53E94739 for ; Fri, 22 May 2020 10:33:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32F98207CB for ; Fri, 22 May 2020 10:33:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="YGIhGcyb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728827AbgEVKdB (ORCPT ); Fri, 22 May 2020 06:33:01 -0400 Received: from mail-eopbgr50047.outbound.protection.outlook.com ([40.107.5.47]:48672 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728362AbgEVKc4 (ORCPT ); Fri, 22 May 2020 06:32:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A186eaDyHD+8ekvVHFqdtlBEge+K6dhPQS5rH7bG1nDxkiYnbXj/KU/eeVJ3FHCXv5OtoeztSzzqM5yyarMl7j5wUbZ2oG50Ja+GnT2kaKsW6pdX76I1q9rGjODe9+1KklagMYSYgpBNK8UuiREDz8jJbSfhZJ+o7X4ZnHbsXiuWvquXBiWSTMQHxk/1+XHhjPTTsO0Z3mERlmgKcP9R7MVcjgQQmC1xylyDzf0tXpdWECuM8oGwQEEb3rZStU6LuaT5vGSnUD9Uw6FEOxlNe/hIWCUmpY8AvDk9G5f2DhR1N7wdcu6hRjk/jTdNR2gOtfWCh5oLupWV68NgVf8auA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uT+DKnQMSqid1P7HUGXEc7h60iy9sSbHaOr2UlWRZOo=; b=dpenxm73pZx1R9KzfmPsH4K6vFnS088jPvXpxpbukkM4f7PPo8dhP1P7flKWB7JW+ubmkoka7SC5Vcm0kZM0sby9r2b36oAJ5nXZiRcw0shWdClfKltydTFmVj6nrnhQ81rU+C/wEiLMJIcJfdgW6iTBBuq7H9FuQVcUz2AgqsI/8CkbieHd6ohXJGNO0QVGHWMmIcdxSNsEp2WclJm+CSEWhUtpUKE2r0/k/wWS+xPHBUy8AtIj3hdKgYWGqSINLGC653ytQZ1/ikAc3H9+fSypRaR3jJaF/kOIfogwfflnFG3DFVJ37SEl8tK16Zy96SPJ0mmTAw6qZGlHobuJwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uT+DKnQMSqid1P7HUGXEc7h60iy9sSbHaOr2UlWRZOo=; b=YGIhGcybpqxw+7IJ5Q+rbv2R2YMJA2ertuo0LIBiIPqHAOu/apUPYAIcRyy4pTpBsyZhNUgkaU+lpJRay/Btg99xH79Z3Z2EDidtlGbn21bVrdzXQPWJNAiXEr1I9ADyZTSQH0bZhY3ZsHwJrx8MHpaBnWqcPZ+M8ElPJMOx3uE= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB7111.eurprd04.prod.outlook.com (2603:10a6:20b:118::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24; Fri, 22 May 2020 10:32:51 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:32:51 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 2/8] usb: cdns3: imx: add glue layer runtime pm implementation Date: Fri, 22 May 2020 18:32:50 +0800 Message-Id: <20200522103256.16322-3-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:32:48 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 401718c4-8ed8-477e-be0d-08d7fe3b7a80 X-MS-TrafficTypeDiagnostic: AM7PR04MB7111: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Juvtkru1oDPPQ9Pb64z43GEAqkdX4JTRAchhJBBKW6jYUvYsq3uwHAhToUb+udXESyBq8+eN36GUxAoyFvIiCkkgTbWKHjP+CwSpcJXgde9sDViEf6QLsKLZYjoQc2wpGAWxuFkpniXntdZMUXX8L/hpcMkedvdPjlQ8eiRUDUVk51HWPfY47wxnxokjUNGuQO4Y+SiUM4kyxFVRbB86jgGMCnMhCgX6k26y5C1xVUETTo/b8V3FelaMpmdMzTQqCY9THam8iGbINguaxssLbMJm4Ney+GdYb6iB0oKmxV8X3DukJpziTCHshe+bNdzgKsvqogqgjSd/CaIXq31bmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(366004)(346002)(136003)(376002)(396003)(39860400002)(8676002)(6506007)(1076003)(6666004)(52116002)(26005)(6512007)(5660300002)(16526019)(86362001)(8936002)(66476007)(66556008)(36756003)(66946007)(186003)(6486002)(2616005)(44832011)(2906002)(478600001)(956004)(316002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +OdrBreLnafzq6Gh4Zbhn7w4p5+k4Vqd4GZcvda8OP3QPMVRgxwiXFzD+iyo8vw+RUD8V5451DDR3W+MeBHYp99LNoM2/9F4WnTpkCSdIwi+q5C5OT/CdiCz/QqB07qWi5zxIqbSr++eHVXFhDC5ckZEYS/3aL1yHIntEhxp9HCo6JUxrIAQWXzpeSzGEwW27Ve/o+HZHALn+SK81GB69Epuke9tRAKsLHc4h8EKg18KH1/Xyjt4fDwP4ejdgXQ56fe2bkQRIgxYelfiEyFiQ5vXjthZA8nJhNAlIl6VP2aQqCFzeBTQTDjw1PoDLA430aWLztNFEIKJaE2RyzoYVOU1+w7CSeGdFSniUC+5BxRzZTesmHpsoQtXGGAPqFLrY6ewvYsj8ZUi+7HSq7YxN1dR/3gdUZOvPZEwYHh+BUgDkGAAOYefSOJqesizoGS0VnhYwYJQWCtzf7L5fuaZuTE1GtrUVzuEqQQwSdeWP3c= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 401718c4-8ed8-477e-be0d-08d7fe3b7a80 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:32:51.0466 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0b8Xq7QPwtCiBkpDBOkrrKJ1bDDDdqJ2VZUv7uDMwGAY6UIw3D1IcEYxiP99em2XpqxZxHfEfbZfXRVggpNrwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7111 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add imx glue layer runtime pm implementation, and the runtime pm is default off. Signed-off-by: Peter Chen --- drivers/usb/cdns3/cdns3-imx.c | 179 +++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 2 deletions(-) diff --git a/drivers/usb/cdns3/cdns3-imx.c b/drivers/usb/cdns3/cdns3-imx.c index aba988e71958..9d247de8e7eb 100644 --- a/drivers/usb/cdns3/cdns3-imx.c +++ b/drivers/usb/cdns3/cdns3-imx.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include "core.h" #define USB3_CORE_CTRL1 0x00 #define USB3_CORE_CTRL2 0x04 @@ -66,11 +68,30 @@ #define CLK_VALID_COMPARE_BITS (0xf << 28) #define PHY_REFCLK_REQ (1 << 0) +/* OTG registers definition */ +#define OTGSTS 0x4 +/* OTGSTS */ +#define OTG_NRDY (1 << 11) + +/* xHCI registers definition */ +#define XECP_PM_PMCSR 0x8018 +#define XECP_AUX_CTRL_REG1 0x8120 + +/* Register bits definition */ +/* XECP_AUX_CTRL_REG1 */ +#define CFG_RXDET_P3_EN (1 << 15) + +/* XECP_PM_PMCSR */ +#define PS_MASK (3 << 0) +#define PS_D0 0 +#define PS_D1 (1 << 0) + struct cdns_imx { struct device *dev; void __iomem *noncore; struct clk_bulk_data *clks; int num_clks; + struct platform_device *cdns3_pdev; }; static inline u32 cdns_imx_readl(struct cdns_imx *data, u32 offset) @@ -126,6 +147,20 @@ static int cdns_imx_noncore_init(struct cdns_imx *data) return ret; } +static int cdns_imx_platform_suspend(struct device *dev, + bool suspend, bool wakeup); +static struct cdns3_platform_data cdns_imx_pdata = { + .platform_suspend = cdns_imx_platform_suspend, +}; + +static struct of_dev_auxdata cdns_imx_auxdata[] = { + { + .compatible = "cdns,usb3", + .platform_data = &cdns_imx_pdata, + }, + {}, +}; + static int cdns_imx_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -162,14 +197,18 @@ static int cdns_imx_probe(struct platform_device *pdev) if (ret) goto err; - ret = of_platform_populate(node, NULL, NULL, dev); + ret = of_platform_populate(node, NULL, cdns_imx_auxdata, dev); if (ret) { dev_err(dev, "failed to create children: %d\n", ret); goto err; } - return ret; + device_set_wakeup_capable(dev, true); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_runtime_forbid(dev); + return ret; err: clk_bulk_disable_unprepare(data->num_clks, data->clks); return ret; @@ -194,6 +233,141 @@ static int cdns_imx_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static void cdns3_set_wakeup(struct cdns_imx *data, bool enable) +{ + u32 value; + + value = cdns_imx_readl(data, USB3_INT_REG); + if (enable) + value |= OTG_WAKEUP_EN | DEVU3_WAEKUP_EN; + else + value &= ~(OTG_WAKEUP_EN | DEVU3_WAEKUP_EN); + + cdns_imx_writel(data, USB3_INT_REG, value); +} + +static int cdns_imx_platform_suspend(struct device *dev, + bool suspend, bool wakeup) +{ + struct cdns3 *cdns = dev_get_drvdata(dev); + struct device *parent = dev->parent; + struct cdns_imx *data = dev_get_drvdata(parent); + void __iomem *otg_regs = cdns->otg_regs; + void __iomem *xhci_regs = cdns->xhci_regs; + u32 value; + int ret = 0; + + if (cdns->role != USB_ROLE_HOST) + return 0; + + if (suspend) { + /* SW request low power when all usb ports allow to it ??? */ + value = readl(xhci_regs + XECP_PM_PMCSR); + value &= ~PS_MASK; + value |= PS_D1; + writel(value, xhci_regs + XECP_PM_PMCSR); + + /* mdctrl_clk_sel */ + value = cdns_imx_readl(data, USB3_CORE_CTRL1); + value |= MDCTRL_CLK_SEL; + cdns_imx_writel(data, USB3_CORE_CTRL1, value); + + /* wait for mdctrl_clk_status */ + value = cdns_imx_readl(data, USB3_CORE_STATUS); + ret = readl_poll_timeout_atomic(data->noncore + USB3_CORE_STATUS, value, + (value & MDCTRL_CLK_STATUS) == MDCTRL_CLK_STATUS, + 10, 100000); + if (ret) + dev_warn(parent, "wait mdctrl_clk_status timeout\n"); + + /* wait lpm_clk_req to be 0 */ + value = cdns_imx_readl(data, USB3_INT_REG); + ret = readl_poll_timeout_atomic(data->noncore + USB3_INT_REG, value, + (value & LPM_CLK_REQ) != LPM_CLK_REQ, + 10, 100000); + if (ret) + dev_warn(parent, "wait lpm_clk_req timeout\n"); + + /* wait phy_refclk_req to be 0 */ + value = cdns_imx_readl(data, USB3_SSPHY_STATUS); + ret = readl_poll_timeout_atomic(data->noncore + USB3_SSPHY_STATUS, value, + (value & PHY_REFCLK_REQ) != PHY_REFCLK_REQ, + 10, 100000); + if (ret) + dev_warn(parent, "wait phy_refclk_req timeout\n"); + + cdns3_set_wakeup(data, wakeup); + } else { + /* wait CLK_125_REQ to be 1 */ + value = cdns_imx_readl(data, USB3_INT_REG); + ret = readl_poll_timeout_atomic(data->noncore + USB3_INT_REG, value, + (value & CLK_125_REQ) != CLK_125_REQ, + 10, 100000); + if (ret) + dev_warn(parent, "wait CLK_125_REQ timeout\n"); + + cdns3_set_wakeup(data, false); + + /* SW request D0 */ + value = readl(xhci_regs + XECP_PM_PMCSR); + value &= ~PS_MASK; + value |= PS_D0; + writel(value, xhci_regs + XECP_PM_PMCSR); + + /* clr CFG_RXDET_P3_EN */ + value = readl(xhci_regs + XECP_AUX_CTRL_REG1); + value &= ~CFG_RXDET_P3_EN; + writel(value, xhci_regs + XECP_AUX_CTRL_REG1); + + /* clear mdctrl_clk_sel */ + value = cdns_imx_readl(data, USB3_CORE_CTRL1); + value &= ~MDCTRL_CLK_SEL; + cdns_imx_writel(data, USB3_CORE_CTRL1, value); + + /* wait for mdctrl_clk_status is cleared */ + value = cdns_imx_readl(data, USB3_CORE_STATUS); + ret = readl_poll_timeout_atomic(data->noncore + USB3_CORE_STATUS, value, + (value & MDCTRL_CLK_STATUS) != MDCTRL_CLK_STATUS, + 10, 100000); + if (ret) + dev_warn(parent, "wait mdctrl_clk_status cleared timeout\n"); + + /* Wait until OTG_NRDY is 0 */ + value = readl(otg_regs + OTGSTS); + ret = readl_poll_timeout_atomic(otg_regs + OTGSTS, value, + (value & OTG_NRDY) != OTG_NRDY, + 10, 100000); + if (ret) + dev_warn(parent, "wait OTG ready timeout\n"); + } + + return ret; + +} + +static int cdns_imx_resume(struct device *dev) +{ + struct cdns_imx *data = dev_get_drvdata(dev); + + return clk_bulk_prepare_enable(data->num_clks, data->clks); +} + +static int cdns_imx_suspend(struct device *dev) +{ + struct cdns_imx *data = dev_get_drvdata(dev); + + clk_bulk_disable_unprepare(data->num_clks, data->clks); + + return 0; +} + +#endif /* CONFIG_PM */ + +static const struct dev_pm_ops cdns_imx_pm_ops = { + SET_RUNTIME_PM_OPS(cdns_imx_suspend, cdns_imx_resume, NULL) +}; + static const struct of_device_id cdns_imx_of_match[] = { { .compatible = "fsl,imx8qm-usb3", }, {}, @@ -206,6 +380,7 @@ static struct platform_driver cdns_imx_driver = { .driver = { .name = "cdns3-imx", .of_match_table = cdns_imx_of_match, + .pm = &cdns_imx_pm_ops, }, }; module_platform_driver(cdns_imx_driver); From patchwork Fri May 22 10:32:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A55C912 for ; Fri, 22 May 2020 10:33:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EA4A207CB for ; Fri, 22 May 2020 10:33:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="kGn7M7eT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728938AbgEVKc7 (ORCPT ); Fri, 22 May 2020 06:32:59 -0400 Received: from mail-vi1eur05on2057.outbound.protection.outlook.com ([40.107.21.57]:6057 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728827AbgEVKc5 (ORCPT ); Fri, 22 May 2020 06:32:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fYMlaFS9gRp/8NKDwXsU8SRlpadZ2jp+tkOgFcfhtBoo57khl1LGqhwhu8FzSwt+rVQr6cL+hVR7XP1RIDLYSs7HZtyWyvPzRJ1bX90pDagfHUjYJR+XpXm6k9RZF7j3kyX9oTiq8WAeviLduDUieys9dK5WHd6VrtEUzfhb0eIdrpwu2M2ZbD2PFMFHb8rWfvmElCgOxfAZejY0GrZbMA4s4RHeWqKLtcKaJ6LFYxK70gHKXzN+LBrPfbNtl0071tLNRCxks2RcsrooWchKr9ilHbu+PbzpatsTAtPCV7RL2xwMj+40O0n15UIMjOFt79ObLkxl4FD+rn54yTzaig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tjRElqrXKYAgA99yuhF3afHtqrTsXTP1mgLePZbIrFs=; b=CuTGBepxsXE9t4pUJVVtlPCHWYwPuZP+w0mWFJpLU0O3Q2XWwdlA+OfCiBxCktGkUdaefiTBRceFl0GrVVLnHvjn/mDa2e5JHueO0JkMf9adEyOmzPIbSd5I8WrU606umdk/G+uOuI3En40hhMybniTRZ865nBP37sIyE4nmyPXTL369AehOBa7GaIE959S3c0y5avmz2XZ8WBu2dbKMExN6jNFNMrx3nbJjc57j+ELW1CjhdIsn8VYCnBQUq87np0YfMFUZxHmfvTuojC8i3siu1lDXBD7HXCviJoWluVqfz6qQ0u8DtpEwBjJ/LHneEjM6+gLeNyUV8AIbC1ySaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tjRElqrXKYAgA99yuhF3afHtqrTsXTP1mgLePZbIrFs=; b=kGn7M7eTJEuhDTbacj9xunjkLECuUd/J3hc0VMGAo+LIAu9ynbcSfZvAm7hwsQ3v8mMxs+sVEdIT2Zzz6e2oIdl8Omtz/MxjMvZk8+8JuO1pRDigumglPeEAaNZkVfFql+yA3pz6o7Plib4BqQU+i3liOGGwZX7ZOYMMKX6nPKI= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB6984.eurprd04.prod.outlook.com (2603:10a6:20b:de::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Fri, 22 May 2020 10:32:54 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:32:54 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 3/8] usb: host: xhci-plat: add platform data support Date: Fri, 22 May 2020 18:32:51 +0800 Message-Id: <20200522103256.16322-4-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:32:51 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 65d9db1a-22c9-46ec-fb4b-08d7fe3b7c65 X-MS-TrafficTypeDiagnostic: AM7PR04MB6984: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1091; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YlN7wOaziV836szmgZJtWFgHT+4493YzyQClCY/3WJx71eKUjI0JUFfBTTK46dTdx6AYdpW0+25m/2frfnGgzGIoJ6G5xwxZ4iVdy0B/Q0eF/QYjHMY4uI3Mg2C41Srj+jQ6q5WSBDUopVYyldfqQcUNN3+dDH7xlepFiLNasKW2yxeP09ImIKGQOBwyq2Cr7mGwyB/+VN+gZ364FOeGEH/Zsw8TBkZ9Eg0B6mOTnSGjk27ITnkpH+okXVtaIdxYHGa6HZkVwEi8LU2Ch1Dxc+456wTEoh096B+TJTp9zVdqTZqS7YlhlQZqLsI9S+lqg2g31djW7oxd/fHzyOatGw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(2616005)(956004)(316002)(16526019)(186003)(2906002)(6486002)(86362001)(52116002)(44832011)(4744005)(8936002)(5660300002)(8676002)(6506007)(6512007)(4326008)(36756003)(26005)(478600001)(66946007)(66556008)(66476007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Ro6AiXyK8+LDnlCYAZoQ1/9yj40H2gnpGQCG+hOLnMLsM8Yp0CN/+TYgdDFAtu3QgxQRZWDUb1Wyxn4PNjTfCzerXRNR6ZsHDqWVpNclpVloox7ER3CssSl8vyG6ptxCblxDs9fyCpaAcX1E4aS94m2EUVqZxxYBf90jiEfpIKURg8HIkfeL0ITUXTF8vmkILWOwIbrXoOm7zAYzxM1WOO7ikokhrRch/v5jTwimjEPFCJMVbzzY0ZioizqAM7H5DAvYaGWyBoxljbK9Lx/Zsbny7ZLdCXRGkDhBcEJ+TuRKY3XVoMYaCAtRUzDK5m02AZZpgRZLxB3VJnIQ9nhjeBt0GJPAqZXUeKGnsEenXOGh6oOjraWd6gqPSctVsG1sKDyy0PV65K1GRaXg1cfbFYDMuoX7C3Okk5MpomJFYdwkaJrq/tK1bYSe140/ah/7p/NF30z5IJqJ0f9iGI6UXCmzXh50tPJZvEssehjiEb8= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65d9db1a-22c9-46ec-fb4b-08d7fe3b7c65 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:32:54.3153 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dnYlCpwbnF1FTW+f9I28JZjyr0vuRtSXBJYKd5+7B13c1kX+P69K5LozOa4QuQWvSSgPoPs3fKfiWIIX7MUExg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6984 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some xhci hosts (eg dwc3 and cdns3) do not use OF to create platform device, they create xhci-plat platform device runtime. And these platforms may also have quirks, and the quirks could be supplied by their parent device through platform data. Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 0b4cdc5af130..e00efd84ea1a 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -255,7 +255,11 @@ static int xhci_plat_probe(struct platform_device *pdev) if (ret) goto disable_reg_clk; - priv_match = of_device_get_match_data(&pdev->dev); + if (pdev->dev.of_node) + priv_match = of_device_get_match_data(&pdev->dev); + else + priv_match = dev_get_platdata(&pdev->dev); + if (priv_match) { struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); From patchwork Fri May 22 10:32:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D25E739 for ; Fri, 22 May 2020 10:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81F19207CB for ; Fri, 22 May 2020 10:33:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="glluzVud" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728956AbgEVKdC (ORCPT ); Fri, 22 May 2020 06:33:02 -0400 Received: from mail-vi1eur05on2057.outbound.protection.outlook.com ([40.107.21.57]:6057 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728822AbgEVKdA (ORCPT ); Fri, 22 May 2020 06:33:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bdEmWjC428PywjN1Opc/sVOWz4sGVkbmi765KLJguJQH0EXofKI5tzILyuT6sHAi63qOYCVmIEmKjwbnSQpVBxpG3+d5YYmlJWTn0JytotRs8bf66gb1HRcQq3hgcOY6q7wy3yhCGhFeMF/3Ihzhg/Ow6BVlw4mdNLbobJosh49TFOfHCPsXIonX9Mtu+7n4hRxh5q+W6JfOhh5UsGnWgZFgTQn2vS7QJT8eMBBjfcZlvGJ8J4XskQzW9vwvZUf7g1obondZEMgfAJRSJPgobxirsWDiRN8BjBXn9WraJZubNPa8STzdRnHvHIRxNFJLGxTzP8rGON6kc3qVokZT9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IFQB0uOvopwrAkhXDCmpo0sPpiaxTGFnzQu+VG/GRmE=; b=G16YQ0u3DP017v7wCTcubzASz6o4X4dVEYkzLee5mWv8jlcfwLjWXcGyMYzauHO7hMD2vVCQp2OcY6Jc4nwp0rUHellP+GU2G8bgxU1umOth3LNHFF7f0lBDRqZBEqh+MzhDVWRB4SdgUOpxzznHEyydGV1RtB5ivgxfaixn1C+h6c6RzcilRA7wxYG91mHCAXUwKFf49GcF9ZSKx7mcBNx98egyIXye6zrVrYe3DAtezIDlIA2HsCECIMT4a1VfC9jknd629ovWtuozU5f7tBorVNYKiP6CCCPuWf/uZEWJR31ZAkHo9DDWltdbx+oZ5gPndpun2PQ2YskNHvkNyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IFQB0uOvopwrAkhXDCmpo0sPpiaxTGFnzQu+VG/GRmE=; b=glluzVudw9h3F/wz7mHpQa8n4Cx8WuXIYZu0jgzbh9HRs6BbwCfXLU8gVWa+P+MK1vPkHg6ZhFcFDSxMtNs+yrdqbe5/Q92CrL6DDWX4qZTw24Jv3eW7Z4RaEpaBRa9B+Y4gsqPJJNc5APx/leWJOAgDfVjyCSPBx2AmQGx8ElU= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB6984.eurprd04.prod.outlook.com (2603:10a6:20b:de::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Fri, 22 May 2020 10:32:57 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:32:57 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 4/8] usb: host: xhci-plat: add .suspend_quirk for struct xhci_plat_priv Date: Fri, 22 May 2020 18:32:52 +0800 Message-Id: <20200522103256.16322-5-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:32:54 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 33a8b879-776a-411d-7692-08d7fe3b7e56 X-MS-TrafficTypeDiagnostic: AM7PR04MB6984: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rGvkEmLD+LiWcRHH9s9ic4w7YuNcHx8PkI2E2hG+ZoPEDOwAO/ZDIBp+4pVGoLeSYgwCeAQvwTo0wS2sUZdEAHfIRncT3XUyITr1EQlV91hw3FRs7Ueu+hDdvG0NsgL/cXCup80sZeRNoGEio+dOuixFqTW2WbDs+ykhjf5V+2JRf8bQ4I6LoGFGfdqeOfZSaLFieJzrqZzjM6RdprPDo63+xMyfaNGTH7AW8RJPFUkAqyCz3ZGySoHmODsrVU3WO8X6hCECjDxXF+7Y9U0bRxxWtjqSdLaBh4jVobs0C3+IDFiTtYxGh6XWhHiEzgyiIZ8Ma52sViFeGgTDf5Ugm/ARptnGw3q+wyqG6xsv0wjTkQUCA4vYKs9jBHW7k7mv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(2616005)(956004)(316002)(16526019)(186003)(2906002)(6486002)(15650500001)(86362001)(52116002)(44832011)(8936002)(5660300002)(8676002)(6506007)(6512007)(4326008)(36756003)(26005)(478600001)(66946007)(66556008)(66476007)(1076003)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CvS4g7kGYgYfDQRTCTRvB6gju1vQKEob7a7D6jZFPK97ePMsh44zYccEumz0DdK47DivJwae9Eqz6LyNOtphZqW1xhD2dxn5xWpJXGUhf0IL+ZxSNdAR2Xt5MFWIsHp+rTgMxsloSiwYsaichbfAcyJOjVHb1teGg9Ssizs4Dyrv63HaH1DcvhhTuYyGLfDmQcsf+UBRDwFYS1RNTwwmzosSuXyCiDKxvzJ9ha/FpZV8KHNDJkuMWbJtzv1n+8esPC7Qc36wtjag01aS6oXrEpMF0SXQXDIwi4+goKEueAyvg0rpQILBSHKlCpRbFbdwylivCewuUr3zrVmrJ8I35/NIR4C9aIkqMJMNNpumuNuvNu5BxOAixZiW9vNt4GyGtdwonbEUhdctq/UsiKLQpDUteSfYhgJZdJl/oB+8pVy1Mdk8hBfnkIHBiXaYKUQ0rS2A6HA1z2zVFKZLv81CCUQuNnL7l46/3OZ7SgkaF2Q= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33a8b879-776a-411d-7692-08d7fe3b7e56 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:32:57.4735 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RJxhIxx6pi6o8ykPdfUGBommfUozw4bM0gv+AJ/0VqgNb9ttucwTGe4I04+aREY7Qyn90YtP66jqGkqKUNu9Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6984 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some platforms (eg cdns3) may have special sequences between xhci_bus_suspend and xhci_suspend, add .suspend_quick for it. Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 19 +++++++++++++++++++ drivers/usb/host/xhci-plat.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index e00efd84ea1a..ca02e7f36238 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -54,6 +54,16 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd) return priv->init_quirk(hcd); } +static int xhci_priv_suspend_quirk(struct usb_hcd *hcd) +{ + struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); + + if (!priv->suspend_quirk) + return 0; + + return priv->suspend_quirk(hcd); +} + static int xhci_priv_resume_quirk(struct usb_hcd *hcd) { struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); @@ -396,7 +406,11 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + ret = xhci_priv_suspend_quirk(hcd); + if (ret) + return ret; /* * xhci_suspend() needs `do_wakeup` to know whether host is allowed * to do wakeup during suspend. Since xhci_plat_suspend is currently @@ -425,6 +439,11 @@ static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + + ret = xhci_priv_suspend_quirk(hcd); + if (ret) + return ret; return xhci_suspend(xhci, true); } diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h index 5681723fc9cd..9338a4f946d0 100644 --- a/drivers/usb/host/xhci-plat.h +++ b/drivers/usb/host/xhci-plat.h @@ -15,6 +15,7 @@ struct xhci_plat_priv { unsigned long long quirks; void (*plat_start)(struct usb_hcd *); int (*init_quirk)(struct usb_hcd *); + int (*suspend_quirk)(struct usb_hcd *); int (*resume_quirk)(struct usb_hcd *); }; From patchwork Fri May 22 10:32:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AABD739 for ; Fri, 22 May 2020 10:33:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7518220757 for ; Fri, 22 May 2020 10:33:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="PJBqVeaZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728822AbgEVKdD (ORCPT ); Fri, 22 May 2020 06:33:03 -0400 Received: from mail-vi1eur05on2057.outbound.protection.outlook.com ([40.107.21.57]:6057 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728362AbgEVKdC (ORCPT ); Fri, 22 May 2020 06:33:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TuFpbzDvZpWjPf6lCqWEOGocEFnTrBQHOoG/FpoeOYSz9+TV/SeOl0ghleJgFCweWki+/u4twBVoMb506M15dQUav3kymtAEAEee1vlQl9ZhgozRiPJR4SDxMaysDe8/ZeA3fip0Lca2WuK/hYDAXtbF5Gj1+1EZVRH39Lw0g55rlkK83HcbQ7AmJjkBlDgJuYwGz8Qs+GL1ogp0EeIt0sbp8oBkq/CM90h3Yva9W1hgAEALV0FOLBRCYx3duc6ZOzpW4Abm4P7KwamWSLY8jMToS8PD+ohLJO3SXh34008kDXcF70H3BkuKZCldhojwMJVk8lvpzPxJxI1hy90wQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wphtIvDB2kfCDDspx0029WSs0K6S4SQNxMGw4AVjxXQ=; b=FtlkmQ9WL8ayo39QKs+8q7gzs4LQhSq39umjMADh9ncxxtldcV9ypGHkro1LOLL+r2hbmKm2RLc1lsvIxh0NYRQoixCAnPwCyYq3fwfu5UJWIJ6RONNwr1a9EpQ2VTnXQ8zZr7CV3Lk2cPSsAdjQ88VSkReREFRMxgbfr+jZdfpWd4AYWCdYR1DtiwjYe1tVTqNB+4ApVm9ixvbhLRaEvG0sm81A4VbrIuU09qc+KGosLdh7HuHYAuDVNtmEzRBYn5r7B+wLxrlO20AqPH5/vuEMetJf/oiQjoUJGNuFiB6oz0uTjF8OOFQhe6cPPswgA3LLg1Tb/T3sOWeQn3bHDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wphtIvDB2kfCDDspx0029WSs0K6S4SQNxMGw4AVjxXQ=; b=PJBqVeaZH8GtrJREpNyXvciPZW408seDH2EiMrtS6GZxMH0GsD/2FtiZVA/oDtS9Dc5MNcg1eLttaYhEdK3rM/TfkiuSV8fu2POKi50EREFRddZ1kOMEEskoI3i7uSC5R/jnNzplYMjHGJ24m+yoKsV+/xqatnV2BchGZO9FplY= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB6984.eurprd04.prod.outlook.com (2603:10a6:20b:de::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Fri, 22 May 2020 10:33:00 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:33:00 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 5/8] usb: host: xhci-plat: delete the unnecessary code Date: Fri, 22 May 2020 18:32:53 +0800 Message-Id: <20200522103256.16322-6-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:32:57 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a324d983-56ef-4703-4bed-08d7fe3b8037 X-MS-TrafficTypeDiagnostic: AM7PR04MB6984: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X0cSvvIHfKQxR9or9McQWqidtjgEyZzffmisq4eqaKcRe2DBA0AOSK0XRM9321KpsCFyH1nv+UndWoj+lQMd3g5B/OGofGhC099ygGxoHuQNLJmJK5syZLFQLE5+hay3Hz4lyp2i3tduoUm4reVVNOlh9I8IWv2pfSlWflOBwhpmaKRnMli2TtluSlLtHLVhAmBFi5zZvgGrFSbeu2FWvGv/bPryEwClxfUnLkMObJvKsMf5roe/4j7ybZdc2eoOhQPg4o+OpkOSMJqbGZ3PZV28DIq2yLbD5X7gR4l6Nalo8gkwCO1rp9cqnvdL2032TBijEn+KVWqdBbeVZWri/w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(2616005)(956004)(316002)(16526019)(186003)(2906002)(6486002)(86362001)(52116002)(44832011)(4744005)(8936002)(5660300002)(6666004)(8676002)(6506007)(6512007)(4326008)(36756003)(26005)(478600001)(66946007)(66556008)(66476007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dZHQrcij4kM3UmG1ZB/Q9yqG5D5JXZdR0RwQwgLfeJwDrbpVXZ57iQIuhmcFvXL1IKrV3p/ofExEEkamRS19LZ2305laVP1vyKgfYXtfSJfZ74WsBcthyqjQtdxpwwQ4k//GoaI6zKJdWkxl/cutV5Hf3AE5mXr3ECrp1sKb+irVsqa88N3fXLMoCBTXaKQ/IhNVeMx0h3hRa4TquH7kIjnXkxOWae0Q2u8Sg6vsa3Ocl84QYrnLBRSMHO3CN8gRXAi/0aAgwQklfwxs+5nO/oCxDkraLEz642Csq2qXU3jQ6li8jN84+l1hKbzkDE4jeT49nzTwdXdL3dPnPqZaip4l/C5QYzU7jMeWeGBHIz7d4STuUjtBuvBKz2oHjFkIGA8wOGVnsYzSxlH6lRdCweB+/fb1RvyfpV3GjfffYnvsWAVE7FjvJoIjpLXCU+hptuUa7NH88LKHePzZFI5nAi4hGyguKt+lct1m6Xu2mFE= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a324d983-56ef-4703-4bed-08d7fe3b8037 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:33:00.7471 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: unqWjpRnuaqGmVPBEWEzwbXFkHhNRlQWgzU80D8htrSeY1daFvZd1p6ZtgnnuVEHnwimJEV3GYAOZfc5I628RQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6984 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The if {} condition is duplicated with outer if {} condition. Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index ca02e7f36238..a45c7ec33ed6 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -274,8 +274,7 @@ static int xhci_plat_probe(struct platform_device *pdev) struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); /* Just copy data for now */ - if (priv_match) - *priv = *priv_match; + *priv = *priv_match; } device_wakeup_enable(hcd->self.controller); From patchwork Fri May 22 10:32:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59A59912 for ; Fri, 22 May 2020 10:33:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4374F20738 for ; Fri, 22 May 2020 10:33:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Wvxcbxtr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729026AbgEVKdI (ORCPT ); Fri, 22 May 2020 06:33:08 -0400 Received: from mail-vi1eur05on2077.outbound.protection.outlook.com ([40.107.21.77]:22662 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728362AbgEVKdH (ORCPT ); Fri, 22 May 2020 06:33:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZROki5I3ddgDLMDhxbd+EZWYskTMR8f7NdXUG9K9cMADc9eXYDw4ZjueZpq46cfDW30oafdR5BNT6yS+O7wYQoGbB6X3gK15m8iQ7otoH4TsJ7XTvz+YsuOmmYmXk7JfhMt7hODHtk4LBFGvAWgIN8tgi6+j1xqeJZAM96oo4XogbA/OnftGoj7hpRN6avN0kE4JLwEDmj/6inlunlllALHN1Vga76tFKIlKNeRIoybqos+3noov8tZgvnUURcPxOr5DQNfGDN8UnzZ90eGmt7jhlYL5uJTVW5bLPhb3njm/yf/jF4L4Y+QePaNVZPBu3WQeFjtitJRviVbRn2tb/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lFc2zv0nLF2LMvjg973n077bmgO6MpzTt9Gk2uJotQA=; b=PZBvixOTErZH1RJphR/QzB/8ZvuUvZRFAjPSxNammJrWaqQjlhY+HCYr+s/nIXARj7jqQYIcO7wQ2DbH1lPsPWMhLyIUKMDrsyeE0bOyQgoDslOj0zKnOr/niqY3Nxm0hXI2Gu95EIDnP+M6klCm0gKQ3qxA4ohr02wsCYAnDNWFj2u1aXvs1xrmDVzJ+bQInAYr/pR+J6Sqyo2/XE2W83lCy4W7zXCYTQQW/AQF20PdlK0ouD9PPOBD4J7/EIH10SaLx5IiOR0Z58mdOJf63pwixwGhV6BDPySSpbhha6UElK1x7oaivPVNmMRUMMzEnAFE7m6We+90JSnmm6vueg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lFc2zv0nLF2LMvjg973n077bmgO6MpzTt9Gk2uJotQA=; b=WvxcbxtrxZjpWZdjJR8D5ul/LzDZy3rnhhAuCVHaUrEOmHMmM1o2r2fuCh6++bG7Y75nV4DU8ZlALLVlHxwD3rK9MMXYeSJ7DD6gpfEV8cPwEwCPY9gDXwpWECi8gCD7SlUk0HxRGTagDwtyFtZFfmD795uGEby3Fde02HvQjmo= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB6984.eurprd04.prod.outlook.com (2603:10a6:20b:de::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Fri, 22 May 2020 10:33:03 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:33:03 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 6/8] usb: host: xhci-plat: add priv flag for skip_phy_initialization Date: Fri, 22 May 2020 18:32:54 +0800 Message-Id: <20200522103256.16322-7-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:33:01 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f6e53b07-98a6-43f3-55f3-08d7fe3b822c X-MS-TrafficTypeDiagnostic: AM7PR04MB6984: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SCECt8auMhb/u8liTXrSJq6EPDqMAFWVNJdMDFiOxlOZOhSTOuG0e1xYBq7T3IlNu3zUiLpaqBIqCgnPsg7ZP5DehKVBWlP5ct4mPZzF4TRiyQLu8ta05++Q6F6H4eFjquJ5iGP0tIr98YqUqZbbXGctjfws38KjaM+Wm7ZH5SV4b2DFYPA4o0Ry6/t3uSM1ddxOkSQjwmdDf/ARLMyWtF0TJ/0bn/YFoFf9vGzy5Y8908ogEFNQNsF7a+HiO03Kt8v/FxrqzDLIdd7+kMlFZGqh6GpVzxvmWjuaX0rd/QgVU0ZAEKKL8dS0V0w/USef67/3c8k8qdiYNAVPgUntUg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(2616005)(956004)(316002)(16526019)(186003)(2906002)(6486002)(86362001)(52116002)(44832011)(8936002)(5660300002)(6666004)(8676002)(6506007)(6512007)(4326008)(36756003)(26005)(478600001)(66946007)(66556008)(66476007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: BeelpMu1lD6aFvcCygge+Ec6xnw57gNZwv0o5qEDBVinVt8fc05/3ppBOP9/YGXFS5Pcs9Oquzcwr+QvEAnQOkJWQXaUw4DQajwhjAm34A1yVDPj3iK/nUC1m/SbMNNMeDyz9yJWSohpZCjdxOC5H80/1EI0ReAcMzhhhi+8RXep6kEzKqyYKqH+0QNyXHndqCBcgVFrt9ZDBy+kwf9hlvBp+dQLl3t6v3+kb4W0pR2qCPimqzrm0lhxgaaP5zI7EuNk4O83fyQirI2gBu6U7BNalsnqRdzCsAIhfxKzPNoGE6WoaSAobh08bZQObADVrFfq6KjY0QBADbBCd/sRVDa4X/RzGUeszjebDzodG6hQQDjkFKGRKyYMzH9VRqk7aGBk5KjX++5WpGhu1Zy7S/dCVly+pMfp4ZuXrCf+dUR3knZ+VfSw4j0TkNPciXtPttCbe2nsLKtcIih6u7IZoetmPepYS72n+5Dsh44xzAg= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6e53b07-98a6-43f3-55f3-08d7fe3b822c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:33:03.8864 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bictITf6bEa/zuLTVfCTJt0t7ECKb8Vwc8YIttzB8Kk0bSUCag6k/U8gYZazBGernNNcZKD/13IV7PRi8TezMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6984 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some DRD controllers (eg, dwc3 & cdns3) have PHY management at their own driver to cover both device and host mode, so add one priv flag for such users to skip PHY management from HCD core. Signed-off-by: Peter Chen --- drivers/usb/host/xhci-plat.c | 8 ++++++-- drivers/usb/host/xhci-plat.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index a45c7ec33ed6..f653b717c098 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -173,6 +173,8 @@ static int xhci_plat_probe(struct platform_device *pdev) struct usb_hcd *hcd; int ret; int irq; + struct xhci_plat_priv *priv = NULL; + if (usb_disabled()) return -ENODEV; @@ -271,8 +273,7 @@ static int xhci_plat_probe(struct platform_device *pdev) priv_match = dev_get_platdata(&pdev->dev); if (priv_match) { - struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); - + priv = hcd_to_xhci_priv(hcd); /* Just copy data for now */ *priv = *priv_match; } @@ -324,6 +325,9 @@ static int xhci_plat_probe(struct platform_device *pdev) hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node); xhci->shared_hcd->tpl_support = hcd->tpl_support; + if (priv && priv->skip_phy_initialization) + hcd->skip_phy_initialization = 1; + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) goto disable_usb_phy; diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h index 9338a4f946d0..d78e86e14f59 100644 --- a/drivers/usb/host/xhci-plat.h +++ b/drivers/usb/host/xhci-plat.h @@ -13,6 +13,7 @@ struct xhci_plat_priv { const char *firmware_name; unsigned long long quirks; + unsigned int skip_phy_initialization:1; void (*plat_start)(struct usb_hcd *); int (*init_quirk)(struct usb_hcd *); int (*suspend_quirk)(struct usb_hcd *); From patchwork Fri May 22 10:32:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D169912 for ; Fri, 22 May 2020 10:33:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2654320738 for ; Fri, 22 May 2020 10:33:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="dAYZrklZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729034AbgEVKdL (ORCPT ); Fri, 22 May 2020 06:33:11 -0400 Received: from mail-vi1eur05on2077.outbound.protection.outlook.com ([40.107.21.77]:22662 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728966AbgEVKdK (ORCPT ); Fri, 22 May 2020 06:33:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mBs5iVtDqCqIj2km69nU1uKm0NCJAebMMSisvkXzaFelyCGmHgSuNScrOEzb9OqHeL8QGh5FAmPIiAE1Gm2VHLQ6GnvPQ4jGw9KoPr73uetMgcFNbkkEKovJt83iN/5ctnc6dn7FGk7zLZQLKFV022zEucDlRd2PqijG5Y68mzJnqBuNAbGCcgIkWB5gzLBOKFdXV1dnE3pyfats/E32Uk8Pk6Q4x/Or26d2NV+jNQbZcOZN+dsG+WTPXjBZVZTG5fOA2kvya4V5DjR/xF1aJkvqZfhOYSK/+B3YmCHeoeickX+JdEA+i7YFrRi5iC5RSBhkOK47EaHyi9szygZuCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=awe7nqB8eZwjtrkIA9n1ZMYGeDJNbopX+R1gbb340Bw=; b=nzsM3r4FfhSSTSKjf5LvSu/vDSex7pM5WnK7bQ89cOsd2Kme1xDDPq1cik9NY39x5i6P4WWhy8/rt8E6Nri6n3zjj5UulLldKDkMFmzsWWcacLphsSfcIFjhTOZQRS7PQlJAxjds39vCxx26I5pcAseATMsNllq/o/6YyNeVXs4Jn9dL5o2xv7rBlmDhBcmmQ180ntBtljsQBPbJ0ETpXhxJVuwKIcSgL1VGCQ3UPVLsrce3nutDQ7zhi5mS8sYetcv/dro8m3nKyPm2ok+H4fYuUH26EkQ9YH1NG863n5VPRDoI/AWctAAzurM4H0Ia+o7IyqvbnwgmCobjHI9Vdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=awe7nqB8eZwjtrkIA9n1ZMYGeDJNbopX+R1gbb340Bw=; b=dAYZrklZ21a2RSI04KcSaLDixCh45guszftLefRjIUnWeeae7GT2AQIWmR0Df0a+JjAJgPtWmg4aKPpRXZF+KyEqHrj0/Zk5XanQXQJb3Rxo038FC02jKmJ9SPRfgWrqtAw35Vg6GpQOZ/YysTMknah4LflyFFgb0pl2YoTdohU= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB6984.eurprd04.prod.outlook.com (2603:10a6:20b:de::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Fri, 22 May 2020 10:33:07 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:33:07 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 7/8] usb: cdns3: host: add .suspend_quirk for xhci-plat.c Date: Fri, 22 May 2020 18:32:55 +0800 Message-Id: <20200522103256.16322-8-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:33:04 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a75b0ca2-9227-4192-9622-08d7fe3b840a X-MS-TrafficTypeDiagnostic: AM7PR04MB6984: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kBx1+MYHTqrjoMZhc72jB/tQtonmzhGg9R6pAd1sA7z0u+7RvBe3ziVjO/wgnoaaLT3UT3KFtz26I58oYLOq8zclhcZdOqWcXnuEVv+LDDDq3qMuWsACf7zHdF52VY7NcXF0vwCxOBo5EMDFD748USVuMGueTUvocwUBmBvt3S9+tt1aC7lTjwPRnIJSAvMVxNWRqDPq32xFMk6Q5HIXaLcjcGTUKh+MOqGg6bNGTx32r4c2W7UI291a3j/aITaiWVTUx5Ad9fpZxSdqplDj25jMJ61+rFA9UT74jlmC4fFEqj+eTalabIC+ww+gVVxp81gMLmhIeN7LD2Uzg7q78o3YuNOXKVBV5Fu4NBUzZb4imrmOWM2t8uNAl9+C6hI4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(2616005)(956004)(316002)(16526019)(186003)(2906002)(6486002)(15650500001)(86362001)(52116002)(44832011)(8936002)(5660300002)(6666004)(8676002)(6506007)(6512007)(4326008)(36756003)(26005)(478600001)(66946007)(66556008)(66476007)(1076003)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: w6Vw2jDJTQEzGjekzs7CF+Rei0WiW2UtbnLewQ1jOWwy5g5yG33fej3Cal1U2qwDOpEYhyAPhfmDQ8wav71qGqyVd78mtDT1kyfiO0UvATOZ92OOjDlONfowH7m88KZrHgAKGk1FOYlXnKdfttNl8ZBksyiR2Riz6ZvSbG2NnWI19HSMtXF+Hxi9HtH7h4KxmvdGnA1DSzVRbFAHCZsX4uTxfPBWUYsHqui5O7KZqFUPeCsJ2/MbT0epiyAIi/ACWzlcCRY/SGzGBKLY+YftPaBepvBKuC+Rg3l4urgy2kKgvT5yD6BR/3qdtU9Y1l8NGnGA14o8WC9EMUqyuymtxjNhsjFBhy764n9P8S+m7sIu19FBmph/zfoB7e7zfOSBkj3fNQgjjU9HveA3T9Nusn1E6LLcnGXL2l+ePyoOLTQEMvPeo2U1eL6KFUtnwW5KO+lSkS8hLgJHKOmyQ6t7fvrpqvkUT/HxyTxf9YDBTC0= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a75b0ca2-9227-4192-9622-08d7fe3b840a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:33:07.0167 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uuiTTIZSwViTV7vlQoVXDVT8+pkZ9hFPghUyB7MgRH11GDL1CC7ucPVRr+ODhMkzvMs+pxkKqERF2JiMjZLJEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6984 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org cdns3 has some special PM sequence between xhci_bus_suspend and xhci_suspend, add quirk to implement it. Signed-off-by: Peter Chen --- drivers/usb/cdns3/host-export.h | 6 +++++ drivers/usb/cdns3/host.c | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/usb/cdns3/host-export.h b/drivers/usb/cdns3/host-export.h index ae11810f8826..26041718a086 100644 --- a/drivers/usb/cdns3/host-export.h +++ b/drivers/usb/cdns3/host-export.h @@ -9,9 +9,11 @@ #ifndef __LINUX_CDNS3_HOST_EXPORT #define __LINUX_CDNS3_HOST_EXPORT +struct usb_hcd; #ifdef CONFIG_USB_CDNS3_HOST int cdns3_host_init(struct cdns3 *cdns); +int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd); #else @@ -21,6 +23,10 @@ static inline int cdns3_host_init(struct cdns3 *cdns) } static inline void cdns3_host_exit(struct cdns3 *cdns) { } +static inline int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd) +{ + return 0; +} #endif /* CONFIG_USB_CDNS3_HOST */ diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index b579ef15f4e0..030d6421abd3 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -14,6 +14,18 @@ #include "drd.h" #include "host-export.h" #include +#include "../host/xhci.h" +#include "../host/xhci-plat.h" + +#define XECP_PORT_CAP_REG 0x8000 +#define XECP_AUX_CTRL_REG1 0x8120 + +#define CFG_RXDET_P3_EN (1 << 15) +#define LPM_2_STB_SWITCH_EN (1 << 25) + +static const struct xhci_plat_priv xhci_plat_cdns3_xhci = { + .suspend_quirk = xhci_cdns3_suspend_quirk, +}; static int __cdns3_host_init(struct cdns3 *cdns) { @@ -39,6 +51,11 @@ static int __cdns3_host_init(struct cdns3 *cdns) goto err1; } + ret = platform_device_add_data(xhci, &xhci_plat_cdns3_xhci, + sizeof(struct xhci_plat_priv)); + if (ret) + goto err1; + ret = platform_device_add(xhci); if (ret) { dev_err(cdns->dev, "failed to register xHCI device\n"); @@ -56,6 +73,29 @@ static int __cdns3_host_init(struct cdns3 *cdns) return ret; } +int xhci_cdns3_suspend_quirk(struct usb_hcd *hcd) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + u32 value; + + /* set usbcmd.EU3S */ + value = readl(&xhci->op_regs->command); + value |= CMD_PM_INDEX; + writel(value, &xhci->op_regs->command); + + if (hcd->regs) { + value = readl(hcd->regs + XECP_AUX_CTRL_REG1); + value |= CFG_RXDET_P3_EN; + writel(value, hcd->regs + XECP_AUX_CTRL_REG1); + + value = readl(hcd->regs + XECP_PORT_CAP_REG); + value |= LPM_2_STB_SWITCH_EN; + writel(value, hcd->regs + XECP_PORT_CAP_REG); + } + + return 0; +} + static void cdns3_host_exit(struct cdns3 *cdns) { platform_device_unregister(cdns->host_dev); From patchwork Fri May 22 10:32:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11565337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 009CF739 for ; Fri, 22 May 2020 10:33:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE37C20757 for ; Fri, 22 May 2020 10:33:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="c68gpQgB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbgEVKdO (ORCPT ); Fri, 22 May 2020 06:33:14 -0400 Received: from mail-vi1eur05on2077.outbound.protection.outlook.com ([40.107.21.77]:22662 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728362AbgEVKdN (ORCPT ); Fri, 22 May 2020 06:33:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GaB8cp2uz+VSGE41AiUNHFNpKKLtpWBXd34YvLloKGQ3IQeTC8nOX5Vyirb/Q7Xp4itd6WKlIhIlPYQ7ogw4ETx/P65GtOzoa+/0QgAXHdoJ0OAbCdltcUAE6CKLB5tcw5eAXC0RL7j66In3UODwXPQKh1Q07jSXj/wT/bNUuFW/VwndkEtwSZyRGEx6DTZWWMnA6bxU9Cw2FtYdR3jkQDK/pDoC0BzXv+1cCHmm52ZjUBMETA7jJ8RPMfTlM8ZZE+7+hodOrTIahErji5Xg3iYc4861OmAAAJcOJMVyFBGY30zfFhViUz2JoIVlC2Hu1HmGv4Na8G3j2rpjQPaNEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PFEnKAx9z8Nqa3HrPCHrL/GMcHDUpPdw26EiTvUC4Rw=; b=ffI2qRpdYfnnwY4UzJJIaG6WlyNPULYFaLcmpv6/likJlq/A+p6AjprdawMgX3jpExcNshJ2i7aPCORBjniNJf2LJh9xfJXGFBg3u2hiGhpIgeSvB9eG2U0SwdEKnOwplfnWwK16Zmj66AxrRs0gXZWi4tWVsjNPEJpcpt0Q4etJMLbocs3V4damwd04F4+9k8a5DRR58N+bsT6oth7KxkPufbvMQr9HUHFJE42IZ3zx9AhDSHbxDMhgofpgYvKckyrH0ZJNEED9q8O1lUY34aB51BAQvN0Rw/XS5SjXH9QsqoqiX0w8tJfvC+2NPvJ9UIbVzZylJlw8mj0JuZ+i2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PFEnKAx9z8Nqa3HrPCHrL/GMcHDUpPdw26EiTvUC4Rw=; b=c68gpQgBqM10CmJHnkHckiDg91gnXzehpLsHHasW4+Ew/tnxI/rJXwJySYaMwxZGKo/IU95zYCDW68b/IQK/SojtmGI6o9v/CRkxdWRvLtK+vgwOXvEgKB+KCVkaYFK2Bo8HxfiFCG/qtV/AOXAe9Agq7RcPumiJQGLwbzybuZ4= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) by AM7PR04MB6984.eurprd04.prod.outlook.com (2603:10a6:20b:de::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Fri, 22 May 2020 10:33:10 +0000 Received: from AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a]) by AM7PR04MB7157.eurprd04.prod.outlook.com ([fe80::1101:adaa:ee89:af2a%3]) with mapi id 15.20.3021.026; Fri, 22 May 2020 10:33:10 +0000 From: Peter Chen To: balbi@kernel.org, mathias.nyman@intel.com Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com, rogerq@ti.com, gregkh@linuxfoundation.org, jun.li@nxp.com, Peter Chen Subject: [PATCH 8/8] usb: cdns3: host: add xhci_plat_priv's flag skip_phy_initialization Date: Fri, 22 May 2020 18:32:56 +0800 Message-Id: <20200522103256.16322-9-peter.chen@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200522103256.16322-1-peter.chen@nxp.com> References: <20200522103256.16322-1-peter.chen@nxp.com> X-ClientProxiedBy: SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) To AM7PR04MB7157.eurprd04.prod.outlook.com (2603:10a6:20b:118::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from b29397-desktop.ap.freescale.net (119.31.174.66) by SG2PR0601CA0019.apcprd06.prod.outlook.com (2603:1096:3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Fri, 22 May 2020 10:33:07 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a5deee71-488b-453e-71e7-08d7fe3b85e9 X-MS-TrafficTypeDiagnostic: AM7PR04MB6984: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-Forefront-PRVS: 04111BAC64 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ITHQbJRUazh/nqxF5r1LpCLh55dbdw9jbS3JTZ2A6RF2qmmyLPVJoDnNLVq0/gYucXpXiGl3WZPfTJjm0HKPgryek3tShj/hJdYlKC3VHBokfn8Rp0CgnqPKF1TDxgtaFR1sSWVuIcTtnuILukbT/AhdSubDoEHlTFgmD0yqAq0bfkQ/06Dp0B8iWP3VrEM6C4ekKS5wxXMopHqOB/v/5hbzmQao9+iimrzeVJhhoZrLjD/56539I45MItpknwmuLOY2b+acF0jX5oIn5vy7oACsxtsvNCbTfQE4Rgx0TmVYiVlCIR7DFvm0z+4Fm64yS7SgFMU/UAp0bBL676R6Lg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7157.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(2616005)(956004)(316002)(16526019)(186003)(2906002)(6486002)(86362001)(52116002)(44832011)(4744005)(8936002)(5660300002)(6666004)(8676002)(6506007)(6512007)(4326008)(36756003)(26005)(478600001)(66946007)(66556008)(66476007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 14oFFs4T26lITFBdmFnYHQPoAJrJiBFdGqfy5NuXbQAcsAicp0+lb7JrEw/1iD+hwLTJ8UHtYiiYbKhsIKkrenhmGQbJ6mMiiKaBCkAh3feOsX/olYzc29psT8xqHXb5aLggl4xA8hdkaAe4RnewqJyzGlSx+VVByAWHfkUQAOFP5JshQUI1SvKGwFLqZmNOJSJet5NxdYZvWEW5dSvqQ6Zwes1kP1r7FC4FbuAHFqmEXkE2gYbLs/CzSWnKhrS1IzsrNFzCardX0oVbj7p10F+sCr+ep5iwVpCM0f5JY8aVArr64TKDK8N2dTujfGf9KoGkgunJRCaVZxan/OmYQfTZCHUdhbG/bQHOTXmEZVcHu0Ky9hsGg0pPteMJs3PT/4WhEQ9ZRJL4ebx/g9NrdlIrsyo/ydPgn9ZCzwd3YvTKR57iq+wR2DtEnxzpVVtj3hTaAoYiXn+AKlCVK8IN6+mFMeBWVtNYF+FpWDN+qus= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5deee71-488b-453e-71e7-08d7fe3b85e9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2020 10:33:10.2863 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EwOwn4VjVHnuvR5IE7RAkpy3btpQF58EgkiYa4SbaXt3+F24XTBmenFrIAiu1Yrq0g3cDx79PkVx1G76Xe+pMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6984 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org cdns3 manages PHY by own DRD driver, so skip the management by HCD core. Signed-off-by: Peter Chen --- drivers/usb/cdns3/host.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index 030d6421abd3..d681c3db25cd 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -24,6 +24,7 @@ #define LPM_2_STB_SWITCH_EN (1 << 25) static const struct xhci_plat_priv xhci_plat_cdns3_xhci = { + .skip_phy_initialization = 1, .suspend_quirk = xhci_cdns3_suspend_quirk, };