From patchwork Thu Jan 14 02:19:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 567237 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 534C9140BA2 for ; Thu, 14 Jan 2016 13:21:15 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B5EEC621B9; Thu, 14 Jan 2016 03:21:13 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GXtNIzLacJRM; Thu, 14 Jan 2016 03:21:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2ED5562246; Thu, 14 Jan 2016 03:21:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 572F8622AF for ; Thu, 14 Jan 2016 03:19:45 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a4-vWf0LGYij for ; Thu, 14 Jan 2016 03:19:45 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.139]) by theia.denx.de (Postfix) with ESMTPS id 69D8A622B8 for ; Thu, 14 Jan 2016 03:19:42 +0100 (CET) Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.78]) by regular1.263xmail.com (Postfix) with SMTP id DCE0D5875; Thu, 14 Jan 2016 10:19:38 +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 4E8CA294F6; Thu, 14 Jan 2016 10:19:35 +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: <49a4a445fd6d559557feef10e124df3e> 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 3769AEO8E; Thu, 14 Jan 2016 10:19:36 +0800 (CST) From: Jeffy Chen To: u-boot@lists.denx.de Date: Thu, 14 Jan 2016 10:19:40 +0800 Message-Id: <1452737981-16682-6-git-send-email-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452737981-16682-1-git-send-email-jeffy.chen@rock-chips.com> References: <1452737981-16682-1-git-send-email-jeffy.chen@rock-chips.com> Cc: Jeffy Chen Subject: [U-Boot] [PATCH v5 5/6] rockchip: kylin: Check fastboot request X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We will save boot mode flag in grf's os_reg[4], if fastboot requested or fastboot key pressed, try to enter fastboot mode at preboot stage. Signed-off-by: Jeffy Chen Acked-by: Simon Glass --- Changes in v5: Change "grf" to local var. Changes in v4: Remove unused reboot mode definitions. Changes in v3: Use rockchip's legacy reboot mode definitions. Changes in v2: None board/kylin/kylin_rk3036/kylin_rk3036.c | 32 ++++++++++++++++++++++++++++++++ include/configs/kylin_rk3036.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/board/kylin/kylin_rk3036/kylin_rk3036.c b/board/kylin/kylin_rk3036/kylin_rk3036.c index 40d6b52..2a25871 100644 --- a/board/kylin/kylin_rk3036/kylin_rk3036.c +++ b/board/kylin/kylin_rk3036/kylin_rk3036.c @@ -8,10 +8,14 @@ #include #include #include +#include #include +#include DECLARE_GLOBAL_DATA_PTR; +#define GRF_BASE 0x20008000 + void get_ddr_config(struct rk3036_ddr_config *config) { /* K4B4G1646Q config */ @@ -28,6 +32,34 @@ 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); +} + +#define ROCKCHIP_BOOT_MODE_FASTBOOT 0x5242C309 + +int board_late_init(void) +{ + struct rk3036_grf * const grf = (void *)GRF_BASE; + 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 48317f9..3fe43eb 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_HUSH_PARSER