From patchwork Thu Sep 13 08:13: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: 183548 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [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 0BBA52C00B9 for ; Thu, 13 Sep 2012 18:29:21 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TC4ZD-0005Hl-Il; Thu, 13 Sep 2012 08:14:31 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TC4Ys-0005Ev-Fq for linux-arm-kernel@lists.infradead.org; Thu, 13 Sep 2012 08:14:11 +0000 MIME-version: 1.0 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAA00L2C46GO2V0@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 13 Sep 2012 17:14:09 +0900 (KST) X-AuditID: cbfee61a-b7fba6d000007d5f-e5-505195d0d4ca Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id B8.81.32095.0D591505; Thu, 13 Sep 2012 17:14:09 +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 <0MAA00F0A477MEF1@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 13 Sep 2012 17:14:08 +0900 (KST) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Subject: [PATCH 2/5] ARM: Add interface for registering and calling firmware-specific operations Date: Thu, 13 Sep 2012 10:13:35 +0200 Message-id: <1347524018-19301-3-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1347524018-19301-1-git-send-email-t.figa@samsung.com> References: <1347524018-19301-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJLMWRmVeSWpSXmKPExsVy+t9jAd2LUwMDDC5MY7bY9PgaqwOjx+Yl 9QGMUVw2Kak5mWWpRfp2CVwZq09cYSy4KVdx6NRXpgbGlZJdjJwcEgImErvevWCDsMUkLtxb D2RzcQgJLGKUaL72lwUkwSsgKPFj8j0gm4ODWUBe4silbJAws4C6xKR5i5gh6jczSaw9cAps EJuAmsTnhkdgtoiAqsTntgXsIEXMAisZJTa+mweWEBZIkng+8xoriM0CVPTjz052iGVOEpeu XmeEuEhe4un9PrB6TgFniQ8PtoDFhYBqthx+xjKBUWAWkvtmIdw3C8l9CxiZVzGKphYkFxQn peca6hUn5haX5qXrJefnbmIEB+AzqR2MKxssDjEKcDAq8fBmPg8IEGJNLCuuzD3EKMHBrCTC q94dGCDEm5JYWZValB9fVJqTWnyIUZqDRUmc1+mcXYCQQHpiSWp2ampBahFMlomDU6qBkTk7 NbCqM2DCmyxzzk9X27PuGbtffTjl8QrrZUohxz4YhtQ9YjZz37Uy9P7a1xLJ0utmmCydLRnW qnklcIa/ulLVmddMNon/r5668WSxw81QjV0i6zYvDGsrVZB49ac1NWbikS2z+fmNgtapJ0dN P7P4crlpyY6V2X7yQdfnNCTtPcIveKKvVomlOCPRUIu5qDgRAHZyxss8AgAA X-Spam-Note: CRM114 invocation failed X-Spam-Score: -7.3 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.25 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.4 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, kyungmin.park@samsung.com, olof@lixom.net, linux-arm-kernel@lists.infradead.org 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 0. By default no operations are provided. This is a follow-up on the patch by Kyungmin Park: [PATCH v5 1/2] ARM: Make a compile firmware conditionally http://thread.gmane.org/gmane.linux.ports.arm.kernel/183607/focus=183988 Example of use: In code using firmware ops: __raw_writel(virt_to_phys(exynos4_secondary_startup), CPU1_BOOT_REG); /* Call Exynos specific smc call */ do_firmware_op(cpu_boot, cpu); 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 void platformX_cpu_boot(int i) { /* tell platformX firmware to boot CPU i */ } static const struct firmware_ops platformX_firmware_ops __initdata = { .do_idle = exynos_do_idle, .cpu_boot = exynos_cpu_boot, /* cpu_boot_reg 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 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 50 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..ed51b02 --- /dev/null +++ b/arch/arm/include/asm/firmware.h @@ -0,0 +1,30 @@ +/* + * 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); + void (*cpu_boot)(int cpu); + void __iomem *(*cpu_boot_reg)(int cpu); +}; + +extern const struct firmware_ops *firmware_ops; + +#define call_firmware_op(op, ...) \ + ((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : 0) + +static inline void register_firmware_ops(const struct firmware_ops *ops) +{ + firmware_ops = ops; +} + +#endif