All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Jonker <jbx6244@gmail.com>
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	[thread overview]
Message-ID: <20220508150825.21711-12-jbx6244@gmail.com> (raw)
In-Reply-To: <20220508150825.21711-1-jbx6244@gmail.com>

Replace adc timer counter by SoC timer to prevent
EBUSY notifications.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 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


  parent reply	other threads:[~2022-05-08 15:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08 15:08 [PATCH v1 00/17] Add rk3066 ADC and USB support Johan Jonker
2022-05-08 15:08 ` [PATCH v1 01/17] rockchip: spl: fix reloc gd and FDT blob pointer Johan Jonker
2022-05-08 15:08 ` [PATCH v1 02/17] rockchip: spl: allow more boot devices Johan Jonker
2022-05-08 15:08 ` [PATCH v1 03/17] rockchip: spl-boot-order: add usb boot option Johan Jonker
2022-05-08 15:08 ` [PATCH v1 04/17] rockchip: board: allow spl compile for usb init functions Johan Jonker
2022-05-08 15:08 ` [PATCH v1 05/17] rockchip: usb: gadget: rockusb: enable spl compile Johan Jonker
2022-05-08 15:08 ` [PATCH v1 06/17] rockchip: configs: mk808: add spl usb configs Johan Jonker
2022-05-08 15:08 ` [PATCH v1 07/17] arm: dts: rockchip: mk808: add adc usb required properties for spl Johan Jonker
2022-05-08 15:08 ` [PATCH v1 08/17] rockchip: adc: enable spl compile class driver Johan Jonker
2022-05-08 15:08 ` [PATCH v1 09/17] rockchip: adc: reduce error notifications from " Johan Jonker
2022-05-08 15:08 ` [PATCH v1 10/17] rockchip: adc: enable spl compile rockchip-saradc driver Johan Jonker
2022-05-08 15:08 ` Johan Jonker [this message]
2022-05-08 15:08 ` [PATCH v1 12/17] rockchip: adc: fix the hangups Johan Jonker
2022-05-08 15:08 ` [PATCH v1 13/17] rockchip: adc: make adc branch compile in SPL Johan Jonker
2022-05-08 15:08 ` [PATCH v1 14/17] rockchip: adc: move config items in a sub menu Johan Jonker
2022-05-08 15:08 ` [PATCH v1 15/17] rockchip: rk3066: config nand data pins in spl Johan Jonker
2022-05-08 15:08 ` [PATCH v1 16/17] rockchip: rk3066: add recovery mode " Johan Jonker
2022-05-08 15:08 ` [PATCH v1 17/17] rockchip: configs: mk808: enable usb support Johan Jonker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220508150825.21711-12-jbx6244@gmail.com \
    --to=jbx6244@gmail.com \
    --cc=kever.yang@rock-chips.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.