From patchwork Wed May 11 05:29:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9065031 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 4CE239F6FA for ; Wed, 11 May 2016 05:31:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65E8520155 for ; Wed, 11 May 2016 05:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24729201BB for ; Wed, 11 May 2016 05:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751397AbcEKFb2 (ORCPT ); Wed, 11 May 2016 01:31:28 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:12989 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbcEKFb0 (ORCPT ); Wed, 11 May 2016 01:31:26 -0400 Received: from vsmta13.fe.internet.bosch.com (unknown [10.4.98.53]) by imta23.fe.bosch.de (Postfix) with ESMTP id 79D9A158020A for ; Wed, 11 May 2016 07:31:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1462944684; bh=2w9EbYfLCZvPRRVt4bNYm0yWWjP24TdBGiPC7asR1v0=; l=10; h=From:From:Reply-To:Sender; b=I4PUHMiyUoH7zMUjwHQKzqr8T9O4S5PQbi6z+rbE7tTmp5e/k1C1gXc7tFXgqKCti /LEqzvOukjZpMKdwrjuMOitxSHxp7iXi6MUA7RmTJRN7lGQNaS+MjFpTuSVboT+GmE AQ+T7kJqKmBHOsOGVA9rcIR6qtr+yYqrkRSKJkT8= Received: from SI-HUB1001.de.bosch.com (vsgw22.fe.internet.bosch.com [10.4.98.11]) by vsmta13.fe.internet.bosch.com (Postfix) with ESMTP id 226982E402BB for ; Wed, 11 May 2016 07:31:24 +0200 (CEST) Received: from hi-z08if.hi.de.bosch.com (10.34.209.31) by SI-HUB1001.de.bosch.com (10.4.103.108) 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 F10C5625E9C; Wed, 11 May 2016 07:29:40 +0200 (CEST) From: Dirk Behme To: Geert Uytterhoeven , Simon Horman , Subject: [PATCH v2 02/10] boot-mode-reg: Add R-Car driver Date: Wed, 11 May 2016 07:29:30 +0200 Message-ID: <1462944578-1220-3-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: HCAnXyXaxO5ZT98H9cWYnPVFR4sC8dPyWjWsWQUWzVpHZg0gWH5yUUc2 fZLt8Liplly9CvCWjMAONQuhuP+61w8LKInWUps8iUPZPmKZOQmT7CrWQoSVJe5ztd+5NgQ2dyG 0kjowQuMUYHw5bdUbZb4OWdg6x9PC1QwDBMM4GezJ5W6OZe5hharFemr66cZVWsKKuc6vT6xTeb 4lcDJW8ABfx9Im5ZjSUi43GA8Sjd8GlwKxlQJO5vsgrpDX6v2esuIso71Vk6Kn5yDc9PwlXHcez RhLUgDz5b9Y3FmoSoEDlLzIFCvgtROvX7kDJ6Oue7MO8jvmPSxTm6UYlo7la5soi2XrUn/Jn6Kd MrRsL14qtq5d3cxkNT9FMMFmEfceQL8jwg72SNKxbqt3d/iQ1uaEMJpnGwcbIQ35RDwDtCxvkeD AYhX/VW5N27DVWWw6SB00aK+4kFqSCZ0uCM0JReBmLRvK4R8ceAky2sUBAeFe7SzjtQSwawN7Be LJGIGERVAutJiWjR8= 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 Boot mode register driver for R-Car. If running on a supported platform it reads the boot mode register and records it using the boot mode register infrastructure established by an earlier patch. rcar_init_boot_mode() is exported allow it to be explicitly called in cases where the boot mode register is needed before init calls are made. Signed-off-by: Simon Horman --- drivers/misc/boot-mode-reg/Kconfig | 8 +++++ drivers/misc/boot-mode-reg/Makefile | 1 + drivers/misc/boot-mode-reg/rcar.c | 60 +++++++++++++++++++++++++++++++++++++ include/misc/boot-mode-reg.h | 3 ++ 4 files changed, 72 insertions(+) create mode 100644 drivers/misc/boot-mode-reg/rcar.c diff --git a/drivers/misc/boot-mode-reg/Kconfig b/drivers/misc/boot-mode-reg/Kconfig index 3c4ddde..3868c36 100644 --- a/drivers/misc/boot-mode-reg/Kconfig +++ b/drivers/misc/boot-mode-reg/Kconfig @@ -9,3 +9,11 @@ config BOOT_MODE_REG_CORE help Say Y here to allow support for drivers to read boot mode registers and make the value available to other subsystems. + +config BOOT_MODE_REG_RCAR + tristate "Boot Mode Register Driver for Renesas R-Car SoCs" + default n + select BOOT_MODE_REG_CORE + help + Say Y here to allow support for reading the boot mode register + on Renesas R-Car SoCs. diff --git a/drivers/misc/boot-mode-reg/Makefile b/drivers/misc/boot-mode-reg/Makefile index 19134b2..5469a1d 100644 --- a/drivers/misc/boot-mode-reg/Makefile +++ b/drivers/misc/boot-mode-reg/Makefile @@ -4,3 +4,4 @@ # obj-$(CONFIG_BOOT_MODE_REG_CORE) += core.o +obj-$(CONFIG_BOOT_MODE_REG_RCAR) += rcar.o diff --git a/drivers/misc/boot-mode-reg/rcar.c b/drivers/misc/boot-mode-reg/rcar.c new file mode 100644 index 0000000..c3b778fe --- /dev/null +++ b/drivers/misc/boot-mode-reg/rcar.c @@ -0,0 +1,60 @@ +/* + * R-Car Boot Mode Register Driver + * + * 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 + +#define MODEMR 0xe6160060 + +static int __init rcar_read_mode_pins(void) +{ + void __iomem *modemr; + int err = -ENOMEM; + static u32 mode; + + modemr = ioremap_nocache(MODEMR, 4); + if (!modemr) { + pr_err("failed to map boot mode register"); + goto err; + } + mode = ioread32(modemr); + iounmap(modemr); + + err = boot_mode_reg_set(mode); +err: + if (err) + pr_err("failed to initialise boot mode"); + return err; +} + +int __init rcar_init_boot_mode(void) +{ + if (of_machine_is_compatible("renesas,r8a7790") || + of_machine_is_compatible("renesas,r8a7791") || + of_machine_is_compatible("renesas,r8a7792") || + of_machine_is_compatible("renesas,r8a7793") || + of_machine_is_compatible("renesas,r8a7794")) + return rcar_read_mode_pins(); + + return 0; +} +early_initcall(rcar_init_boot_mode); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Simon Horman "); +MODULE_DESCRIPTION("R-Car Boot Mode Register Driver"); diff --git a/include/misc/boot-mode-reg.h b/include/misc/boot-mode-reg.h index 34ee653..35d7f57 100644 --- a/include/misc/boot-mode-reg.h +++ b/include/misc/boot-mode-reg.h @@ -21,4 +21,7 @@ int boot_mode_reg_get(u32 *mode); int boot_mode_reg_set(u32 mode); +/* Allow explicit initialisation before initcalls */ +int rcar_init_boot_mode(void); + #endif