Skip to contentSkip to conversation

arm/acpi: Add Server Base System Architecture UART support

PATCH Superseded Shanker Donthineni 4 participants 9 messages May 27, 2016 – May 30, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm/acpi: Add Server Base System Architecture UART support

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

---
https://silver.arm.com/download/download.tm?pv=2950177

 xen/drivers/char/pl011.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
xen/drivers/char/pl011.c +21 -4
index 1212d5c..81d095f 100644
@@ -226,14 +226,14 @@ static struct uart_driver __read_mostly pl011_driver = {
     .vuart_info   = pl011_vuart,
 };
 
-static int __init pl011_uart_init(int irq, u64 addr, u64 size)
+static int __init pl011_uart_init(int irq, u64 addr, u64 size, int baud)
 {
     struct pl011 *uart;
 
     uart = &pl011_com;
     uart->irq       = irq;
     uart->clock_hz  = 0x16e3600;
-    uart->baud      = BAUD_AUTO;
+    uart->baud      = baud;
     uart->data_bits = 8;
     uart->parity    = PARITY_NONE;
     uart->stop_bits = 1;
@@ -285,7 +285,7 @@ static int __init pl011_dt_uart_init(struct dt_device_node *dev,
         return -EINVAL;
     }
 
-    res = pl011_uart_init(res, addr, size);
+    res = pl011_uart_init(res, addr, size, BAUD_AUTO);
     if ( res < 0 )
     {
         printk("pl011: Unable to initialize\n");
@@ -315,6 +315,7 @@ static int __init pl011_acpi_uart_init(const void *data)
 {
     acpi_status status;
     struct acpi_table_spcr *spcr = NULL;
+    int baud = BAUD_AUTO;
     int res;
 
     status = acpi_get_table(ACPI_SIG_SPCR, 0,
@@ -326,17 +327,23 @@ static int __init pl011_acpi_uart_init(const void *data)
         return -EINVAL;
     }
 
+    if ( (spcr->interface_type == ACPI_DBG2_SBSA_32) ||
+         (spcr->interface_type == ACPI_DBG2_SBSA) )
+        baud = 115200;
+
     /* trigger/polarity information is not available in spcr */
     irq_set_type(spcr->interrupt, IRQ_TYPE_LEVEL_HIGH);
 
     res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
-                          PAGE_SIZE);
+                          PAGE_SIZE, baud);
     if ( res < 0 )
     {
         printk("pl011: Unable to initialize\n");
         return res;
     }
 
+
+
     return 0;
 }
 
@@ -344,6 +351,16 @@ ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
         .class_type = ACPI_DBG2_PL011,
         .init = pl011_acpi_uart_init,
 ACPI_DEVICE_END
