* [U-Boot] [PATCH v2 4/8] x86: slimbootloader: Add serial driver
@ 2019-06-25 23:19 Park, Aiden
2019-07-02 14:13 ` Bin Meng
0 siblings, 1 reply; 3+ messages in thread
From: Park, Aiden @ 2019-06-25 23:19 UTC (permalink / raw)
To: u-boot
- Get serial port information from the serial port info hob
- Leverage ns16550 driver with slimbootloader specific platform data
Signed-off-by: Aiden Park <aiden.park@intel.com>
---
arch/x86/cpu/slimbootloader/Makefile | 2 +-
arch/x86/cpu/slimbootloader/serial.c | 62 +++++++++++++++++++
.../asm/arch-slimbootloader/slimbootloader.h | 33 ++++++++++
3 files changed, 96 insertions(+), 1 deletion(-)
create mode 100644 arch/x86/cpu/slimbootloader/serial.c
diff --git a/arch/x86/cpu/slimbootloader/Makefile b/arch/x86/cpu/slimbootloader/Makefile
index 4b0b3e71c9..3e62f564cd 100644
--- a/arch/x86/cpu/slimbootloader/Makefile
+++ b/arch/x86/cpu/slimbootloader/Makefile
@@ -2,4 +2,4 @@
#
# Copyright (C) 2019 Intel Corporation <www.intel.com>
-obj-y += car.o slimbootloader.o hob.o dram.o
+obj-y += car.o slimbootloader.o hob.o dram.o serial.o
diff --git a/arch/x86/cpu/slimbootloader/serial.c b/arch/x86/cpu/slimbootloader/serial.c
new file mode 100644
index 0000000000..186c7a79ef
--- /dev/null
+++ b/arch/x86/cpu/slimbootloader/serial.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <ns16550.h>
+#include <serial.h>
+#include <asm/arch/slimbootloader.h>
+
+int slimbootloader_serial_ofdata_to_platdata(struct udevice *dev)
+{
+ const struct efi_guid guid = LOADER_SERIAL_PORT_INFO_GUID;
+ struct serial_port_info *serial_info = NULL;
+ struct ns16550_platdata *plat = dev->platdata;
+
+ serial_info = (struct serial_port_info *)
+ get_next_guid_hob_data(&guid, gd->arch.hob_list);
+
+ if (!serial_info) {
+ debug("failed to get serial port information\n");
+ return -ENOENT;
+ }
+ debug("type:%d base=0x%08x baudrate=%d stride=%d clk=%d\n",
+ serial_info->type,
+ serial_info->base,
+ serial_info->baud,
+ serial_info->stride,
+ serial_info->clk);
+
+ /*
+ * The serial_info->type provides port io or mmio access type info,
+ * but the access type will be controlled by
+ * CONFIG_SYS_NS16550_PORT_MAPPED or CONFIG_SYS_NS16550_MEM32.
+ *
+ * TBD: ns16550 access type configuration in runtime.
+ * ex) plat->access_type = serial_info->type
+ */
+ plat->base = serial_info->base;
+ /* ns16550 uses reg_shift, then covert stride to shift */
+ plat->reg_shift = (serial_info->stride >> 1);
+ plat->clock = serial_info->clk;
+
+ return 0;
+}
+
+static const struct udevice_id slimbootloader_serial_ids[] = {
+ { .compatible = "intel,slimbootloader-uart" },
+ {}
+};
+
+U_BOOT_DRIVER(serial_slimbootloader) = {
+ .name = "serial_slimbootloader",
+ .id = UCLASS_SERIAL,
+ .of_match = slimbootloader_serial_ids,
+ .ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata,
+ .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
+ .priv_auto_alloc_size = sizeof(struct NS16550),
+ .probe = ns16550_serial_probe,
+ .ops = &ns16550_serial_ops,
+};
diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
index c85201e711..b05e527148 100644
--- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
+++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
@@ -16,6 +16,12 @@
{ 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } \
}
+#define LOADER_SERIAL_PORT_INFO_GUID \
+ { \
+ 0x6c6872fe, 0x56a9, 0x4403, \
+ { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } \
+ }
+
/**
* A single entry of memory map information
*
@@ -48,6 +54,33 @@ struct memory_map_info {
struct memory_map_entry entry[0];
} __packed;
+/**
+ * This includes serial port info which has already been initialized in previous
+ * Slim Bootloader stage.
+ * The Slim Bootloader initializes serial port regardless of debug/release build
+ * modes, and it passes the information to a payload thru hob. So, a payload can
+ * re-use the serial information without re-initializing serial port.
+ *
+ * @rev : revision of serial_port_info structure. currently 1.
+ * @rsvd : padding for alignment
+ * @type : port io: 1, mmio: 2
+ * @base : io base address. ex) 0x3f8, 0x80001000
+ * @baud : uart baud rate
+ * @stride: register stride in Bytes
+ * @clk : uart frequency in Hz
+ * @rsvd1 : reserved
+ */
+struct serial_port_info {
+ u8 rev;
+ u8 rsvd[3];
+ u32 type;
+ u32 base;
+ u32 baud;
+ u32 stride;
+ u32 clk;
+ u32 rsvd1;
+} __packed;
+
/**
* This returns a pointer to hob data buffer if the given guid hob is found.
*
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2 4/8] x86: slimbootloader: Add serial driver
2019-06-25 23:19 [U-Boot] [PATCH v2 4/8] x86: slimbootloader: Add serial driver Park, Aiden
@ 2019-07-02 14:13 ` Bin Meng
2019-07-08 16:37 ` Park, Aiden
0 siblings, 1 reply; 3+ messages in thread
From: Bin Meng @ 2019-07-02 14:13 UTC (permalink / raw)
To: u-boot
Hi Aiden,
On Wed, Jun 26, 2019 at 7:19 AM Park, Aiden <aiden.park@intel.com> wrote:
>
> - Get serial port information from the serial port info hob
Again, the same question: does this serial port info hob apply to FSP
based board? (eg: newer FSP produces such hob for bootloader to use?)
If yes, we probably need rename the driver to something more generic,
like "intel,hob-uart"?
> - Leverage ns16550 driver with slimbootloader specific platform data
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
> arch/x86/cpu/slimbootloader/Makefile | 2 +-
> arch/x86/cpu/slimbootloader/serial.c | 62 +++++++++++++++++++
> .../asm/arch-slimbootloader/slimbootloader.h | 33 ++++++++++
> 3 files changed, 96 insertions(+), 1 deletion(-)
> create mode 100644 arch/x86/cpu/slimbootloader/serial.c
>
> diff --git a/arch/x86/cpu/slimbootloader/Makefile b/arch/x86/cpu/slimbootloader/Makefile
> index 4b0b3e71c9..3e62f564cd 100644
> --- a/arch/x86/cpu/slimbootloader/Makefile
> +++ b/arch/x86/cpu/slimbootloader/Makefile
> @@ -2,4 +2,4 @@
> #
> # Copyright (C) 2019 Intel Corporation <www.intel.com>
>
> -obj-y += car.o slimbootloader.o hob.o dram.o
> +obj-y += car.o slimbootloader.o hob.o dram.o serial.o
> diff --git a/arch/x86/cpu/slimbootloader/serial.c b/arch/x86/cpu/slimbootloader/serial.c
> new file mode 100644
> index 0000000000..186c7a79ef
> --- /dev/null
> +++ b/arch/x86/cpu/slimbootloader/serial.c
> @@ -0,0 +1,62 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2019 Intel Corporation <www.intel.com>
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <ns16550.h>
> +#include <serial.h>
> +#include <asm/arch/slimbootloader.h>
> +
> +int slimbootloader_serial_ofdata_to_platdata(struct udevice *dev)
> +{
> + const struct efi_guid guid = LOADER_SERIAL_PORT_INFO_GUID;
> + struct serial_port_info *serial_info = NULL;
> + struct ns16550_platdata *plat = dev->platdata;
> +
> + serial_info = (struct serial_port_info *)
> + get_next_guid_hob_data(&guid, gd->arch.hob_list);
> +
> + if (!serial_info) {
> + debug("failed to get serial port information\n");
> + return -ENOENT;
> + }
> + debug("type:%d base=0x%08x baudrate=%d stride=%d clk=%d\n",
> + serial_info->type,
> + serial_info->base,
> + serial_info->baud,
> + serial_info->stride,
> + serial_info->clk);
> +
> + /*
> + * The serial_info->type provides port io or mmio access type info,
> + * but the access type will be controlled by
> + * CONFIG_SYS_NS16550_PORT_MAPPED or CONFIG_SYS_NS16550_MEM32.
> + *
> + * TBD: ns16550 access type configuration in runtime.
> + * ex) plat->access_type = serial_info->type
> + */
> + plat->base = serial_info->base;
> + /* ns16550 uses reg_shift, then covert stride to shift */
> + plat->reg_shift = (serial_info->stride >> 1);
> + plat->clock = serial_info->clk;
> +
> + return 0;
> +}
> +
> +static const struct udevice_id slimbootloader_serial_ids[] = {
> + { .compatible = "intel,slimbootloader-uart" },
> + {}
> +};
> +
> +U_BOOT_DRIVER(serial_slimbootloader) = {
> + .name = "serial_slimbootloader",
> + .id = UCLASS_SERIAL,
> + .of_match = slimbootloader_serial_ids,
> + .ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata,
> + .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
> + .priv_auto_alloc_size = sizeof(struct NS16550),
> + .probe = ns16550_serial_probe,
> + .ops = &ns16550_serial_ops,
> +};
> diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
> index c85201e711..b05e527148 100644
> --- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
> +++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
> @@ -16,6 +16,12 @@
> { 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } \
> }
>
> +#define LOADER_SERIAL_PORT_INFO_GUID \
> + { \
> + 0x6c6872fe, 0x56a9, 0x4403, \
> + { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } \
> + }
> +
> /**
> * A single entry of memory map information
> *
> @@ -48,6 +54,33 @@ struct memory_map_info {
> struct memory_map_entry entry[0];
> } __packed;
>
> +/**
> + * This includes serial port info which has already been initialized in previous
> + * Slim Bootloader stage.
> + * The Slim Bootloader initializes serial port regardless of debug/release build
> + * modes, and it passes the information to a payload thru hob. So, a payload can
> + * re-use the serial information without re-initializing serial port.
> + *
> + * @rev : revision of serial_port_info structure. currently 1.
> + * @rsvd : padding for alignment
> + * @type : port io: 1, mmio: 2
> + * @base : io base address. ex) 0x3f8, 0x80001000
> + * @baud : uart baud rate
> + * @stride: register stride in Bytes
> + * @clk : uart frequency in Hz
> + * @rsvd1 : reserved
> + */
> +struct serial_port_info {
> + u8 rev;
> + u8 rsvd[3];
> + u32 type;
> + u32 base;
> + u32 baud;
> + u32 stride;
> + u32 clk;
> + u32 rsvd1;
> +} __packed;
> +
> /**
> * This returns a pointer to hob data buffer if the given guid hob is found.
> *
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2 4/8] x86: slimbootloader: Add serial driver
2019-07-02 14:13 ` Bin Meng
@ 2019-07-08 16:37 ` Park, Aiden
0 siblings, 0 replies; 3+ messages in thread
From: Park, Aiden @ 2019-07-08 16:37 UTC (permalink / raw)
To: u-boot
Hi Bin,
> -----Original Message-----
> From: Bin Meng [mailto:bmeng.cn at gmail.com]
> Sent: Tuesday, July 2, 2019 7:14 AM
> To: Park, Aiden <aiden.park@intel.com>
> Cc: U-Boot Mailing List <u-boot@lists.denx.de>; Simon Glass
> <sjg@chromium.org>
> Subject: Re: [PATCH v2 4/8] x86: slimbootloader: Add serial driver
>
> Hi Aiden,
>
> On Wed, Jun 26, 2019 at 7:19 AM Park, Aiden <aiden.park@intel.com> wrote:
> >
> > - Get serial port information from the serial port info hob
>
> Again, the same question: does this serial port info hob apply to FSP based
> board? (eg: newer FSP produces such hob for bootloader to use?) If yes, we
> probably need rename the driver to something more generic, like "intel,hob-
> uart"?
These HOB is provided from Slim Bootloader, not from FSP. Slim Bootloader consumes FSP HOB, but it's removed before loading a Payload. Instead of FSP HOB, Slim Bootloader generates some new HOBs for Payload usages only. This serial port info hob also is only generated from Slim Bootloader. Let me add a brief description in next patch.
>
>
> > - Leverage ns16550 driver with slimbootloader specific platform data
> >
> > Signed-off-by: Aiden Park <aiden.park@intel.com>
> > ---
> > arch/x86/cpu/slimbootloader/Makefile | 2 +-
> > arch/x86/cpu/slimbootloader/serial.c | 62 +++++++++++++++++++
> > .../asm/arch-slimbootloader/slimbootloader.h | 33 ++++++++++
> > 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644
> > arch/x86/cpu/slimbootloader/serial.c
> >
> > diff --git a/arch/x86/cpu/slimbootloader/Makefile
> > b/arch/x86/cpu/slimbootloader/Makefile
> > index 4b0b3e71c9..3e62f564cd 100644
> > --- a/arch/x86/cpu/slimbootloader/Makefile
> > +++ b/arch/x86/cpu/slimbootloader/Makefile
> > @@ -2,4 +2,4 @@
> > #
> > # Copyright (C) 2019 Intel Corporation <www.intel.com>
> >
> > -obj-y += car.o slimbootloader.o hob.o dram.o
> > +obj-y += car.o slimbootloader.o hob.o dram.o serial.o
> > diff --git a/arch/x86/cpu/slimbootloader/serial.c
> > b/arch/x86/cpu/slimbootloader/serial.c
> > new file mode 100644
> > index 0000000000..186c7a79ef
> > --- /dev/null
> > +++ b/arch/x86/cpu/slimbootloader/serial.c
> > @@ -0,0 +1,62 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright (C) 2019 Intel Corporation <www.intel.com> */
> > +
> > +#include <common.h>
> > +#include <dm.h>
> > +#include <ns16550.h>
> > +#include <serial.h>
> > +#include <asm/arch/slimbootloader.h>
> > +
> > +int slimbootloader_serial_ofdata_to_platdata(struct udevice *dev) {
> > + const struct efi_guid guid = LOADER_SERIAL_PORT_INFO_GUID;
> > + struct serial_port_info *serial_info = NULL;
> > + struct ns16550_platdata *plat = dev->platdata;
> > +
> > + serial_info = (struct serial_port_info *)
> > + get_next_guid_hob_data(&guid, gd->arch.hob_list);
> > +
> > + if (!serial_info) {
> > + debug("failed to get serial port information\n");
> > + return -ENOENT;
> > + }
> > + debug("type:%d base=0x%08x baudrate=%d stride=%d clk=%d\n",
> > + serial_info->type,
> > + serial_info->base,
> > + serial_info->baud,
> > + serial_info->stride,
> > + serial_info->clk);
> > +
> > + /*
> > + * The serial_info->type provides port io or mmio access type info,
> > + * but the access type will be controlled by
> > + * CONFIG_SYS_NS16550_PORT_MAPPED or
> CONFIG_SYS_NS16550_MEM32.
> > + *
> > + * TBD: ns16550 access type configuration in runtime.
> > + * ex) plat->access_type = serial_info->type
> > + */
> > + plat->base = serial_info->base;
> > + /* ns16550 uses reg_shift, then covert stride to shift */
> > + plat->reg_shift = (serial_info->stride >> 1);
> > + plat->clock = serial_info->clk;
> > +
> > + return 0;
> > +}
> > +
> > +static const struct udevice_id slimbootloader_serial_ids[] = {
> > + { .compatible = "intel,slimbootloader-uart" },
> > + {}
> > +};
> > +
> > +U_BOOT_DRIVER(serial_slimbootloader) = {
> > + .name = "serial_slimbootloader",
> > + .id = UCLASS_SERIAL,
> > + .of_match = slimbootloader_serial_ids,
> > + .ofdata_to_platdata = slimbootloader_serial_ofdata_to_platdata,
> > + .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
> > + .priv_auto_alloc_size = sizeof(struct NS16550),
> > + .probe = ns16550_serial_probe,
> > + .ops = &ns16550_serial_ops,
> > +};
> > diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
> > b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
> > index c85201e711..b05e527148 100644
> > --- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
> > +++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
> > @@ -16,6 +16,12 @@
> > { 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } \
> > }
> >
> > +#define LOADER_SERIAL_PORT_INFO_GUID \
> > + { \
> > + 0x6c6872fe, 0x56a9, 0x4403, \
> > + { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } \
> > + }
> > +
> > /**
> > * A single entry of memory map information
> > *
> > @@ -48,6 +54,33 @@ struct memory_map_info {
> > struct memory_map_entry entry[0]; } __packed;
> >
> > +/**
> > + * This includes serial port info which has already been initialized
> > +in previous
> > + * Slim Bootloader stage.
> > + * The Slim Bootloader initializes serial port regardless of
> > +debug/release build
> > + * modes, and it passes the information to a payload thru hob. So, a
> > +payload can
> > + * re-use the serial information without re-initializing serial port.
> > + *
> > + * @rev : revision of serial_port_info structure. currently 1.
> > + * @rsvd : padding for alignment
> > + * @type : port io: 1, mmio: 2
> > + * @base : io base address. ex) 0x3f8, 0x80001000
> > + * @baud : uart baud rate
> > + * @stride: register stride in Bytes
> > + * @clk : uart frequency in Hz
> > + * @rsvd1 : reserved
> > + */
> > +struct serial_port_info {
> > + u8 rev;
> > + u8 rsvd[3];
> > + u32 type;
> > + u32 base;
> > + u32 baud;
> > + u32 stride;
> > + u32 clk;
> > + u32 rsvd1;
> > +} __packed;
> > +
> > /**
> > * This returns a pointer to hob data buffer if the given guid hob is found.
> > *
> > --
> > 2.20.1
> >
Best Regards,
Aiden
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-08 16:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 23:19 [U-Boot] [PATCH v2 4/8] x86: slimbootloader: Add serial driver Park, Aiden
2019-07-02 14:13 ` Bin Meng
2019-07-08 16:37 ` Park, Aiden
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.