[PATCH 10/20] clk: imx: pfd: add set_rate()

Lukasz Majewski lukma at denx.de
Sun Dec 8 15:38:04 CET 2019


On Wed,  4 Dec 2019 18:44:29 +0100
Giulio Benetti <giulio.benetti at benettiengineering.com> wrote:

> Implement set_rate() for pfd.
> 
> Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
> ---
>  drivers/clk/imx/clk-pfd.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/clk/imx/clk-pfd.c b/drivers/clk/imx/clk-pfd.c
> index 188b2b3b90..4ae55f5a07 100644
> --- a/drivers/clk/imx/clk-pfd.c
> +++ b/drivers/clk/imx/clk-pfd.c
> @@ -52,8 +52,30 @@ static unsigned long clk_pfd_recalc_rate(struct
> clk *clk) return tmp;
>  }
>  
> +static unsigned long clk_pfd_set_rate(struct clk *clk, unsigned long
> rate) +{
> +	struct clk_pfd *pfd = to_clk_pfd(clk);
> +	unsigned long parent_rate = clk_get_parent_rate(clk);
> +	u64 tmp = parent_rate;
> +	u8 frac;
> +
> +	tmp = tmp * 18 + rate / 2;
> +	do_div(tmp, rate);
> +	frac = tmp;
> +	if (frac < 12)
> +		frac = 12;
> +	else if (frac > 35)
> +		frac = 35;
> +
> +	writel(0x3f << (pfd->idx * 8), pfd->reg + CLR);
> +	writel(frac << (pfd->idx * 8), pfd->reg + SET);
> +
> +	return 0;
> +}
> +
>  static const struct clk_ops clk_pfd_ops = {
>  	.get_rate	= clk_pfd_recalc_rate,
> +	.set_rate	= clk_pfd_set_rate,
>  };
>  
>  struct clk *imx_clk_pfd(const char *name, const char *parent_name,

Reviewed-by: Lukasz Majewski <lukma at denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191208/6008cdc2/attachment.sig>


More information about the U-Boot mailing list