[v4,18/21] arm/acpi: Add a new ACPI initialized function for UART
diff mbox

Message ID 1453540813-15764-19-git-send-email-zhaoshenglong@huawei.com
State New, archived
Headers show

Commit Message

Shannon Zhao Jan. 23, 2016, 9:20 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

This adds a new function to initialize UART for ACPI on ARM.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c        |  2 +-
 xen/drivers/char/arm-uart.c | 33 +++++++++++++++++++++++++++++++--
 xen/include/xen/serial.h    |  2 +-
 3 files changed, 33 insertions(+), 4 deletions(-)

Comments

Jan Beulich Jan. 25, 2016, 3:04 p.m. UTC | #1
>>> On 23.01.16 at 10:20, <zhaoshenglong@huawei.com> wrote:
> --- a/xen/include/xen/serial.h
> +++ b/xen/include/xen/serial.h
> @@ -170,7 +170,7 @@ struct ns16550_defaults {
>  void ns16550_init(int index, struct ns16550_defaults *defaults);
>  void ehci_dbgp_init(void);
>  
> -void __init dt_uart_init(void);
> +void __init arm_uart_init(void);

As mentioned before - if you already have to touch this, please
take the opportunity to drop the stray __init here (section
placement annotations belong only on definitions, never on
declarations).

Jan
Stefano Stabellini Feb. 2, 2016, 5:48 p.m. UTC | #2
On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This adds a new function to initialize UART for ACPI on ARM.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/setup.c        |  2 +-
>  xen/drivers/char/arm-uart.c | 33 +++++++++++++++++++++++++++++++--
>  xen/include/xen/serial.h    |  2 +-
>  3 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index c15a09d..63feadf 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -766,7 +766,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>  
>      gic_preinit();
>  
> -    dt_uart_init();
> +    arm_uart_init();
>      console_init_preirq();
>      console_init_ring();
>  
> diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c
> index 883e615..a68959b 100644
> --- a/xen/drivers/char/arm-uart.c
> +++ b/xen/drivers/char/arm-uart.c
> @@ -1,7 +1,7 @@
>  /*
>   * xen/drivers/char/arm-uart.c
>   *
> - * Generic uart retrieved via the device tree
> + * Generic uart retrieved via the device tree or ACPI
>   *
>   * Julien Grall <julien.grall@linaro.org>
>   * Copyright (c) 2013 Linaro Limited.
> @@ -23,6 +23,7 @@
>  #include <xen/device_tree.h>
>  #include <xen/serial.h>
>  #include <xen/errno.h>
> +#include <xen/acpi.h>
>  
>  /*
>   * Configure UART port with a string:
> @@ -35,7 +36,7 @@
>  static char __initdata opt_dtuart[256] = "";
>  string_param("dtuart", opt_dtuart);
>  
> -void __init dt_uart_init(void)
> +static void __init dt_uart_init(void)
>  {
>      struct dt_device_node *dev;
>      int ret;
> @@ -96,6 +97,34 @@ void __init dt_uart_init(void)
>          printk("Unable to initialize dtuart: %d\n", ret);
>  }
>  
> +static void __init acpi_uart_init(void)
> +{
> +#ifdef CONFIG_ACPI

With acpi_disabled as an #define, you can ifdef the whole function.


> +    struct acpi_table_spcr *spcr=NULL;
                                  ^ code style


> +    int ret;
> +
> +    acpi_get_table(ACPI_SIG_SPCR, 0,(struct acpi_table_header **)&spcr);
                                       ^ code style

> +    if ( spcr == NULL )
> +        printk("Unable to get spcr table\n");
> +    else
> +    {
> +        ret = acpi_device_init(DEVICE_SERIAL, NULL, spcr->interface_type);
> +
> +        if ( ret )
> +            printk("Unable to initialize acpi uart: %d\n", ret);
> +    }
> +#endif
> +}
> +
> +void __init arm_uart_init(void)
> +{
> +    if ( acpi_disabled )
> +        dt_uart_init();
> +    else
> +        acpi_uart_init();
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
> index 71e6ade..5e1a536 100644
> --- a/xen/include/xen/serial.h
> +++ b/xen/include/xen/serial.h
> @@ -170,7 +170,7 @@ struct ns16550_defaults {
>  void ns16550_init(int index, struct ns16550_defaults *defaults);
>  void ehci_dbgp_init(void);
>  
> -void __init dt_uart_init(void);
> +void __init arm_uart_init(void);
>  
>  struct physdev_dbgp_op;
>  int dbgp_op(const struct physdev_dbgp_op *);
> -- 
> 2.0.4
> 
>

Patch
diff mbox

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index c15a09d..63feadf 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -766,7 +766,7 @@  void __init start_xen(unsigned long boot_phys_offset,
 
     gic_preinit();
 
-    dt_uart_init();
+    arm_uart_init();
     console_init_preirq();
     console_init_ring();
 
diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c
index 883e615..a68959b 100644
--- a/xen/drivers/char/arm-uart.c
+++ b/xen/drivers/char/arm-uart.c
@@ -1,7 +1,7 @@ 
 /*
  * xen/drivers/char/arm-uart.c
  *
- * Generic uart retrieved via the device tree
+ * Generic uart retrieved via the device tree or ACPI
  *
  * Julien Grall <julien.grall@linaro.org>
  * Copyright (c) 2013 Linaro Limited.
@@ -23,6 +23,7 @@ 
 #include <xen/device_tree.h>
 #include <xen/serial.h>
 #include <xen/errno.h>
+#include <xen/acpi.h>
 
 /*
  * Configure UART port with a string:
@@ -35,7 +36,7 @@ 
 static char __initdata opt_dtuart[256] = "";
 string_param("dtuart", opt_dtuart);
 
-void __init dt_uart_init(void)
+static void __init dt_uart_init(void)
 {
     struct dt_device_node *dev;
     int ret;
@@ -96,6 +97,34 @@  void __init dt_uart_init(void)
         printk("Unable to initialize dtuart: %d\n", ret);
 }
 
+static void __init acpi_uart_init(void)
+{
+#ifdef CONFIG_ACPI
+    struct acpi_table_spcr *spcr=NULL;
+    int ret;
+
+    acpi_get_table(ACPI_SIG_SPCR, 0,(struct acpi_table_header **)&spcr);
+
+    if ( spcr == NULL )
+        printk("Unable to get spcr table\n");
+    else
+    {
+        ret = acpi_device_init(DEVICE_SERIAL, NULL, spcr->interface_type);
+
+        if ( ret )
+            printk("Unable to initialize acpi uart: %d\n", ret);
+    }
+#endif
+}
+
+void __init arm_uart_init(void)
+{
+    if ( acpi_disabled )
+        dt_uart_init();
+    else
+        acpi_uart_init();
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 71e6ade..5e1a536 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -170,7 +170,7 @@  struct ns16550_defaults {
 void ns16550_init(int index, struct ns16550_defaults *defaults);
 void ehci_dbgp_init(void);
 
-void __init dt_uart_init(void);
+void __init arm_uart_init(void);
 
 struct physdev_dbgp_op;
 int dbgp_op(const struct physdev_dbgp_op *);