Skip to contentSkip to conversation

Introduce Nuvoton ma35d1 SoC

PATCH Superseded Jacky Huang 5 participants 18 messages Jun 12, 2023 – Jun 15, 2023

Subsystems (3)

v14 of 16 Superseded Latest is v16 →

lore
Share & tools
lore
#0 lore raw

v14 cover Introduce Nuvoton ma35d1 SoC

From: Jacky Huang <[email protected]>

This patchset adds initial support for the Nuvoton ma35d1 SoC, including initial device tree, clock driver, reset driver, and serial driver.

This patchset cover letter is based from the initial support for Nuvoton ma35d1 to keep tracking the version history.

This patchset had been applied to Linux kernel 6.4.0-rc6 and tested on the Nuvoton ma35d1 SOM evaluation board.

(ma35d1 information: https://www.nuvoton.com/products/microprocessors/arm-cortex-a35-mpus/)
MA35D1 porting on linux-5.10.y can be found at: https://github.com/OpenNuvoton/MPU-Family

v14:
- Removed patches PATCH v13 1/10 ~ 9/10 as they were applied
- Modify serial driver
- Fixed coding style issues

v13:
- Modify serial driver
- Added a check for oops_in_progress in ma35d1serial_console_write to determine whether to perform the spin_lock.
- Rebased drivers/tty/serial/Kconfig and recreate the patch
- Rebased MAINTAINERS and recreate the patch

v12:
- Modify serial driver
- Added PORT_MA35 to include/uapi/linux/serial_core.h, and apply to the port->type of ma35d1 serial driver
- Added check for the return value of ioremap()
- Fixed several coding issues
- Rebase MAINTAINERS and recreate the patch

v11:
- Rebase on top of 2023.05.24
- Modify serial driver
- Fixed several coding style issues
- Fixed ma35d1serial_set_mctrl()
- Added the 'MA35_' prefix to all register and bit field definitions.
- Used 'ttyNVT' instead of 'ttyS'
- Modify clock driver
- Added 'source nuvoton/Kconfig' to drivers/clk/Kconfig
- Fixed several coding issues
- Removed unnecessary inline specifier
- Modify reset driver
- Fixed typo and added comments
- Modify ma35d1.dtsi l2-cache node
- Added cache-unified and cache-size properties

v10:
- Change from using ARCH_NUVOTON to using ARCH_MA35. The following patch files have been modified:
- patch 1 arch/arm64/Kconfig.platforms
- patch 2 arch/arm64/configs/defconfig
- patch 7 arch/arm64/boot/dts/nuvoton/Makefile
- patch 8 drivers/clk/Makefile
drivers/clk/nuvoton/Kconfig drivers/clk/nuvoton/Makefile
- patch 9 drivers/reset/Kconfig
- patch 10 drivers/tty/serial/Kconfig

v9:
- Combine MAINTAINERS patch into patch 5 'dt-bindings: arm: Add initial bindings for Nuvoton platform'
- Modify clock driver
- Use the helper function for 64-bit division
- Fixed minor issues
- Modify reset driver
- Refine coding style and add required header files
- Add spin_lock protection
- Add error return handling to the serial driver probe function

v8:
- Remove '0005-dt-bindings-mfd-syscon-Add-nuvoton-ma35d1-sys-compat.patch' as it was applied.
- Modify MAINTAINERS NUVOTON MA35 and NPCM path settings
- Remove 'syscon' from dtsi 'sys' node and modify the corresponding yaml
- Modify clock driver
- Remove the header file and move definitions into .c files.
- Use parent_data instead of parent name.
- Modify serial driver
- Modify reset driver
- Modify reset register/offset lookup table to be indexed by reset id
- Combined reset and reboot structure

v7:
- Fixed dts system-management node and compatible driver
- move 'nuvoton,npcm-gcr.yaml' from 'binding/arm/nuvoton' to 'binding/soc/nuvoton'
- In ma35d1.dtsi, create the soc node for ma35d1 SoC
- Modify the issues found in serial driver
- Modify the issues found in clock driver
- Modify the IDs of reset driver to be contiguous numbers and use lookup table to find register offset and bit position.
- Modify MAINTAINERS NUVOTON NPCM path as npcm directory name to nuvoton

v6:
- Combine nuvoton,ma35d1-clk.yaml and nuvoton,ma35d1-clk.h into one patch
- Combine nuvoton,ma35d1-reset.yaml and nuvoton,ma35d1-reset.h into one patch
- rename Documentation/devicetree/bindings/arm/npcm directory as nuvoton
- Remove patch for adding include/linux/mfd/ma35d1-sys.h as it's not required
- Update dtsi & dts files and move board-specific nodes to dts
- Modify reset driver
- Modify serial driver, fix coding style issues
- Modify clock driver, rewrite the PLL calculation functions

v5:
- Add ARCH_NUVOTON to arm64 Kconfig
- Add ARCH_NUVOTON to defconfig
- Add the clock driver
- Add the reset driver
- Add the serial driver
- Add us to the maintainer

v4:
- patch 4/5 is a resend
- Fixed dt_binding_check errors of nuvoton,ma35d1-clk.yaml
- Modify ma35d1.dtsi
1. Add a node hxt_24m
2. Fixed the base address of gic node
3. Add clocks and clock-names to clock node
- Fixed borad binding mistakes of nuvoton.yaml

v3:
- added patch 4/5 and 5/5
- introduce CONFIG_ARCH_NUVOTON option
- add initial bindings for Nuvoton Platform boards
- fixed coding style problem of nuvoton,ma35d1-clk.h
- added CAPLL to clock-controller node
- modify the chosen node of ma35d1-evb.dts
- modify clock yaml "clk-pll-mode" to "nuvoton,clk-pll-mode"

v2:
- fixed dt_binding_check failed of nuvoton,ma35d1-clk.yaml

Jacky Huang (1):
tty: serial: Add Nuvoton ma35d1 serial driver support

 drivers/tty/serial/Kconfig         |  18 +
 drivers/tty/serial/Makefile        |   1 +
 drivers/tty/serial/ma35d1_serial.c | 817 +++++++++++++++++++++++++++++
 include/uapi/linux/serial_core.h   |   3 +
 4 files changed, 839 insertions(+)
 create mode 100644 drivers/tty/serial/ma35d1_serial.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v14 1/1 tty: serial: Add Nuvoton ma35d1 serial driver support

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

---
 drivers/tty/serial/Kconfig         |  18 +
 drivers/tty/serial/Makefile        |   1 +
 drivers/tty/serial/ma35d1_serial.c | 817 +++++++++++++++++++++++++++++
 include/uapi/linux/serial_core.h   |   3 +
 4 files changed, 839 insertions(+)
 create mode 100644 drivers/tty/serial/ma35d1_serial.c
drivers/tty/serial/Kconfig +18 -0
index 3e3fb377d90d..71ea5138adce 100644
@@ -1555,6 +1555,24 @@ config SERIAL_SUNPLUS_CONSOLE
 	  you can alter that using a kernel command line option such as
 	  "console=ttySUPx".
 
+config SERIAL_NUVOTON_MA35D1
+	tristate "Nuvoton MA35D1 family UART support"
+	depends on ARCH_MA35 || COMPILE_TEST
+	select SERIAL_CORE
+	help
+	  This driver supports Nuvoton MA35D1 family UART ports. If you would
+	  like to use them, you must answer Y or M to this option. Note that
+	  for use as console, it must be included in kernel and not as a
+	  module
+
+config SERIAL_NUVOTON_MA35D1_CONSOLE
+	bool "Console on a Nuvotn MA35D1 family UART port"
+	depends on SERIAL_NUVOTON_MA35D1=y
+	select SERIAL_CORE_CONSOLE
+	help
+	  Select this options if you'd like to use the UART port0 of the
+	  Nuvoton MA35D1 family as a console.
+
 endmenu
 
 config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
index cd9afd9e3018..0e823851c42c 100644
@@ -93,3 +93,4 @@ obj-$(CONFIG_SERIAL_MCTRL_GPIO)	+= serial_mctrl_gpio.o
 
 obj-$(CONFIG_SERIAL_KGDB_NMI) += kgdb_nmi.o
 obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
+obj-$(CONFIG_SERIAL_NUVOTON_MA35D1) += ma35d1_serial.o
drivers/tty/serial/ma35d1_serial.c new file +817 -0

817 lines not on this page · raw message

include/uapi/linux/serial_core.h +3 -0
index 281fa286555c..c11600bb1b0d 100644
@@ -279,4 +279,7 @@
 /* Sunplus UART */
 #define PORT_SUNPLUS	123
 
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+
 #endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 1 line
2.34.1
maintainer
#3 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

In reply to Jacky Huang
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

include/uapi/linux/serial_core.h line 284

Quoted 9 lines
include/uapi/linux/serial_core.h +3 -0
@@ -279,4 +279,7 @@
 /* Sunplus UART */
 #define PORT_SUNPLUS	123
 
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

greg k-h

#4 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Dear Greg,

Quoted 14 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

Quoted 6 lines
include/uapi/linux/serial_core.h +0 -0
@@ -279,4 +279,7 @@
  /* Sunplus UART */
  #define PORT_SUNPLUS	123
 
Quoted 8 lines

include/uapi/linux/serial_core.h line 284

Quoted 3 lines
include/uapi/linux/serial_core.h +3 -0
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

greg k-h

Because the serial driver requires a port->type, and almost all serial drivers defined their port type here. We follow the practice of most serial drivers here.
If we don't do it this way, we would have to directly assign a value to port->type. However, such modifications were questioned in the past, which is why we changed it back to defining the port type in serial_core.h.

Best regards,
Jacky Huang

maintainer
#5 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 24 lines · Jacky Huang

Dear Greg,

Quoted 20 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

include/uapi/linux/serial_core.h line 283

Quoted 8 lines
include/uapi/linux/serial_core.h +3 -0
@@ -279,4 +279,7 @@
  /* Sunplus UART */
  #define PORT_SUNPLUS	123
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

Quoted 8 lines
Quoted 1 line

greg k-h

Because the serial driver requires a port->type, and almost all serial drivers defined their port type here. We follow the practice of most serial drivers here.
If we don't do it this way, we would have to directly assign a value to port->type. However, such modifications were questioned in the past, which is why we changed it back to defining the port type in serial_core.h.

I really really want to get rid of this list, as it's a UAPI that no one uses. So please don't use it, it doesn't help anything, and while the serial driver might require it, it doesn't actually do anything with that field, right? So why don't we just set all of the values to the same one?

thanks,

greg k-h

#6 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 32 lines · Greg KH
Quoted 22 lines · Jacky Huang
Quoted 20 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

include/uapi/linux/serial_core.h line 283

Quoted 8 lines
include/uapi/linux/serial_core.h +3 -0
@@ -279,4 +279,7 @@
  /* Sunplus UART */
  #define PORT_SUNPLUS	123
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

Quoted 8 lines
Quoted 1 line

greg k-h

Because the serial driver requires a port->type, and almost all serial drivers defined their port type here. We follow the practice of most serial drivers here.
If we don't do it this way, we would have to directly assign a value to port->type. However, such modifications were questioned in the past, which is why we changed it back to defining the port type in serial_core.h.

Quoted 5 lines

I really really want to get rid of this list, as it's a UAPI that no one uses. So please don't use it, it doesn't help anything, and while the serial driver might require it, it doesn't actually do anything with that field, right? So why don't we just set all of the values to the same one?

I don't see how Jacky can come up with a patch to do this correctly without more specific guidance to what exactly you are looking for, after the last 123 people that added support for a new port got that merged.

I checked debian codesearch and found only three obscure packages that accidentally include this header instead of including linux/serial.h, a couple of lists of all kernel headers, and none that include it on purpose. I agree that this header should really not exist in uapi, but the question is what exactly to do about it.

Possible changes would be:

- add a special value PORT_* constant other than PORT_UNKNOWN that can be used by serial drivers instead of a unique value, and ensure that the serial core can handle drivers using it.

- move all values used by the 8250 driver from serial_core.h to serial.h, as this driver actually uses the constants.

- Move the remaining contents of uapi/linux/serial.h into the non-uapi version.

- Change all drivers that only reference a single PORT_* value to use the generic one.

Arnd

maintainer
#7 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 56 lines · Arnd Bergmann
Quoted 32 lines · Greg KH
Quoted 22 lines · Jacky Huang
Quoted 20 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

include/uapi/linux/serial_core.h line 283

Quoted 8 lines
include/uapi/linux/serial_core.h +3 -0
@@ -279,4 +279,7 @@
   /* Sunplus UART */
   #define PORT_SUNPLUS	123
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

Quoted 8 lines
Quoted 1 line

greg k-h

Because the serial driver requires a port->type, and almost all serial drivers defined their port type here. We follow the practice of most serial drivers here.
If we don't do it this way, we would have to directly assign a value to port->type. However, such modifications were questioned in the past, which is why we changed it back to defining the port type in serial_core.h.

Quoted 5 lines

I really really want to get rid of this list, as it's a UAPI that no one uses. So please don't use it, it doesn't help anything, and while the serial driver might require it, it doesn't actually do anything with that field, right? So why don't we just set all of the values to the same one?

I don't see how Jacky can come up with a patch to do this correctly without more specific guidance to what exactly you are looking for, after the last 123 people that added support for a new port got that merged.

I checked debian codesearch and found only three obscure packages that accidentally include this header instead of including linux/serial.h, a couple of lists of all kernel headers, and none that include it on purpose. I agree that this header should really not exist in uapi, but the question is what exactly to do about it.

Possible changes would be:

- add a special value PORT_* constant other than PORT_UNKNOWN that can be used by serial drivers instead of a unique value, and ensure that the serial core can handle drivers using it.

Quoted 8 lines

- move all values used by the 8250 driver from serial_core.h to serial.h, as this driver actually uses the constants.

- Move the remaining contents of uapi/linux/serial.h into the non-uapi version.

- Change all drivers that only reference a single PORT_* value to use the generic one.

Hmm, we are looping :).

