From patchwork Wed Sep 16 12:56:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 1365259 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=CAhVhaZs; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Brzy6672lz9sS8 for ; Wed, 16 Sep 2020 22:32:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE4638234E; Wed, 16 Sep 2020 14:31:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="CAhVhaZs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8005B8234C; Wed, 16 Sep 2020 14:31:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0601.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7337082322 for ; Wed, 16 Sep 2020 14:31:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peng.fan@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Thw1jkDNZGFOg2WQ8WJdMJSy9OgdEYqy/tCwgTx2UPOSGKVb74PX9S72cOcpMbsZNN5oVeWQlDc11avYXaj+cFyTgkOD/eRMouRHUAiGUJaDD+UJE45zZAsjftAqn2WM6rhaFMFnc601YDHqZcRqy1PbA/SLoIundtf+NoBxSL4V7MfNT14dEgHYNW3HvkFOHdjIzau/PjNNUiqjpj50o7NzRRhVf+1MZOHr3jOsSEdDhCgqvVw8nAkBfEk8RIGcW3lRm4t+qem1EnLsdoH1l3pZEL8HLNIkiyk2dxOcS6IeAmOduPL/7YMTdBSdryoB8DxsAHwZOXv5WXMqSy/k9g== 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=61W1vWuYRIgXtJQxVsKccDyQV1F0Yof69Z2cRKgZd8g=; b=TVFbfFNDEQan4ia8b3n8ANlnxJWSNSp2GGiga5Vdari1eyY9q2i2i0HhOUekkA/Pmh06DyUChW3S4Nd3vwpqYIX/11tttCfleDVaw28aVQ+njO5vS9rRgYJkUmTP27fWEl/TQFcrz98WInoJtA/tGoPVhIco92xqvgmyuDGlh1p6cVb5EF0UUtV5JxYrdrYfkvbh2zoWU1ySDF3L0rAri7JuzMPzVC4IU6Ztt6xz9Vd6EPrxd5F/nyVESalRyCLDvpoIQf8h7I7lhdQ/70M35ZDY7HZneIu0WRWN27DqkK1ZWVss2Kgw7Y3jeznf+8zUR1A8+PRRvvfzWfQWPnEM3g== 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=61W1vWuYRIgXtJQxVsKccDyQV1F0Yof69Z2cRKgZd8g=; b=CAhVhaZsYHarY1UDxZ2wdlDonF0hEGML1UC457bwmRBmEymtsuqkJ2NHdAcxSPS9vHMnPsQXkfmKC7nJSi4I2dLP9kgwNg2lkzQ86aYAG4LxERZ8dHl2mebMOuDYESAQJ9Fr+7bpxWOgPzdC3uczTscRIHQPq5Fy0pPcjAP9T+0= Authentication-Results: denx.de; dkim=none (message not signed) header.d=none;denx.de; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB3PR0402MB3915.eurprd04.prod.outlook.com (2603:10a6:8:e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.17; Wed, 16 Sep 2020 12:31:18 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::39ff:13b4:4f28:1413]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::39ff:13b4:4f28:1413%10]) with mapi id 15.20.3370.019; Wed, 16 Sep 2020 12:31:18 +0000 From: peng.fan@nxp.com To: sbabic@denx.de, marex@denx.de Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Ye Li , Peng Fan Subject: [PATCH 05/13] usb: ehci-mx6: Update driver to support i.MX8MM Date: Wed, 16 Sep 2020 20:56:57 +0800 Message-Id: <20200916125705.4341-6-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916125705.4341-1-peng.fan@nxp.com> References: <20200916125705.4341-1-peng.fan@nxp.com> X-ClientProxiedBy: SGBP274CA0023.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::35) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SGBP274CA0023.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Wed, 16 Sep 2020 12:31:16 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 456a98d2-173d-48e9-e15e-08d85a3c6919 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DS94+lqFu1vxfJw4/GwKTQR0jKgep8Xoxarm2h6ByefqI9Kas4NJZTeBkG9MBJEduoDVCOqp4VkP+TpKF6cS+XHQnI7JuwrQrY30M0zwTCmHJ7TMSMwdwHWcfpw4QD3UPqor9IyRMJ3ulYyEFBG2j4v61kUMmIgE6DzRvTwFaMv4u6I03cat07OSARQmuPFw4hSMXb7HPQTGQjLKBgffkJgZJCUHRDaaFA6Dh8BFu+i8VL4/P7FvAP/DerRZFPMXw/C8GIQ9E6YZfZ15Gwy9CUxg1myQ3AXC5MqKVyU1ODrKay9lHgaz9QFvf9nX0Ayv+cGFbq00A9PbeO+ZRLDg0A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(376002)(346002)(39860400002)(396003)(186003)(16526019)(6512007)(8936002)(54906003)(36756003)(6486002)(2906002)(1076003)(6506007)(478600001)(2616005)(956004)(5660300002)(6666004)(83380400001)(52116002)(316002)(86362001)(4326008)(26005)(66476007)(8676002)(9686003)(66946007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iJBN1vq3T6fFGVlxweDt6DOpA7Wr/vGkRikpvoo/1iXM9W/2GoPUYgunDmfnTlgQq56Lhzjw9esX3MLu7rUVs9ppJa1RbXs/RAp6c0+Oa8VsLS7eRqMek82L1qaHOfzo8hiUJ+yGzPyqKiEDYqj0O2byLuoqw9mYCcTEsu/29nM/AxBH8BSh/ui5hOOo2s37ZCoDApIQMWZ8FgpmwR7kcXUZkGZm7G4rTMHS1aI1oN2mpNxMv3SQ8jpK1n4FMFOd2HjaX44M4qJXrpTY+K8YHS6ABIEWiGZsP1m3SNnYBmCeibR0casDS38j0Iq0zGETAt4LpHM8bWhmXMWYNTFQ3b9V1IQ1cHPlkm3p/oKnPg+X6YZXCqW8PDiwerVR9tx3BeH2+xB0mrgPKU9hnVWVKyDNJfvyVLxhvsdYpwxguhHRlqbtgE1b9ilpgATJZ4k9TfBNXIJmDq5wmI21kdF8G0LrWhGFfjlDmu6+I8DaZsLIapw/rIASZaljg5D9yB2OUZoSBTDKM61sMG6PfjuHFfkv9xNL1VrEibLQflwb7UevVhXqCMFyt7asWH7LvGWLvHzq60OHeBG8BZgQwBI0EIEznUgj46699rHC7iRDokD4vCYJaiSj72x2fkiUEf3hv0fqsw1Fiutytxg4l8CXSg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 456a98d2-173d-48e9-e15e-08d85a3c6919 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 12:31:18.3125 (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: 2Alqamar9JBzvoOvPjAB1ZK83B6oCenHvBZuQm9cisOqmYSHcud8hvM+hhUcnyHjDLfPDrbeyHy5Z7QuuLjJew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3915 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Ye Li Since the i.MX8MM reuses the otg controllers on i.MX7D. We can use CONFIG_USB_EHCI_MX7 for them. Due the TCPC and load switch are used on Typec circuit. Add the board_usb_init and board_usb_cleanup to ehci-mx6 DM driver. So we can implement the TCPC settings in these board functions. Signed-off-by: Ye Li Signed-off-by: Peng Fan --- drivers/usb/host/Kconfig | 2 +- drivers/usb/host/ehci-mx6.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index f48547caa0..1e2c5006d4 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -147,7 +147,7 @@ config USB_EHCI_MX6 config USB_EHCI_MX7 bool "Support for i.MX7 on-chip EHCI USB controller" - depends on ARCH_MX7 + depends on ARCH_MX7 || IMX8MM default y ---help--- Enables support for the on-chip EHCI controller on i.MX7 SoCs. diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 0727aafc92..1db27949c6 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -277,7 +277,7 @@ struct usbnc_regs { }; #endif -#elif defined(CONFIG_MX7) +#elif defined(CONFIG_USB_EHCI_MX7) struct usbnc_regs { u32 ctrl1; u32 ctrl2; @@ -342,8 +342,8 @@ static void usb_oc_config(int index) struct usbnc_regs *usbnc = (struct usbnc_regs *)(uintptr_t)(USB_BASE_ADDR + USB_OTHERREGS_OFFSET); void __iomem *ctrl = (void __iomem *)(&usbnc->ctrl[index]); -#elif defined(CONFIG_MX7) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMX8) - struct usbnc_regs *usbnc = (struct usbnc_regs *)(uintptr_t)(USB_BASE_ADDR + +#elif defined(CONFIG_USB_EHCI_MX7) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMX8) + struct usbnc_regs *usbnc = (struct usbnc_regs *)(ulong)(USB_BASE_ADDR + (0x10000 * index) + USBNC_OFFSET); void __iomem *ctrl = (void __iomem *)(&usbnc->ctrl1); #endif @@ -445,7 +445,7 @@ int ehci_hcd_init(int index, enum usb_init_type init, enum usb_init_type type; #if defined(CONFIG_MX6) u32 controller_spacing = 0x200; -#elif defined(CONFIG_MX7) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMX8) +#elif defined(CONFIG_USB_EHCI_MX7) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMX8) u32 controller_spacing = 0x10000; #endif struct usb_ehci *ehci = (struct usb_ehci *)(uintptr_t)(USB_BASE_ADDR + @@ -513,6 +513,12 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) struct usb_ehci *ehci = priv->ehci; int ret; + ret = board_usb_init(priv->portnr, priv->init_type); + if (ret) { + printf("Failed to initialize board for USB\n"); + return ret; + } + ret = ehci_mx6_common_init(priv->ehci, priv->portnr); if (ret) return ret; @@ -592,7 +598,7 @@ static int ehci_usb_phy_mode(struct udevice *dev) plat->init_type = USB_INIT_DEVICE; else plat->init_type = USB_INIT_HOST; - } else if (is_mx7()) { + } else if (is_mx7() || is_imx8mm()) { phy_status = (void __iomem *)(addr + USBNC_PHY_STATUS_OFFSET); val = readl(phy_status); @@ -689,6 +695,12 @@ static int ehci_usb_probe(struct udevice *dev) priv->portnr = dev->seq; priv->init_type = type; + ret = board_usb_init(priv->portnr, priv->init_type); + if (ret) { + printf("Failed to initialize board for USB\n"); + return ret; + } + #if CONFIG_IS_ENABLED(DM_REGULATOR) ret = device_get_supply_regulator(dev, "vbus-supply", &priv->vbus_supply); @@ -726,6 +738,15 @@ static int ehci_usb_probe(struct udevice *dev) return ehci_register(dev, hccr, hcor, &mx6_ehci_ops, 0, priv->init_type); } +int ehci_usb_remove(struct udevice *dev) +{ + struct ehci_mx6_priv_data *priv = dev_get_priv(dev); + + ehci_deregister(dev); + + return board_usb_cleanup(dev->seq, priv->init_type); +} + static const struct udevice_id mx6_usb_ids[] = { { .compatible = "fsl,imx27-usb" }, { } @@ -738,7 +759,7 @@ U_BOOT_DRIVER(usb_mx6) = { .ofdata_to_platdata = ehci_usb_ofdata_to_platdata, .bind = ehci_usb_bind, .probe = ehci_usb_probe, - .remove = ehci_deregister, + .remove = ehci_usb_remove, .ops = &ehci_usb_ops, .platdata_auto_alloc_size = sizeof(struct usb_platdata), .priv_auto_alloc_size = sizeof(struct ehci_mx6_priv_data),