From patchwork Fri Oct 4 14:27:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1171871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="T5cjhZN8"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46lC1T0YK6z9sPv for ; Sat, 5 Oct 2019 00:29:16 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3B176C21E6A; Fri, 4 Oct 2019 14:28:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5EA00C21F53; Fri, 4 Oct 2019 14:28:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 489D1C21F68; Fri, 4 Oct 2019 14:27:59 +0000 (UTC) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by lists.denx.de (Postfix) with ESMTPS id 0931DC21F17 for ; Fri, 4 Oct 2019 14:27:57 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id 3so6094067wmi.3 for ; Fri, 04 Oct 2019 07:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=lJCBTnOpI++jDJHbLP3jAjOtRFynxBqUZ6tOna1WJyY=; b=T5cjhZN8ofqyMnQ1mNaYWxP8fHE+4ieaM3v8SKS/HvfuS1dVM9FwF6X4oyaODLlyr9 FSD7OjdltbWj/nGB9Q1GEsL5Uu6pLYn+tLBvlO2bagzl+Ovwjvb+tP/C+LQbxiw8xkVa PN+/6RfoGqHFCQrRXJIoxh7Ql8AaM4UvuGehQrgjo3zJACdHTfMWBlr16Ofp2ggSZdP8 /nLBavdbTv/n1neIOOOLdRzmYOMeEpqZtO0Tl0rcVxYObzlW/9NMYgoTkYkHj/iKhLn5 lG2aj018d4GRRZrDtLEDzm1bdzH8owbE/CRcZfMqvyOFon5N3yJl+WA2QVce9jctVocp lifQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=lJCBTnOpI++jDJHbLP3jAjOtRFynxBqUZ6tOna1WJyY=; b=Ox66yUtbml9WAL6cnWxc+tlB6kL+ecQJvSXX0WoKg1/+7qDhZiS9fqk6kWY74LtDG7 0gXq7++TQaoGXEFY4L+eoaq821D/eUNab+DJPsyr5HQamnieKytJOeptSo0ohYT5jx9G /0J65SoRBAEUfQCZTmi8WxPUbOB9WNmfP82NxtScGaR4Lvu0MAOiCwWrgcn6uL1jEu44 5gVHzeKOsd8roBOp8DD2xqCJ/5miXGUde4cYkW2nzqSLH+YkbkyNOUUAft89cu06UbbH 1WvlAwpYCg4H5Tb0YBVecLAZfWufuaJHzealNvKAsVu9clAz1+UbMymmjUUS39g64+TS /k/w== X-Gm-Message-State: APjAAAUDTlitKRLGfk8cz/kP9fqFSN4FG7/HdS7J9nVv6t+W+vHCE3i+ tgRhPSWSYWA/OS/9gXvgnI8X/wrWKDL21Q== X-Google-Smtp-Source: APXvYqwI98DwTlWC+yRZavNrw9uibo7ERg7XI73jusQHCGBvHYE8xStYpcpIfgIxsPRPce7asm7YAQ== X-Received: by 2002:a7b:cd08:: with SMTP id f8mr10229852wmj.87.1570199276285; Fri, 04 Oct 2019 07:27:56 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id h10sm6878831wrq.95.2019.10.04.07.27.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Oct 2019 07:27:55 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Date: Fri, 4 Oct 2019 16:27:48 +0200 Message-Id: <7a294f10532b5b1a78e4700a4acc2f346e7a8c63.1570199266.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Cc: Ibai Erkiaga , Luca Ceresoli , Rajan Vaja Subject: [U-Boot] [PATCH 2/4] arm64: xilinx: Move firmware functions from platform to driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" versal_pm_request() and invoke_smc() are almost the same. Only one difference is that versal_pm_request is adding PM_SIP_SVC offset to api_id. The patch is moving platform implementation to firmware driver code for synchronization. Signed-off-by: Michal Simek Reviewed-by: Luca Ceresoli --- arch/arm/mach-versal/cpu.c | 26 ------------- arch/arm/mach-versal/include/mach/sys_proto.h | 3 -- arch/arm/mach-zynqmp/cpu.c | 26 ------------- arch/arm/mach-zynqmp/include/mach/sys_proto.h | 2 - drivers/firmware/firmware-zynqmp.c | 38 ++++++++++++++++++- drivers/fpga/versalpl.c | 1 + include/zynqmp_firmware.h | 4 ++ 7 files changed, 42 insertions(+), 58 deletions(-) diff --git a/arch/arm/mach-versal/cpu.c b/arch/arm/mach-versal/cpu.c index 0d10e7f194db..46ab5348d732 100644 --- a/arch/arm/mach-versal/cpu.c +++ b/arch/arm/mach-versal/cpu.c @@ -10,7 +10,6 @@ #include #include #include -#include DECLARE_GLOBAL_DATA_PTR; @@ -109,28 +108,3 @@ int reserve_mmu(void) return 0; } #endif - -int versal_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, - u32 arg3, u32 *ret_payload) -{ - struct pt_regs regs; - - if (current_el() == 3) - return 0; - - regs.regs[0] = PM_SIP_SVC | api_id; - regs.regs[1] = ((u64)arg1 << 32) | arg0; - regs.regs[2] = ((u64)arg3 << 32) | arg2; - - smc_call(®s); - - if (ret_payload) { - ret_payload[0] = (u32)regs.regs[0]; - ret_payload[1] = upper_32_bits(regs.regs[0]); - ret_payload[2] = (u32)regs.regs[1]; - ret_payload[3] = upper_32_bits(regs.regs[1]); - ret_payload[4] = (u32)regs.regs[2]; - } - - return regs.regs[0]; -} diff --git a/arch/arm/mach-versal/include/mach/sys_proto.h b/arch/arm/mach-versal/include/mach/sys_proto.h index c282078f8626..31af049a21c9 100644 --- a/arch/arm/mach-versal/include/mach/sys_proto.h +++ b/arch/arm/mach-versal/include/mach/sys_proto.h @@ -12,6 +12,3 @@ enum { void tcm_init(u8 mode); void mem_map_fill(void); - -int versal_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, - u32 arg3, u32 *ret_payload); diff --git a/arch/arm/mach-zynqmp/cpu.c b/arch/arm/mach-zynqmp/cpu.c index bb21cbcadf69..ef73a75cf9a3 100644 --- a/arch/arm/mach-zynqmp/cpu.c +++ b/arch/arm/mach-zynqmp/cpu.c @@ -154,32 +154,6 @@ unsigned int zynqmp_get_silicon_version(void) #define ZYNQMP_MMIO_READ 0xC2000014 #define ZYNQMP_MMIO_WRITE 0xC2000013 -int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, - u32 arg3, u32 *ret_payload) -{ - /* - * Added SIP service call Function Identifier - * Make sure to stay in x0 register - */ - struct pt_regs regs; - - regs.regs[0] = pm_api_id; - regs.regs[1] = ((u64)arg1 << 32) | arg0; - regs.regs[2] = ((u64)arg3 << 32) | arg2; - - smc_call(®s); - - if (ret_payload != NULL) { - ret_payload[0] = (u32)regs.regs[0]; - ret_payload[1] = upper_32_bits(regs.regs[0]); - ret_payload[2] = (u32)regs.regs[1]; - ret_payload[3] = upper_32_bits(regs.regs[1]); - ret_payload[4] = (u32)regs.regs[2]; - } - - return regs.regs[0]; -} - static int zynqmp_mmio_rawwrite(const u32 address, const u32 mask, const u32 value) diff --git a/arch/arm/mach-zynqmp/include/mach/sys_proto.h b/arch/arm/mach-zynqmp/include/mach/sys_proto.h index 69e729fb7625..10b70761de4a 100644 --- a/arch/arm/mach-zynqmp/include/mach/sys_proto.h +++ b/arch/arm/mach-zynqmp/include/mach/sys_proto.h @@ -50,8 +50,6 @@ void handoff_setup(void); int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value); int zynqmp_mmio_read(const u32 address, u32 *value); -int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, - u32 *ret_payload); void initialize_tcm(bool mode); void mem_map_fill(void); diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index 42a627e1dd05..11f5030e85c7 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -7,10 +7,10 @@ #include #include +#include #if defined(CONFIG_ZYNQMP_IPI) #include -#include #include #define PMUFW_PAYLOAD_ARG_CNT 8 @@ -147,6 +147,42 @@ U_BOOT_DRIVER(zynqmp_power) = { }; #endif +int __maybe_unused invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, + u32 arg3, u32 *ret_payload) +{ + /* + * Added SIP service call Function Identifier + * Make sure to stay in x0 register + */ + struct pt_regs regs; + + if (current_el() == 3) + return 0; + + regs.regs[0] = pm_api_id; + regs.regs[1] = ((u64)arg1 << 32) | arg0; + regs.regs[2] = ((u64)arg3 << 32) | arg2; + + smc_call(®s); + + if (ret_payload) { + ret_payload[0] = (u32)regs.regs[0]; + ret_payload[1] = upper_32_bits(regs.regs[0]); + ret_payload[2] = (u32)regs.regs[1]; + ret_payload[3] = upper_32_bits(regs.regs[1]); + ret_payload[4] = (u32)regs.regs[2]; + } + + return regs.regs[0]; +} + +int __maybe_unused versal_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, + u32 arg3, u32 *ret_payload) +{ + return invoke_smc(PM_SIP_SVC | api_id, arg0, arg1, arg2, arg3, + ret_payload); +} + static const struct udevice_id zynqmp_firmware_ids[] = { { .compatible = "xlnx,zynqmp-firmware" }, { .compatible = "xlnx,versal-firmware-wip"}, diff --git a/drivers/fpga/versalpl.c b/drivers/fpga/versalpl.c index 69617a9b1d7f..8337b8306d76 100644 --- a/drivers/fpga/versalpl.c +++ b/drivers/fpga/versalpl.c @@ -8,6 +8,7 @@ #include #include #include +#include static ulong versal_align_dma_buffer(ulong *buf, u32 len) { diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 742934814cb0..088ba30e0bb8 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -81,5 +81,9 @@ enum pm_api_id { unsigned int zynqmp_firmware_version(void); void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size); +int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, + u32 *ret_payload); +int versal_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, + u32 arg3, u32 *ret_payload); #endif /* _ZYNQMP_FIRMWARE_H_ */