+
+ACPI_DEVICE_START(asbsa_uart, "SBSA UART", DEVICE_SERIAL)
+        .class_type = ACPI_DBG2_SBSA,
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
+
+ACPI_DEVICE_START(asbsa32_uart, "SBSA32 UART", DEVICE_SERIAL)
+        .class_type = ACPI_DBG2_SBSA_32,
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
 #endif
 
 /*
Signature · 9 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc. 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

Hello Shanker,

Quoted 4 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

I cannot find any mention of the baudrate in the SBSA. Where does it come from?

Also the driver is using registers which should not be touch for the SBSA UART (see appendix B in the SBSA ARM-DEN-0029 v3.0). So this need to be address to get a proper support.

Quoted 45 lines

---
https://silver.arm.com/download/download.tm?pv=2950177

  xen/drivers/char/pl011.c | 25 +++++++++++++++++++++----
  1 file changed, 21 insertions(+), 4 deletions(-)
xen/drivers/char/pl011.c +4 -3
index 1212d5c..81d095f 100644
@@ -226,14 +226,14 @@ static struct uart_driver __read_mostly pl011_driver = {
      .vuart_info   = pl011_vuart,
  };
 
-static int __init pl011_uart_init(int irq, u64 addr, u64 size)
+static int __init pl011_uart_init(int irq, u64 addr, u64 size, int baud)
  {
      struct pl011 *uart;
 
      uart = &pl011_com;
      uart->irq       = irq;
      uart->clock_hz  = 0x16e3600;
-    uart->baud      = BAUD_AUTO;
+    uart->baud      = baud;
      uart->data_bits = 8;
      uart->parity    = PARITY_NONE;
      uart->stop_bits = 1;
@@ -285,7 +285,7 @@ static int __init pl011_dt_uart_init(struct dt_device_node *dev,
          return -EINVAL;
      }
 
-    res = pl011_uart_init(res, addr, size);
+    res = pl011_uart_init(res, addr, size, BAUD_AUTO);
      if ( res < 0 )
      {
          printk("pl011: Unable to initialize\n");
@@ -315,6 +315,7 @@ static int __init pl011_acpi_uart_init(const void *data)
  {
      acpi_status status;
      struct acpi_table_spcr *spcr = NULL;
+    int baud = BAUD_AUTO;
      int res;
 
      status = acpi_get_table(ACPI_SIG_SPCR, 0,

xen/drivers/char/pl011.c static int __init pl011_acpi_uart_init(const void *data) · line 330

Quoted 4 lines
xen/drivers/char/pl011.c +1 -0
@@ -326,17 +327,23 @@ static int __init pl011_acpi_uart_init(const void *data)
          return -EINVAL;
      }
 
+    if ( (spcr->interface_type == ACPI_DBG2_SBSA_32) ||

Based on the DBG2 spec, this value is deprecated. So I do not think we should support it.

Quoted 7 lines
xen/drivers/char/pl011.c +3 -0
+         (spcr->interface_type == ACPI_DBG2_SBSA) )
+        baud = 115200;
+
      /* trigger/polarity information is not available in spcr */
      irq_set_type(spcr->interrupt, IRQ_TYPE_LEVEL_HIGH);
 
      res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,

xen/drivers/char/pl011.c static int __init pl011_acpi_uart_init(const void *data) · line 346

Quoted 10 lines
xen/drivers/char/pl011.c +3 -1
-                          PAGE_SIZE);
+                          PAGE_SIZE, baud);
      if ( res < 0 )
      {
          printk("pl011: Unable to initialize\n");
          return res;
      }
 
+
+

Spurious changes.

Quoted 11 lines
xen/drivers/char/pl011.c +3 -0
      return 0;
  }
 
@@ -344,6 +351,16 @@ ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
          .class_type = ACPI_DBG2_PL011,
          .init = pl011_acpi_uart_init,
  ACPI_DEVICE_END
+
+ACPI_DEVICE_START(asbsa_uart, "SBSA UART", DEVICE_SERIAL)
+        .class_type = ACPI_DBG2_SBSA,

xen/drivers/char/pl011.c ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL) · line 366