https://lore.kernel.org/all/[email protected]/

regards,

Signature · 2 lines
js
suse labs
#8 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

In reply to Arnd Bergmann
Quoted 39 lines · Arnd Bergmann
Quoted 32 lines · Greg KH
Quoted 22 lines · Jacky Huang
Quoted 20 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

include/uapi/linux/serial_core.h line 283

Quoted 8 lines
include/uapi/linux/serial_core.h +3 -0
@@ -279,4 +279,7 @@
  /* Sunplus UART */
  #define PORT_SUNPLUS	123
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

Quoted 8 lines
Quoted 1 line

greg k-h

Because the serial driver requires a port->type, and almost all serial drivers defined their port type here. We follow the practice of most serial drivers here.
If we don't do it this way, we would have to directly assign a value to port->type. However, such modifications were questioned in the past, which is why we changed it back to defining the port type in serial_core.h.

Quoted 5 lines

I really really want to get rid of this list, as it's a UAPI that no one uses. So please don't use it, it doesn't help anything, and while the serial driver might require it, it doesn't actually do anything with that field, right? So why don't we just set all of the values to the same one?

Quoted 4 lines

I don't see how Jacky can come up with a patch to do this correctly without more specific guidance to what exactly you are looking for, after the last 123 people that added support for a new port got that merged.

