Message ID | 20200110144711.81938-16-giulio.benetti@benettiengineering.com |
---|---|
State | Accepted |
Commit | 55631db8bd6d63d4049ca7301f06aaa0e6e6824e |
Headers | show |
Series | Add i.MXRT family support | expand |
> 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. If clock is not > found, because DM is not used, let's emit a warning and proceed, because > serial clock could also be already enabled by non DM code. If clock is > found but cna't be enabled then return with error. > Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com> Applied to u-boot-imx, master, thanks ! Best regards, Stefano Babic
Hi Giulio, > 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. If clock is not > found, because DM is not used, let's emit a warning and proceed, > because serial clock could also be already enabled by non DM code. If > clock is found but cna't be enabled then return with error. ^^^^ - can't > > Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com> > --- > V1->V2: > * moved error as warning if clk not found > --- > drivers/serial/serial_lpuart.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/serial/serial_lpuart.c > b/drivers/serial/serial_lpuart.c index 4b0a964d1b..b2ec56172e 100644 > --- a/drivers/serial/serial_lpuart.c > +++ b/drivers/serial/serial_lpuart.c > @@ -483,6 +483,22 @@ 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) { > + ret = clk_enable(&per_clk); > + if (ret) { > + dev_err(dev, "Failed to get per clk: %d\n", > ret); > + return ret; > + } > + } else { > + dev_warn(dev, "Failed to get per clk: %d\n", ret); ^^^^^^ - please change to debug() as some devices may enable CONFIG_CLK, but did not yet support (have implemented) this clock in CCF. > + } > +#endif > + > if (is_lpuart32(dev)) > return _lpuart32_serial_init(dev); > else 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/20200128/5e819bd1/attachment.sig>
Hi Lukasz, On 1/28/20 9:36 AM, Lukasz Majewski wrote: > Hi Giulio, > >> 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. If clock is not >> found, because DM is not used, let's emit a warning and proceed, >> because serial clock could also be already enabled by non DM code. If >> clock is found but cna't be enabled then return with error. > ^^^^ - can't It's too late now, but... >> >> Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com> >> --- >> V1->V2: >> * moved error as warning if clk not found >> --- >> drivers/serial/serial_lpuart.c | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/drivers/serial/serial_lpuart.c >> b/drivers/serial/serial_lpuart.c index 4b0a964d1b..b2ec56172e 100644 >> --- a/drivers/serial/serial_lpuart.c >> +++ b/drivers/serial/serial_lpuart.c >> @@ -483,6 +483,22 @@ 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) { >> + ret = clk_enable(&per_clk); >> + if (ret) { >> + dev_err(dev, "Failed to get per clk: %d\n", >> ret); >> + return ret; >> + } >> + } else { >> + dev_warn(dev, "Failed to get per clk: %d\n", ret); > ^^^^^^ - please change to debug() as some devices may > enable CONFIG_CLK, but did not yet support (have > implemented) this clock in CCF. ...not for this, I'm going to send a patch changing this string. Best regards
diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c index 4b0a964d1b..b2ec56172e 100644 --- a/drivers/serial/serial_lpuart.c +++ b/drivers/serial/serial_lpuart.c @@ -483,6 +483,22 @@ 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) { + ret = clk_enable(&per_clk); + if (ret) { + dev_err(dev, "Failed to get per clk: %d\n", ret); + return ret; + } + } else { + dev_warn(dev, "Failed to get per clk: %d\n", ret); + } +#endif + if (is_lpuart32(dev)) return _lpuart32_serial_init(dev); else
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. If clock is not found, because DM is not used, let's emit a warning and proceed, because serial clock could also be already enabled by non DM code. If clock is found but cna't be enabled then return with error. Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com> --- V1->V2: * moved error as warning if clk not found --- drivers/serial/serial_lpuart.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)