linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: ingenic: Add support for appended devicetree
@ 2019-02-21 20:38 Paul Cercueil
  2019-02-21 21:13 ` Jonas Gorski
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Cercueil @ 2019-02-21 20:38 UTC (permalink / raw)
  To: Ralf Baechle, Paul Burton, James Hogan
  Cc: linux-mips, linux-kernel, Paul Cercueil

Add support for booting the kernel from an externally-appended
devicetree, if no devicetree was built-in.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 arch/mips/Kconfig        |  2 +-
 arch/mips/jz4740/setup.c | 14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index a84c24d894aa..8b7ea9062198 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -391,7 +391,7 @@ config MACH_INGENIC
 	select GPIOLIB
 	select COMMON_CLK
 	select GENERIC_IRQ_CHIP
-	select BUILTIN_DTB
+	select BUILTIN_DTB if MIPS_NO_APPENDED_DTB
 	select USE_OF
 	select LIBFDT
 
diff --git a/arch/mips/jz4740/setup.c b/arch/mips/jz4740/setup.c
index afb40f8bce96..5c00064937c4 100644
--- a/arch/mips/jz4740/setup.c
+++ b/arch/mips/jz4740/setup.c
@@ -31,6 +31,7 @@
 
 #define JZ4740_EMC_SDRAM_CTRL 0x80
 
+extern const char __appended_dtb;
 
 static void __init jz4740_detect_mem(void)
 {
@@ -66,15 +67,22 @@ static unsigned long __init get_board_mach_type(const void *fdt)
 void __init plat_mem_setup(void)
 {
 	int offset;
+	void *dtb;
 
 	jz4740_reset_init();
-	__dt_setup_arch(__dtb_start);
 
-	offset = fdt_path_offset(__dtb_start, "/memory");
+	if (__dtb_start != __dtb_end)
+		dtb = __dtb_start;
+	else
+		dtb = (void *)&__appended_dtb;
+
+	__dt_setup_arch(dtb);
+
+	offset = fdt_path_offset(dtb, "/memory");
 	if (offset < 0)
 		jz4740_detect_mem();
 
-	mips_machtype = get_board_mach_type(__dtb_start);
+	mips_machtype = get_board_mach_type(dtb);
 }
 
 void __init device_tree_init(void)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: ingenic: Add support for appended devicetree
  2019-02-21 20:38 [PATCH] MIPS: ingenic: Add support for appended devicetree Paul Cercueil
@ 2019-02-21 21:13 ` Jonas Gorski
  2019-02-21 21:50   ` Paul Cercueil
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Gorski @ 2019-02-21 21:13 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Ralf Baechle, Paul Burton, James Hogan, linux-mips, linux-kernel

On Thu, 21 Feb 2019 at 21:39, Paul Cercueil <paul@crapouillou.net> wrote:
>
> Add support for booting the kernel from an externally-appended
> devicetree, if no devicetree was built-in.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  arch/mips/Kconfig        |  2 +-
>  arch/mips/jz4740/setup.c | 14 +++++++++++---
>  2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index a84c24d894aa..8b7ea9062198 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -391,7 +391,7 @@ config MACH_INGENIC
>         select GPIOLIB
>         select COMMON_CLK
>         select GENERIC_IRQ_CHIP
> -       select BUILTIN_DTB
> +       select BUILTIN_DTB if MIPS_NO_APPENDED_DTB
>         select USE_OF
>         select LIBFDT
>
> diff --git a/arch/mips/jz4740/setup.c b/arch/mips/jz4740/setup.c
> index afb40f8bce96..5c00064937c4 100644
> --- a/arch/mips/jz4740/setup.c
> +++ b/arch/mips/jz4740/setup.c
> @@ -31,6 +31,7 @@
>
>  #define JZ4740_EMC_SDRAM_CTRL 0x80
>
> +extern const char __appended_dtb;

Does this build/link with MIPS_NO_APPENDED_DTB? I would assume it
won't be able to resolve the symbol in that case.

You can also just use fw_passed_dtb from asm/bootinfo.h, which will be
populated automatically from fw_args (if UHI) or __appended_dtb (if
present and valid)[1], without having to care where it came from.

Regards
Jonas

[1] https://elixir.bootlin.com/linux/latest/source/arch/mips/kernel/head.S#L96

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: ingenic: Add support for appended devicetree
  2019-02-21 21:13 ` Jonas Gorski
@ 2019-02-21 21:50   ` Paul Cercueil
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Cercueil @ 2019-02-21 21:50 UTC (permalink / raw)
  To: Jonas Gorski
  Cc: Ralf Baechle, Paul Burton, James Hogan, linux-mips, linux-kernel

Hi Jonas,

On Thu, 21 Feb 2019 at 21:39, Jonas Gorski <jonas.gorski@gmail.com> 
wrote:
> On Thu, 21 Feb 2019 at 21:39, Paul Cercueil <paul@crapouillou.net> 
> wrote:
>> 
>>  Add support for booting the kernel from an externally-appended
>>  devicetree, if no devicetree was built-in.
>> 
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  ---
>>   arch/mips/Kconfig        |  2 +-
>>   arch/mips/jz4740/setup.c | 14 +++++++++++---
>>   2 files changed, 12 insertions(+), 4 deletions(-)
>> 
>>  diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>>  index a84c24d894aa..8b7ea9062198 100644
>>  --- a/arch/mips/Kconfig
>>  +++ b/arch/mips/Kconfig
>>  @@ -391,7 +391,7 @@ config MACH_INGENIC
>>          select GPIOLIB
>>          select COMMON_CLK
>>          select GENERIC_IRQ_CHIP
>>  -       select BUILTIN_DTB
>>  +       select BUILTIN_DTB if MIPS_NO_APPENDED_DTB
>>          select USE_OF
>>          select LIBFDT
>> 
>>  diff --git a/arch/mips/jz4740/setup.c b/arch/mips/jz4740/setup.c
>>  index afb40f8bce96..5c00064937c4 100644
>>  --- a/arch/mips/jz4740/setup.c
>>  +++ b/arch/mips/jz4740/setup.c
>>  @@ -31,6 +31,7 @@
>> 
>>   #define JZ4740_EMC_SDRAM_CTRL 0x80
>> 
>>  +extern const char __appended_dtb;
> 
> Does this build/link with MIPS_NO_APPENDED_DTB? I would assume it
> won't be able to resolve the symbol in that case.

Oops. You're right.

> You can also just use fw_passed_dtb from asm/bootinfo.h, which will be
> populated automatically from fw_args (if UHI) or __appended_dtb (if
> present and valid)[1], without having to care where it came from.

Thanks, I will.

Regards,
-Paul


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-21 21:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 20:38 [PATCH] MIPS: ingenic: Add support for appended devicetree Paul Cercueil
2019-02-21 21:13 ` Jonas Gorski
2019-02-21 21:50   ` Paul Cercueil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).