From patchwork Wed Jan 13 01:59:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 8021531 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 77A42BEEED for ; Wed, 13 Jan 2016 02:00:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97A2E2041E for ; Wed, 13 Jan 2016 01:59:59 +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 4629E2042B for ; Wed, 13 Jan 2016 01:59:56 +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 1aJAj5-00062J-VF; Wed, 13 Jan 2016 01:59:55 +0000 Received: from regular1.263xmail.com ([211.150.99.138]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJAj1-0005vQ-CA for linux-rockchip@lists.infradead.org; Wed, 13 Jan 2016 01:59:54 +0000 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.158]) by regular1.263xmail.com (Postfix) with SMTP id D860C5289; Wed, 13 Jan 2016 09:59:25 +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 (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 1E8802B6AA; Wed, 13 Jan 2016 09:59:24 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: u-boot@lists.denx.de X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <8be96fd52d21ea5d3847b73f284727f7> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 26196BEXUYV; Wed, 13 Jan 2016 09:59:24 +0800 (CST) From: Jeffy Chen To: u-boot@lists.denx.de Subject: [PATCH v3 6/6] rockchip: kylin: Check fastboot request Date: Wed, 13 Jan 2016 09:59:20 +0800 Message-Id: <1452650360-24149-7-git-send-email-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452650360-24149-1-git-send-email-jeffy.chen@rock-chips.com> References: <1452650360-24149-1-git-send-email-jeffy.chen@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160112_175953_972972_D7C6FA1D X-CRM114-Status: UNSURE ( 6.89 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) 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: linux-rockchip@lists.infradead.org, sjg@chromium.org, Jeffy Chen , huang lin 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 We will save boot mode flag in grf's os_reg[0], if fastboot requested or fastboot key pressed, try to enter fastboot mode at preboot stage. Signed-off-by: Jeffy Chen --- Changes in v3: Use rockchip's legacy reboot mode definitions. Changes in v2: None board/kylin/kylin_rk3036/kylin_rk3036.c | 46 +++++++++++++++++++++++++++++++++ include/configs/kylin_rk3036.h | 3 +++ 2 files changed, 49 insertions(+) diff --git a/board/kylin/kylin_rk3036/kylin_rk3036.c b/board/kylin/kylin_rk3036/kylin_rk3036.c index 40d6b52..4fc31b1 100644 --- a/board/kylin/kylin_rk3036/kylin_rk3036.c +++ b/board/kylin/kylin_rk3036/kylin_rk3036.c @@ -8,10 +8,15 @@ #include #include #include +#include #include +#include DECLARE_GLOBAL_DATA_PTR; +#define GRF_BASE 0x20008000 +static struct rk3036_grf * const grf = (void *)GRF_BASE; + void get_ddr_config(struct rk3036_ddr_config *config) { /* K4B4G1646Q config */ @@ -28,6 +33,47 @@ void get_ddr_config(struct rk3036_ddr_config *config) config->bw = 1; } +#define FASTBOOT_KEY_GPIO 93 + +int fastboot_key_pressed(void) +{ + gpio_request(FASTBOOT_KEY_GPIO, "fastboot_key"); + gpio_direction_input(FASTBOOT_KEY_GPIO); + return !gpio_get_value(FASTBOOT_KEY_GPIO); +} + +enum rockchip_boot_mode { + ROCKCHIP_BOOT_MODE_NORMAL = 0x5242C300, + ROCKCHIP_BOOT_MODE_LOADER, + ROCKCHIP_BOOT_MODE_MASKROM, + ROCKCHIP_BOOT_MODE_RECOVER, + ROCKCHIP_BOOT_MODE_NORECOVER, + ROCKCHIP_BOOT_MODE_SECONDOS, + ROCKCHIP_BOOT_MODE_WIPEDATA, + ROCKCHIP_BOOT_MODE_WIPEALL, + ROCKCHIP_BOOT_MODE_CHECKIMG, + ROCKCHIP_BOOT_MODE_FASTBOOT, + ROCKCHIP_BOOT_MODE_SECUREBOOT_DISABLE, + ROCKCHIP_BOOT_MODE_CHARGING, + ROCKCHIP_BOOT_MODE_MAX, +}; + +int board_late_init(void) +{ + int boot_mode = readl(&grf->os_reg[4]); + + /* Clear boot mode */ + writel(0, &grf->os_reg[4]); + + if (boot_mode == ROCKCHIP_BOOT_MODE_FASTBOOT || + fastboot_key_pressed()) { + printf("enter fastboot!\n"); + setenv("preboot", "setenv preboot; fastboot usb0"); + } + + return 0; +} + int board_init(void) { return 0; diff --git a/include/configs/kylin_rk3036.h b/include/configs/kylin_rk3036.h index 49997ec..424e81b 100644 --- a/include/configs/kylin_rk3036.h +++ b/include/configs/kylin_rk3036.h @@ -39,6 +39,9 @@ "mmcpart=5\0" \ "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \ +#define CONFIG_BOARD_LATE_INIT +#define CONFIG_PREBOOT + #define CONFIG_ANDROID_BOOT_IMAGE #define CONFIG_SYS_BOOT_RAMDISK_HIGH #define CONFIG_SYS_HUSH_PARSER