I keep complaining about this, when I notice it. Just use the "default" port type in the serial driver and don't add a new type here and it should just work, right?

Quoted 11 lines

I checked debian codesearch and found only three obscure packages that accidentally include this header instead of including linux/serial.h, a couple of lists of all kernel headers, and none that include it on purpose. I agree that this header should really not exist in uapi, but the question is what exactly to do about it.

Possible changes would be:

- add a special value PORT_* constant other than PORT_UNKNOWN that can be used by serial drivers instead of a unique value, and ensure that the serial core can handle drivers using it.

Why do we need a special constant?

Quoted 2 lines

- move all values used by the 8250 driver from serial_core.h to serial.h, as this driver actually uses the constants.

Makes sense.

Quoted 5 lines

- Move the remaining contents of uapi/linux/serial.h into the non-uapi version.

- Change all drivers that only reference a single PORT_* value to use the generic one.

I think this is the best thing to do.

thanks,

greg k-h

#9 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 64 lines · Greg Kroah-Hartman
Quoted 35 lines · Arnd Bergmann
Quoted 29 lines · Greg KH
Quoted 21 lines · Jacky Huang
Quoted 20 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

include/uapi/linux/serial_core.h line 283

Quoted 8 lines
include/uapi/linux/serial_core.h +3 -0
@@ -279,4 +279,7 @@
   /* Sunplus UART */
   #define PORT_SUNPLUS	123
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

