From patchwork Sun May 8 15:08:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Jonker X-Patchwork-Id: 1628102 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=kLcNjZcp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kx77K198Lz9tkB for ; Mon, 9 May 2022 01:11:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A2164841B3; Sun, 8 May 2022 17:09:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kLcNjZcp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 033FB83F64; Sun, 8 May 2022 17:09:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0D63383F40 for ; Sun, 8 May 2022 17:08:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jbx6244@gmail.com Received: by mail-ej1-x62a.google.com with SMTP id gh6so22547668ejb.0 for ; Sun, 08 May 2022 08:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A3Re1fbppWqciQry1ghFhhNiIcaMuTaBHvH0pDwDEAY=; b=kLcNjZcpp3G0fBKG5soyrQRXp1gY6J+scagFgpJDPf6QNWGcw6iU8rAcvBAgr0B7Wt XAcxfgZDFV20Bu5qaRhDlxNK3Rr6tVEwLKy9CcZgxweC+fKmgQQkQTgB4ncrLVp1rFi0 6ZA7FKQFuZAy3jxh0MA8nJukIHoWv06fNZnDP7VrDZ+FxC4E8wkZUD+SDxxUgvjNuY1S NuXKW05c2JAi4d5nAWbaZO4raGj3tiT1+uQBEIsdiWn+UDFV9JaAv7V2Nv6nB+D7mPFU 7yUldYNpWXvnsCBVZQEJhcdJalhsy4ZINY7qeMIMIiDeS+dC+UWY8kzPR33MDWH3nDXw PaEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A3Re1fbppWqciQry1ghFhhNiIcaMuTaBHvH0pDwDEAY=; b=DwAvdY5zKwSYYdtnO2df10iqizkBIjjIamDKsDsJ0KsSvtrDVS/lO7wdaVOakSF+LE 54D3Uh27jp2FNIzwEvwiV7VVntm1s+qDyHILsbiNsDY9xQsanob5dNlSMcu+OTVswPqs Pcq9KLajC6rF6rcMSZbJ9Ky9jg9AwdreXBpIUS7tviDkU3lEAcisx6SN7bDe1mGam8LY dsaeTLNe1Kd4bJr9pJIk7hZM9Xh1Aldcv1tEbi0dP7M9r6OmmD7VUT3oy8hHESGRmU5b OODK7BE0kKB/SDdbLwMJ2CbkOgbc2WXgNLjHVVfd64uKOruIuJmUzDHjcRhQY+kRd6FN F+xg== X-Gm-Message-State: AOAM533qQlGsKt6QtQmnlZpO6Z96pUy2zOKoC7oGFz/xToh7XqQHVFPm 8Tio/wYwoR2NP4ezyLeHJb4= X-Google-Smtp-Source: ABdhPJy0U2W9gDLPDQm1jJI6WOoo/jFgFAhr4lmjKkTHExj1BtEsIagP0dxgbtOyPS9vt4a41G2Iig== X-Received: by 2002:a17:907:6eaa:b0:6f4:7e59:feae with SMTP id sh42-20020a1709076eaa00b006f47e59feaemr10967460ejc.99.1652022520868; Sun, 08 May 2022 08:08:40 -0700 (PDT) Received: from debian.home (81-204-249-205.fixed.kpn.net. [81.204.249.205]) by smtp.gmail.com with ESMTPSA id yl26-20020a17090693fa00b006f3ef214dc2sm4102721ejb.40.2022.05.08.08.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 08:08:40 -0700 (PDT) From: Johan Jonker To: kever.yang@rock-chips.com Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, lukma@denx.de, marex@denx.de, u-boot@lists.denx.de Subject: [PATCH v1 12/17] rockchip: adc: fix the hangups Date: Sun, 8 May 2022 17:08:20 +0200 Message-Id: <20220508150825.21711-13-jbx6244@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220508150825.21711-1-jbx6244@gmail.com> References: <20220508150825.21711-1-jbx6244@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The Rockchip saradc behaves strange when doing an "adc scan" with hang ups. Fix by adding an adc power down before the settings are made. Similair to what TRM recommands follow this flow below: Power-down A/D Converter in SARADC_CTRL[3] Power-up A/D Converter in SARADC_CTRL[3] and select input channel of A/D Converter in SARADC_CTRL[2:0] bit Wait an A/D interrupt or poll the SARADC_STAS register to determine when the conversion is completed Read the conversion result in the SARADC_DATA register Signed-off-by: Johan Jonker --- drivers/adc/rockchip-saradc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c index e6a0341d..fb0f2e03 100644 --- a/drivers/adc/rockchip-saradc.c +++ b/drivers/adc/rockchip-saradc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -82,6 +83,10 @@ int rockchip_saradc_start_channel(struct udevice *dev, int channel) return -EINVAL; } + writel(0, &priv->regs->ctrl); + + udelay(1); + /* 8 clock periods as delay between power up and start cmd */ writel(8, &priv->regs->dly_pu_soc);