[PATCH v3 10/16] rockchip: adc: rockchip-saradc: factor out stop callback
Kever Yang
kever.yang at rock-chips.com
Mon Mar 11 11:13:16 CET 2024
On 2024/3/4 19:30, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz at theobroma-systems.com>
>
> SARADC v2 doesn't have a stop mechanism once in single mode. In series
> conversion, the logic is different anyway. Therefore, let's abstract
> this function so that it can be provided from the udevice.data pointer.
>
> Cc: Quentin Schulz <foss+uboot at 0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz at theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>
Thanks,
- Kever
> ---
> drivers/adc/rockchip-saradc.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
> index 607d10b5b70..b5df58fe3eb 100644
> --- a/drivers/adc/rockchip-saradc.c
> +++ b/drivers/adc/rockchip-saradc.c
> @@ -39,6 +39,7 @@ struct rockchip_saradc_data {
> unsigned long clk_rate;
> int (*channel_data)(struct udevice *dev, int channel, unsigned int *data);
> int (*start_channel)(struct udevice *dev, int channel);
> + int (*stop)(struct udevice *dev);
> };
>
> struct rockchip_saradc_priv {
> @@ -124,13 +125,29 @@ int rockchip_saradc_start_channel(struct udevice *dev, int channel)
> return 0;
> }
>
> -int rockchip_saradc_stop(struct udevice *dev)
> +int rockchip_saradc_stop_v1(struct udevice *dev)
> {
> struct rockchip_saradc_priv *priv = dev_get_priv(dev);
>
> /* Power down adc */
> writel(0, &priv->regs.v1->ctrl);
>
> + return 0;
> +}
> +
> +int rockchip_saradc_stop(struct udevice *dev)
> +{
> + struct rockchip_saradc_priv *priv = dev_get_priv(dev);
> +
> + if (priv->data->stop) {
> + int ret = priv->data->stop(dev);
> +
> + if (ret) {
> + pr_err("Error stopping channel, %d!", ret);
> + return ret;
> + }
> + }
> +
> priv->active_channel = -1;
>
> return 0;
> @@ -209,6 +226,7 @@ static const struct rockchip_saradc_data saradc_data = {
> .clk_rate = 1000000,
> .channel_data = rockchip_saradc_channel_data_v1,
> .start_channel = rockchip_saradc_start_channel_v1,
> + .stop = rockchip_saradc_stop_v1,
> };
>
> static const struct rockchip_saradc_data rk3066_tsadc_data = {
> @@ -217,6 +235,7 @@ static const struct rockchip_saradc_data rk3066_tsadc_data = {
> .clk_rate = 50000,
> .channel_data = rockchip_saradc_channel_data_v1,
> .start_channel = rockchip_saradc_start_channel_v1,
> + .stop = rockchip_saradc_stop_v1,
> };
>
> static const struct rockchip_saradc_data rk3399_saradc_data = {
> @@ -225,6 +244,7 @@ static const struct rockchip_saradc_data rk3399_saradc_data = {
> .clk_rate = 1000000,
> .channel_data = rockchip_saradc_channel_data_v1,
> .start_channel = rockchip_saradc_start_channel_v1,
> + .stop = rockchip_saradc_stop_v1,
> };
>
> static const struct udevice_id rockchip_saradc_ids[] = {
>
More information about the U-Boot
mailing list