{"id":813749,"url":"http://patchwork.ozlabs.org/api/patches/813749/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1505379140-5490-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":"<1505379140-5490-1-git-send-email-andy.yan@rock-chips.com>","list_archive_url":null,"date":"2017-09-14T08:52:20","name":"[U-Boot,v2,3/3] rockchip: check download key before bootup","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"231f0a70b1175306d8b7cf27f2209b9c6f230235","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/1505379140-5490-1-git-send-email-andy.yan@rock-chips.com/mbox/","series":[{"id":3052,"url":"http://patchwork.ozlabs.org/api/series/3052/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3052","date":"2017-09-14T08:51:06","name":"support enter download mode on rockchip platform","version":2,"mbox":"http://patchwork.ozlabs.org/series/3052/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/813749/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/813749/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 3xtC4731t9z9sPs\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 18:53:27 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 2483DC21F2C; Thu, 14 Sep 2017 08:52:51 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 30442C21F18;\n\tThu, 14 Sep 2017 08:52:49 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 7B7F2C21EE2; Thu, 14 Sep 2017 08:52:35 +0000 (UTC)","from regular1.263xmail.com (regular1.263xmail.com [211.150.99.131])\n\tby lists.denx.de (Postfix) with ESMTPS id 7BE06C21E78\n\tfor <u-boot@lists.denx.de>; Thu, 14 Sep 2017 08:52:31 +0000 (UTC)","from andy.yan?rock-chips.com (unknown [192.168.167.160])\n\tby regular1.263xmail.com (Postfix) with ESMTP id 444825E8A\n\tfor <u-boot@lists.denx.de>; Thu, 14 Sep 2017 16:52:27 +0800 (CST)","from localhost.localdomain (localhost [127.0.0.1])\n\tby smtp.263.net (Postfix) with ESMTPA id 2FE08389;\n\tThu, 14 Sep 2017 16:52:24 +0800 (CST)","from localhost.localdomain (unknown [58.22.7.114])\n\tby smtp.263.net (Postfix) whith ESMTP id 5401WHYYYL;\n\tThu, 14 Sep 2017 16:52:26 +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":"sjg@chromium.org","X-SENDER-IP":"58.22.7.114","X-LOGIN-NAME":"andy.yan@rock-chips.com","X-UNIQUE-TAG":"<4263e149801eab2158b05a3be3c0f212>","X-ATTACHMENT-NUM":"0","X-SENDER":"yxj@rock-chips.com","X-DNS-TYPE":"0","From":"Andy Yan <andy.yan@rock-chips.com>","To":"sjg@chromium.org,\n\tphilipp.tomsich@theobroma-systems.com","Date":"Thu, 14 Sep 2017 16:52:20 +0800","Message-Id":"<1505379140-5490-1-git-send-email-andy.yan@rock-chips.com>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1505379066-5334-1-git-send-email-andy.yan@rock-chips.com>","References":"<1505379066-5334-1-git-send-email-andy.yan@rock-chips.com>","Cc":"u-boot@lists.denx.de, Andy Yan <andy.yan@rock-chips.com>,\n\tdavid.wu@rock-chips.com","Subject":"[U-Boot] [PATCH v2 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\nChanges in v2:\n- more document\n- move adc key detect as the defaut\n\n arch/arm/mach-rockchip/boot_mode.c | 43 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 43 insertions(+)","diff":"diff --git a/arch/arm/mach-rockchip/boot_mode.c b/arch/arm/mach-rockchip/boot_mode.c\nindex 4652490..bf0a410 100644\n--- a/arch/arm/mach-rockchip/boot_mode.c\n+++ b/arch/arm/mach-rockchip/boot_mode.c\n@@ -5,14 +5,57 @@\n  */\n \n #include <common.h>\n+#include <adc.h>\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+ * detect download key status by adc, most rockchip\n+ * based boards use adc sample the download key status,\n+ * but there are also some use gpio. So it's better to\n+ * make this a weak function that can be override by\n+ * some special boards.\n+ */\n+#define KEY_DOWN_MIN_VAL\t0\n+#define KEY_DOWN_MAX_VAL\t30\n+\n+__weak int rockchip_dnl_key_pressed(void)\n+{\n+\tunsigned int val;\n+\n+\tif (adc_channel_single_shot(\"saradc\", 1, &val)) {\n+\t\tprintf(\"%s adc_channel_single_shot fail!\\n\", __func__);\n+\t\treturn false;\n+\t}\n+\n+\tif ((val >= KEY_DOWN_MIN_VAL) && (val <= KEY_DOWN_MAX_VAL))\n+\t\treturn true;\n+\telse\n+\t\treturn false;\n+}\n+\n+void rockchip_dnl_mode_check(void)\n+{\n+\tif (rockchip_dnl_key_pressed()) {\n+\t\tprintf(\"download key pressed, entering 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 \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 */\n","prefixes":["U-Boot","v2","3/3"]}