From patchwork Thu Jul 2 08:02:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faiz Abbas X-Patchwork-Id: 1321148 X-Patchwork-Delegate: lokeshvutla@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=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256 header.s=ti-com-17Q1 header.b=FXu9lbUb; 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 49yBV60Lnkz9sR4 for ; Thu, 2 Jul 2020 18:44:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 554078229B; Thu, 2 Jul 2020 10:26:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.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=ti.com header.i=@ti.com header.b="FXu9lbUb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 96ABA81B48; Thu, 2 Jul 2020 10:02:59 +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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 7B7AF8006D for ; Thu, 2 Jul 2020 10:02:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=faiz_abbas@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 06282r1S036873 for ; Thu, 2 Jul 2020 03:02:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593676974; bh=iXkAx48zBW2aAREhsHh4Xqh+ea03CVknZXP9Jri3SNU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=FXu9lbUb0Zw/UG7sRmSo3sPeKds0w68CdZpwz5qXBDaL7+5Z7YzbSOeJ1XVMwrQiI 4cc+uhWCLvvx+hKLhDc5sTG5RK7kix4v6BFy4eSObfYVLx3TjZgphDIZq0RhxfkJ5A oWQ6t6BkrEYsEpt3O0Itl3RrbI2EAlnPKni3Zpp0= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 06282rP6031978 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 2 Jul 2020 03:02:53 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 2 Jul 2020 03:02:52 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 2 Jul 2020 03:02:52 -0500 Received: from a0230074-Latitude-E7470.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 06282YsX118905; Thu, 2 Jul 2020 03:02:51 -0500 From: Faiz Abbas To: , CC: , , Subject: [PATCH 06/13] arm: mach-k3: am6_init: Do USB fixups to facilitate host and device boot modes Date: Thu, 2 Jul 2020 13:32:26 +0530 Message-ID: <20200702080233.27582-7-faiz_abbas@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702080233.27582-1-faiz_abbas@ti.com> References: <20200702080233.27582-1-faiz_abbas@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 U-boot only supports either USB host or device mode for a node at a time in dts To support both host and dfu bootmodes, set "peripheral" as the default dr_mode but fixup property to "host" if host bootmode is detected This needs to happen before the dwc3 generic layer binds the usb device to a host or device driver. Therefore, open code the configurations in spl_early_init() and add the fixup after the fdtdec_setup() and before the dm_init_scan() Also use the same fixup function to set the USB-PCIe Serdes mux to PCIe in both the host and device cases. This is required for accessing the interface at USB 2.0 speeds Signed-off-by: Faiz Abbas --- arch/arm/mach-k3/am6_init.c | 68 +++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 42d13a39f8..b65860fef3 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -17,11 +18,15 @@ #include #include #include +#include +#include #include #include #include #include +DECLARE_GLOBAL_DATA_PTR; + #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW #ifdef CONFIG_TI_SECURE_DEVICE @@ -119,7 +124,67 @@ void k3_mmc_restart_clock(void) void k3_mmc_stop_clock(void) {} void k3_mmc_restart_clock(void) {} #endif +#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE) +#define CTRLMMR_SERDES0_CTRL 0x00104080 +#define PCIE_LANE0 0x1 +void fixup_usb_boot(void) +{ + int ret; + switch (spl_boot_device()) { + case BOOT_DEVICE_USB: + /* + * If bootmode is Host bootmode, fixup the dr_mode to host + * before the dwc3 bind takes place + */ + ret = fdt_find_and_setprop((void *)gd->fdt_blob, + "/interconnect@100000/dwc3@4000000/usb@10000", + "dr_mode", "host", 11, 0); + if (ret) + printf("%s: fdt_find_and_setprop() failed:%d\n", __func__, + ret); + /* fallthrough */ + case BOOT_DEVICE_DFU: + /* + * The serdes mux between PCIe and USB3 needs to be set to PCIe for + * accessing the interface at USB 2.0 + */ + writel(PCIE_LANE0, CTRLMMR_SERDES0_CTRL); + default: + ; + } +} +#endif +int am6_spl_early_init(void) +{ + int ret; +#if CONFIG_VAL(SYS_MALLOC_F_LEN) +#ifdef CONFIG_MALLOC_F_ADDR + gd->malloc_base = CONFIG_MALLOC_F_ADDR; +#endif + gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN); + gd->malloc_ptr = 0; +#endif + ret = fdtdec_setup(); + if (ret) { + printf("fdtdec_setup() returned error %d\n", ret); + return ret; + } + +#if CONFIG_IS_ENABLED(DFU) || CONFIG_IS_ENABLED(USB_STORAGE) + fixup_usb_boot(); +#endif + /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */ + ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA)); + if (ret) { + printf("dm_init_and_scan() returned error %d\n", ret); + return ret; + } + + gd->flags |= GD_FLG_SPL_EARLY_INIT; + + return 0; +} void board_init_f(ulong dummy) { #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS) @@ -141,9 +206,8 @@ void board_init_f(ulong dummy) disable_linefill_optimization(); setup_k3_mpu_regions(); #endif - /* Init DM early in-order to invoke system controller */ - spl_early_init(); + am6_spl_early_init(); #ifdef CONFIG_K3_EARLY_CONS /*