2023-07-05 18:46:12

by Dmitry Rokosov

[permalink] [raw]
Subject: [PATCH v2 0/7] tty: serial: meson: support ttyS devname

During a IRC discussion with Neil, as reported in reference [1], an idea
emerged to provide support for a standard devname 'ttyS' in new SoCs
such as A1, S4, T7, C3 and others. The current devname 'ttyAML' is not
widely known and has caused several issues with both low and high-level
software, without any apparent justification for its implementation.
Consequently, it has been deemed necessary to introduce the 'ttyS'
devname for all new 'compatible' entries, while still retaining backward
compatibility with the old 'ttyAML' devname by supporting it in parallel
with the new approach. This patch series therefore aims to implement
these changes.

Changes v2 since v1 at [2]:
- as suggested by Conor, relocate modifications with the new
uart_data structures of S4 and A1 SoC from the main meson_uart
patchset to a separate patchsets
- ensure that the uart_driver is not unregistered if there is at
least one active port
- per Neil's suggestion declare separate uart_driver and console
objects for both tty devnames (ttyAML and ttyS) to enable the use
of multiple uart objects with different compatibility strings

Links:
[1]: https://libera.irclog.whitequark.org/linux-amlogic/2023-07-03
[2]: https://lore.kernel.org/linux-amlogic/[email protected]/

Dmitry Rokosov (7):
tty: serial: meson: use dev_err_probe
tty: serial: meson: redesign the module to platform_driver
tty: serial: meson: apply ttyS devname instead of ttyAML for new SoCs
tty: serial: meson: introduce separate uart_data for S4 SoC family
tty: serial: meson: add independent uart_data for A1 SoC family
dt-bindings: serial: amlogic,meson-uart: support Amlogic A1
arm64: dts: meson: a1: change uart compatible string

.../bindings/serial/amlogic,meson-uart.yaml | 2 +
arch/arm64/boot/dts/amlogic/meson-a1.dtsi | 4 +-
drivers/tty/serial/meson_uart.c | 145 ++++++++++--------
3 files changed, 88 insertions(+), 63 deletions(-)

--
2.36.0



2023-07-05 18:47:07

by Dmitry Rokosov

[permalink] [raw]
Subject: [PATCH v2 6/7] dt-bindings: serial: amlogic,meson-uart: support Amlogic A1

Introduce meson uart serial bindings for A1 SoC family.

Signed-off-by: Dmitry Rokosov <[email protected]>
---
.../devicetree/bindings/serial/amlogic,meson-uart.yaml | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
index 01ec45b3b406..f1ae8c4934d9 100644
--- a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
@@ -33,6 +33,7 @@ properties:
- amlogic,meson8b-uart
- amlogic,meson-gx-uart
- amlogic,meson-s4-uart
+ - amlogic,meson-a1-uart
- const: amlogic,meson-ao-uart
- description: Always-on power domain UART controller on G12A SoCs
items:
@@ -46,6 +47,7 @@ properties:
- amlogic,meson8b-uart
- amlogic,meson-gx-uart
- amlogic,meson-s4-uart
+ - amlogic,meson-a1-uart
- description: Everything-Else power domain UART controller on G12A SoCs
items:
- const: amlogic,meson-g12a-uart
--
2.36.0


2023-07-05 18:47:58

by Dmitry Rokosov

[permalink] [raw]
Subject: [PATCH v2 2/7] tty: serial: meson: redesign the module to platform_driver

Actually, the meson_uart module is already a platform_driver, but it is
currently registered manually and the uart core registration is run
outside the probe() scope, which results in some restrictions. For
instance, it is not possible to communicate with the OF subsystem
because it requires an initialized device object.

To address this issue, apply module_platform_driver() instead of direct
module init/exit routines. Additionally, move uart_register_driver() to
the driver probe(), and destroy manual console registration because it's
already run in the uart_register_driver() flow.

