Skip to contentSkip to conversation

drivers: char: omap-uart: provide a default clock frequency

PATCH In review Amneesh Singh 3 participants 5 messages Aug 20, 2024 – Aug 22, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drivers: char: omap-uart: provide a default clock frequency

Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, use a default frequency of 48MHz if the device tree does not specify one.

---
 xen/drivers/char/omap-uart.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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

v1 -> v2
- Ditch adding a dtuart option
- Use a default value instead

This default is the same one as found in the 8250_omap driver of the linux tree. Already tested with Xen.

xen/drivers/char/omap-uart.c +6 -2
index 1079198..9d3d39c 100644
@@ -48,6 +48,9 @@
 /* System configuration register */
 #define UART_OMAP_SYSC_DEF_CONF   0x0d   /* autoidle mode, wakeup is enabled */
 
+/* default clock frequency in hz */
+#define UART_OMAP_DEFAULT_CLK_SPEED 48000000
+
 #define omap_read(uart, off)       readl((uart)->regs + ((off) << REG_SHIFT))
 #define omap_write(uart, off, val) writel(val, \
                                           (uart)->regs + ((off) << REG_SHIFT))
@@ -322,8 +325,9 @@ static int __init omap_uart_init(struct dt_device_node *dev,
     res = dt_property_read_u32(dev, "clock-frequency", &clkspec);
     if ( !res )
     {
-        printk("omap-uart: Unable to retrieve the clock frequency\n");
-        return -EINVAL;
+        printk("omap-uart: Unable to retrieve the clock frequency, "
+               "defaulting to %uHz\n", UART_OMAP_DEFAULT_CLK_SPEED);
+        clkspec = UART_OMAP_DEFAULT_CLK_SPEED;
     }
 
     uart->clock_hz = clkspec;
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Amneesh Singh

Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, use a default frequency of 48MHz if the device tree does not specify one.

I'd mention that this is same as Linux

Quoted 20 lines
---
 xen/drivers/char/omap-uart.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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

v1 -> v2
- Ditch adding a dtuart option
- Use a default value instead

This default is the same one as found in the 8250_omap driver of the linux tree. Already tested with Xen.

xen/drivers/char/omap-uart.c +0 -0
index 1079198..9d3d39c 100644

xen/drivers/char/omap-uart.c line 52

Quoted 5 lines
xen/drivers/char/omap-uart.c +2 -0
@@ -48,6 +48,9 @@
 /* System configuration register */
 #define UART_OMAP_SYSC_DEF_CONF   0x0d   /* autoidle mode, wakeup is enabled */
 
+/* default clock frequency in hz */
+#define UART_OMAP_DEFAULT_CLK_SPEED 48000000

I think this should have U suffix to please MISRA 7.2

xen/drivers/char/omap-uart.c static int __init omap_uart_init(struct dt_device_node *dev, · line 329

Quoted 12 lines
xen/drivers/char/omap-uart.c +3 -2
+
 #define omap_read(uart, off)       readl((uart)->regs + ((off) << REG_SHIFT))
 #define omap_write(uart, off, val) writel(val, \
                                           (uart)->regs + ((off) << REG_SHIFT))
@@ -322,8 +325,9 @@ static int __init omap_uart_init(struct dt_device_node *dev,
     res = dt_property_read_u32(dev, "clock-frequency", &clkspec);
     if ( !res )
     {
-        printk("omap-uart: Unable to retrieve the clock frequency\n");
-        return -EINVAL;
+        printk("omap-uart: Unable to retrieve the clock frequency, "
+               "defaulting to %uHz\n", UART_OMAP_DEFAULT_CLK_SPEED);

Even though there is a comma, printk messages should not really be split. In such cases it's fine to exceed 80 chars limit. Or do:
printk("omap-uart: Clock frequency not specified, defaulting to %uHz\n",
UART_OMAP_DEFAULT_CLK_SPEED);

Other than that:

~Michal

#2 lore raw

Hi,

Quoted 36 lines · Michal Orzel
Quoted 6 lines · Amneesh Singh

Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, use a default frequency of 48MHz if the device tree does not specify one.

I'd mention that this is same as Linux

Quoted 20 lines
---
  xen/drivers/char/omap-uart.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)

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

v1 -> v2
- Ditch adding a dtuart option
- Use a default value instead

This default is the same one as found in the 8250_omap driver of the linux tree. Already tested with Xen.

xen/drivers/char/omap-uart.c +0 -0
index 1079198..9d3d39c 100644

xen/drivers/char/omap-uart.c line 52

Quoted 5 lines
xen/drivers/char/omap-uart.c +2 -0
@@ -48,6 +48,9 @@
  /* System configuration register */
  #define UART_OMAP_SYSC_DEF_CONF   0x0d   /* autoidle mode, wakeup is enabled */
 
+/* default clock frequency in hz */
+#define UART_OMAP_DEFAULT_CLK_SPEED 48000000

I think this should have U suffix to please MISRA 7.2

Quoted 14 lines

xen/drivers/char/omap-uart.c static int __init omap_uart_init(struct dt_device_node *dev, · line 329

Quoted 12 lines
xen/drivers/char/omap-uart.c +3 -2
+
  #define omap_read(uart, off)       readl((uart)->regs + ((off) << REG_SHIFT))
  #define omap_write(uart, off, val) writel(val, \
                                            (uart)->regs + ((off) << REG_SHIFT))
@@ -322,8 +325,9 @@ static int __init omap_uart_init(struct dt_device_node *dev,
      res = dt_property_read_u32(dev, "clock-frequency", &clkspec);
      if ( !res )
      {
-        printk("omap-uart: Unable to retrieve the clock frequency\n");
-        return -EINVAL;
+        printk("omap-uart: Unable to retrieve the clock frequency, "
+               "defaulting to %uHz\n", UART_OMAP_DEFAULT_CLK_SPEED);

Even though there is a comma, printk messages should not really be split. In such cases it's fine to exceed 80 chars limit. Or do:

In general, we allow to exceed the limit only for the message. If there are arguments then ...

Quoted 2 lines

printk("omap-uart: Clock frequency not specified, defaulting to %uHz\n",
UART_OMAP_DEFAULT_CLK_SPEED);

... this is the preferred approach. I can do the update on commit if an updated commit message is provided.

Cheers,

Signature · 1 line
Julien Grall
#3 lore raw

Hello,

Quoted 38 lines · Julien Grall

Hi,

Quoted 35 lines · Michal Orzel
Quoted 6 lines · Amneesh Singh

Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, use a default frequency of 48MHz if the device tree does not specify one.

I'd mention that this is same as Linux

Quoted 20 lines
---
  xen/drivers/char/omap-uart.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)

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

v1 -> v2
- Ditch adding a dtuart option
- Use a default value instead

This default is the same one as found in the 8250_omap driver of the linux tree. Already tested with Xen.

xen/drivers/char/omap-uart.c +0 -0
index 1079198..9d3d39c 100644

xen/drivers/char/omap-uart.c line 52

Quoted 5 lines
xen/drivers/char/omap-uart.c +2 -0
@@ -48,6 +48,9 @@
  /* System configuration register */
  #define UART_OMAP_SYSC_DEF_CONF   0x0d   /* autoidle mode, wakeup is enabled */
 
+/* default clock frequency in hz */
+#define UART_OMAP_DEFAULT_CLK_SPEED 48000000

I think this should have U suffix to please MISRA 7.2

Can I count on you to add this unsigned suffix as well? Thanks.

Quoted 16 lines
Quoted 15 lines

xen/drivers/char/omap-uart.c static int __init omap_uart_init(struct dt_device_node *dev, · line 329

Quoted 13 lines
xen/drivers/char/omap-uart.c +3 -2
+
  #define omap_read(uart, off)       readl((uart)->regs + ((off) << REG_SHIFT))
  #define omap_write(uart, off, val) writel(val, \
                                            (uart)->regs + ((off) << REG_SHIFT))
@@ -322,8 +325,9 @@ static int __init omap_uart_init(struct dt_device_node *dev,
      res = dt_property_read_u32(dev, "clock-frequency", &clkspec);
      if ( !res )
      {
-        printk("omap-uart: Unable to retrieve the clock frequency\n");
-        return -EINVAL;
+        printk("omap-uart: Unable to retrieve the clock frequency, "
+               "defaulting to %uHz\n", UART_OMAP_DEFAULT_CLK_SPEED);

Even though there is a comma, printk messages should not really be split. In such cases it's fine to exceed 80 chars limit. Or do:

Quoted 8 lines

In general, we allow to exceed the limit only for the message. If there are arguments then ...

Quoted 2 lines

printk("omap-uart: Clock frequency not specified, defaulting to %uHz\n",
UART_OMAP_DEFAULT_CLK_SPEED);

... this is the preferred approach. I can do the update on commit if an updated commit message is provided.

Please do, thanks. You can use this as the commit message:

[quote]

Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, use a default frequency of 48MHz, which is the same as the linux default (see 8250_omap.c), if the device tree does not specify it.

[/quote]

Or if you'd prefer, I can resend the thing with the suggested changes.

Quoted 7 lines

Cheers,

--
Julien Grall

Regards
Amneesh

#4 lore raw
Quoted 1 line · Amneesh Singh

Hello,

Hi Amneesh,

Quoted 71 lines · Julien Grall
Quoted 38 lines

Hi,

Quoted 35 lines · Michal Orzel
Quoted 6 lines · Amneesh Singh

Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, use a default frequency of 48MHz if the device tree does not specify one.

I'd mention that this is same as Linux

Quoted 20 lines
---
   xen/drivers/char/omap-uart.c | 8 ++++++--
   1 file changed, 6 insertions(+), 2 deletions(-)

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

v1 -> v2
- Ditch adding a dtuart option
- Use a default value instead

This default is the same one as found in the 8250_omap driver of the linux tree. Already tested with Xen.

xen/drivers/char/omap-uart.c +0 -0
index 1079198..9d3d39c 100644

xen/drivers/char/omap-uart.c line 52

Quoted 5 lines
xen/drivers/char/omap-uart.c +2 -0
@@ -48,6 +48,9 @@
   /* System configuration register */
   #define UART_OMAP_SYSC_DEF_CONF   0x0d   /* autoidle mode, wakeup is enabled */
 
+/* default clock frequency in hz */
+#define UART_OMAP_DEFAULT_CLK_SPEED 48000000

I think this should have U suffix to please MISRA 7.2

Can I count on you to add this unsigned suffix as well? Thanks.

Quoted 16 lines
Quoted 15 lines

xen/drivers/char/omap-uart.c static int __init omap_uart_init(struct dt_device_node *dev, · line 329

Quoted 13 lines
xen/drivers/char/omap-uart.c +3 -2
+
   #define omap_read(uart, off)       readl((uart)->regs + ((off) << REG_SHIFT))
   #define omap_write(uart, off, val) writel(val, \
                                             (uart)->regs + ((off) << REG_SHIFT))
@@ -322,8 +325,9 @@ static int __init omap_uart_init(struct dt_device_node *dev,
       res = dt_property_read_u32(dev, "clock-frequency", &clkspec);
       if ( !res )
       {
-        printk("omap-uart: Unable to retrieve the clock frequency\n");
-        return -EINVAL;
+        printk("omap-uart: Unable to retrieve the clock frequency, "
+               "defaulting to %uHz\n", UART_OMAP_DEFAULT_CLK_SPEED);

Even though there is a comma, printk messages should not really be split. In such cases it's fine to exceed 80 chars limit. Or do:

Quoted 8 lines

In general, we allow to exceed the limit only for the message. If there are arguments then ...

Quoted 2 lines

printk("omap-uart: Clock frequency not specified, defaulting to %uHz\n",
UART_OMAP_DEFAULT_CLK_SPEED);

... this is the preferred approach. I can do the update on commit if an updated commit message is provided.

Please do, thanks. You can use this as the commit message:

[quote]

Quoted 7 lines

Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, use a default frequency of 48MHz, which is the same as the linux default (see 8250_omap.c), if the device tree does not specify it.

[/quote]

Thanks for the updated commit message. I have updated it while commiting the patch.

Cheers,

Signature · 1 line
Julien Grall