From patchwork Thu Oct 25 15:22:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 194234 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DBE902C0091 for ; Fri, 26 Oct 2012 02:25:40 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TRPHB-0004gA-Vt; Thu, 25 Oct 2012 15:23:18 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TRPGu-0004bw-WF for linux-arm-kernel@lists.infradead.org; Thu, 25 Oct 2012 15:23:02 +0000 MIME-version: 1.0 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MCG00L3YG23WU40@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 26 Oct 2012 00:22:55 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-02-5089594e0ea1 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 6E.28.12699.E4959805; Fri, 26 Oct 2012 00:22:55 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MCG008XQG1VUL00@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 26 Oct 2012 00:22:54 +0900 (KST) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Subject: [PATCH v3 1/6] ARM: Add interface for registering and calling firmware-specific operations Date: Thu, 25 Oct 2012 17:22:35 +0200 Message-id: <1351178560-19188-2-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1351178560-19188-1-git-send-email-t.figa@samsung.com> References: <1351178560-19188-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBLMWRmVeSWpSXmKPExsVy+t9jAV3/yM4Ag+77rBabHl9jdWD02Lyk PoAxissmJTUnsyy1SN8ugSuj8do1toK9chW39s1kbmDskOxi5OSQEDCR+PrpAiuELSZx4d56 ti5GLg4hgUWMEvd3fWIDSfAKCEr8mHyPpYuRg4NZQF7iyKVskDCzgLrEpHmLmCHqNzNJTFy4 hhEkwSagJvG54RFYr4iAqsTntgXsIEXMArcYJQ7f/AtWJCyQKjHz1wGwIhagoqf/2pghljlJ 7Hn5jBniInmJp/f7wGo4BZwlmg5fZgI5Qgio5v8B6QmMArOQnDcL4bxZSM5bwMi8ilE0tSC5 oDgpPddIrzgxt7g0L10vOT93EyM4/J5J72Bc1WBxiFGAg1GJh/eBa2eAEGtiWXFl7iFGCQ5m JRFe33CgEG9KYmVValF+fFFpTmrxIUZpDhYlcd5mj5QAIYH0xJLU7NTUgtQimCwTB6dUA2Nm HuuEUsUXjzuVrEWiqw7EsnoumrLxn5BMdc9rHqWlZb0TJPtuX+O9YbfZ8v4tFWs7/zPRCv9n nzCJ1jpiKCxbcmnKow7WnR/+/VFh25n70vX8o79di9pl/y6dXXI++UvOBsF/BT588ded24X+ rTVL9A4y+BGwinmnKkvl7TT+JZdY1/mq2iixFGckGmoxFxUnAgDl9i0zOwIAAA== X-Spam-Note: CRM114 invocation failed X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.33 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, linux@arm.linux.org.uk, arnd@arndb.de, t.figa@samsung.com, tomasz.figa@gmail.com, kyungmin.park@samsung.com, olof@lixom.net, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Some boards are running with secure firmware running in TrustZone secure world, which changes the way some things have to be initialized. This patch adds an interface for platforms to specify available firmware operations and call them. A wrapper macro, call_firmware_op(), checks if the operation is provided and calls it if so, otherwise returns -ENOSYS to allow fallback to legacy operation.. By default no operations are provided. Example of use: In code using firmware ops: __raw_writel(virt_to_phys(exynos4_secondary_startup), CPU1_BOOT_REG); /* Call Exynos specific smc call */ if (call_firmware_op(cpu_boot, cpu) == -ENOSYS) cpu_boot_legacy(...); /* Try legacy way */ gic_raise_softirq(cpumask_of(cpu), 1); In board-/platform-specific code: static int platformX_do_idle(void) { /* tell platformX firmware to enter idle */ return 0; } static int platformX_cpu_boot(int i) { /* tell platformX firmware to boot CPU i */ return 0; } static const struct firmware_ops platformX_firmware_ops = { .do_idle = exynos_do_idle, .cpu_boot = exynos_cpu_boot, /* other operations not available on platformX */ }; static void __init board_init_early(void) {         register_firmware_ops(&platformX_firmware_ops); } Signed-off-by: Kyungmin Park Signed-off-by: Tomasz Figa --- arch/arm/common/Makefile | 2 ++ arch/arm/common/firmware.c | 18 ++++++++++++++++++ arch/arm/include/asm/firmware.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 arch/arm/common/firmware.c create mode 100644 arch/arm/include/asm/firmware.h diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile index e8a4e58..55d4182 100644 --- a/arch/arm/common/Makefile +++ b/arch/arm/common/Makefile @@ -2,6 +2,8 @@ # Makefile for the linux kernel. # +obj-y += firmware.o + obj-$(CONFIG_ARM_GIC) += gic.o obj-$(CONFIG_ARM_VIC) += vic.o obj-$(CONFIG_ICST) += icst.o diff --git a/arch/arm/common/firmware.c b/arch/arm/common/firmware.c new file mode 100644 index 0000000..27ddccb --- /dev/null +++ b/arch/arm/common/firmware.c @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2012 Samsung Electronics. + * Kyungmin Park + * Tomasz Figa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include + +#include + +static const struct firmware_ops default_firmware_ops; + +const struct firmware_ops *firmware_ops = &default_firmware_ops; diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h new file mode 100644 index 0000000..5d87d8e --- /dev/null +++ b/arch/arm/include/asm/firmware.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2012 Samsung Electronics. + * Kyungmin Park + * Tomasz Figa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_ARM_FIRMWARE_H +#define __ASM_ARM_FIRMWARE_H + +struct firmware_ops { + int (*do_idle)(void); + int (*cpu_boot)(int cpu); + int (*cpu_boot_reg)(int cpu, void __iomem **ptr); + int (*l2x0_init)(void); +}; + +extern const struct firmware_ops *firmware_ops; + +#define call_firmware_op(op, ...) \ + ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : (-ENOSYS)) + +static inline void register_firmware_ops(const struct firmware_ops *ops) +{ + firmware_ops = ops; +} + +#endif