* [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel
@ 2018-03-16 17:38 Ivan Gorinov
2018-03-16 17:52 ` Andy Shevchenko
2018-03-16 19:40 ` Simon Glass
0 siblings, 2 replies; 6+ messages in thread
From: Ivan Gorinov @ 2018-03-16 17:38 UTC (permalink / raw)
To: u-boot
On x86 platforms, U-Boot does not provide Device Tree data to the kernel.
This prevents the kernel from using the same hardware description.
Make a copy of DTB data with setup_data header and insert new item
into the the setup data linked list.
Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
---
arch/x86/include/asm/bootparam.h | 1 +
arch/x86/lib/zimage.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 90768a9..ea25cf7 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -12,6 +12,7 @@
/* setup data types */
#define SETUP_NONE 0
#define SETUP_E820_EXT 1
+#define SETUP_DTB 2
/* extensible setup data list node */
struct setup_data {
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 2a82bc8..41ad4c7 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -14,6 +14,8 @@
*/
#include <common.h>
+#include <malloc.h>
+#include <asm/global_data.h>
#include <asm/acpi_table.h>
#include <asm/io.h>
#include <asm/ptrace.h>
@@ -95,6 +97,35 @@ static int get_boot_protocol(struct setup_header *hdr)
}
}
+static int setup_device_tree(struct setup_header *hdr)
+{
+ const void *fdt_blob = gd->fdt_blob;
+ struct setup_data *sd;
+ int size;
+
+ if (!fdt_blob)
+ return 0;
+
+ size = fdt_totalsize(fdt_blob);
+ if (size < 0)
+ return -EINVAL;
+
+ size += sizeof(struct setup_data);
+ sd = (struct setup_data *)malloc(size);
+ if (!sd) {
+ printf("Not enough memory for DTB setup data\n");
+ return -ENOMEM;
+ }
+
+ sd->next = hdr->setup_data;
+ sd->type = SETUP_DTB;
+ sd->len = fdt_totalsize(fdt_blob);
+ memcpy(sd->data, fdt_blob, sd->len);
+ hdr->setup_data = (unsigned long)sd;
+
+ return 0;
+}
+
struct boot_params *load_zimage(char *image, unsigned long kernel_size,
ulong *load_addressp)
{
@@ -262,6 +293,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
#endif
setup_video(&setup_base->screen_info);
+ setup_device_tree(hdr);
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel
2018-03-16 17:38 [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel Ivan Gorinov
@ 2018-03-16 17:52 ` Andy Shevchenko
2018-03-16 17:55 ` Andy Shevchenko
2018-03-17 0:16 ` Ivan Gorinov
2018-03-16 19:40 ` Simon Glass
1 sibling, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-03-16 17:52 UTC (permalink / raw)
To: u-boot
On Fri, 2018-03-16 at 10:38 -0700, Ivan Gorinov wrote:
> On x86 platforms, U-Boot does not provide Device Tree data to the
> kernel.
> This prevents the kernel from using the same hardware description.
>
> Make a copy of DTB data with setup_data header and insert new item
> into the the setup data linked list.
So, now is the question, what to do with x86 hardware that has DTS in U-
Boot, but uses ACPI tables, generated by U-Boot.
Would it work properly?
I would try to test it on Intel Edison (I hope you may do this yourself
as well), though I don't know when, have not much time to work with
Edison right now.
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
> arch/x86/include/asm/bootparam.h | 1 +
> arch/x86/lib/zimage.c | 32
> ++++++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
>
> diff --git a/arch/x86/include/asm/bootparam.h
> b/arch/x86/include/asm/bootparam.h
> index 90768a9..ea25cf7 100644
> --- a/arch/x86/include/asm/bootparam.h
> +++ b/arch/x86/include/asm/bootparam.h
> @@ -12,6 +12,7 @@
> /* setup data types */
> #define SETUP_NONE 0
> #define SETUP_E820_EXT 1
> +#define SETUP_DTB 2
>
> /* extensible setup data list node */
> struct setup_data {
> diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
> index 2a82bc8..41ad4c7 100644
> --- a/arch/x86/lib/zimage.c
> +++ b/arch/x86/lib/zimage.c
> @@ -14,6 +14,8 @@
> */
>
> #include <common.h>
> +#include <malloc.h>
> +#include <asm/global_data.h>
> #include <asm/acpi_table.h>
> #include <asm/io.h>
> #include <asm/ptrace.h>
> @@ -95,6 +97,35 @@ static int get_boot_protocol(struct setup_header
> *hdr)
> }
> }
>
> +static int setup_device_tree(struct setup_header *hdr)
> +{
> + const void *fdt_blob = gd->fdt_blob;
> + struct setup_data *sd;
> + int size;
> +
> + if (!fdt_blob)
> + return 0;
> +
> + size = fdt_totalsize(fdt_blob);
> + if (size < 0)
> + return -EINVAL;
> +
> + size += sizeof(struct setup_data);
> + sd = (struct setup_data *)malloc(size);
> + if (!sd) {
> + printf("Not enough memory for DTB setup data\n");
> + return -ENOMEM;
> + }
> +
> + sd->next = hdr->setup_data;
> + sd->type = SETUP_DTB;
> + sd->len = fdt_totalsize(fdt_blob);
> + memcpy(sd->data, fdt_blob, sd->len);
> + hdr->setup_data = (unsigned long)sd;
> +
> + return 0;
> +}
> +
> struct boot_params *load_zimage(char *image, unsigned long
> kernel_size,
> ulong *load_addressp)
> {
> @@ -262,6 +293,7 @@ int setup_zimage(struct boot_params *setup_base,
> char *cmd_line, int auto_boot,
> #endif
>
> setup_video(&setup_base->screen_info);
> + setup_device_tree(hdr);
>
> return 0;
> }
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 6+ messages in thread* [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel
2018-03-16 17:52 ` Andy Shevchenko
@ 2018-03-16 17:55 ` Andy Shevchenko
2018-03-17 0:16 ` Ivan Gorinov
1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-03-16 17:55 UTC (permalink / raw)
To: u-boot
On Fri, 2018-03-16 at 19:52 +0200, Andy Shevchenko wrote:
> On Fri, 2018-03-16 at 10:38 -0700, Ivan Gorinov wrote:
> > On x86 platforms, U-Boot does not provide Device Tree data to the
> > kernel.
> > This prevents the kernel from using the same hardware description.
> >
> > Make a copy of DTB data with setup_data header and insert new item
> > into the the setup data linked list.
>
> So, now is the question, what to do with x86 hardware that has DTS in
> U-
> Boot, but uses ACPI tables, generated by U-Boot.
>
> Would it work properly?
>
> I would try to test it on Intel Edison (I hope you may do this
> yourself
> as well), though I don't know when, have not much time to work with
> Edison right now.
Perhaps for now you may use CONFIG_ACPI_GENERATE (or how it's called?).
> > #include <common.h>
> > +#include <malloc.h>
> > +#include <asm/global_data.h>
> > #include <asm/acpi_table.h>
Not in order.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel
2018-03-16 17:52 ` Andy Shevchenko
2018-03-16 17:55 ` Andy Shevchenko
@ 2018-03-17 0:16 ` Ivan Gorinov
2018-03-19 9:19 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Ivan Gorinov @ 2018-03-17 0:16 UTC (permalink / raw)
To: u-boot
On Fri, 2018-03-16 at 19:52 +0200, Andy Shevchenko wrote:
> On x86 platforms, U-Boot does not provide Device Tree data to the
> > kernel.
> > This prevents the kernel from using the same hardware description.
> >
> > Make a copy of DTB data with setup_data header and insert new item
> > into the the setup data linked list.
> So, now is the question, what to do with x86 hardware that has DTS in U-
> Boot, but uses ACPI tables, generated by U-Boot.
>
> Would it work properly?
It will work because CONFIG_OF is disabled in most x86 kernel configurations.
> I would try to test it on Intel Edison (I hope you may do this yourself
> as well), though I don't know when, have not much time to work with
> Edison right now.
I am going to try that on a Minnowboard.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel
2018-03-17 0:16 ` Ivan Gorinov
@ 2018-03-19 9:19 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-03-19 9:19 UTC (permalink / raw)
To: u-boot
On Fri, 2018-03-16 at 17:16 -0700, Ivan Gorinov wrote:
> On Fri, 2018-03-16 at 19:52 +0200, Andy Shevchenko wrote:
> > On x86 platforms, U-Boot does not provide Device Tree data to the
> > > kernel.
> > > This prevents the kernel from using the same hardware description.
> > >
> > > Make a copy of DTB data with setup_data header and insert new item
> > > into the the setup data linked list.
> >
> > So, now is the question, what to do with x86 hardware that has DTS
> > in U-
> > Boot, but uses ACPI tables, generated by U-Boot.
> >
> > Would it work properly?
>
> It will work because CONFIG_OF is disabled in most x86 kernel
> configurations.
No one prevents to put CONFIG_OF=y into kernel configuration.
> > I would try to test it on Intel Edison (I hope you may do this
> > yourself
> > as well), though I don't know when, have not much time to work with
> > Edison right now.
>
> I am going to try that on a Minnowboard.
Yes, please.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel
2018-03-16 17:38 [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel Ivan Gorinov
2018-03-16 17:52 ` Andy Shevchenko
@ 2018-03-16 19:40 ` Simon Glass
1 sibling, 0 replies; 6+ messages in thread
From: Simon Glass @ 2018-03-16 19:40 UTC (permalink / raw)
To: u-boot
On 16 March 2018 at 11:38, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
>
> On x86 platforms, U-Boot does not provide Device Tree data to the kernel.
> This prevents the kernel from using the same hardware description.
>
> Make a copy of DTB data with setup_data header and insert new item
> into the the setup data linked list.
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
> arch/x86/include/asm/bootparam.h | 1 +
> arch/x86/lib/zimage.c | 32 ++++++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
>
Reviewed-by: Simon Glass <sjg@chromium.org>
See below
> diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
> index 90768a9..ea25cf7 100644
> --- a/arch/x86/include/asm/bootparam.h
> +++ b/arch/x86/include/asm/bootparam.h
> @@ -12,6 +12,7 @@
> /* setup data types */
> #define SETUP_NONE 0
> #define SETUP_E820_EXT 1
> +#define SETUP_DTB 2
Make that an enum?
>
> /* extensible setup data list node */
> struct setup_data {
> diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
> index 2a82bc8..41ad4c7 100644
> --- a/arch/x86/lib/zimage.c
> +++ b/arch/x86/lib/zimage.c
> @@ -14,6 +14,8 @@
> */
>
> #include <common.h>
> +#include <malloc.h>
> +#include <asm/global_data.h>
> #include <asm/acpi_table.h>
> #include <asm/io.h>
> #include <asm/ptrace.h>
> @@ -95,6 +97,35 @@ static int get_boot_protocol(struct setup_header *hdr)
> }
> }
>
> +static int setup_device_tree(struct setup_header *hdr)
> +{
> + const void *fdt_blob = gd->fdt_blob;
> + struct setup_data *sd;
> + int size;
> +
> + if (!fdt_blob)
> + return 0;
> +
> + size = fdt_totalsize(fdt_blob);
> + if (size < 0)
> + return -EINVAL;
> +
> + size += sizeof(struct setup_data);
> + sd = (struct setup_data *)malloc(size);
> + if (!sd) {
> + printf("Not enough memory for DTB setup data\n");
> + return -ENOMEM;
> + }
> +
> + sd->next = hdr->setup_data;
> + sd->type = SETUP_DTB;
> + sd->len = fdt_totalsize(fdt_blob);
> + memcpy(sd->data, fdt_blob, sd->len);
> + hdr->setup_data = (unsigned long)sd;
> +
> + return 0;
> +}
> +
> struct boot_params *load_zimage(char *image, unsigned long kernel_size,
> ulong *load_addressp)
> {
> @@ -262,6 +293,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
> #endif
>
> setup_video(&setup_base->screen_info);
> + setup_device_tree(hdr);
>
> return 0;
> }
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-19 9:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-16 17:38 [U-Boot] [PATCH v2] x86: zImage: pass device tree setup data to the kernel Ivan Gorinov
2018-03-16 17:52 ` Andy Shevchenko
2018-03-16 17:55 ` Andy Shevchenko
2018-03-17 0:16 ` Ivan Gorinov
2018-03-19 9:19 ` Andy Shevchenko
2018-03-16 19:40 ` Simon Glass
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox