From patchwork Wed Nov 11 10:04:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 56372 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1269292lbb; Wed, 11 Nov 2015 02:04:55 -0800 (PST) X-Received: by 10.25.21.70 with SMTP id l67mr3971926lfi.27.1447236295043; Wed, 11 Nov 2015 02:04:55 -0800 (PST) Return-Path: Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id pd10si5548919lbc.109.2015.11.11.02.04.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2015 02:04:55 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by lffu14 with SMTP id u14so13582646lff.1 for ; Wed, 11 Nov 2015 02:04:54 -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=KSkT0W/oyYVjrHOXNF4JqMQVUw4e9+YY+cIBsIODxmY=; b=1SS5IHp2DqW5HJvGJnp/62Ic58zh5oe3g5NK6WbcPGbg8lE5UxzZnOOQePp2spdaXd t88Gr7gGMxwkz1BI01iFcpBUsSNbh68cDd9On6LNLRKZqa2ua4ZNxygS1paTU/bFNV6g SNYTEyilfy+pP3b26zb5p6kHBXr1NH2jR1ruYFbJJgnl0DhwEp2cykQoaTPjfLN9G1fm MtkxoRxw4fWn10macZlFXZWZYnHcO/1/UqV9PyGtjvjLi3GJNAN61PIbLRKJgb0LC+h6 Vl9JHesL3nyzVht8dWG+Nxr7Zl4uVOkorRQXeEtvO5uU+MAY62gpcJKRu/5M7tiWLuJR UjzA== 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=KSkT0W/oyYVjrHOXNF4JqMQVUw4e9+YY+cIBsIODxmY=; b=ebPpDmX4sVP84HiR5BzvCFFhY91prEuk9XN050vNnuPT3W8BuARjz91/XhjAWU1ybo md23G2SREVk2aaR/A18ecapR6AvksaUkRrgT+NNZvGsJjga1st+KabaXV16XG/ufI4Y5 KJrWZ324c/vBfop9DwKOATv6utuTqpL/BQnJSXwoI0cPqBRaKnVboroYQ7YWJZ15sTfh +iibES/DSL9KBlXCeIQyJsvkKC1nt/lgpsYdrStVIYiqNZO7fKbMaEvetbkajtB/Z4yo 1/zz1queynrneusDvAS6n5em3sgppWq6UJqSTYfbbuphujJXUJPxE3QaeYBFEn3zFirx SpRQ== X-Gm-Message-State: ALoCoQmMoR7GXsKxqi8wxZq0LZTmiDHrV/c+YdTc7poHo3Bg7o0ItqpG/XoiFqg6VzGVo5hvApes X-Received: by 10.25.3.207 with SMTP id 198mr3889751lfd.47.1447236294865; Wed, 11 Nov 2015 02:04:54 -0800 (PST) Return-Path: Received: from ermac.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 102sm1344558lft.21.2015.11.11.02.04.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Nov 2015 02:04:53 -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 v2 2/4] arm: add implementation for arm-smccc Date: Wed, 11 Nov 2015 11:04:24 +0100 Message-Id: <1447236266-7491-3-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447236266-7491-1-git-send-email-jens.wiklander@linaro.org> References: <1447236266-7491-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 | 50 ++++++++++++++++++++++++++++++++++++++++++++ arch/arm/kernel/smccc.c | 18 ++++++++++++++++ 4 files changed, 71 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..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) 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);