Quoted 7 lines
Quoted 1 line

greg k-h

Because the serial driver requires a port->type, and almost all serial drivers defined their port type here. We follow the practice of most serial drivers here.
If we don't do it this way, we would have to directly assign a value to port->type. However, such modifications were questioned in the past, which is why we changed it back to defining the port type in serial_core.h.

Quoted 5 lines

I really really want to get rid of this list, as it's a UAPI that no one uses. So please don't use it, it doesn't help anything, and while the serial driver might require it, it doesn't actually do anything with that field, right? So why don't we just set all of the values to the same one?

Quoted 4 lines

I don't see how Jacky can come up with a patch to do this correctly without more specific guidance to what exactly you are looking for, after the last 123 people that added support for a new port got that merged.

I keep complaining about this, when I notice it. Just use the "default" port type in the serial driver and don't add a new type here and it should just work, right?

Quoted 11 lines

I checked debian codesearch and found only three obscure packages that accidentally include this header instead of including linux/serial.h, a couple of lists of all kernel headers, and none that include it on purpose. I agree that this header should really not exist in uapi, but the question is what exactly to do about it.

Possible changes would be:

- add a special value PORT_* constant other than PORT_UNKNOWN that can be used by serial drivers instead of a unique value, and ensure that the serial core can handle drivers using it.

