From patchwork Wed May 11 05:29:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9064971 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5146A9F372 for ; Wed, 11 May 2016 05:31:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 661D020155 for ; Wed, 11 May 2016 05:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 346B320172 for ; Wed, 11 May 2016 05:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751386AbcEKFbZ (ORCPT ); Wed, 11 May 2016 01:31:25 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:12982 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbcEKFbY (ORCPT ); Wed, 11 May 2016 01:31:24 -0400 Received: from vsmta14.fe.internet.bosch.com (unknown [10.4.98.54]) by imta23.fe.bosch.de (Postfix) with ESMTP id ED92B158014F for ; Wed, 11 May 2016 07:31:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1462944682; bh=2w9EbYfLCZvPRRVt4bNYm0yWWjP24TdBGiPC7asR1v0=; l=10; h=From:From:Reply-To:Sender; b=q/p+rE2rKoevOyvzhxUy7k7YwKyS1dq/x8wNu+Qw8G0JCv6/Nj2jepj08GfvmASNZ FBmoIu//k4fcVisObusQVcjlp+Hpi4osGVA8jInsJQYhxcF/G/Z346CjJwh7CrjU66 i2H5Zm7o/375xpc7TPsbNGxGQgP8PUs+cQbcGKkY= Received: from FE-HUB1000.de.bosch.com (vsgw24.fe.internet.bosch.com [10.4.98.24]) by vsmta14.fe.internet.bosch.com (Postfix) with ESMTP id 98CE8A40248 for ; Wed, 11 May 2016 07:31:22 +0200 (CEST) Received: from hi-z08if.hi.de.bosch.com (10.34.209.31) by FE-HUB1000.de.bosch.com (10.4.103.107) with Microsoft SMTP Server id 14.3.195.1; Wed, 11 May 2016 07:31:21 +0200 Received: from hi-z08if.hi.de.bosch.com (localhost [127.0.0.1]) by hi-z08if.hi.de.bosch.com (Postfix) with ESMTP id E176F625E9B; Wed, 11 May 2016 07:29:40 +0200 (CEST) From: Dirk Behme To: Geert Uytterhoeven , Simon Horman , CC: Dirk Behme Subject: [PATCH v2 01/10] boot-mode-reg: Add core Date: Wed, 11 May 2016 07:29:29 +0200 Message-ID: <1462944578-1220-2-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1462944578-1220-1-git-send-email-dirk.behme@de.bosch.com> References: <1462944578-1220-1-git-send-email-dirk.behme@de.bosch.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22312.006 X-TMASE-MatchedRID: Og+3VANeZRsyNFM0Xa1tqLiMC5wdwKqdrHCvytg5b45cKZwALwMGs2Ma KH8MJgnxPzekzMDUqlDNYHrYf448jTh59PYaaSC17spMO3HwKCCusS9CiBzL8cKQkd8YrGEvvo0 1NMfybhOu5Tpg5oJt0jGE6Kn8QbxdNywWm0gqi5jJ1E/nrJFED2PSZS8C9XYNKsfKSWXHQh7f/T epSvSh+o+pAn19BHXOftRpysGxPQYG2TL4XyqsveCFYN4xFYD95Y0kb0hqatz7efdnqtsaE9roE GQiudNyAuO9Byrs4AcDxfP+w91lHudesP6bOpQp7TovvZPhLcDvSp2iuuHtoqNyAXxH2EZjgp6I z3m9lxHEp9zJ2nd/975Z2dQ7w/Rj4QsjLzswuv6EryjhqiyzypdhffisWXfHCqIJhrrDy29K/7B PQD8oRFlRp61LJHlhFkA/YV5i9ROYO0IZ/mjyn2wbuvhCHs3cfS0Ip2eEHnz3IzXlXlpamPoLR4 +zsDTtGM6W3U+LnndYdGJsQg/RT8nvpiRBpo1pXGnqTU+T0advTb4yR10YfA== Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 From: Simon Horman The motivation for this new module is to add a small frame work to allow kernel subsystems to obtain boot mode information from a centralised source using a new, and hopefully soon well-known, API. The new API consists of two function calls and nothing more: boot_mode_reg_set: Should be called by platform-specific drivers to register the boot mode register value which they obtain from hardware or otherwise. boot_mode_reg_get: Should be called by consumers; subsystems that wish to know he boot mode register. The boot mode register is a 32bit unsigned entity, the meaning of its values are implementation dependent. Signed-off-by: Simon Horman Signed-off-by: Dirk Behme --- MAINTAINERS | 1 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/boot-mode-reg/Kconfig | 11 ++++++ drivers/misc/boot-mode-reg/Makefile | 6 +++ drivers/misc/boot-mode-reg/core.c | 76 +++++++++++++++++++++++++++++++++++++ include/misc/boot-mode-reg.h | 24 ++++++++++++ 7 files changed, 120 insertions(+) create mode 100644 drivers/misc/boot-mode-reg/Kconfig create mode 100644 drivers/misc/boot-mode-reg/Makefile create mode 100644 drivers/misc/boot-mode-reg/core.c create mode 100644 include/misc/boot-mode-reg.h diff --git a/MAINTAINERS b/MAINTAINERS index 23e68db..e2bf6ea 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10734,6 +10734,7 @@ S: Maintained F: Documentation/sh/ F: arch/sh/ F: drivers/sh/ +F: drivers/misc/boot-mode-reg/ SUSPEND TO RAM M: "Rafael J. Wysocki" diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index a216b46..deba6b6 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -816,4 +816,5 @@ source "drivers/misc/mic/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" source "drivers/misc/cxl/Kconfig" +source "drivers/misc/boot-mode-reg/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index b2fb6dbf..d2a8ae4 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -57,3 +57,4 @@ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_PANEL) += panel.o +obj-$(CONFIG_BOOT_MODE_REG_CORE) += boot-mode-reg/ diff --git a/drivers/misc/boot-mode-reg/Kconfig b/drivers/misc/boot-mode-reg/Kconfig new file mode 100644 index 0000000..3c4ddde --- /dev/null +++ b/drivers/misc/boot-mode-reg/Kconfig @@ -0,0 +1,11 @@ +# +# Boot Mode Register Drivers +# + +config BOOT_MODE_REG_CORE + tristate "Boot Mode Register Core Driver" + default n + depends on ARCH_SHMOBILE || ARCH_RENESAS || COMPILE_TEST + help + Say Y here to allow support for drivers to read boot mode + registers and make the value available to other subsystems. diff --git a/drivers/misc/boot-mode-reg/Makefile b/drivers/misc/boot-mode-reg/Makefile new file mode 100644 index 0000000..19134b2 --- /dev/null +++ b/drivers/misc/boot-mode-reg/Makefile @@ -0,0 +1,6 @@ + +# +# Makefile for misc devices that really don't fit anywhere else. +# + +obj-$(CONFIG_BOOT_MODE_REG_CORE) += core.o diff --git a/drivers/misc/boot-mode-reg/core.c b/drivers/misc/boot-mode-reg/core.c new file mode 100644 index 0000000..983bf4c --- /dev/null +++ b/drivers/misc/boot-mode-reg/core.c @@ -0,0 +1,76 @@ +/* + * Boot Mode Register + * + * Copyright (C) 2015 Simon Horman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * 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 + +static DEFINE_MUTEX(boot_mode_mutex); +static bool boot_mode_is_set; +static u32 boot_mode; + +/** + * boot_mode_reg_get() - retrieve boot mode register value + * @mode: implementation-dependent boot mode register value + * + * Retrieves the boot mode register value previously registered + * using boot_mode_reg_set(). + * + * return: 0 on success + */ +int boot_mode_reg_get(u32 *mode) +{ + int err = -ENOENT; + + mutex_lock(&boot_mode_mutex); + if (boot_mode_is_set) { + *mode = boot_mode; + err = 0; + } + mutex_unlock(&boot_mode_mutex); + return err; +} +EXPORT_SYMBOL_GPL(boot_mode_reg_get); + +/** + * boot_mode_reg_set() - record boot mode register value + * @mode: implementation-dependent boot mode register value + * + * Records the boot mode register value which may subsequently + * be retrieved using boot_mode_reg_get(). + * + * return: 0 on success + */ +int boot_mode_reg_set(u32 mode) +{ + int err = -EBUSY; + + mutex_lock(&boot_mode_mutex); + if (!boot_mode_is_set) { + boot_mode = mode; + boot_mode_is_set = true; + err = 0; + } + mutex_unlock(&boot_mode_mutex); + return err; +} +EXPORT_SYMBOL_GPL(boot_mode_reg_set); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Simon Horman "); +MODULE_DESCRIPTION("Core Boot Mode Register Driver"); diff --git a/include/misc/boot-mode-reg.h b/include/misc/boot-mode-reg.h new file mode 100644 index 0000000..34ee653 --- /dev/null +++ b/include/misc/boot-mode-reg.h @@ -0,0 +1,24 @@ +/* + * Boot Mode Register + * + * Copyright (C) 2015 Simon Horman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * 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. + */ + +#ifndef _BOOT_MODE_REG_H +#define _BOOT_MODE_REG_H + +#include + +int boot_mode_reg_get(u32 *mode); +int boot_mode_reg_set(u32 mode); + +#endif