diff mbox

[v5,20/22] arm/acpi: Initialize serial port from ACPI SPCR table

Message ID 1456467780-8476-21-git-send-email-zhaoshenglong@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shannon Zhao Feb. 26, 2016, 6:22 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Parse ACPI SPCR (Serial Port Console Redirection table) table and
initialize the serial port pl011.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/char/pl011.c  | 37 +++++++++++++++++++++++++++++++++++++
 xen/include/acpi/actbl2.h |  5 +++++
 2 files changed, 42 insertions(+)

Comments

Jan Beulich Feb. 26, 2016, 10:04 a.m. UTC | #1
>>> On 26.02.16 at 07:22, <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Parse ACPI SPCR (Serial Port Console Redirection table) table and
> initialize the serial port pl011.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

It's not obvious to me whether this could go in ahead of most of
the rest of the series, together with patch 19 (which clearly can
go in right away).

Jan
Shannon Zhao Feb. 26, 2016, 10:20 a.m. UTC | #2
On 2016/2/26 18:04, Jan Beulich wrote:
>>>> On 26.02.16 at 07:22, <zhaoshenglong@huawei.com> wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Parse ACPI SPCR (Serial Port Console Redirection table) table and
>> > initialize the serial port pl011.
>> > 
>> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
Thanks a lot!

> It's not obvious to me whether this could go in ahead of most of
> the rest of the series, together with patch 19 (which clearly can
> go in right away).

I think this one could go in ahead with patch 19 since it's independent.

Thanks,
Shannon Zhao Feb. 26, 2016, 11:10 a.m. UTC | #3
On 2016/2/26 18:20, Shannon Zhao wrote:
> 
> On 2016/2/26 18:04, Jan Beulich wrote:
>>>>> >>>> On 26.02.16 at 07:22, <zhaoshenglong@huawei.com> wrote:
>>>> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>> >> > 
>>>> >> > Parse ACPI SPCR (Serial Port Console Redirection table) table and
>>>> >> > initialize the serial port pl011.
>>>> >> > 
>>>> >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>>>> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>> >> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>> > Acked-by: Jan Beulich <jbeulich@suse.com>
>> > 
> Thanks a lot!
> 
>> > It's not obvious to me whether this could go in ahead of most of
>> > the rest of the series, together with patch 19 (which clearly can
>> > go in right away).
> I think this one could go in ahead with patch 19 since it's independent.
Actually it's not that independent since it relies on patch 11 to
compile. So this one could be picked up by Ian if you don't mind.

Thanks,
Jan Beulich Feb. 26, 2016, 12:32 p.m. UTC | #4
>>> On 26.02.16 at 12:10, <zhaoshenglong@huawei.com> wrote:

> 
> On 2016/2/26 18:20, Shannon Zhao wrote:
>> 
>> On 2016/2/26 18:04, Jan Beulich wrote:
>>>>>> >>>> On 26.02.16 at 07:22, <zhaoshenglong@huawei.com> wrote:
>>>>> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> >> > 
>>>>> >> > Parse ACPI SPCR (Serial Port Console Redirection table) table and
>>>>> >> > initialize the serial port pl011.
>>>>> >> > 
>>>>> >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>>>>> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> >> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>>> > Acked-by: Jan Beulich <jbeulich@suse.com>
>>> > 
>> Thanks a lot!
>> 
>>> > It's not obvious to me whether this could go in ahead of most of
>>> > the rest of the series, together with patch 19 (which clearly can
>>> > go in right away).
>> I think this one could go in ahead with patch 19 since it's independent.
> Actually it's not that independent since it relies on patch 11 to
> compile. So this one could be picked up by Ian if you don't mind.

I don't think Ian's going to pick up any of these patches
anymore. I've applied it already, fixing the build issue.

Jan
diff mbox

Patch

diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 7e16294..30a8551 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -27,6 +27,7 @@ 
 #include <asm/device.h>
 #include <xen/mm.h>
 #include <xen/vmap.h>
+#include <xen/acpi.h>
 #include <asm/pl011-uart.h>
 #include <asm/io.h>
 
@@ -308,6 +309,42 @@  DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
         .init = pl011_dt_uart_init,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+static int __init pl011_acpi_uart_init(const void *data)
+{
+    acpi_status status;
+    struct acpi_table_spcr *spcr = NULL;
+    int res;
+
+    status = acpi_get_table(ACPI_SIG_SPCR, 0,
+                            (struct acpi_table_header **)&spcr);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        printk("pl011: Failed to get SPCR table\n");
+        return -EINVAL;
+    }
+
+    /* trigger/polarity information is not available in spcr */
+    irq_set_type(spcr->interrupt, IRQ_TYPE_EDGE_BOTH);
+
+    res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
+                          PAGE_SIZE);
+    if ( res < 0 )
+    {
+        printk("pl011: Unable to initialize\n");
+        return res;
+    }
+
+    return 0;
+}
+
+ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
+        .class_type = ACPI_DBG2_PL011,
+        .init = pl011_acpi_uart_init,
+ACPI_DEVICE_END
+#endif
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h
index 1ad67f8..4341a30 100644
--- a/xen/include/acpi/actbl2.h
+++ b/xen/include/acpi/actbl2.h
@@ -281,6 +281,11 @@  struct acpi_dbg2_device {
 
 #define ACPI_DBG2_16550_COMPATIBLE  0x0000
 #define ACPI_DBG2_16550_SUBSET      0x0001
+#define ACPI_DBG2_PL011             0x0003
+#define ACPI_DBG2_SBSA_32           0x000d
+#define ACPI_DBG2_SBSA              0x000e
+#define ACPI_DBG2_DCC               0x000f
+#define ACPI_DBG2_BCM2835           0x0010
 
 #define ACPI_DBG2_1394_STANDARD     0x0000