Signed-off-by: Dmitry Rokosov <[email protected]>
---
drivers/tty/serial/meson_uart.c | 51 ++++++++++-----------------------
1 file changed, 15 insertions(+), 36 deletions(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index bca54f3d92a1..dcf994a11a21 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -621,12 +621,6 @@ static struct console meson_serial_console = {
.data = &meson_uart_driver,
};

-static int __init meson_serial_console_init(void)
-{
- register_console(&meson_serial_console);
- return 0;
-}
-
static void meson_serial_early_console_write(struct console *co,
const char *s,
u_int count)
@@ -652,9 +646,6 @@ OF_EARLYCON_DECLARE(meson, "amlogic,meson-ao-uart",

#define MESON_SERIAL_CONSOLE (&meson_serial_console)
#else
-static int __init meson_serial_console_init(void) {
- return 0;
-}
#define MESON_SERIAL_CONSOLE NULL
#endif

@@ -738,6 +729,13 @@ static int meson_uart_probe(struct platform_device *pdev)
if (ret)
return ret;

+ if (!meson_uart_driver.state) {
+ ret = uart_register_driver(&meson_uart_driver);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "can't register uart driver\n");
+ }
+
port->iotype = UPIO_MEM;
port->mapbase = res_mem->start;
port->mapsize = resource_size(res_mem);
@@ -776,6 +774,13 @@ static int meson_uart_remove(struct platform_device *pdev)
uart_remove_one_port(&meson_uart_driver, port);
meson_ports[pdev->id] = NULL;

+ for (int id = 0; id < AML_UART_PORT_NUM; id++)
+ if (meson_ports[id])
+ return 0;
+
+ /* No more available uart ports, unregister uart driver */
+ uart_unregister_driver(&meson_uart_driver);
+
return 0;
}

@@ -809,33 +814,7 @@ static struct platform_driver meson_uart_platform_driver = {
},
};

-static int __init meson_uart_init(void)
-{
- int ret;
-
- ret = meson_serial_console_init();
- if (ret)
- return ret;
-
- ret = uart_register_driver(&meson_uart_driver);
- if (ret)
- return ret;
-
- ret = platform_driver_register(&meson_uart_platform_driver);
- if (ret)
- uart_unregister_driver(&meson_uart_driver);
-
- return ret;
-}
-
-static void __exit meson_uart_exit(void)
-{
- platform_driver_unregister(&meson_uart_platform_driver);
- uart_unregister_driver(&meson_uart_driver);
-}
-
-module_init(meson_uart_init);
-module_exit(meson_uart_exit);
+module_platform_driver(meson_uart_platform_driver);

MODULE_AUTHOR("Carlo Caione <[email protected]>");
MODULE_DESCRIPTION("Amlogic Meson serial port driver");
--
2.36.0


2023-07-05 21:29:05

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v2 6/7] dt-bindings: serial: amlogic,meson-uart: support Amlogic A1

On Wed, Jul 05, 2023 at 09:18:32PM +0300, Dmitry Rokosov wrote:
> Introduce meson uart serial bindings for A1 SoC family.
>
> Signed-off-by: Dmitry Rokosov <[email protected]>

Looks like there's a missing Ack here from Rob:
https://lore.kernel.org/all/[email protected]/

Cheers,
Conor.

> ---
> .../devicetree/bindings/serial/amlogic,meson-uart.yaml | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
> index 01ec45b3b406..f1ae8c4934d9 100644
> --- a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
> +++ b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
> @@ -33,6 +33,7 @@ properties:
> - amlogic,meson8b-uart
> - amlogic,meson-gx-uart
> - amlogic,meson-s4-uart
> + - amlogic,meson-a1-uart
> - const: amlogic,meson-ao-uart
> - description: Always-on power domain UART controller on G12A SoCs
> items:
> @@ -46,6 +47,7 @@ properties:
> - amlogic,meson8b-uart
> - amlogic,meson-gx-uart
> - amlogic,meson-s4-uart
> + - amlogic,meson-a1-uart
> - description: Everything-Else power domain UART controller on G12A SoCs
> items:
> - const: amlogic,meson-g12a-uart
> --
> 2.36.0
>


Attachments:
(No filename) (1.47 kB)
signature.asc (235.00 B)
Download all attachments

2023-07-06 07:21:04

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH v2 2/7] tty: serial: meson: redesign the module to platform_driver

