[PATCH 14/20] serial_lpuart: add clock enable if CONFIG_CLK is defined

Simon Glass sjg at chromium.org
Mon Dec 30 02:21:22 CET 2019


Hi Giulio,

On Tue, 17 Dec 2019 at 11:37, Giulio Benetti
<giulio.benetti at benettiengineering.com> wrote:
>
> Hi Lukasz and all,
>
> On 12/10/19 12:48 AM, Lukasz Majewski wrote:
> > On Mon, 9 Dec 2019 16:20:10 +0100
> > Giulio Benetti <giulio.benetti at benettiengineering.com> wrote:
> >
> >> Hi Lukasz,
> >>
> >> On 12/8/19 3:52 PM, Lukasz Majewski wrote:
> >>> On Wed,  4 Dec 2019 18:44:33 +0100
> >>> Giulio Benetti <giulio.benetti at benettiengineering.com> wrote:
> >>>
> >>>> This driver assumes that lpuart clock is already enabled before
> >>>> probing but using DM only lpuart won't be automatically enabled so
> >>>> add clk_enable() when probing if CONFIG_CLK is defined.
> >>>>
> >>>> Signed-off-by: Giulio Benetti
> >>>> <giulio.benetti at benettiengineering.com> ---
> >>>>    drivers/serial/serial_lpuart.c | 13 +++++++++++++
> >>>>    1 file changed, 13 insertions(+)
> >>>>
> >>>> diff --git a/drivers/serial/serial_lpuart.c
> >>>> b/drivers/serial/serial_lpuart.c index 4b0a964d1b..52bd2baf7d
> >>>> 100644 --- a/drivers/serial/serial_lpuart.c
> >>>> +++ b/drivers/serial/serial_lpuart.c
> >>>> @@ -483,6 +483,19 @@ static int lpuart_serial_pending(struct
> >>>> udevice *dev, bool input)
> >>>>    static int lpuart_serial_probe(struct udevice *dev)
> >>>>    {
> >>>> +#if CONFIG_IS_ENABLED(CLK)
> >>>> +  struct clk per_clk;
> >>>> +  int ret;
> >>>> +
> >>>> +  ret = clk_get_by_name(dev, "per", &per_clk);
>
> While adding support for OF_PLATDATA, I've realized that when using
> OF_PLATDATA I can only use clk_get_by_index_platdata() but often imx
> peripheral drivers(as done in Linux) get clock by name("per" clock)
> instead of other clock sources. So here the problem is that I can't know
> for sure which id "per" clock source will have. I wouldn't use 0 as
> default clock-id since it's not sure "per" will be the 0 index.
> And this will occur for fsl_esdhc_imx.c driver too.
>
> Do you have any suggestions?

I can't think of anything other than defining the values perhaps in a
header, then asserting that they are valid in the non-OF_PLATDATA
code.

I'm not sure how we could enhance of-platdata to support this. Of
course, adding the strings would be bad since we are trying to
minimise overhere.

Regards,
Simon


More information about the U-Boot mailing list