linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] serial: max310x: Use clock-names property matching to recognize XTAL
@ 2021-07-22 15:02 Andy Shevchenko
  2021-07-22 15:45 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-07-22 15:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-serial, linux-kernel
  Cc: Jiri Slaby, Andy Shevchenko, Dennis Giaya

Dennis reported that on ACPI-based systems the clock frequency
isn't enough to configure device properly. We have to respect
the clock source as well. To achieve this match the clock-names
property against "xtal" to recognize crystal connection.

Reported-by: Dennis Giaya <dgiaya@whoi.edu>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/max310x.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index ef11860cd69e..e2ab8d4eb7ad 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1271,18 +1271,13 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
 	/* Always ask for fixed clock rate from a property. */
 	device_property_read_u32(dev, "clock-frequency", &uartclk);
 
-	s->clk = devm_clk_get_optional(dev, "osc");
+	xtal = device_property_match_string(dev, "clock-names", "xtal") >= 0;
+	if (xtal)
+		s->clk = devm_clk_get_optional(dev, "xtal");
+	else
+		s->clk = devm_clk_get_optional(dev, "osc");
 	if (IS_ERR(s->clk))
 		return PTR_ERR(s->clk);
-	if (s->clk) {
-		xtal = false;
-	} else {
-		s->clk = devm_clk_get_optional(dev, "xtal");
-		if (IS_ERR(s->clk))
-			return PTR_ERR(s->clk);
-
-		xtal = true;
-	}
 
 	ret = clk_prepare_enable(s->clk);
 	if (ret)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] serial: max310x: Use clock-names property matching to recognize XTAL
  2021-07-22 15:02 [PATCH v1 1/1] serial: max310x: Use clock-names property matching to recognize XTAL Andy Shevchenko
@ 2021-07-22 15:45 ` Andy Shevchenko
  2021-07-22 21:05   ` Dennis Giaya
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-07-22 15:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-serial, linux-kernel; +Cc: Jiri Slaby, Dennis Giaya

On Thu, Jul 22, 2021 at 06:02:33PM +0300, Andy Shevchenko wrote:
> Dennis reported that on ACPI-based systems the clock frequency
> isn't enough to configure device properly. We have to respect
> the clock source as well. To achieve this match the clock-names
> property against "xtal" to recognize crystal connection.

Dennis, please test this.

...

> -	s->clk = devm_clk_get_optional(dev, "osc");
> +	xtal = device_property_match_string(dev, "clock-names", "xtal") >= 0;

Meanwhile I will change this (not affects the testing in your case) to actually
negative one as:

	..., "osc") < 0;

to be compatible with the original flow (in case there are two clock names, the
"osc" has a priority).


-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] serial: max310x: Use clock-names property matching to recognize XTAL
  2021-07-22 15:45 ` Andy Shevchenko
@ 2021-07-22 21:05   ` Dennis Giaya
  2021-07-23 12:28     ` andriy.shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Dennis Giaya @ 2021-07-22 21:05 UTC (permalink / raw)
  To: linux-serial, andriy.shevchenko, gregkh, linux-kernel; +Cc: jirislaby

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

Andy,

I've tested this out on my hardware that uses an external oscillator
'osc' (as opposed to external crystal 'xtal').

With the relevant asl
	Package () {"compatible", "maxim,max14830"},
	Package ()
{"clock-frequency", 19200000},
	Package () {"clock-names", "osc"},

Previously, the driver logic would default to 'xtal' and then compare
against the narrower frequency range and throw an error because 19.2MHz
was not allowed. With your patch, it proceeds as 'osc' and appears to
work as intended.

Thanks!
Dennis


On Thu, 2021-07-22 at 18:45 +0300, Andy Shevchenko wrote:
> On Thu, Jul 22, 2021 at 06:02:33PM +0300, Andy Shevchenko wrote:
> > Dennis reported that on ACPI-based systems the clock frequency
> > isn't enough to configure device properly. We have to respect
> > the clock source as well. To achieve this match the clock-names
> > property against "xtal" to recognize crystal connection.
> 
> Dennis, please test this.
> 
> ...
> 
> > -	s->clk = devm_clk_get_optional(dev, "osc");
> > +	xtal = device_property_match_string(dev, "clock-names", "xtal")
> > >= 0;
> 
> Meanwhile I will change this (not affects the testing in your case)
> to actually
> negative one as:
> 
> 	..., "osc") < 0;
> 
> to be compatible with the original flow (in case there are two clock
> names, the
> "osc" has a priority).
> 
> 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5624 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] serial: max310x: Use clock-names property matching to recognize XTAL
  2021-07-22 21:05   ` Dennis Giaya
@ 2021-07-23 12:28     ` andriy.shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: andriy.shevchenko @ 2021-07-23 12:28 UTC (permalink / raw)
  To: Dennis Giaya; +Cc: linux-serial, gregkh, linux-kernel, jirislaby

On Thu, Jul 22, 2021 at 09:05:13PM +0000, Dennis Giaya wrote:
> Andy,
> 
> I've tested this out on my hardware that uses an external oscillator
> 'osc' (as opposed to external crystal 'xtal').
> 
> With the relevant asl
> 	Package () {"compatible", "maxim,max14830"},
> 	Package ()
> {"clock-frequency", 19200000},
> 	Package () {"clock-names", "osc"},
> 
> Previously, the driver logic would default to 'xtal' and then compare
> against the narrower frequency range and throw an error because 19.2MHz
> was not allowed. With your patch, it proceeds as 'osc' and appears to
> work as intended.

Thanks for testing!
I assume I may convert above to the Tested-by: or equivalent tag.

JFYI, in OSS mailing lists we do not top post.


-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-23 12:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 15:02 [PATCH v1 1/1] serial: max310x: Use clock-names property matching to recognize XTAL Andy Shevchenko
2021-07-22 15:45 ` Andy Shevchenko
2021-07-22 21:05   ` Dennis Giaya
2021-07-23 12:28     ` andriy.shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).