Quoted 10 lines
xen/drivers/char/pl011.c +7 -0
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
+
+ACPI_DEVICE_START(asbsa32_uart, "SBSA32 UART", DEVICE_SERIAL)
+        .class_type = ACPI_DBG2_SBSA_32,
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
  #endif
 
  /*

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw
Quoted 10 lines · Julien Grall

Hello Shanker,

Quoted 4 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

I cannot find any mention of the baudrate in the SBSA. Where does it come from?

Yes, no where mentioned about the baudrate in SBSA document. I used 115200 based on the the Linux PL011 driver.

Quoted 2 lines

Also the driver is using registers which should not be touch for the SBSA UART (see appendix B in the SBSA ARM-DEN-0029 v3.0). So this need to be address to get a proper support.

Yes, I agree with you, Which registers it is touching other than baudrate control registers?

Quoted 43 lines
Quoted 43 lines

---
https://silver.arm.com/download/download.tm?pv=2950177

  xen/drivers/char/pl011.c | 25 +++++++++++++++++++++----
  1 file changed, 21 insertions(+), 4 deletions(-)
xen/drivers/char/pl011.c +4 -3
index 1212d5c..81d095f 100644
@@ -226,14 +226,14 @@ static struct uart_driver __read_mostly pl011_driver = {
      .vuart_info   = pl011_vuart,
  };
 
-static int __init pl011_uart_init(int irq, u64 addr, u64 size)
+static int __init pl011_uart_init(int irq, u64 addr, u64 size, int baud)
  {
      struct pl011 *uart;
 
      uart = &pl011_com;
      uart->irq       = irq;
      uart->clock_hz  = 0x16e3600;
-    uart->baud      = BAUD_AUTO;
+    uart->baud      = baud;
      uart->data_bits = 8;
      uart->parity    = PARITY_NONE;
      uart->stop_bits = 1;
@@ -285,7 +285,7 @@ static int __init pl011_dt_uart_init(struct dt_device_node *dev,
          return -EINVAL;
      }
 
-    res = pl011_uart_init(res, addr, size);
+    res = pl011_uart_init(res, addr, size, BAUD_AUTO);
      if ( res < 0 )
      {
          printk("pl011: Unable to initialize\n");
@@ -315,6 +315,7 @@ static int __init pl011_acpi_uart_init(const void *data)
  {
      acpi_status status;
      struct acpi_table_spcr *spcr = NULL;
+    int baud = BAUD_AUTO;
      int res;
 
Quoted 9 lines

xen/drivers/char/pl011.c static int __init pl011_acpi_uart_init(const void *data) · line 330

Quoted 6 lines
xen/drivers/char/pl011.c +1 -0
      status = acpi_get_table(ACPI_SIG_SPCR, 0,
@@ -326,17 +327,23 @@ static int __init pl011_acpi_uart_init(const void *data)
          return -EINVAL;
      }
 
+    if ( (spcr->interface_type == ACPI_DBG2_SBSA_32) ||

Based on the DBG2 spec, this value is deprecated. So I do not think we should support it.

I'll fix.

Quoted 44 lines
Quoted 7 lines
xen/drivers/char/pl011.c +3 -0
+         (spcr->interface_type == ACPI_DBG2_SBSA) )
+        baud = 115200;
+
      /* trigger/polarity information is not available in spcr */
      irq_set_type(spcr->interrupt, IRQ_TYPE_LEVEL_HIGH);
 
      res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,

xen/drivers/char/pl011.c static int __init pl011_acpi_uart_init(const void *data) · line 346

Quoted 10 lines
xen/drivers/char/pl011.c +3 -1
-                          PAGE_SIZE);
+                          PAGE_SIZE, baud);
      if ( res < 0 )
      {
          printk("pl011: Unable to initialize\n");
          return res;
      }
 
+
+

Spurious changes.

Quoted 11 lines
xen/drivers/char/pl011.c +3 -0
      return 0;
  }
 
@@ -344,6 +351,16 @@ ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
          .class_type = ACPI_DBG2_PL011,
          .init = pl011_acpi_uart_init,
  ACPI_DEVICE_END
+
+ACPI_DEVICE_START(asbsa_uart, "SBSA UART", DEVICE_SERIAL)
+        .class_type = ACPI_DBG2_SBSA,

xen/drivers/char/pl011.c ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL) · line 366

