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

Lukasz Majewski
2019-12-09T23:48:38Z

On Mon, 9 Dec 2019 16:20:10 +0100
Giulio Benetti <giulio.benetti@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@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@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);
> >> + if (ret) {
> >> + dev_err(dev, "Failed to get per clk: %d\n", ret);
> >> + return ret;
> >> + }
> >> +
> >> + clk_enable(&per_clk);
> >> +#endif
> >> +
> >
> > I think that this change will _silently_ break all boards which do
> > have CONFIG_CLK enabled (for some clocks/drivers), but did not yet
> > provided CCF definition for lpuart clock.
>
> Oops, yes, you're totally right.
> Would it be correct if I try to retrieve clock and otherwise I
> fallback sending warnings like following?:
>
> `
> 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);
> if (!ret) {
> ret = clk_enable(&per_clk);
> if (ret) {
> dev_err(dev, "Failed to get per clk: %d\n",
> ret);
> return;
> }
> } else {
> dev_warn(dev, "Failed to get per clk: %d\n",
> ret);
> }
> #endif
>

Yes, warning is OK.

> ....
>
> `
>
> Best regards

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/20191210/ff2188d8/attachment.sig>