{"id":812860,"url":"http://patchwork.ozlabs.org/api/patches/812860/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1505224713-30097-1-git-send-email-andy.yan@rock-chips.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1505224713-30097-1-git-send-email-andy.yan@rock-chips.com>","list_archive_url":null,"date":"2017-09-12T13:58:33","name":"[U-Boot,3/3] rockchip: check download key before bootup","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"330deaf774c6c61266f447ec7d3951543eb1e193","submitter":{"id":65124,"url":"http://patchwork.ozlabs.org/api/people/65124/?format=json","name":"Andy Yan","email":"andy.yan@rock-chips.com"},"delegate":{"id":69486,"url":"http://patchwork.ozlabs.org/api/users/69486/?format=json","username":"ptomsich","first_name":"Philipp","last_name":"Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1505224713-30097-1-git-send-email-andy.yan@rock-chips.com/mbox/","series":[{"id":2709,"url":"http://patchwork.ozlabs.org/api/series/2709/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=2709","date":"2017-09-12T13:55:49","name":"support enter download mode on rockchip platform","version":1,"mbox":"http://patchwork.ozlabs.org/series/2709/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812860/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812860/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xs5zQ48Pcz9s7B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 00:00:34 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 58735C2221E; Tue, 12 Sep 2017 14:00:01 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id BBF7CC22219;\n\tTue, 12 Sep 2017 13:59:39 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 99046C2221A; Tue, 12 Sep 2017 13:58:50 +0000 (UTC)","from regular1.263xmail.com (regular1.263xmail.com [211.150.99.134])\n\tby lists.denx.de (Postfix) with ESMTPS id 6DB78C221BA\n\tfor <u-boot@lists.denx.de>; Tue, 12 Sep 2017 13:58:44 +0000 (UTC)","from andy.yan?rock-chips.com (unknown [192.168.167.227])\n\tby regular1.263xmail.com (Postfix) with ESMTP id 3A1AE8116\n\tfor <u-boot@lists.denx.de>; Tue, 12 Sep 2017 21:58:38 +0800 (CST)","from localhost.localdomain (localhost [127.0.0.1])\n\tby smtp.263.net (Postfix) with ESMTPA id 9CCC0360;\n\tTue, 12 Sep 2017 21:58:39 +0800 (CST)","from localhost.localdomain (unknown [58.22.7.114])\n\tby smtp.263.net (Postfix) whith ESMTP id 38066PVGN1;\n\tTue, 12 Sep 2017 21:58:40 +0800 (CST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.6 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H2,RCVD_IN_SORBS_WEB autolearn=no autolearn_force=no\n\tversion=3.4.0","X-263anti-spam":"KSV:0;","X-MAIL-GRAY":"0","X-MAIL-DELIVERY":"1","X-KSVirus-check":"0","X-ABS-CHECKED":"4","X-RL-SENDER":"andy.yan@rock-chips.com","X-FST-TO":"philipp.tomsich@theobroma-systems.com","X-SENDER-IP":"58.22.7.114","X-LOGIN-NAME":"andy.yan@rock-chips.com","X-UNIQUE-TAG":"<eee43e946c3df25cde07bfa90c630eb7>","X-ATTACHMENT-NUM":"0","X-SENDER":"yxj@rock-chips.com","X-DNS-TYPE":"0","From":"Andy Yan <andy.yan@rock-chips.com>","To":"philipp.tomsich@theobroma-systems.com,\n\tsjg@chromium.org","Date":"Tue, 12 Sep 2017 21:58:33 +0800","Message-Id":"<1505224713-30097-1-git-send-email-andy.yan@rock-chips.com>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1505224549-29936-1-git-send-email-andy.yan@rock-chips.com>","References":"<1505224549-29936-1-git-send-email-andy.yan@rock-chips.com>","Cc":"u-boot@lists.denx.de, Andy Yan <andy.yan@rock-chips.com>","Subject":"[U-Boot] [PATCH 3/3] rockchip: check download key before bootup","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Enter download mode if the download key pressed.\n\nSigned-off-by: Andy Yan <andy.yan@rock-chips.com>\n---\n\n arch/arm/mach-rockchip/boot_mode.c     | 27 ++++++++++++++++++++++++++-\n board/rockchip/evb_rk3399/evb-rk3399.c | 28 ++++++++++++++++++++++++++++\n 2 files changed, 54 insertions(+), 1 deletion(-)","diff":"diff --git a/arch/arm/mach-rockchip/boot_mode.c b/arch/arm/mach-rockchip/boot_mode.c\nindex 7b3cbc5..bff1cbc 100644\n--- a/arch/arm/mach-rockchip/boot_mode.c\n+++ b/arch/arm/mach-rockchip/boot_mode.c\n@@ -8,11 +8,36 @@\n #include <asm/io.h>\n #include <asm/arch/boot_mode.h>\n \n+void set_back_to_bootrom_dnl_flag(void)\n+{\n+\twritel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);\n+}\n+\n+/*\n+ * some boards use a adc key, but some use gpio\n+ */\n+__weak int rockchip_dnl_key_pressed(void)\n+{\n+\treturn false;\n+}\n+\n+void rockchip_dnl_mode_check(void)\n+{\n+\tif (rockchip_dnl_key_pressed()) {\n+\t\tprintf(\"download key pressed, enter download mode...\");\n+\t\tset_back_to_bootrom_dnl_flag();\n+\t\tdo_reset(NULL, 0, 0, NULL);\n+\t}\n+}\n+\n int setup_boot_mode(void)\n {\n \tvoid* reg = (void *)CONFIG_ROCKCHIP_BOOT_MODE_REG;\n-\tint boot_mode = readl(reg);\n+\tint boot_mode;\n+\n+\trockchip_dnl_mode_check();\n \n+\tboot_mode = readl(reg);\n \tdebug(\"boot mode %x.\\n\", boot_mode);\n \n \t/* Clear boot mode */\ndiff --git a/board/rockchip/evb_rk3399/evb-rk3399.c b/board/rockchip/evb_rk3399/evb-rk3399.c\nindex d50c59d..738d942 100644\n--- a/board/rockchip/evb_rk3399/evb-rk3399.c\n+++ b/board/rockchip/evb_rk3399/evb-rk3399.c\n@@ -4,6 +4,7 @@\n  * SPDX-License-Identifier:     GPL-2.0+\n  */\n #include <common.h>\n+#include <adc.h>\n #include <dm.h>\n #include <ram.h>\n #include <dm/pinctrl.h>\n@@ -13,6 +14,33 @@\n \n DECLARE_GLOBAL_DATA_PTR;\n \n+#define KEY_DOWN_MIN_VAL\t1\n+#define KEY_DOWN_MAX_VAL\t20\n+\n+int rockchip_dnl_key_pressed(void)\n+{\n+\tunsigned int ret;\n+\tunsigned int i;\n+\tunsigned int val;\n+\tint cnt = 0;\n+\n+\tfor (i = 0; i < 10; i++) {\n+\t\tret = adc_channel_single_shot(\"saradc\", 1, &val);\n+\t\tif (ret) {\n+\t\t\tprintf(\"%s adc_channel_single_shot fail!\\n\", __func__);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif ((val >= KEY_DOWN_MIN_VAL) && (val <= KEY_DOWN_MAX_VAL))\n+\t\t\tcnt++;\n+\t}\n+\n+\tif (cnt >= 8)\n+\t\treturn true;\n+\telse\n+\t\treturn false;\n+}\n+\n int board_init(void)\n {\n \tstruct udevice *pinctrl, *regulator;\n","prefixes":["U-Boot","3/3"]}