From patchwork Tue Dec 22 09:13:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Yan X-Patchwork-Id: 7902991 Return-Path: X-Original-To: patchwork-linux-rockchip@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 D12159F349 for ; Tue, 22 Dec 2015 09:16:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E550B205B1 for ; Tue, 22 Dec 2015 09:16:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EFAD420553 for ; Tue, 22 Dec 2015 09:16:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aBJ3b-0002o4-Nw; Tue, 22 Dec 2015 09:16:35 +0000 Received: from regular2.263xmail.com ([211.157.152.3]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aBJ3O-0002eX-Dg; Tue, 22 Dec 2015 09:16:24 +0000 Received: from regular1.263xmail.com (unknown [192.168.165.185]) by regular2.263xmail.com (Postfix) with ESMTP id B6A531EB76; Tue, 22 Dec 2015 17:15:57 +0800 (CST) Received: from andy.yan?rock-chips.com (unknown [192.168.167.229]) by regular1.263xmail.com (Postfix) with SMTP id 11D6F53E8; Tue, 22 Dec 2015 17:15:24 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 7B70746E; Tue, 22 Dec 2015 17:15:17 +0800 (CST) X-RL-SENDER: andy.yan@rock-chips.com X-FST-TO: robh+dt@kernel.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: andy.yan@rock-chips.com X-UNIQUE-TAG: <85df883c700a0d3a755e060812905192> X-ATTACHMENT-NUM: 0 X-SENDER: yxj@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 27315HIY19I; Tue, 22 Dec 2015 17:15:22 +0800 (CST) From: Andy Yan To: robh+dt@kernel.org, heiko@sntech.de, arnd@arndb.de, john.stultz@linaro.org Subject: [PATCH v1 4/6] soc: rockchip: add reboot mode driver Date: Tue, 22 Dec 2015 17:13:19 +0800 Message-Id: <1450775599-24127-1-git-send-email-andy.yan@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450774949-23901-1-git-send-email-andy.yan@rock-chips.com> References: <1450774949-23901-1-git-send-email-andy.yan@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151222_011623_119849_A5F8E929 X-CRM114-Status: GOOD ( 15.23 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geert+renesas@glider.be, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, alexandre.belloni@free-electrons.com, lorenzo.pieralisi@arm.com, linux@arm.linux.org.uk, dbaryshkov@gmail.com, linux-rockchip@lists.infradead.org, joel@jms.id.au, treding@nvidia.com, wxt@rock-chips.com, devicetree@vger.kernel.org, khilman@linaro.org, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, moritz.fischer@ettus.com, gregkh@linuxfoundation.org, sjg@chromium.org, sre@kernel.org, galak@codeaurora.org, olof@lixom.net, Andy Yan , jun.nie@linaro.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 rockchip platform have a protocol to pass the kernel reboot mode to bootloader by some special registers when system reboot. By this way the bootloader can take different action according to the different kernel reboot mode, for example, command "reboot loader" will reboot the board to rockusb mode, this is a very convenient way to get the board enter download mode. Signed-off-by: Andy Yan --- Changes in v1: - fix the embarrassed compile warning - correct the maskrom magic number - check for the normal reboot drivers/soc/rockchip/Kconfig | 9 ++++ drivers/soc/rockchip/Makefile | 1 + drivers/soc/rockchip/reboot.c | 68 ++++++++++++++++++++++++++++ include/dt-bindings/soc/rockchip_boot-mode.h | 30 ++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 drivers/soc/rockchip/reboot.c create mode 100644 include/dt-bindings/soc/rockchip_boot-mode.h diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig index 7140ff8..42525f8 100644 --- a/drivers/soc/rockchip/Kconfig +++ b/drivers/soc/rockchip/Kconfig @@ -15,4 +15,13 @@ config ROCKCHIP_PM_DOMAINS If unsure, say N. +config ROCKCHIP_REBOOT + bool "Rockchip reboot mode driver" + select REBOOT_MODE + help + Say y here will enable reboot mode driver. This will + get reboot mode arguments from userspace and store it + in special register, then the bootloader will read it + to take different action according to the mode. + endif diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile index 3d73d06..9817496 100644 --- a/drivers/soc/rockchip/Makefile +++ b/drivers/soc/rockchip/Makefile @@ -2,3 +2,4 @@ # Rockchip Soc drivers # obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o +obj-$(CONFIG_ROCKCHIP_REBOOT) += reboot.o diff --git a/drivers/soc/rockchip/reboot.c b/drivers/soc/rockchip/reboot.c new file mode 100644 index 0000000..7024532 --- /dev/null +++ b/drivers/soc/rockchip/reboot.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd + * + * 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; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct regmap *map; +static u32 offset; + +static int rockchip_reboot_mode_write(int magic) +{ + if (!magic) + magic = BOOT_NORMAL; + + regmap_write(map, offset, magic); + + return 0; +} + +static int rockchip_reboot_probe(struct platform_device *pdev) +{ + int ret; + + map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, + "rockchip,regmap"); + if (IS_ERR(map)) + return PTR_ERR(map); + + if (of_property_read_u32(pdev->dev.of_node, "offset", &offset)) + return -EINVAL; + + ret = reboot_mode_register(&pdev->dev, rockchip_reboot_mode_write); + if (ret) + dev_err(&pdev->dev, "can't register reboot mode\n"); + + return ret; +} + +static const struct of_device_id rockchip_reboot_of_match[] = { + { .compatible = "rockchip,reboot-mode" }, + {} +}; + +static struct platform_driver rockchip_reboot_driver = { + .probe = rockchip_reboot_probe, + .driver = { + .name = "rockchip-reboot", + .of_match_table = rockchip_reboot_of_match, + }, +}; +module_platform_driver(rockchip_reboot_driver); + +MODULE_AUTHOR("Andy Yan