From patchwork Wed Nov 4 09:46:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 55968 Delivered-To: patches@linaro.org Received: by 10.112.61.134 with SMTP id p6csp2318778lbr; Wed, 4 Nov 2015 01:47:07 -0800 (PST) X-Received: by 10.112.140.197 with SMTP id ri5mr383131lbb.65.1446630427400; Wed, 04 Nov 2015 01:47:07 -0800 (PST) Return-Path: Received: from mail-lb0-x230.google.com (mail-lb0-x230.google.com. [2a00:1450:4010:c04::230]) by mx.google.com with ESMTPS id v1si355162lbb.82.2015.11.04.01.47.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Nov 2015 01:47:07 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) client-ip=2a00:1450:4010:c04::230; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by lbbes7 with SMTP id es7so11847494lbb.2 for ; Wed, 04 Nov 2015 01:47:07 -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=DXYt+EibnjOHe5z0vR7KHyXH3Opp3foN7TrBm7TeRnQ=; b=0HD4w7ziAcjhf6vHQUIcDE43lNBAAI+74YRKbYNguhtM60PTjsCGgF7U1SsIOYEWvL oxqdgmzAPSvfHI0/whnMS2ZxuKfsHOzrR/XXOOOb8yVdCIX+Dq5FubDSgb0Oh5YzPZBX 80QYr3HUf0IYR4LqpJcD6U4hh+2N1dd9NXEZddjLTJxOOkbtv3H2DfgDAv8HDi0V/Byp eLMTpjni3qQB3uFp4+3nPe6RKEa0vEaei1Pr5wnCTRcG99WSNr2NPp8s0s6jO7A0mE0T JzIEmcYW3rrb1UEy3P8gMKT0gw0bBFx6DQRyPIiZ0ydBrWAUQC+olJHGEryAdvAOxv8F ss6g== 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=DXYt+EibnjOHe5z0vR7KHyXH3Opp3foN7TrBm7TeRnQ=; b=j8rXAXkfu8GRkSDFl78VtRuO37HvWlabcjRy1CxahLHy5hLWJdco02Bc68X7+cW/xp NAJI0j4ZbbfgziAI52+zy8Lbhkxre2xGRL1wOleVeblpocHfR/Fi9Z3Nd0hba2TF9huC p3M+/PhDzUzLavPeDQfW3FsZaLCHgtOPvHGXsGD66EVIbkGSyi2edHKPXMeY/NLrVcsz rvxVEq6Ri/0Gv3YrhCfDx1LpzozaC7NO2rKCp1ZFjdJ5VvfPhbPBO8LyxiF5TOIByM+r RnUfZTezu3AOwYfq2fGTdLC6Yxe86iRtgqpO2FFvouOGwdBiJflpRqZk6kgAeXyloWUj tHQQ== X-Gm-Message-State: ALoCoQmN5siBMiCxlG6M5TpL5kt5Oo3RnZRmpc8vKB0rS9iDI0DpJAi+yOTZ+BJJ1qUZs9lPdC9+ X-Received: by 10.112.155.195 with SMTP id vy3mr400014lbb.9.1446630427170; Wed, 04 Nov 2015 01:47:07 -0800 (PST) Return-Path: Received: from ermac.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id qh2sm74250lbb.42.2015.11.04.01.47.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Nov 2015 01:47:06 -0800 (PST) From: Jens Wiklander To: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Mark Rutland , Will Deacon , Catalin Marinas , Russell King Cc: Lars Persson , Jens Wiklander Subject: [PATCH 2/4] arm: add implementation for arm-smccc Date: Wed, 4 Nov 2015 10:46:10 +0100 Message-Id: <1446630372-1598-3-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446630372-1598-1-git-send-email-jens.wiklander@linaro.org> References: <1446630372-1598-1-git-send-email-jens.wiklander@linaro.org> 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 --- arch/arm/Kconfig | 1 + arch/arm/kernel/Makefile | 2 ++ arch/arm/kernel/smccc-call.S | 46 ++++++++++++++++++++++++++++++++++++++++++++ arch/arm/kernel/smccc.c | 18 +++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 arch/arm/kernel/smccc-call.S create mode 100644 arch/arm/kernel/smccc.c -- 1.9.1 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 639411f..d394727 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -325,6 +325,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..c89e6ab 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 smccc.o + extra-y := $(head-y) vmlinux.lds diff --git a/arch/arm/kernel/smccc-call.S b/arch/arm/kernel/smccc-call.S new file mode 100644 index 0000000..bbed9f1 --- /dev/null +++ b/arch/arm/kernel/smccc-call.S @@ -0,0 +1,46 @@ +/* + * 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 + + .macro SMCCC instr + mov r12, sp + push {r4-r7} + ldm r12, {r4-r7} + \instr + pop {r4-r7} + ldr r12, [sp, #(4 * 4)] + stm r12, {r0-r3} + bx lr + .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) diff --git a/arch/arm/kernel/smccc.c b/arch/arm/kernel/smccc.c new file mode 100644 index 0000000..7941210 --- /dev/null +++ b/arch/arm/kernel/smccc.c @@ -0,0 +1,18 @@ +/* + * 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 + +EXPORT_SYMBOL_GPL(arm_smccc_smc); +EXPORT_SYMBOL_GPL(arm_smccc_hvc);