Why do we need a special constant?

Quoted 2 lines

- move all values used by the 8250 driver from serial_core.h to serial.h, as this driver actually uses the constants.

Makes sense.

Quoted 3 lines

- Move the remaining contents of uapi/linux/serial.h into the non-uapi version.

Quoted 7 lines
Quoted 2 lines

- Change all drivers that only reference a single PORT_* value to use the generic one.

I think this is the best thing to do.

thanks,

greg k-h

I will remove the definition of PORT_MA35 without modifying serial_core.h.

However, we still need to assign a value to port->type. So, can we follow the approach used in the LiteUART driver and directly assign port->type = 1?

Best regards,
Jacky Huang

#10 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 71 lines · Jacky Huang
Quoted 68 lines · Greg Kroah-Hartman
Quoted 35 lines · Arnd Bergmann
Quoted 29 lines · Greg KH
Quoted 21 lines · Jacky Huang
Quoted 20 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You get a full 72 columns for your changelog :)

include/uapi/linux/serial_core.h line 283

Quoted 8 lines
include/uapi/linux/serial_core.h +3 -0
@@ -279,4 +279,7 @@
   /* Sunplus UART */
   #define PORT_SUNPLUS	123
+/* Nuvoton MA35 SoC */
+#define PORT_MA35	124
+

Why is this change needed? What userspace code is going to rely on it?

thanks,

Quoted 7 lines
Quoted 1 line

greg k-h

Because the serial driver requires a port->type, and almost all serial drivers defined their port type here. We follow the practice of most serial drivers here.
If we don't do it this way, we would have to directly assign a value to port->type. However, such modifications were questioned in the past, which is why we changed it back to defining the port type in serial_core.h.

Quoted 5 lines

I really really want to get rid of this list, as it's a UAPI that no one uses. So please don't use it, it doesn't help anything, and while the serial driver might require it, it doesn't actually do anything with that field, right? So why don't we just set all of the values to the same one?

Quoted 4 lines

I don't see how Jacky can come up with a patch to do this correctly without more specific guidance to what exactly you are looking for, after the last 123 people that added support for a new port got that merged.

I keep complaining about this, when I notice it. Just use the "default" port type in the serial driver and don't add a new type here and it should just work, right?

Quoted 11 lines

I checked debian codesearch and found only three obscure packages that accidentally include this header instead of including linux/serial.h, a couple of lists of all kernel headers, and none that include it on purpose. I agree that this header should really not exist in uapi, but the question is what exactly to do about it.

Possible changes would be:

- add a special value PORT_* constant other than PORT_UNKNOWN that can be used by serial drivers instead of a unique value, and ensure that the serial core can handle drivers using it.

