From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D701C433F5 for ; Sun, 8 May 2022 15:11:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0977284099; Sun, 8 May 2022 17:09:27 +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="M+gjrsus"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3091783F52; Sun, 8 May 2022 17:08:58 +0200 (CEST) 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 755B283F3C for ; Sun, 8 May 2022 17:08:40 +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:40 -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=6ihoxWv8/uC8xQRG1L2WUpIYUaBN/wxERBSqihzbtP0=; b=M+gjrsusA4BHiwhV87c44GOT8cbrYE09RR11jmxhtzRAJ2i0ZIKnhqH8XD7xcIVeX8 oeuSY1BMpBGa4g0Jmdws9iCNUoa4baqNn6hpJB4rE4rxuV6hnCYIMyAZtmEuUiKuWPLH yhrZdzMHnE28VHeDLR0SqTU28nz6q2qwI9QDNpAnKd2IAYq+O+77UIbHXWLZq4adpVlh tSnnqHl3QUPWXcZDblJmnBbUqYUv7Vv0dGBROPB8vONgP6SkG96JeyCPqmAMEDtKwHbq UOwwDHdHmXSwFT64MSTLYszObKVrGM6qHPb/UrKvvl5icdsxGwXIfHinnL08GxAQENb8 uiyQ== 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=6ihoxWv8/uC8xQRG1L2WUpIYUaBN/wxERBSqihzbtP0=; b=h+XcBqgx9oK+PLTCse7tyTmXpl6ZUAda+dMJYdkV7Rd4JZtZyeT9y4CKkGGGkizMKj //0K/rU8FzVrgnJMzzbhpfsN5RZLyHa2pxzi8oj4G7mTUWvjgnkoAoMs8q7WXZIB8Occ MXL/THfFXwESX07zovIT6puShsQmnaL5ePN1hxdbxnECEYWQgaYxGWfvoOasbSB+uSr+ G3R2wHmbGKigFJTIc/eI7bYGNjaU4iI5KlSyd6Mqe0f7fvFFh4IPAF2T/+lX83FUibm4 pGjemgQy3np6VJ7CfuU7KB+FwmlR2Mb7njOEpPeghBspvrCV9xHzXcIjhm30UUyKEivT YdvA== X-Gm-Message-State: AOAM5339ON6TDfu+Hu30LfFHNYEbf4z2eyBo9aE94q/R0K9rDKFhr4Np QqE73NJyA+Yt4LiQbuVh2UM= X-Google-Smtp-Source: ABdhPJxGD6oW34W2VP+8IJ+/FmvgCAaOSAwoWZP+unN+wBsZBoShPBkxO7PaJOYrKMRbmPqWMS4c8g== X-Received: by 2002:a17:907:3e0f:b0:6f4:5cfd:e6bb with SMTP id hp15-20020a1709073e0f00b006f45cfde6bbmr11129474ejc.38.1652022520239; 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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 08:08:39 -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 11/17] rockchip: adc: fix adc timer Date: Sun, 8 May 2022 17:08:19 +0200 Message-Id: <20220508150825.21711-12-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 Content-Transfer-Encoding: 8bit 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 Replace adc timer counter by SoC timer to prevent EBUSY notifications. Signed-off-by: Johan Jonker --- drivers/adc/adc-uclass.c | 10 ++++++---- drivers/adc/rockchip-saradc.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c index 3dbdfa6f..a539f999 100644 --- a/drivers/adc/adc-uclass.c +++ b/drivers/adc/adc-uclass.c @@ -146,6 +146,7 @@ int adc_channel_data(struct udevice *dev, int channel, unsigned int *data) struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); const struct adc_ops *ops = dev_get_driver_ops(dev); unsigned int timeout_us = uc_pdata->data_timeout_us; + unsigned long start_time; int ret; if (!ops->channel_data) @@ -155,14 +156,14 @@ int adc_channel_data(struct udevice *dev, int channel, unsigned int *data) if (ret) return ret; + start_time = get_timer(0); do { ret = ops->channel_data(dev, channel, data); if (!ret || ret != -EBUSY) break; - /* TODO: use timer uclass (for early calls). */ sdelay(5); - } while (timeout_us--); + } while (get_timer(start_time) < timeout_us); return ret; } @@ -173,6 +174,7 @@ int adc_channels_data(struct udevice *dev, unsigned int channel_mask, struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); unsigned int timeout_us = uc_pdata->multidata_timeout_us; const struct adc_ops *ops = dev_get_driver_ops(dev); + unsigned long start_time; int ret; if (!ops->channels_data) @@ -182,14 +184,14 @@ int adc_channels_data(struct udevice *dev, unsigned int channel_mask, if (ret) return ret; + start_time = get_timer(0); do { ret = ops->channels_data(dev, channel_mask, channels); if (!ret || ret != -EBUSY) break; - /* TODO: use timer uclass (for early calls). */ sdelay(5); - } while (timeout_us--); + } while (get_timer(start_time) < timeout_us); return ret; } diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c index f61cfe4b..e6a0341d 100644 --- a/drivers/adc/rockchip-saradc.c +++ b/drivers/adc/rockchip-saradc.c @@ -183,7 +183,7 @@ int rockchip_saradc_of_to_plat(struct udevice *dev) uc_pdata->data_mask = (1 << priv->data->num_bits) - 1; uc_pdata->data_format = ADC_DATA_FORMAT_BIN; - uc_pdata->data_timeout_us = SARADC_TIMEOUT / 5; + uc_pdata->data_timeout_us = SARADC_TIMEOUT; uc_pdata->channel_mask = (1 << priv->data->num_channels) - 1; return 0; -- 2.20.1