From patchwork Wed Dec 2 09:47:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 7743991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 24BEBBEEE1 for ; Wed, 2 Dec 2015 09:50:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18D6720638 for ; Wed, 2 Dec 2015 09:50:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B452204F6 for ; Wed, 2 Dec 2015 09:50:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a441R-0003RD-CB; Wed, 02 Dec 2015 09:48:25 +0000 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a4419-0003L2-1u for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2015 09:48:09 +0000 Received: by wmvv187 with SMTP id v187so246050141wmv.1 for ; Wed, 02 Dec 2015 01:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YbgqQ21CrWTaHtsmy3L4koJROgk9KxOfYrd+PPkJNV4=; b=eZyX5ofp012kyU0sX8qwq0spwCm73N80NiwFyx7VwLby3U5CntGNpRuL2D8HiZlQJF QVMvkiJour1QAoqx7NN7LwazohSWp7y/rbNRGmyRgS2OWw+b18SkUHu9/lQ3RNorxrDO cyUqqRLKYc2JdNNUaaTZYhF8WwmQ5SBYXGGyl/aCqYHOAPbAZCORw9daj/UO9SdBdQ5G p4O2qL1w/Q2QcdCJtfKgYHtX8rN0e0f4eXZ3Jtu+NJWDkNQpuIlbRmphS4UmBbkxjKIt v9lFpq6RXSSkxUJw5slWhlqGdQz6Dq0v0XoQCE3NOmMSvKYal6ySOCTLE4n8cfFfLydf QrDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YbgqQ21CrWTaHtsmy3L4koJROgk9KxOfYrd+PPkJNV4=; b=mDqPVMnRzj9QRaGmeXdCJTBCBg64aHB6ovrVWfrw7Syubpr+BVb/+6ILCe6FD4Zsj5 CyGj2VtPGnOmtkyBt6KPkxu+vCILak5uHhtgV0qNbcgfJeytRmPxMu1Oj07yZfJTOxF3 ha1JxkqNOoTy+duusz3U0QyBrCuIcYtlvti4IVJLYaEKkKijziOhDDcM5aHPtPoh+15d P3QY7f+CVggesIv4cjKS4RFrWmbTf5pGHJ16GzzEnQY4usTCGoAXKuew21aJUzXXjyca 8PCwbq64m6J2iz+G148G2NDtH1dTF94fKgEgSO5gWqRmFoeVJhGa70nqrzXVWjYRsE+r QNZA== X-Gm-Message-State: ALoCoQnQUwJ3SsgIh9f3aOyk4ue6r04nI8McjlBWGD5dcAFiMKWnrTUw128q1BWVK579GebSnqaN X-Received: by 10.194.2.33 with SMTP id 1mr3667570wjr.150.1449049665546; Wed, 02 Dec 2015 01:47:45 -0800 (PST) Received: from ermac.urgonet (h-84-45.a175.priv.bahnhof.se. [79.136.84.45]) by smtp.gmail.com with ESMTPSA id bh6sm1987805wjb.0.2015.12.02.01.47.43 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Dec 2015 01:47:44 -0800 (PST) From: Jens Wiklander To: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Mark Rutland , Will Deacon , Catalin Marinas , Russell King , Lorenzo Pieralisi Subject: [PATCH v4 2/4] arm: add implementation for arm-smccc Date: Wed, 2 Dec 2015 10:47:04 +0100 Message-Id: <1449049626-13991-3-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449049626-13991-1-git-send-email-jens.wiklander@linaro.org> References: <1449049626-13991-1-git-send-email-jens.wiklander@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151202_014807_394569_6ACD02A8 X-CRM114-Status: GOOD ( 17.40 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Wiklander , Lars Persson MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds implementation for arm-smccc and enables CONFIG_HAVE_SMCCC for architectures that may support arm-smccc. It's the responsibility of the caller to know if the SMC instruction is supported by the platform. Signed-off-by: Jens Wiklander Reviewed-by: Lars Persson --- arch/arm/Kconfig | 1 + arch/arm/kernel/Makefile | 2 ++ arch/arm/kernel/armksyms.c | 6 ++++++ arch/arm/kernel/smccc-call.S | 50 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 arch/arm/kernel/smccc-call.S diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 34e1569..f6a3167 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -327,6 +327,7 @@ config ARCH_MULTIPLATFORM select CLKSRC_OF select COMMON_CLK select GENERIC_CLOCKEVENTS + select HAVE_ARM_SMCCC if CPU_V7 select MIGHT_HAVE_PCI select MULTI_IRQ_HANDLER select SPARSE_IRQ diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index af9e59b..d2d0042 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -92,4 +92,6 @@ obj-y += psci-call.o obj-$(CONFIG_SMP) += psci_smp.o endif +obj-$(CONFIG_HAVE_ARM_SMCCC) += smccc-call.o + extra-y := $(head-y) vmlinux.lds diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c index f89811f..7e45f69 100644 --- a/arch/arm/kernel/armksyms.c +++ b/arch/arm/kernel/armksyms.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -175,3 +176,8 @@ EXPORT_SYMBOL(__gnu_mcount_nc); EXPORT_SYMBOL(__pv_phys_pfn_offset); EXPORT_SYMBOL(__pv_offset); #endif + +#ifdef CONFIG_HAVE_ARM_SMCCC +EXPORT_SYMBOL(arm_smccc_smc); +EXPORT_SYMBOL(arm_smccc_hvc); +#endif diff --git a/arch/arm/kernel/smccc-call.S b/arch/arm/kernel/smccc-call.S new file mode 100644 index 0000000..8621e06 --- /dev/null +++ b/arch/arm/kernel/smccc-call.S @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, Linaro Limited + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include + +#include +#include +#include + + .macro SMCCC instr +UNWIND( .fnstart) + mov r12, sp + push {r4-r7} +UNWIND( .save {r4-r7}) + ldm r12, {r4-r7} + \instr + pop {r4-r7} + ldr r12, [sp, #(4 * 4)] + stm r12, {r0-r3} + bx lr +UNWIND( .fnend) + .endm + +/* + * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, + * unsigned long a3, unsigned long a4, unsigned long a5, + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) + */ +ENTRY(arm_smccc_smc) + SMCCC __SMC(0) +ENDPROC(arm_smccc_smc) + +/* + * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, + * unsigned long a3, unsigned long a4, unsigned long a5, + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) + */ +ENTRY(arm_smccc_hvc) + SMCCC __HVC(0) +ENDPROC(arm_smccc_hvc)