Why do we need a special constant?

Quoted 2 lines

- move all values used by the 8250 driver from serial_core.h to serial.h, as this driver actually uses the constants.

Makes sense.

Quoted 5 lines

- Move the remaining contents of uapi/linux/serial.h into the non-uapi version.

- Change all drivers that only reference a single PORT_* value to use the generic one.

I think this is the best thing to do.

Quoted 8 lines
Quoted 3 lines

thanks,

greg k-h

I will remove the definition of PORT_MA35 without modifying serial_core.h.

However, we still need to assign a value to port->type. So, can we follow the approach used in the LiteUART driver and directly assign port->type = 1?

Works for me, thanks.

greg k-h

#11 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

In reply to Greg Kroah-Hartman
Quoted 17 lines · Greg Kroah-Hartman
Quoted 5 lines · Arnd Bergmann

On Tue, Jun 13, 2023, at 16:49, Greg KH wrote:
I don't see how Jacky can come up with a patch to do this correctly without more specific guidance to what exactly you are looking for, after the last 123 people that added support for a new port got that merged.

I keep complaining about this, when I notice it. Just use the "default" port type in the serial driver and don't add a new type here and it should just work, right?

Quoted 6 lines

I checked debian codesearch and found only three obscure packages that accidentally include this header instead of including linux/serial.h, a couple of lists of all kernel headers, and none that include it on purpose. I agree that this header should really not exist in uapi, but the question is what exactly to do about it.

Quoted 7 lines
Quoted 5 lines

Possible changes would be:

- add a special value PORT_* constant other than PORT_UNKNOWN that can be used by serial drivers instead of a unique value, and ensure that the serial core can handle drivers using it.

Why do we need a special constant?

The "default" value is 0, which translates to PORT_UNKNOWN, and the serial core code prevents this from working. I think Jacky tried to use this the last one or two times you commented on it, and it did not work.

Setting it to a plain '1' as Jacky suggested in his reply is the same as PORT_8250, which may or may not be a good choice here.

Since the number is exported to userspace in serial_struct, it might be better to pick a new constant such as

#define PORT_SERIAL_GENERIC (-1)

in order to be less ambiguous. It's a signed integer, so -1 would work here this would clearly be a special value, or another option might be to use 255 as something that is slightly less special but still recognizable as something that may have a special meaning.

Arnd

#12 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 24 lines · Arnd Bergmann
Quoted 23 lines · Greg Kroah-Hartman
Quoted 5 lines · Arnd Bergmann

On Tue, Jun 13, 2023, at 16:49, Greg KH wrote:
I don't see how Jacky can come up with a patch to do this correctly without more specific guidance to what exactly you are looking for, after the last 123 people that added support for a new port got that merged.

I keep complaining about this, when I notice it. Just use the "default" port type in the serial driver and don't add a new type here and it should just work, right?

Quoted 11 lines

I checked debian codesearch and found only three obscure packages that accidentally include this header instead of including linux/serial.h, a couple of lists of all kernel headers, and none that include it on purpose. I agree that this header should really not exist in uapi, but the question is what exactly to do about it.

Possible changes would be:

- add a special value PORT_* constant other than PORT_UNKNOWN that can be used by serial drivers instead of a unique value, and ensure that the serial core can handle drivers using it.

Quoted 6 lines
Quoted 1 line

Why do we need a special constant?

The "default" value is 0, which translates to PORT_UNKNOWN, and the serial core code prevents this from working. I think Jacky tried to use this the last one or two times you commented on it, and it did not work.

Ah, thanks, that makes sense.

Quoted 2 lines

Setting it to a plain '1' as Jacky suggested in his reply is the same as PORT_8250, which may or may not be a good choice here.

Odds are it would be fine :)

Quoted 10 lines

Since the number is exported to userspace in serial_struct, it might be better to pick a new constant such as

#define PORT_SERIAL_GENERIC (-1)

in order to be less ambiguous. It's a signed integer, so -1 would work here this would clearly be a special value, or another option might be to use 255 as something that is slightly less special but still recognizable as something that may have a special meaning.

A new constant would be good, 255 is nice, and then we can move everyone to use it unless they can specifically show a reason why it will not work for them.