On 05/07/2023 20:18, Dmitry Rokosov wrote:
> Actually, the meson_uart module is already a platform_driver, but it is
> currently registered manually and the uart core registration is run
> outside the probe() scope, which results in some restrictions. For
> instance, it is not possible to communicate with the OF subsystem
> because it requires an initialized device object.
>
> To address this issue, apply module_platform_driver() instead of direct
> module init/exit routines. Additionally, move uart_register_driver() to
> the driver probe(), and destroy manual console registration because it's
> already run in the uart_register_driver() flow.
>
> Signed-off-by: Dmitry Rokosov <[email protected]>
> ---
> drivers/tty/serial/meson_uart.c | 51 ++++++++++-----------------------
> 1 file changed, 15 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
> index bca54f3d92a1..dcf994a11a21 100644
> --- a/drivers/tty/serial/meson_uart.c
> +++ b/drivers/tty/serial/meson_uart.c
> @@ -621,12 +621,6 @@ static struct console meson_serial_console = {
> .data = &meson_uart_driver,
> };
>
> -static int __init meson_serial_console_init(void)
> -{
> - register_console(&meson_serial_console);
> - return 0;
> -}
> -
> static void meson_serial_early_console_write(struct console *co,
> const char *s,
> u_int count)
> @@ -652,9 +646,6 @@ OF_EARLYCON_DECLARE(meson, "amlogic,meson-ao-uart",
>
> #define MESON_SERIAL_CONSOLE (&meson_serial_console)
> #else
> -static int __init meson_serial_console_init(void) {
> - return 0;
> -}
> #define MESON_SERIAL_CONSOLE NULL
> #endif
>
> @@ -738,6 +729,13 @@ static int meson_uart_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + if (!meson_uart_driver.state) {
> + ret = uart_register_driver(&meson_uart_driver);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "can't register uart driver\n");
> + }
> +
> port->iotype = UPIO_MEM;
> port->mapbase = res_mem->start;
> port->mapsize = resource_size(res_mem);
> @@ -776,6 +774,13 @@ static int meson_uart_remove(struct platform_device *pdev)
> uart_remove_one_port(&meson_uart_driver, port);
> meson_ports[pdev->id] = NULL;
>
> + for (int id = 0; id < AML_UART_PORT_NUM; id++)
> + if (meson_ports[id])
> + return 0;
> +
> + /* No more available uart ports, unregister uart driver */
> + uart_unregister_driver(&meson_uart_driver);
> +
> return 0;
> }
>
> @@ -809,33 +814,7 @@ static struct platform_driver meson_uart_platform_driver = {
> },
> };
>
> -static int __init meson_uart_init(void)
> -{
> - int ret;
> -
> - ret = meson_serial_console_init();
> - if (ret)
> - return ret;
> -
> - ret = uart_register_driver(&meson_uart_driver);
> - if (ret)
> - return ret;
> -
> - ret = platform_driver_register(&meson_uart_platform_driver);
> - if (ret)
> - uart_unregister_driver(&meson_uart_driver);
> -
> - return ret;
> -}
> -
> -static void __exit meson_uart_exit(void)
> -{
> - platform_driver_unregister(&meson_uart_platform_driver);
> - uart_unregister_driver(&meson_uart_driver);
> -}
> -
> -module_init(meson_uart_init);
> -module_exit(meson_uart_exit);
> +module_platform_driver(meson_uart_platform_driver);
>
> MODULE_AUTHOR("Carlo Caione <[email protected]>");
> MODULE_DESCRIPTION("Amlogic Meson serial port driver");

Reviewed-by: Neil Armstrong <[email protected]>

2023-07-06 18:26:52

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v2 6/7] dt-bindings: serial: amlogic,meson-uart: support Amlogic A1


On Wed, 05 Jul 2023 21:18:32 +0300, Dmitry Rokosov wrote:
> Introduce meson uart serial bindings for A1 SoC family.
>
> Signed-off-by: Dmitry Rokosov <[email protected]>
> ---
> .../devicetree/bindings/serial/amlogic,meson-uart.yaml | 2 ++
> 1 file changed, 2 insertions(+)
>


Please add Acked-by/Reviewed-by tags when posting new versions. However,
there's no need to repost patches *only* to add the tags. The upstream
maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

Missing tags:

Acked-by: Rob Herring <[email protected]>