[PATCH 3/6] misc: k3_avs: Add k3_check_opp function

Neha Malcom Francis n-francis at ti.com
Thu Oct 17 12:36:14 CEST 2024


Hi Aniket

On 17/10/24 11:59, Aniket Limaye wrote:
> From: Reid Tonking <reidt at ti.com>
> 
> Useful when trying to check if an opp efuse is burned in or not.
> 
> k3_avs driver checks opp_ids when probing and overwrites the voltage
> values in vd_data for the respective board. This can be called to check
> that data and returns 0 if valid.
> 
> Signed-off-by: Reid Tonking <reidt at ti.com>
> Signed-off-by: Aniket Limaye <a-limaye at ti.com>
> ---
>   drivers/misc/k3_avs.c | 25 +++++++++++++++++++++++++
>   include/k3-avs.h      |  1 +
>   2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c
> index 9d950d034a5..90cd9dfe7f9 100644
> --- a/drivers/misc/k3_avs.c
> +++ b/drivers/misc/k3_avs.c
> @@ -192,6 +192,31 @@ static int match_opp(struct vd_data *vd, u32 freq)
>   	return -EINVAL;
>   }
>   
> +/**
> + * k3_check_opp: Check for presence of opp efuse
> + * @opp_id: opp id to check if voltage is present
> + *
> + * Checks to see if an opp has voltage. k3_avs probe will populate
> + * votlage data if efuse is present. Returns 0 if data is valid.
> + */
> +int k3_check_opp(struct udevice *dev, int vdd_id, int opp_id)

Can this be a static function?

> +{
> +	struct k3_avs_privdata *priv = dev_get_priv(dev);
> +	struct vd_data *vd;
> +	int volt;
> +
> +	vd = get_vd(priv, vdd_id);
> +	if (!vd)
> +		return -EINVAL;
> +
> +	volt = vd->opps[opp_id].volt;
> +	if (volt)
> +		return 0;
> +
> +	printf("No efuse found for opp_%d\n", opp_id);
> +	return -EINVAL;
> +}
> +
>   /**
>    * k3_avs_notify_freq: Notify clock rate change towards AVS subsystem
>    * @dev_id: Device ID for the clock to be changed
> diff --git a/include/k3-avs.h b/include/k3-avs.h
> index f6f1031c9cc..41a1da36356 100644
> --- a/include/k3-avs.h
> +++ b/include/k3-avs.h
> @@ -27,5 +27,6 @@
>   
>   int k3_avs_set_opp(struct udevice *dev, int vdd_id, int opp_id);
>   int k3_avs_notify_freq(int dev_id, int clk_id, u32 freq);
> +int k3_check_opp(struct udevice *dev, int vdd_id, int opp_id);
>   
>   #endif

-- 
Thanking You
Neha Malcom Francis


More information about the U-Boot mailing list