Quoted 10 lines
xen/drivers/char/pl011.c +7 -0
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
+
+ACPI_DEVICE_START(asbsa32_uart, "SBSA32 UART", DEVICE_SERIAL)
+        .class_type = ACPI_DBG2_SBSA_32,
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
  #endif
 
  /*

Regards,

Signature · 9 lines
Shanker Donthineni
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#3 lore raw

Hello Shanker,

Quoted 10 lines · Shanker Donthineni
Quoted 8 lines · Julien Grall
Quoted 4 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

I cannot find any mention of the baudrate in the SBSA. Where does it come from?

Yes, no where mentioned about the baudrate in SBSA document. I used 115200 based on the the Linux PL011 driver.

Looking at the Linux code, it is a default when there is no valid configuration (which may not be suitable for any platform?).

Whilst Linux userspace cares about the baudrate, Xen only use it to configure the hardware. Given that the UART should have been configured by the hardware-specific software, the proper value should be BAUD_AUTO.

If you look at the code, pl011_init_preirq will read the baud rate when uart->baud == BAUD_AUTO but will never be used after.

Quoted 3 lines
Quoted 2 lines

Also the driver is using registers which should not be touch for the SBSA UART (see appendix B in the SBSA ARM-DEN-0029 v3.0). So this need to be address to get a proper support.

Yes, I agree with you, Which registers it is touching other than baudrate control registers?

Well, I only gave a quick look and noticed the difference between the SBSA and the pl011 (e.g CR, IFLS,...) . I am sure you can find out the rest of the registers by looking at the code (pl011-uart.h) and the spec.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#4 lore raw

I'll address your review comments in V2 patch.

Quoted 28 lines · Julien Grall

Hello Shanker,

Quoted 10 lines · Shanker Donthineni
Quoted 8 lines · Julien Grall
Quoted 4 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

I cannot find any mention of the baudrate in the SBSA. Where does it come from?

Yes, no where mentioned about the baudrate in SBSA document. I used 115200 based on the the Linux PL011 driver.

Looking at the Linux code, it is a default when there is no valid configuration (which may not be suitable for any platform?).

Whilst Linux userspace cares about the baudrate, Xen only use it to configure the hardware. Given that the UART should have been configured by the hardware-specific software, the proper value should be BAUD_AUTO.

If you look at the code, pl011_init_preirq will read the baud rate when uart->baud == BAUD_AUTO but will never be used after.

Quoted 3 lines
Quoted 2 lines

Also the driver is using registers which should not be touch for the SBSA UART (see appendix B in the SBSA ARM-DEN-0029 v3.0). So this need to be address to get a proper support.

Yes, I agree with you, Which registers it is touching other than baudrate control registers?

Well, I only gave a quick look and noticed the difference between the SBSA and the pl011 (e.g CR, IFLS,...) . I am sure you can find out the rest of the registers by looking at the code (pl011-uart.h) and the spec.

Regards,

Signature · 9 lines
Shanker Donthineni
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#5 lore raw
In reply to Julien Grall

Hi Shanker,

Quoted 35 lines · Julien Grall

Hello Shanker,

Quoted 11 lines · Shanker Donthineni
Quoted 9 lines · Julien Grall
Quoted 5 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

Quoted 5 lines
Quoted 3 lines

I cannot find any mention of the baudrate in the SBSA. Where does it come from?

Yes, no where mentioned about the baudrate in SBSA document. I used 115200 based on the the Linux PL011 driver.

Looking at the Linux code, it is a default when there is no valid configuration (which may not be suitable for any platform?).

Whilst Linux userspace cares about the baudrate, Xen only use it to configure the hardware. Given that the UART should have been configured by the hardware-specific software, the proper value should be BAUD_AUTO.

If you look at the code, pl011_init_preirq will read the baud rate when uart->baud == BAUD_AUTO but will never be used after.

Quoted 4 lines
Quoted 4 lines

Also the driver is using registers which should not be touch for the SBSA UART (see appendix B in the SBSA ARM-DEN-0029 v3.0). So this need to be address to get a proper support.

Quoted 8 lines
Quoted 2 lines

Yes, I agree with you, Which registers it is touching other than baudrate control registers?

Well, I only gave a quick look and noticed the difference between the SBSA and the pl011 (e.g CR, IFLS,...) . I am sure you can find out the rest of the registers by looking at the code (pl011-uart.h) and the spec.

The SBSA (ARM-DEN-0029 v3.0) has defined a minimum set of UART registers. When driver customizes the bandrate, it will access the IBRD and FBRD registers. But these two registers are not listed in the minimum set registers. In this case, not
all SBSA UARTs have these two registers. When uart->baud != BAUD_AUTO, the code will cause some UARTs' initialization to fail.

Quoted 10 lines

Regards,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
In reply to Julien Grall
Quoted 19 lines · Julien Grall

Hello Shanker,

Quoted 7 lines · Shanker Donthineni
Quoted 6 lines · Julien Grall
Quoted 4 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

Quoted 5 lines
Quoted 3 lines

I cannot find any mention of the baudrate in the SBSA. Where does it come from?

Yes, no where mentioned about the baudrate in SBSA document. I used 115200 based on the the Linux PL011 driver.

Looking at the Linux code, it is a default when there is no valid configuration (which may not be suitable for any platform?).

Quoted 6 lines

Whilst Linux userspace cares about the baudrate, Xen only use it to configure the hardware. Given that the UART should have been configured by the hardware-specific software, the proper value should be BAUD_AUTO.

If you look at the code, pl011_init_preirq will read the baud rate when uart->baud == BAUD_AUTO but will never be used after.

The problem is that IBRD and FBRD are not part of the SBSA doc, so to make the driver compliant, we would have to skip reading the baudrate too, which shouldn't be a problem.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw
Quoted 24 lines · Stefano Stabellini
Quoted 23 lines · Julien Grall

Hello Shanker,

Quoted 7 lines · Shanker Donthineni
Quoted 6 lines · Julien Grall
Quoted 4 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

Quoted 5 lines
Quoted 3 lines

I cannot find any mention of the baudrate in the SBSA. Where does it come from?

Yes, no where mentioned about the baudrate in SBSA document. I used 115200 based on the the Linux PL011 driver.

Looking at the Linux code, it is a default when there is no valid configuration (which may not be suitable for any platform?).

Whilst Linux userspace cares about the baudrate, Xen only use it to configure the hardware. Given that the UART should have been configured by the hardware-specific software, the proper value should be BAUD_AUTO.

Quoted 6 lines
Quoted 2 lines

If you look at the code, pl011_init_preirq will read the baud rate when uart->baud == BAUD_AUTO but will never be used after.

The problem is that IBRD and FBRD are not part of the SBSA doc, so to make the driver compliant, we would have to skip reading the baudrate too, which shouldn't be a problem.

Well, we are reading the baud rate, but it is never used within the driver except. So I would drop the code rather than skip it.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#8 lore raw
Quoted 33 lines · Julien Grall
Quoted 30 lines · Stefano Stabellini
Quoted 28 lines · Julien Grall

Hello Shanker,

Quoted 7 lines · Shanker Donthineni
Quoted 6 lines · Julien Grall
Quoted 4 lines · Shanker Donthineni

The ARM Server Base System Architecture describes a generic UART interface. It doesn't support clock control registers to set baudrate. So, extend the driver probe() to handle SBSA interface types and set the baudrate to 115200 for SBSA interfaces.

Quoted 7 lines
Quoted 4 lines

I cannot find any mention of the baudrate in the SBSA. Where does it come
from?

Yes, no where mentioned about the baudrate in SBSA document. I used 115200
based on the the Linux PL011 driver.

Looking at the Linux code, it is a default when there is no valid configuration (which may not be suitable for any platform?).

Whilst Linux userspace cares about the baudrate, Xen only use it to configure
the hardware. Given that the UART should have been configured by the hardware-specific software, the proper value should be BAUD_AUTO.

If you look at the code, pl011_init_preirq will read the baud rate when uart->baud == BAUD_AUTO but will never be used after.

Quoted 6 lines
Quoted 3 lines

The problem is that IBRD and FBRD are not part of the SBSA doc, so to make the driver compliant, we would have to skip reading the baudrate too, which shouldn't be a problem.

Well, we are reading the baud rate, but it is never used within the driver except. So I would drop the code rather than skip it.

Actually, looking a bit more at the code. The code to handle a fixed baud rate (baud != BAUD_AUTO) is likely buggy because the clock frequency (clk_hz) is hardcoded in Xen. Based on the commit log, the value is versatile express specific.

Anyway, the driver is always setting the baud rate to auto. So I will send a patch to drop completely the selection of the baud rate.

Note, that this may not be sufficient to support the SBSA UART.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel