* [PATCH v4 0/3] serial: 8250_of: support an optional bus clock
@ 2025-04-11 20:38 Alex Elder
2025-04-11 20:38 ` [PATCH v4 1/3] dt-bindings: serial: 8250: support an optional second clock Alex Elder
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alex Elder @ 2025-04-11 20:38 UTC (permalink / raw)
To: gregkh, jirislaby, robh, krzk+dt, conor+dt
Cc: andy.shevchenko, dlan, benjamin.larsson, bastien.curutchet,
andriy.shevchenko, u.kleine-koenig, lkundrak, devicetree,
linux-serial, spacemit, linux-kernel
The SpacemiT UART hardware requires a bus clock to be enabled in addition
to the primary function clock.
This series makes it possible to specify both clocks via DTS. If a
bus clock is required, it and the primary clock are fetched by name.
This code is available here:
https://github.com/riscstar/linux/tree/outgoing/serial-v4
Changes between v3 and v4:
- I simplified the third patch by reusing the local variable, as
suggested by Andy Shevchenko
- The first two patches are identical to what was in v3
Here is version 3 of this series:
https://lore.kernel.org/lkml/20250411154419.1379529-1-elder@riscstar.com/
Changes between v2 and v3:
- A third patch was added to disable the bus clock on suspend and
enable it again on resume, as requested by Yixun Lan
- Rob's Reviewed-by tag has been added to patch 1
- The first two patches are otherwise identical to what was in v2
Here is version 2 of this series:
https://lore.kernel.org/lkml/20250409192213.1130181-1-elder@riscstar.com/
Changes between v1 and v2:
- The DT binding was fixed to properly define the number of clocks and
clock names based on the compatible string, as suggested by Rob Herring
- Logic to look up the optional bus clock was changed as requested
by Andy Shevchenko
- The bus clock pointer (which was never used after it was enabled)
was renmoved from the of_serial_info structure
Here is the first version of this series:
https://lore.kernel.org/lkml/20250408175146.979557-1-elder@riscstar.com/
-Alex
Alex Elder (3):
dt-bindings: serial: 8250: support an optional second clock
serial: 8250_of: add support for an optional bus clock
serial: 8250_of: manage bus clock in suspend/resume
.../devicetree/bindings/serial/8250.yaml | 30 ++++++++++++++++++-
drivers/tty/serial/8250/8250_of.c | 15 +++++++++-
2 files changed, 43 insertions(+), 2 deletions(-)
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
--
2.45.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/3] dt-bindings: serial: 8250: support an optional second clock
2025-04-11 20:38 [PATCH v4 0/3] serial: 8250_of: support an optional bus clock Alex Elder
@ 2025-04-11 20:38 ` Alex Elder
2025-04-11 20:38 ` [PATCH v4 2/3] serial: 8250_of: add support for an optional bus clock Alex Elder
2025-04-11 20:38 ` [PATCH v4 3/3] serial: 8250_of: manage bus clock in suspend/resume Alex Elder
2 siblings, 0 replies; 6+ messages in thread
From: Alex Elder @ 2025-04-11 20:38 UTC (permalink / raw)
To: robh, krzk+dt, conor+dt, gregkh, jirislaby
Cc: andy.shevchenko, dlan, benjamin.larsson, bastien.curutchet,
andriy.shevchenko, u.kleine-koenig, lkundrak, devicetree,
linux-serial, spacemit, linux-kernel
The SpacemiT UART driver requires a bus clock to be enabled in addition
to the primary function clock. Add the option to specify two clocks
for an 8250-compatible UART, named "core" and "bus". If both are needed,
require them to be named.
Signed-off-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
---
.../devicetree/bindings/serial/8250.yaml | 30 ++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/serial/8250.yaml b/Documentation/devicetree/bindings/serial/8250.yaml
index dc0d52920575f..33d2016b65090 100644
--- a/Documentation/devicetree/bindings/serial/8250.yaml
+++ b/Documentation/devicetree/bindings/serial/8250.yaml
@@ -135,7 +135,16 @@ properties:
clock-frequency: true
clocks:
- maxItems: 1
+ minItems: 1
+ items:
+ - description: The core function clock
+ - description: An optional bus clock
+
+ clock-names:
+ minItems: 1
+ items:
+ - const: core
+ - const: bus
resets:
maxItems: 1
@@ -224,6 +233,25 @@ required:
- reg
- interrupts
+if:
+ properties:
+ compatible:
+ contains:
+ const: spacemit,k1-uart
+then:
+ required: [clock-names]
+ properties:
+ clocks:
+ minItems: 2
+ clock-names:
+ minItems: 2
+else:
+ properties:
+ clocks:
+ maxItems: 1
+ clock-names:
+ maxItems: 1
+
unevaluatedProperties: false
examples:
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/3] serial: 8250_of: add support for an optional bus clock
2025-04-11 20:38 [PATCH v4 0/3] serial: 8250_of: support an optional bus clock Alex Elder
2025-04-11 20:38 ` [PATCH v4 1/3] dt-bindings: serial: 8250: support an optional second clock Alex Elder
@ 2025-04-11 20:38 ` Alex Elder
2025-04-11 20:38 ` [PATCH v4 3/3] serial: 8250_of: manage bus clock in suspend/resume Alex Elder
2 siblings, 0 replies; 6+ messages in thread
From: Alex Elder @ 2025-04-11 20:38 UTC (permalink / raw)
To: gregkh, jirislaby, robh, krzk+dt, conor+dt
Cc: andy.shevchenko, dlan, benjamin.larsson, bastien.curutchet,
andriy.shevchenko, u.kleine-koenig, lkundrak, devicetree,
linux-serial, spacemit, linux-kernel
The SpacemiT UART requires a bus clock to be enabled, in addition to
it's "normal" core clock. Look up the optional bus clock by name,
and if that's found, look up the core clock using the name "core".
Supplying a bus clock is optional. If no bus clock is needed, the
the first/only clock is used for the core clock.
Signed-off-by: Alex Elder <elder@riscstar.com>
---
drivers/tty/serial/8250/8250_of.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 11c860ea80f60..a90a5462aa72a 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -123,7 +123,16 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
/* Get clk rate through clk driver if present */
if (!port->uartclk) {
- info->clk = devm_clk_get_enabled(dev, NULL);
+ struct clk *bus_clk;
+
+ bus_clk = devm_clk_get_optional_enabled(dev, "bus");
+ if (IS_ERR(bus_clk)) {
+ ret = dev_err_probe(dev, PTR_ERR(bus_clk), "failed to get bus clock\n");
+ goto err_pmruntime;
+ }
+
+ /* If the bus clock is required, core clock must be named */
+ info->clk = devm_clk_get_enabled(dev, bus_clk ? "core" : NULL);
if (IS_ERR(info->clk)) {
ret = dev_err_probe(dev, PTR_ERR(info->clk), "failed to get clock\n");
goto err_pmruntime;
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/3] serial: 8250_of: manage bus clock in suspend/resume
2025-04-11 20:38 [PATCH v4 0/3] serial: 8250_of: support an optional bus clock Alex Elder
2025-04-11 20:38 ` [PATCH v4 1/3] dt-bindings: serial: 8250: support an optional second clock Alex Elder
2025-04-11 20:38 ` [PATCH v4 2/3] serial: 8250_of: add support for an optional bus clock Alex Elder
@ 2025-04-11 20:38 ` Alex Elder
2025-04-11 22:04 ` Yixun Lan
2 siblings, 1 reply; 6+ messages in thread
From: Alex Elder @ 2025-04-11 20:38 UTC (permalink / raw)
To: gregkh, jirislaby, robh, krzk+dt, conor+dt
Cc: andy.shevchenko, dlan, benjamin.larsson, bastien.curutchet,
andriy.shevchenko, u.kleine-koenig, lkundrak, devicetree,
linux-serial, spacemit, linux-kernel
Save the bus clock pointer in the of_serial_info structure, and use
that to disable the bus clock on suspend and re-enable it on resume.
Signed-off-by: Alex Elder <elder@riscstar.com>
---
drivers/tty/serial/8250/8250_of.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index a90a5462aa72a..d178b6c54ea18 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -24,6 +24,7 @@
struct of_serial_info {
struct clk *clk;
+ struct clk *bus_clk;
struct reset_control *rst;
int type;
int line;
@@ -138,6 +139,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
goto err_pmruntime;
}
+ info->bus_clk = bus_clk;
port->uartclk = clk_get_rate(info->clk);
}
/* If current-speed was set, then try not to change it. */
@@ -299,6 +301,7 @@ static int of_serial_suspend(struct device *dev)
if (!uart_console(port) || console_suspend_enabled) {
pm_runtime_put_sync(dev);
clk_disable_unprepare(info->clk);
+ clk_disable_unprepare(info->bus_clk);
}
return 0;
}
@@ -311,6 +314,7 @@ static int of_serial_resume(struct device *dev)
if (!uart_console(port) || console_suspend_enabled) {
pm_runtime_get_sync(dev);
+ clk_prepare_enable(info->bus_clk);
clk_prepare_enable(info->clk);
}
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 3/3] serial: 8250_of: manage bus clock in suspend/resume
2025-04-11 20:38 ` [PATCH v4 3/3] serial: 8250_of: manage bus clock in suspend/resume Alex Elder
@ 2025-04-11 22:04 ` Yixun Lan
2025-04-12 12:44 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Yixun Lan @ 2025-04-11 22:04 UTC (permalink / raw)
To: Alex Elder
Cc: gregkh, jirislaby, robh, krzk+dt, conor+dt, andy.shevchenko,
benjamin.larsson, bastien.curutchet, andriy.shevchenko,
u.kleine-koenig, lkundrak, devicetree, linux-serial, spacemit,
linux-kernel
hi Alex,
Glad to see first 2 patches already accepted
This version is better than v3, thanks
On 15:38 Fri 11 Apr , Alex Elder wrote:
> Save the bus clock pointer in the of_serial_info structure, and use
> that to disable the bus clock on suspend and re-enable it on resume.
>
> Signed-off-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Yixun Lan <dlan@gentoo.org>
> ---
> drivers/tty/serial/8250/8250_of.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
> index a90a5462aa72a..d178b6c54ea18 100644
> --- a/drivers/tty/serial/8250/8250_of.c
> +++ b/drivers/tty/serial/8250/8250_of.c
> @@ -24,6 +24,7 @@
>
> struct of_serial_info {
> struct clk *clk;
> + struct clk *bus_clk;
> struct reset_control *rst;
> int type;
> int line;
> @@ -138,6 +139,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
> goto err_pmruntime;
> }
>
> + info->bus_clk = bus_clk;
> port->uartclk = clk_get_rate(info->clk);
> }
> /* If current-speed was set, then try not to change it. */
> @@ -299,6 +301,7 @@ static int of_serial_suspend(struct device *dev)
> if (!uart_console(port) || console_suspend_enabled) {
> pm_runtime_put_sync(dev);
> clk_disable_unprepare(info->clk);
> + clk_disable_unprepare(info->bus_clk);
> }
> return 0;
> }
> @@ -311,6 +314,7 @@ static int of_serial_resume(struct device *dev)
>
> if (!uart_console(port) || console_suspend_enabled) {
> pm_runtime_get_sync(dev);
> + clk_prepare_enable(info->bus_clk);
> clk_prepare_enable(info->clk);
> }
>
> --
> 2.45.2
>
>
--
Yixun Lan (dlan)
Gentoo Linux Developer
GPG Key ID AABEFD55
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 3/3] serial: 8250_of: manage bus clock in suspend/resume
2025-04-11 22:04 ` Yixun Lan
@ 2025-04-12 12:44 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-04-12 12:44 UTC (permalink / raw)
To: Yixun Lan
Cc: Alex Elder, gregkh, jirislaby, robh, krzk+dt, conor+dt,
benjamin.larsson, bastien.curutchet, andriy.shevchenko,
u.kleine-koenig, lkundrak, devicetree, linux-serial, spacemit,
linux-kernel
On Sat, Apr 12, 2025 at 1:04 AM Yixun Lan <dlan@gentoo.org> wrote:
>
> hi Alex,
>
> Glad to see first 2 patches already accepted
> This version is better than v3, thanks
Exactly! I'm not sure this series can be applied due to that. You need
to rebase on top of tty-next.
> On 15:38 Fri 11 Apr , Alex Elder wrote:
> > Save the bus clock pointer in the of_serial_info structure, and use
> > that to disable the bus clock on suspend and re-enable it on resume.
> >
> > Signed-off-by: Alex Elder <elder@riscstar.com>
> Reviewed-by: Yixun Lan <dlan@gentoo.org>
Code wise this one is what I have expected, thanks!
Reviewed-by: Andy Shevchenko <andy@kernel.org>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-12 12:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 20:38 [PATCH v4 0/3] serial: 8250_of: support an optional bus clock Alex Elder
2025-04-11 20:38 ` [PATCH v4 1/3] dt-bindings: serial: 8250: support an optional second clock Alex Elder
2025-04-11 20:38 ` [PATCH v4 2/3] serial: 8250_of: add support for an optional bus clock Alex Elder
2025-04-11 20:38 ` [PATCH v4 3/3] serial: 8250_of: manage bus clock in suspend/resume Alex Elder
2025-04-11 22:04 ` Yixun Lan
2025-04-12 12:44 ` Andy 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).