serial: sh-sci: Clock handling improvements
Subsystems (2)
cover serial: sh-sci: Clock handling improvements
Hi Greg, Jiri,
This patch series contains a legacy cleanup and two small improvements for the Renesas (H)SCI(F) serial driver.
This been tested on a various of Renesas (SuperH and ARM) SoCs.
Thanks!
Geert Uytterhoeven (3):
serial: sh-sci: Drop support for "sci_ick" clock
serial: sh-sci: Use dev_err_probe()
serial: sh-sci: Use devm_clk_get_optional()
drivers/tty/serial/sh-sci.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-)
Signature · 12 lines
2.25.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsPATCH 1/3 serial: sh-sci: Drop support for "sci_ick" clock
Since commit 1b463bd51042927e ("ARM: dts: r8a7794: Rename the serial port clock to fck") in v4.6, all upstream DTS files call the SCIF functional clock "fck".
Hence the time is ripe to drop backward-compatibility with old DTBs that use the old "sci_ick" name.
---
Note that such old DTBs have stopped working anyway since commit 58256143cff7c2e0 ("clk: renesas: Remove R-Car Gen2 legacy DT clock support") in v5.5.
--- drivers/tty/serial/sh-sci.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/tty/serial/sh-sci.c +0 -11
@@ -2784,17 +2784,6 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)return -EPROBE_DEFER ;if (IS_ERR (clk) && i ==SCI_FCK ) { -/* -* "fck" used to be called "sci_ick", and we need to -* maintain DT backward compatibility. -*/ - clk =devm_clk_get (dev,"sci_ick" ); -if (PTR_ERR (clk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; - -if (!IS_ERR (clk)) - goto found; -/* * Not all SH platforms declare a clock lookup entry * for SCI devices, in which case we need to get the
Signature · 1 line
2.25.1
Re: [PATCH 1/3] serial: sh-sci: Drop support for "sci_ick" clock
Hi Geert,
Thank you for the patch.
Quoted 8 lines · Geert Uytterhoeven
Since commit
1b463bd51042927e("ARM: dts: r8a7794: Rename the serial port clock to fck") in v4.6, all upstream DTS files call the SCIF functional clock "fck".Hence the time is ripe to drop backward-compatibility with old DTBs that use the old "
sci_ick" name.Signed-off-by Geert Uytterhoeven <[email protected]>
Quoted 30 lines
---
Note that such old DTBs have stopped working anyway since commit58256143cff7c2e0("clk: renesas: Remove R-Car Gen2 legacy DT clock support") in v5.5.--- drivers/tty/serial/sh-sci.c | 11 ----------- 1 file changed, 11 deletions(-)drivers/tty/serial/sh-sci.c +0
-11@@ -2784,17 +2784,6 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)return -EPROBE_DEFER ;if (IS_ERR (clk) && i ==SCI_FCK ) { -/* -* "fck" used to be called "sci_ick", and we need to -* maintain DT backward compatibility. -*/ - clk =devm_clk_get (dev,"sci_ick" ); -if (PTR_ERR (clk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; - -if (!IS_ERR (clk)) - goto found; -/* * Not all SH platforms declare a clock lookup entry * for SCI devices, in which case we need to get the
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 1/3] serial: sh-sci: Drop support for "sci_ick" clock
In reply to Geert UytterhoevenQuoted 4 lines · Geert Uytterhoeven
Since commit
1b463bd51042927e("ARM: dts: r8a7794: Rename the serial port clock to fck") in v4.6, all upstream DTS files call the SCIF functional clock "fck".
Quoted 8 lines
Hence the time is ripe to drop backward-compatibility with old DTBs that use the old "
sci_ick" name.Signed-off-by Geert Uytterhoeven <[email protected]>---
Note that such old DTBs have stopped working anyway since commit58256143cff7c2e0("clk: renesas: Remove R-Car Gen2 legacy DT clock support") in v5.5.
Ah, with that paragraph in mind:
PATCH 2/3 serial: sh-sci: Use dev_err_probe()
In reply to Geert UytterhoevenUse the dev_err_probe() helper to streamline error handling.
--- drivers/tty/serial/sh-sci.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/tty/serial/sh-sci.c +4 -7
@@ -2790,15 +2790,12 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)* global "peripheral_clk" clock. */ clk =devm_clk_get (dev,"peripheral_clk" ); -if (!IS_ERR (clk)) - goto found; - -dev_err (dev,"failed to get %s (%ld)\n" , clk_names[i], -PTR_ERR (clk)); -return PTR_ERR (clk); +if (IS_ERR (clk)) +return dev_err_probe (dev,PTR_ERR (clk), +"failed to get %s\n" , + clk_names[i]); } -found:if (IS_ERR (clk))dev_dbg (dev,"failed to get %s (%ld)\n" , clk_names[i],PTR_ERR (clk));
Signature · 1 line
2.25.1
Re: [PATCH 2/3] serial: sh-sci: Use dev_err_probe()
Hi Geert,
Thank you for the patch.
Quoted 3 lines · Geert Uytterhoeven
Use the
dev_err_probe()helper to streamline error handling.Signed-off-by Geert Uytterhoeven <[email protected]>
Quoted 28 lines
--- drivers/tty/serial/sh-sci.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/tty/serial/sh-sci.c +4
-7@@ -2790,15 +2790,12 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)* global "peripheral_clk" clock. */ clk =devm_clk_get (dev,"peripheral_clk" ); -if (!IS_ERR (clk)) - goto found; - -dev_err (dev,"failed to get %s (%ld)\n" , clk_names[i], -PTR_ERR (clk)); -return PTR_ERR (clk); +if (IS_ERR (clk)) +return dev_err_probe (dev,PTR_ERR (clk), +"failed to get %s\n" , + clk_names[i]); } -found:if (IS_ERR (clk))dev_dbg (dev,"failed to get %s (%ld)\n" , clk_names[i],PTR_ERR (clk));
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 2/3] serial: sh-sci: Use dev_err_probe()
In reply to Geert UytterhoevenQuoted 3 lines · Geert Uytterhoeven
Use the
dev_err_probe()helper to streamline error handling.Signed-off-by Geert Uytterhoeven <[email protected]>
PATCH 3/3 serial: sh-sci: Use devm_clk_get_optional()
In reply to Geert UytterhoevenThe sh-sci driver supports up to four input clocks, of which only the first one is mandatory.
Replace devm_clk_get() and custom error checking by devm_clk_get_optional(), to simplify the code and to catch all real errors.
--- drivers/tty/serial/sh-sci.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/tty/serial/sh-sci.c +7 -8
@@ -2779,11 +2779,11 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) clk_names[SCI_SCK ] ="hsck" ;for (i =0 ; i <SCI_NUM_CLKS ; i++) { - clk =devm_clk_get (dev, clk_names[i]); -if (PTR_ERR (clk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; + clk =devm_clk_get_optional (dev, clk_names[i]); +if (IS_ERR (clk)) +return PTR_ERR (clk); -if (IS_ERR (clk) && i ==SCI_FCK ) { +if (!clk && i ==SCI_FCK ) {/* * Not all SH platforms declare a clock lookup entry * for SCI devices, in which case we need to get the
@@ -2796,13 +2796,12 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) clk_names[i]); } -if (IS_ERR (clk)) -dev_dbg (dev,"failed to get %s (%ld)\n" , clk_names[i], -PTR_ERR (clk)); +if (!clk) +dev_dbg (dev,"failed to get %s\n" , clk_names[i]);else dev_dbg (dev,"clk %s is %pC rate %lu\n" , clk_names[i], clk,clk_get_rate (clk)); - sci_port->clks[i] =IS_ERR (clk) ?NULL : clk; + sci_port->clks[i] = clk; }return 0 ; }
Signature · 1 line
2.25.1
Re: [PATCH 3/3] serial: sh-sci: Use devm_clk_get_optional()
Hi Geert,
Thank you for the patch.
Quoted 8 lines · Geert Uytterhoeven
The sh-sci driver supports up to four input clocks, of which only the first one is mandatory.
Replace
devm_clk_get()and custom error checking bydevm_clk_get_optional(), to simplify the code and to catch all real errors.Signed-off-by Geert Uytterhoeven <[email protected]>
Quoted 41 lines
--- drivers/tty/serial/sh-sci.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)drivers/tty/serial/sh-sci.c +7
-8@@ -2779,11 +2779,11 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) clk_names[SCI_SCK ] ="hsck" ;for (i =0 ; i <SCI_NUM_CLKS ; i++) { - clk =devm_clk_get (dev, clk_names[i]); -if (PTR_ERR (clk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; + clk =devm_clk_get_optional (dev, clk_names[i]); +if (IS_ERR (clk)) +return PTR_ERR (clk); -if (IS_ERR (clk) && i ==SCI_FCK ) { +if (!clk && i ==SCI_FCK ) {/* * Not all SH platforms declare a clock lookup entry * for SCI devices, in which case we need to get the @@ -2796,13 +2796,12 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) clk_names[i]); } -if (IS_ERR (clk)) -dev_dbg (dev,"failed to get %s (%ld)\n" , clk_names[i], -PTR_ERR (clk)); +if (!clk) +dev_dbg (dev,"failed to get %s\n" , clk_names[i]);else dev_dbg (dev,"clk %s is %pC rate %lu\n" , clk_names[i], clk,clk_get_rate (clk)); - sci_port->clks[i] =IS_ERR (clk) ?NULL : clk; + sci_port->clks[i] = clk; }return 0 ; }
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 3/3] serial: sh-sci: Use devm_clk_get_optional()
In reply to Geert UytterhoevenQuoted 8 lines · Geert Uytterhoeven
The sh-sci driver supports up to four input clocks, of which only the first one is mandatory.
Replace
devm_clk_get()and custom error checking bydevm_clk_get_optional(), to simplify the code and to catch all real errors.Signed-off-by Geert Uytterhoeven <[email protected]>
Yeah, much better. Great cleanup!
Quoted 4 lines · Geert Uytterhoeven
Hi Greg, Jiri,
This patch series contains a legacy cleanup and two small improvements for the Renesas (H)SCI(F) serial driver.
By the way, did you ever figure out how to get the first serial port to work on qemu so qemu-system-sh4 doesn't have to "-serial null -serial mon:stdio" to get a serial console?
Rob
Hi Rob,
Quoted 7 lines · Rob Landley
Quoted 4 lines · Geert Uytterhoeven
Hi Greg, Jiri,
This patch series contains a legacy cleanup and two small improvements for the Renesas (H)SCI(F) serial driver.
Tested-by Rob Landley <[email protected]>
Thanks!
Quoted 3 lines
By the way, did you ever figure out how to get the first serial port to work on qemu so qemu-system-sh4 doesn't have to "-serial null -serial mon:stdio" to get a serial console?
Nope, same as last time you asked ;-)
However, upon a fresh look at linux/arch/sh/boards/mach-r2d/setup.c, I noticed something I missed before: the SCI port is not available as a UART, as it is used to talk SPI to an RTC. So that means qemu has the hardware description wrong?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 5 lines · Geert Uytterhoeven
Quoted 3 lines
By the way, did you ever figure out how to get the first serial port to work on qemu so qemu-system-sh4 doesn't have to "-serial null -serial mon:stdio" to get a serial console?
Nope, same as last time you asked ;-)
Well it had been a couple years, you never know...
Quoted 3 lines
However, upon a fresh look at
linux/arch/sh/boards/mach-r2d/setup.c, I noticed something I missed before: the SCI port is not available as a UART, as it is used to talk SPI to an RTC.
/* Single Epson RTC-9701JE attached on CS0 */
Huh. That does explain the CONFIG_RTC_DRV_R9701=y in rts7751r2d*_defconfig. (And also SPI SPI_SH_SCI MFD_SM501 RTC_CLASS and RTC_DRV_SH RTC_HCTOSYS which I've never gotten connected to QEMU.)
Quoted 2 lines
So that means qemu
has the hardware description wrong?
It would be nice if qemu-system-sh4 grew an RTC. Looks like Sato-san and Magnus Damm are the qemu-system-sh4 maintainers? (cc'd)
Thanks,
Rob
Yoshinori Sato
maintainerQuoted 13 lines · Rob Landley
Quoted 5 lines · Geert Uytterhoeven
Quoted 3 lines
By the way, did you ever figure out how to get the first serial port to work on qemu so qemu-system-sh4 doesn't have to "-serial null -serial mon:stdio" to get a serial console?
Nope, same as last time you asked ;-)
Well it had been a couple years, you never know...
Quoted 3 lines
However, upon a fresh look at
linux/arch/sh/boards/mach-r2d/setup.c, I noticed something I missed before: the SCI port is not available as a UART, as it is used to talk SPI to an RTC.
Yes.
R2D plus serial port connected SuperI/O UART. It not cpu on-chip SCI. It is not possible to check SCI with the standard version of qemu-system-sh4. There is SCI emulation, so you can change it to connect to the qemu serial port.
Quoted 5 lines
/* Single Epson RTC-9701JE attached on CS0 */
Huh. That does explain the
CONFIG_RTC_DRV_R9701=yin rts7751r2d*_defconfig. (And also SPISPI_SH_SCIMFD_SM501RTC_CLASSandRTC_DRV_SHRTC_HCTOSYSwhich I've never gotten connected to QEMU.)
SPI_SH_SCI using SCI pin like GPIO.
qemu-system-sh4 is not support this.
Quoted 9 lines
Quoted 2 lines
So that means qemu
has the hardware description wrong?It would be nice if qemu-system-sh4 grew an RTC. Looks like Sato-san and Magnus Damm are the qemu-system-sh4 maintainers? (cc'd)
Thanks,
Rob
Signature · 1 line
Yosinori Sato