I think originally this was used to do device-specific ioctls, right? That shouldn't be happening anymore, hopefully...

thanks,

greg k-h

#13 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 12 lines · Greg Kroah-Hartman
Quoted 10 lines · Arnd Bergmann

Since the number is exported to userspace in serial_struct, it might be better to pick a new constant such as

#define PORT_SERIAL_GENERIC (-1)

in order to be less ambiguous. It's a signed integer, so -1 would work here this would clearly be a special value, or another option might be to use 255 as something that is slightly less special but still recognizable as something that may have a special meaning.

Quoted 6 lines

A new constant would be good, 255 is nice, and then we can move everyone to use it unless they can specifically show a reason why it will not work for them.

I think originally this was used to do device-specific ioctls, right? That shouldn't be happening anymore, hopefully...

The only thing I could find is that you can use TIOCSSERIAL to set the type between the supported types within a driver, which changes the behavior in some cases, e.g. the exact size and layout of the register file or its capabilities.

We may need a proper audit of TIOCSSERIAL anyway, I suspect there are worse things you can do with other settings.

Arnd

maintainer
#14 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

In reply to Jacky Huang
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You don't specify here what your tty device name is going to be, why?

It's not written anywhere, is that intentional?

Same for your tty major/minor, what numbers are you using that might also be in use by a different device in the system?

thanks,

greg k-h

#15 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Dear Greg,

Quoted 8 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You don't specify here what your tty device name is going to be, why?

Quoted 8 lines

It's not written anywhere, is that intentional?

Same for your tty major/minor, what numbers are you using that might also be in use by a different device in the system?

thanks,

greg k-h

I will add description about the tty name to the log. In practical testing, we specified in the u-boot parameters to use ttyNVT0 for the console, and it worked fine.

Best regards,
Jacky Huang

maintainer
#16 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Quoted 17 lines · Jacky Huang

Dear Greg,

Quoted 13 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You don't specify here what your tty device name is going to be, why?

It's not written anywhere, is that intentional?

Same for your tty major/minor, what numbers are you using that might also be in use by a different device in the system?

Quoted 7 lines
Quoted 3 lines

thanks,

greg k-h

I will add description about the tty name to the log. In practical testing, we specified in the u-boot parameters to use ttyNVT0 for the console, and it worked fine.

Where did you pick that name from? Why can't you use the "default" uart name instead?

I thought we had a list of tty names around somewhere, but I can't find it right now...

thanks,

greg k-h

#17 lore raw

Re: [PATCH v14 1/1] tty: serial: Add Nuvoton ma35d1 serial driver support

Dear Greg,

Quoted 27 lines · Greg KH
Quoted 17 lines · Jacky Huang

Dear Greg,

Quoted 13 lines · Greg KH
Quoted 5 lines · Jacky Huang

From: Jacky Huang <[email protected]>

This adds UART and console driver for Nuvoton ma35d1 Soc. It supports full-duplex communication, FIFO control, and hardware flow control.

You don't specify here what your tty device name is going to be, why?

It's not written anywhere, is that intentional?

Same for your tty major/minor, what numbers are you using that might also be in use by a different device in the system?

Quoted 6 lines
Quoted 3 lines

thanks,

greg k-h

I will add description about the tty name to the log. In practical testing, we specified in the u-boot parameters to use ttyNVT0 for the console, and it worked fine.

Where did you pick that name from? Why can't you use the "default" uart name instead?

Quoted 6 lines

I thought we had a list of tty names around somewhere, but I can't find it right now...

thanks,

greg k-h

Initially, we were using the well-known ttyS, but it is used by the 8250 driver. Since the MA35D1 UART is incompatible with the 8250 driver, Andr raised concerns about using ttyS.

To differentiate this UART from the incompatible 8250, we defined ttyNVT. This name is specified in the driver's UART name and console name structure, and other serial drivers follow a similar approach. For example, we can find names like ttySA, ttySAC, ttySC, ttySIF, ttySTM, ttySUP, and so on.

If you believe that this UART driver can use ttyS, I am more than willing to make the modification. After all, some applications and scripts default to using ttyS, and using ttyNVT can indeed cause some inconvenience in certain situations.

Best regards,
Jacky Huang