From patchwork Mon Oct 12 06:23:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 317612 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp4324621ilm; Sun, 11 Oct 2020 22:58:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAZd8I3oJZa29c/A7RUWZixf3ouIoe92Y9RPR+bZUmIVXRL0rC/XYLMJJJZpDojxqgV1tM X-Received: by 2002:a17:906:22d8:: with SMTP id q24mr25685150eja.479.1602482314316; Sun, 11 Oct 2020 22:58:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1602482314; cv=pass; d=google.com; s=arc-20160816; b=EXKEcphjuZX6rQZ9RLfoOyVu1xaEVyOVY6/8fn7o3vtYabcq9Yjul+wYP129NI5Snf X94s0ZoBx5yJf5/e7dr4aJR26sGZQA79xCQpoOf3RVC4VSk2HDQMtsnlW2joqJ9PZxuW Py4LMzBvLzBbnPZclCY4ZDBwSLEMy8udB0l1cXx+fOolKmZJMEqsTkX6xhVaccAwbVyz Ub4S+t//H0xP1IIJGuAlnatKsnhra/HLL7K+18u//aCExJ2jMUxtPd14BpFZxn/yxJa4 BtdgKd3DNDA39ie2I5a+xRUDtFj97kfYKBMbPhE457IvXYrblDcmUinLGR6yJygDPSRj y8fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ktfwC4+ZDNxo7RRPk+9DbYsRTw+y5VQuQdrrYF5I9pI=; b=IakK/cIuKci5VkvZ5ujWKYOzsw1QGP6T8rU/DxtYQX3iax8xFujBB6Luo3b2crn2NM LD/M5bnrMj8zxtF7V9c0vbpHIKf5o42RII5cu8OHSk1U2xG3+rHW3NDV0IMdclkz7Sli 6m14m+Psgvp3YuFMspRrYptAcGwSJeCGcARrKXufARCPkTcQD7RyizNp0jtUag0q6urx 13q9HJnkjjHqjwH3Sf05n+YUVlKnDn1ieAh5aXPfs7/KeaA8OeAV1SioU2eDbMKeTXdQ eLG2ARNPy95nBraMMFUtgG9aZFv5s41fsrnv+qHPOc1e/j4NaKLf1VpVoI64QrCRd/H1 s7sA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=dzDlH6Bz; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id r17si407075edo.383.2020.10.11.22.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2020 22:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=dzDlH6Bz; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A8EC824BE; Mon, 12 Oct 2020 07:57:37 +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="dzDlH6Bz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE9CD824A9; Mon, 12 Oct 2020 07:57:34 +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=-0.9 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 EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2061d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::61d]) (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 A07F4824A7 for ; Mon, 12 Oct 2020 07:57:31 +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=DMnayZ11wURihbvWpT6jnCb9iHesVUg1LBnu7KX1gUilF8KWCjdWEH4EiDPJpEQALiucTNnN84nlcqx7YG+WYIp7ncF+ZdIBFCfDYFvClw3RDyMLjLJsAsarVckhyV/HvLHGe9yMbBJ4ErKaZj0jHHhApComK42TbY4uY/dbiLGEpTFfnNUJYbirk6a1ctz/tjQ9wBOjWS27cmJqlPTXgBrOt/cWZ+Ui7qAZLJpTLvWy9mA1hhOsAcxozgqepRQUJQ30fXK1AnnIrtOJxDoC4QiqLdZJ15OFMsYy3ecuwvQkDDQTKMssz3DQDdht6jk0iOMnfOjUAZXqgpQcAMhqKQ== 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=ktfwC4+ZDNxo7RRPk+9DbYsRTw+y5VQuQdrrYF5I9pI=; b=bzPW2pUoDWmrWQd0RddMZxRPnKi1P0heFoi7DZESfWQfg3U76sZE7/9dxurRN5A/+A3Cfc2FCIrae7GFIllU5ShBtU6HZgZZFkpaS/dfoD6Trc+osBrpYPeWio73Eqfk+9gR01JtZAxPDSRcyyDZ87NPv4CUoeTU6nkwLe6Fb3OtEQN7i3jm9VUTBBtKS42PQH0lYuQMl39sw64jQ5YZH83bbBDFyoo0YHcTzAm90XIzulMDK3+PD6Hu0KscG8fEXIwCe6fNpYLRrvhUUMNhPWtiXXDW2QjzEBq1OzzN84EC2K/4rCmTmIkltg285oWPa/NYxiG9HbnjjWEtFyzHBw== 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=ktfwC4+ZDNxo7RRPk+9DbYsRTw+y5VQuQdrrYF5I9pI=; b=dzDlH6BzI+yW0U1CMaQ7h0OLe2flJvPIyb73BGAIu++YmN08AuAc9fXYHGVu5Q7w81cGHxpxR86OlBpQh7+O/q51a8qzdxQ+nZ6SL9OLyuiW77teo3pl2UcgMtIDHHAYuUr4xjv9N98R3gMSDKj7dgGRpwhMDeNUYF7JDJGbPrw= 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 DB7PR04MB4235.eurprd04.prod.outlook.com (2603:10a6:5:22::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.26; Mon, 12 Oct 2020 05:57:30 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3455.029; Mon, 12 Oct 2020 05:57:30 +0000 From: Peng Fan To: sbabic@denx.de, festevam@gmail.com, marex@denx.de, lukma@denx.de Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Peng Fan Subject: [PATCH 6/8] imx8mm_evk: add usbotg1 host support Date: Mon, 12 Oct 2020 14:23:52 +0800 Message-Id: <20201012062354.3743-7-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012062354.3743-1-peng.fan@nxp.com> References: <20201012062354.3743-1-peng.fan@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR01CA0105.apcprd01.prod.exchangelabs.com (2603:1096:3:15::31) 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 SG2PR01CA0105.apcprd01.prod.exchangelabs.com (2603:1096:3:15::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.22 via Frontend Transport; Mon, 12 Oct 2020 05:57:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: acf56621-7f55-44b4-0501-08d86e73b471 X-MS-TrafficTypeDiagnostic: DB7PR04MB4235: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:70; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mo4l5rv40+LHQpz3XkTL78HR9IObbNeAfdcUumMMvdCI8aHI9LrMx1atOT2asJQ3/I40UrPvvsXVEyZSI9dTvsjpiKpX4+dWR8yToYrtJC9Mvj1FiKoGWUUQPewSztGnyoZwQU8SLfxZ37GoXJkG5QnLXYiC8e2s9zmFL3XvyhrdOqKvTbjcfuDCguMYmYYKY6SGNGNzE3Zt6/De6+LIYL+JtgTeGOl9Mop319++AlU/1170AmoxZGcnXKjOWJeFAPvLGtKB4pRSvxqRiiwaBnERact2NYyENFVV0VPwDVglEGOb/pRwlNuhMaBJrq6z 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)(396003)(39860400002)(376002)(346002)(366004)(136003)(52116002)(83380400001)(8936002)(6506007)(4326008)(8676002)(44832011)(6512007)(1076003)(6486002)(86362001)(5660300002)(6666004)(66476007)(66946007)(66556008)(316002)(36756003)(2616005)(956004)(2906002)(186003)(26005)(478600001)(16526019); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 7iS8eYYr2z59QwGNR/tmnD/zT67zkx0csJYEj3d6fx6aHY3YyIUxnngXc7LR7ZSfU6RGFxFrnsDz7I4PnJuxvhlqhP4yHyFetBZfVyB7cakrlEkTXVs0LM4kA4ITMjjMRMfpmemJ4pkTDUYfUq01V43X2JL40D2btAydKG1zEAl3mYchcr9UTbqCp2AfjWzBji7sNaN1Kw4bLLBbxheJy7uYr0kDK+svLhZbnWt0AxkwVoL39AaKnA5jNn4ugx7iPgqn69itCKSzkuYVJ+3UzTLzX18t6AHZw6n2TvOyyaO3PGHZAkRxZegZfasaWEb7inGIui7A2S3UKwTzGGxnvQ79X4XZwUWS4Z9dtgm7ZIgZprzTCTc6cMI0UT6NlaXc1oPfjUqNWhBpm+2YGkK/pYZec2RAljTrWJpJZOERTmUlPf4OumUvtsVwhEwv9Pcqn0vg5jq8ghwX3LfwNMNj6CdQqplK3BaY6vXfQmUov3k/hHt9egL6HXEqu9pAr2fR8HlVkygKyyVId1KmPlY986vchwKli7HVfouxVIAt8bTpPsYGBsODik7VuP5XqJJOzY8O1m32HcS3bqNlo1kMhCSg96vo9Ph+w2OCWmGmpIm/jgAtzSUz98n1JoHWjneqOkVvKyaTDAH0MpzuQHm4GA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: acf56621-7f55-44b4-0501-08d86e73b471 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2020 05:57:30.3174 (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: BuUM0CKKNOmeHIwwBYc/M8o02KrhYYkGCs4OEkyY93Ln3YADy4Dtan3mFoBuax+z7DxlM9idmg2RmbVZ/IZqBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4235 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 Add tcpc port and pd switch code board code Add U-Boot specific dtsi property, we use nop-phy driver for the phy Add relevant config options Test: u-boot=> usb start starting USB... Bus usb@32e40000: USB EHCI 1.00 scanning bus usb@32e40000 for devices... 2 USB Device(s) found scanning usb for storage devices... 1 Storage Device(s) found u-boot=> usb tree USB device tree: 1 Hub (480 Mb/s, 0mA) | u-boot EHCI Host Controller | +-2 Mass Storage (480 Mb/s, 300mA) Kingston DataTraveler 2.0 50E54951344CB04199CA8CE6 Signed-off-by: Peng Fan --- arch/arm/dts/imx8mm-evk-u-boot.dtsi | 26 ++++ board/freescale/imx8mm_evk/Kconfig | 1 + board/freescale/imx8mm_evk/imx8mm_evk.c | 181 ++++++++++++++++++++++++ configs/imx8mm_evk_defconfig | 12 ++ include/configs/imx8mm_evk.h | 3 + 5 files changed, 223 insertions(+) -- 2.28.0 diff --git a/arch/arm/dts/imx8mm-evk-u-boot.dtsi b/arch/arm/dts/imx8mm-evk-u-boot.dtsi index b5c12105a9..241dfd656f 100644 --- a/arch/arm/dts/imx8mm-evk-u-boot.dtsi +++ b/arch/arm/dts/imx8mm-evk-u-boot.dtsi @@ -4,6 +4,12 @@ */ / { + + aliases { + usb0 = &usbotg1; + usb1 = &usbotg2; + }; + wdt-reboot { compatible = "wdt-reboot"; wdt = <&wdog1>; @@ -129,3 +135,23 @@ &wdog1 { u-boot,dm-spl; }; + +&usbotg1 { + extcon = "tcpc"; + phys = <&usbphynop1>; +}; + +&usbphynop1 { + compatible = "nop-phy"; + #phy-cells = <0>; +}; + +&usbotg2 { + extcon = "tcpc"; + phys = <&usbphynop2>; +}; + +&usbphynop2 { + compatible = "nop-phy"; + #phy-cells = <0>; +}; diff --git a/board/freescale/imx8mm_evk/Kconfig b/board/freescale/imx8mm_evk/Kconfig index 299691a619..cbd9d4e8f2 100644 --- a/board/freescale/imx8mm_evk/Kconfig +++ b/board/freescale/imx8mm_evk/Kconfig @@ -9,4 +9,5 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "imx8mm_evk" +source "board/freescale/common/Kconfig" endif diff --git a/board/freescale/imx8mm_evk/imx8mm_evk.c b/board/freescale/imx8mm_evk/imx8mm_evk.c index 6af7100696..187ea19b91 100644 --- a/board/freescale/imx8mm_evk/imx8mm_evk.c +++ b/board/freescale/imx8mm_evk/imx8mm_evk.c @@ -6,11 +6,14 @@ #include #include #include +#include #include #include +#include #include #include +#include "../common/tcpc.h" #include DECLARE_GLOBAL_DATA_PTR; @@ -44,8 +47,186 @@ int board_phy_config(struct phy_device *phydev) } #endif +#if IS_ENABLED(CONFIG_USB_TCPC) +struct tcpc_port port1; +struct tcpc_port port2; + +static int setup_pd_switch(uint8_t i2c_bus, uint8_t addr) +{ + struct udevice *bus; + struct udevice *i2c_dev = NULL; + int ret; + uint8_t valb; + + ret = uclass_get_device_by_seq(UCLASS_I2C, i2c_bus, &bus); + if (ret) { + printf("%s: Can't find bus\n", __func__); + return -EINVAL; + } + + ret = dm_i2c_probe(bus, addr, 0, &i2c_dev); + if (ret) { + printf("%s: Can't find device id=0x%x\n", + __func__, addr); + return -ENODEV; + } + + ret = dm_i2c_read(i2c_dev, 0xB, &valb, 1); + if (ret) { + printf("%s dm_i2c_read failed, err %d\n", __func__, ret); + return -EIO; + } + valb |= 0x4; /* Set DB_EXIT to exit dead battery mode */ + ret = dm_i2c_write(i2c_dev, 0xB, (const uint8_t *)&valb, 1); + if (ret) { + printf("%s dm_i2c_write failed, err %d\n", __func__, ret); + return -EIO; + } + + /* Set OVP threshold to 23V */ + valb = 0x6; + ret = dm_i2c_write(i2c_dev, 0x8, (const uint8_t *)&valb, 1); + if (ret) { + printf("%s dm_i2c_write failed, err %d\n", __func__, ret); + return -EIO; + } + + return 0; +} + +int pd_switch_snk_enable(struct tcpc_port *port) +{ + if (port == &port1) { + debug("Setup pd switch on port 1\n"); + return setup_pd_switch(1, 0x72); + } else if (port == &port2) { + debug("Setup pd switch on port 2\n"); + return setup_pd_switch(1, 0x73); + } else + return -EINVAL; +} + +struct tcpc_port_config port1_config = { + .i2c_bus = 1, /*i2c2*/ + .addr = 0x50, + .port_type = TYPEC_PORT_UFP, + .max_snk_mv = 5000, + .max_snk_ma = 3000, + .max_snk_mw = 40000, + .op_snk_mv = 9000, + .switch_setup_func = &pd_switch_snk_enable, +}; + +struct tcpc_port_config port2_config = { + .i2c_bus = 1, /*i2c2*/ + .addr = 0x52, + .port_type = TYPEC_PORT_UFP, + .max_snk_mv = 9000, + .max_snk_ma = 3000, + .max_snk_mw = 40000, + .op_snk_mv = 9000, + .switch_setup_func = &pd_switch_snk_enable, +}; + +static int setup_typec(void) +{ + int ret; + + debug("tcpc_init port 2\n"); + ret = tcpc_init(&port2, port2_config, NULL); + if (ret) { + printf("%s: tcpc port2 init failed, err=%d\n", + __func__, ret); + } else if (tcpc_pd_sink_check_charging(&port2)) { + /* Disable PD for USB1, since USB2 has priority */ + port1_config.disable_pd = true; + printf("Power supply on USB2\n"); + } + + debug("tcpc_init port 1\n"); + ret = tcpc_init(&port1, port1_config, NULL); + if (ret) { + printf("%s: tcpc port1 init failed, err=%d\n", + __func__, ret); + } else { + if (!port1_config.disable_pd) + printf("Power supply on USB1\n"); + return ret; + } + + return ret; +} + +int board_usb_init(int index, enum usb_init_type init) +{ + int ret = 0; + struct tcpc_port *port_ptr; + + debug("board_usb_init %d, type %d\n", index, init); + + if (index == 0) + port_ptr = &port1; + else + port_ptr = &port2; + + imx8m_usb_power(index, true); + + if (init == USB_INIT_HOST) + tcpc_setup_dfp_mode(port_ptr); + else + tcpc_setup_ufp_mode(port_ptr); + + return ret; +} + +int board_usb_cleanup(int index, enum usb_init_type init) +{ + int ret = 0; + + debug("board_usb_cleanup %d, type %d\n", index, init); + + if (init == USB_INIT_HOST) { + if (index == 0) + ret = tcpc_disable_src_vbus(&port1); + else + ret = tcpc_disable_src_vbus(&port2); + } + + imx8m_usb_power(index, false); + return ret; +} + +int board_ehci_usb_phy_mode(struct udevice *dev) +{ + int ret = 0; + enum typec_cc_polarity pol; + enum typec_cc_state state; + struct tcpc_port *port_ptr; + + if (dev->req_seq == 0) + port_ptr = &port1; + else + port_ptr = &port2; + + tcpc_setup_ufp_mode(port_ptr); + + ret = tcpc_get_cc_status(port_ptr, &pol, &state); + if (!ret) { + if (state == TYPEC_STATE_SRC_RD_RA || state == TYPEC_STATE_SRC_RD) + return USB_INIT_HOST; + } + + return USB_INIT_DEVICE; +} + +#endif + + int board_init(void) { + if (IS_ENABLED(CONFIG_USB_TCPC)) + setup_typec(); + if (IS_ENABLED(CONFIG_FEC_MXC)) setup_fec(); diff --git a/configs/imx8mm_evk_defconfig b/configs/imx8mm_evk_defconfig index 91d3bc3ac9..10e95d8d5c 100644 --- a/configs/imx8mm_evk_defconfig +++ b/configs/imx8mm_evk_defconfig @@ -12,12 +12,14 @@ CONFIG_SYS_I2C_MXC_I2C2=y CONFIG_SYS_I2C_MXC_I2C3=y CONFIG_DM_GPIO=y CONFIG_SPL_TEXT_BASE=0x7E1000 +CONFIG_USB_TCPC=y CONFIG_TARGET_IMX8MM_EVK=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="imx8mm-evk" +CONFIG_ANDROID_BOOT_IMAGE=y CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y @@ -40,6 +42,7 @@ CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y @@ -73,6 +76,8 @@ CONFIG_DM_ETH=y CONFIG_PHY_GIGE=y CONFIG_FEC_MXC=y CONFIG_MII=y +CONFIG_PHY=y +CONFIG_NOP_PHY=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y CONFIG_PINCTRL_IMX8M=y @@ -87,4 +92,11 @@ CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_PSCI=y CONFIG_SYSRESET_WATCHDOG=y CONFIG_DM_THERMAL=y +CONFIG_USB=y +CONFIG_DM_USB=y +# CONFIG_SPL_DM_USB is not set +CONFIG_USB_EHCI_HCD=y +# CONFIG_USB_EHCI_MX7 is not set +CONFIG_USB_EHCI_IMX=y +CONFIG_USB_STORAGE=y CONFIG_IMX_WATCHDOG=y diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h index 83521ad401..5e865f0bef 100644 --- a/include/configs/imx8mm_evk.h +++ b/include/configs/imx8mm_evk.h @@ -145,4 +145,7 @@ #define IMX_FEC_BASE 0x30BE0000 +#define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW) +#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 + #endif