From patchwork Wed Aug 5 17:14:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 1341307 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=PMzStHox; 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 4BMJDb2KGYz9sPB for ; Thu, 6 Aug 2020 03:15:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D64C3821DD; Wed, 5 Aug 2020 19:14:53 +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="PMzStHox"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 04C67821D0; Wed, 5 Aug 2020 19:14:52 +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 fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 01664821B7 for ; Wed, 5 Aug 2020 19:14:48 +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=lokeshvutla@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 075HElUh020854 for ; Wed, 5 Aug 2020 12:14:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1596647687; bh=VNlTswvfMMCqSFGmKk2GQPeWcoqcyrpaF5qJWv4zHcM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PMzStHox/Lg5t0l/BWRl6UlSKnZGfP5fJdJKYSrt8SOmFQ875zeh5urtCpcs5hev6 t+Ovl+ZYHuxkkNx1hk+fZWybu8lubDVWrz6ozvsG0e6sNn26VBu35Ur/dbCH8inDYZ Z8iQCoHSoVqJqc4MD2vnAIGD16Je+Bclgalb2QhM= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 075HEluT101508 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 5 Aug 2020 12:14:47 -0500 Received: from DLEE106.ent.ti.com (157.170.170.36) 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; Wed, 5 Aug 2020 12:14:47 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE106.ent.ti.com (157.170.170.36) 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; Wed, 5 Aug 2020 12:14:47 -0500 Received: from uda0131933.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 075HEWML101104; Wed, 5 Aug 2020 12:14:45 -0500 From: Lokesh Vutla To: CC: Sekhar Nori , Lokesh Vutla , Suman Anna , Vignesh R Subject: [PATCH v2 06/19] arm: mach-k3: sysfw-loader: Add support for rom loading sysfw image Date: Wed, 5 Aug 2020 22:44:18 +0530 Message-ID: <20200805171431.5737-7-lokeshvutla@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200805171431.5737-1-lokeshvutla@ti.com> References: <20200805171431.5737-1-lokeshvutla@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 Starting J7200 SoC, ROM supports for loading sysfw directly from boot image. In such cases, SPL need not load sysfw from boot media, but need to receive boot notification message from sysfw. So separate out remoteproc calls for system controller from sysfw loader and just receive the boot notification if sysfw is already loaded. Signed-off-by: Lokesh Vutla Reviewed-by: Suman Anna --- arch/arm/mach-k3/am6_init.c | 2 +- arch/arm/mach-k3/include/mach/sysfw-loader.h | 4 +- arch/arm/mach-k3/j721e_init.c | 2 +- arch/arm/mach-k3/sysfw-loader.c | 56 +++++++++++++------- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index e66d1c1fe1..603834e507 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -216,7 +216,7 @@ void board_init_f(ulong dummy) * Load, start up, and configure system controller firmware while * also populating the SYSFW post-PM configuration callback hook. */ - k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock); + k3_sysfw_loader(false, k3_mmc_stop_clock, k3_mmc_restart_clock); /* Prepare console output */ preloader_console_init(); diff --git a/arch/arm/mach-k3/include/mach/sysfw-loader.h b/arch/arm/mach-k3/include/mach/sysfw-loader.h index 6f5612b4fd..b23a9e821e 100644 --- a/arch/arm/mach-k3/include/mach/sysfw-loader.h +++ b/arch/arm/mach-k3/include/mach/sysfw-loader.h @@ -7,6 +7,8 @@ #ifndef _SYSFW_LOADER_H_ #define _SYSFW_LOADER_H_ -void k3_sysfw_loader(void (*config_pm_pre_callback)(void), void (*config_pm_done_callback)(void)); +void k3_sysfw_loader(bool rom_loaded_sysfw, + void (*config_pm_pre_callback)(void), + void (*config_pm_done_callback)(void)); #endif diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c index 2010cab1d1..461a9d7f8f 100644 --- a/arch/arm/mach-k3/j721e_init.c +++ b/arch/arm/mach-k3/j721e_init.c @@ -174,7 +174,7 @@ void board_init_f(ulong dummy) * callback hook, effectively switching on (or over) the console * output. */ - k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock); + k3_sysfw_loader(false, k3_mmc_stop_clock, k3_mmc_restart_clock); /* Prepare console output */ preloader_console_init(); diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c index f4b0d4a928..78c158c63f 100644 --- a/arch/arm/mach-k3/sysfw-loader.c +++ b/arch/arm/mach-k3/sysfw-loader.c @@ -33,6 +33,12 @@ DECLARE_GLOBAL_DATA_PTR; #define SYSFW_CFG_RM "rm-cfg.bin" #define SYSFW_CFG_SEC "sec-cfg.bin" +/* + * It is assumed that remoteproc device 0 is the corresponding + * system-controller that runs SYSFW. Make sure DT reflects the same. + */ +#define K3_SYSTEM_CONTROLLER_RPROC_ID 0 + static bool sysfw_loaded; static void *sysfw_load_address; @@ -72,6 +78,26 @@ static int fit_get_data_by_name(const void *fit, int images, const char *name, return fit_image_get_data(fit, node_offset, addr, size); } +static void k3_start_system_controller(int rproc_id, bool rproc_loaded, + ulong addr, ulong size) +{ + int ret; + + ret = rproc_dev_init(rproc_id); + if (ret) + panic("rproc failed to be initialized (%d)\n", ret); + + if (!rproc_loaded) { + ret = rproc_load(rproc_id, addr, size); + if (ret) + panic("Firmware failed to start on rproc (%d)\n", ret); + } + + ret = rproc_start(0); + if (ret) + panic("Firmware init failed on rproc (%d)\n", ret); +} + static void k3_sysfw_load_using_fit(void *fit) { int images; @@ -91,23 +117,9 @@ static void k3_sysfw_load_using_fit(void *fit) panic("Error accessing %s node in FIT (%d)\n", SYSFW_FIRMWARE, ret); - /* - * Start up system controller firmware - * - * It is assumed that remoteproc device 0 is the corresponding - * system-controller that runs SYSFW. Make sure DT reflects the same. - */ - ret = rproc_dev_init(0); - if (ret) - panic("rproc failed to be initialized (%d)\n", ret); - - ret = rproc_load(0, (ulong)sysfw_addr, (ulong)sysfw_size); - if (ret) - panic("Firmware failed to start on rproc (%d)\n", ret); - - ret = rproc_start(0); - if (ret) - panic("Firmware init failed on rproc (%d)\n", ret); + /* Start up system controller firmware */ + k3_start_system_controller(K3_SYSTEM_CONTROLLER_RPROC_ID, false, + (ulong)sysfw_addr, (ulong)sysfw_size); } static void k3_sysfw_configure_using_fit(void *fit, @@ -223,7 +235,8 @@ static void *k3_sysfw_get_spi_addr(void) } #endif -void k3_sysfw_loader(void (*config_pm_pre_callback) (void), +void k3_sysfw_loader(bool rom_loaded_sysfw, + void (*config_pm_pre_callback)(void), void (*config_pm_done_callback)(void)) { struct spl_image_info spl_image = { 0 }; @@ -231,6 +244,13 @@ void k3_sysfw_loader(void (*config_pm_pre_callback) (void), struct ti_sci_handle *ti_sci; int ret = 0; + if (rom_loaded_sysfw) { + k3_start_system_controller(K3_SYSTEM_CONTROLLER_RPROC_ID, + rom_loaded_sysfw, 0, 0); + sysfw_loaded = true; + return; + } + /* Reserve a block of aligned memory for loading the SYSFW image */ sysfw_load_address = memalign(ARCH_DMA_MINALIGN, CONFIG_K3_SYSFW_IMAGE_SIZE_MAX);