From patchwork Tue Nov 28 06:33:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Yan X-Patchwork-Id: 841987 X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ymDQx1g16z9sPt for ; Tue, 28 Nov 2017 17:34:17 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C5F57C21D8C; Tue, 28 Nov 2017 06:34:14 +0000 (UTC) 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_BLOCKED, RCVD_IN_SORBS_WEB autolearn=no autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 25111C21D56; Tue, 28 Nov 2017 06:34:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6F6EFC21C4C; Tue, 28 Nov 2017 06:34:10 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.140]) by lists.denx.de (Postfix) with ESMTPS id 56A94C21C29 for ; Tue, 28 Nov 2017 06:34:09 +0000 (UTC) Received: from andy.yan?rock-chips.com (unknown [192.168.167.205]) by regular1.263xmail.com (Postfix) with ESMTP id 30B2D4A76 for ; Tue, 28 Nov 2017 14:34:04 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 876F23B0; Tue, 28 Nov 2017 14:34:04 +0800 (CST) 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: 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 12936IANMZQ; Tue, 28 Nov 2017 14:34:05 +0800 (CST) From: Andy Yan To: philipp.tomsich@theobroma-systems.com Date: Tue, 28 Nov 2017 14:33:58 +0800 Message-Id: <1511850838-32621-1-git-send-email-andy.yan@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511850761-32567-1-git-send-email-andy.yan@rock-chips.com> References: <1511850761-32567-1-git-send-email-andy.yan@rock-chips.com> Cc: u-boot@lists.denx.de, Andy Yan , david.wu@rock-chips.com Subject: [U-Boot] [PATCH 1/3] rockchip: boot mode: parse adc channel from dts X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Most the current rockchip based boards use adc channel 1 detect the download key, but there are also some boards like rv1108 based plaform use adc channel 0. So we parse the adc channel from dts if we can get it, otherwise we use the channel 1 as default. Signed-off-by: Andy Yan Acked-by: Philipp Tomsich --- arch/arm/mach-rockchip/boot_mode.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/boot_mode.c b/arch/arm/mach-rockchip/boot_mode.c index 942849f..49dfd39 100644 --- a/arch/arm/mach-rockchip/boot_mode.c +++ b/arch/arm/mach-rockchip/boot_mode.c @@ -8,6 +8,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; void set_back_to_bootrom_dnl_flag(void) { @@ -26,9 +29,19 @@ void set_back_to_bootrom_dnl_flag(void) __weak int rockchip_dnl_key_pressed(void) { + const void *blob = gd->fdt_blob; unsigned int val; + int channel = 1; + int node; + u32 chns[2]; + + node = fdt_node_offset_by_compatible(blob, 0, "adc-keys"); + if (node >= 0) { + if (!fdtdec_get_int_array(blob, node, "io-channels", chns, 2)) + channel = chns[1]; + } - if (adc_channel_single_shot("saradc", 1, &val)) { + if (adc_channel_single_shot("saradc", channel, &val)) { pr_err("%s: adc_channel_single_shot fail!\n", __func__); return false; }