devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Maarten ter Huurne <maarten@treewalker.org>,
	devicetree@vger.kernel.org,
	open list <linux-kernel@vger.kernel.org>,
	linux-mips@linux-mips.org, linux-clk@vger.kernel.org
Subject: Re: [PATCH v5 10/15] MIPS: ingenic: Add machine info for supported boards
Date: Tue, 02 Jan 2018 17:32:27 +0100	[thread overview]
Message-ID: <1514910747.3623.0@smtp.crapouillou.net> (raw)
In-Reply-To: <CANc+2y7ePJ9PwXQp2EQS_CFj541iOkWLbZm7K3U0G7j0bx4RDg@mail.gmail.com>

Hi PrasannaKumar,

Le mar. 2 janv. 2018 à 17:02, PrasannaKumar Muralidharan 
<prasannatsmkumar@gmail.com> a écrit :
> Hi Paul,
> 
> On 2 January 2018 at 20:38, Paul Cercueil <paul@crapouillou.net> 
> wrote:
>>  This makes sure that 'mips_machtype' will be initialized to the SoC
>>  version used on the board.
>> 
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  ---
>>   arch/mips/Kconfig         |  1 +
>>   arch/mips/jz4740/Makefile |  2 +-
>>   arch/mips/jz4740/boards.c | 12 ++++++++++++
>>   arch/mips/jz4740/setup.c  | 34 +++++++++++++++++++++++++++++-----
>>   4 files changed, 43 insertions(+), 6 deletions(-)
>>   create mode 100644 arch/mips/jz4740/boards.c
>> 
>>   v2: No change
>>   v3: No change
>>   v4: No change
>>   v5: Use SPDX license identifier
>> 
>>  diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>>  index 350a990fc719..83243e427e36 100644
>>  --- a/arch/mips/Kconfig
>>  +++ b/arch/mips/Kconfig
>>  @@ -376,6 +376,7 @@ config MACH_INGENIC
>>          select BUILTIN_DTB
>>          select USE_OF
>>          select LIBFDT
>>  +       select MIPS_MACHINE
>> 
>>   config LANTIQ
>>          bool "Lantiq based platforms"
>>  diff --git a/arch/mips/jz4740/Makefile b/arch/mips/jz4740/Makefile
>>  index 88d6aa7d000b..fc2d3b3c4a80 100644
>>  --- a/arch/mips/jz4740/Makefile
>>  +++ b/arch/mips/jz4740/Makefile
>>  @@ -6,7 +6,7 @@
>>   # Object file lists.
>> 
>>   obj-y += prom.o time.o reset.o setup.o \
>>  -       platform.o timer.o
>>  +       platform.o timer.o boards.o
>> 
>>   CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt
>> 
>>  diff --git a/arch/mips/jz4740/boards.c b/arch/mips/jz4740/boards.c
>>  new file mode 100644
>>  index 000000000000..13b0bddd8cb7
>>  --- /dev/null
>>  +++ b/arch/mips/jz4740/boards.c
>>  @@ -0,0 +1,12 @@
>>  +// SPDX-License-Identifier: GPL-2.0
>>  +/*
>>  + * Ingenic boards support
>>  + * Copyright 2017, Paul Cercueil <paul@crapouillou.net>
>>  + */
>>  +
>>  +#include <asm/bootinfo.h>
>>  +#include <asm/mips_machine.h>
>>  +
>>  +MIPS_MACHINE(MACH_INGENIC_JZ4740, "qi,lb60", "Qi Hardware Ben 
>> Nanonote", NULL);
>>  +MIPS_MACHINE(MACH_INGENIC_JZ4780, "img,ci20",
>>  +                       "Imagination Technologies CI20", NULL);
>>  diff --git a/arch/mips/jz4740/setup.c b/arch/mips/jz4740/setup.c
>>  index 6d0152321819..afd84ee966e8 100644
>>  --- a/arch/mips/jz4740/setup.c
>>  +++ b/arch/mips/jz4740/setup.c
>>  @@ -22,6 +22,7 @@
>>   #include <linux/of_fdt.h>
>> 
>>   #include <asm/bootinfo.h>
>>  +#include <asm/mips_machine.h>
>>   #include <asm/prom.h>
>> 
>>   #include <asm/mach-jz4740/base.h>
>>  @@ -53,16 +54,34 @@ static void __init jz4740_detect_mem(void)
>>          add_memory_region(0, size, BOOT_MEM_RAM);
>>   }
>> 
>>  +static unsigned long __init get_board_mach_type(const void *fdt)
>>  +{
>>  +       const struct mips_machine *mach;
>>  +
>>  +       for (mach = (struct mips_machine *)&__mips_machines_start;
>>  +                       mach < (struct mips_machine 
>> *)&__mips_machines_end;
>>  +                       mach++) {
>>  +               if (!fdt_node_check_compatible(fdt, 0, 
>> mach->mach_id))
>>  +                       return mach->mach_type;
>>  +       }
>>  +
>>  +       return MACH_INGENIC_JZ4740;
>>  +}
>>  +
>>   void __init plat_mem_setup(void)
>>   {
>>          int offset;
>> 
>>  +       if (!early_init_dt_scan(__dtb_start))
>>  +               return;
>>  +
>>          jz4740_reset_init();
>>  -       __dt_setup_arch(__dtb_start);
>> 
>>          offset = fdt_path_offset(__dtb_start, "/memory");
>>          if (offset < 0)
>>                  jz4740_detect_mem();
>>  +
>>  +       mips_machtype = get_board_mach_type(__dtb_start);
>>   }
>> 
>>   void __init device_tree_init(void)
>>  @@ -75,13 +94,18 @@ void __init device_tree_init(void)
>> 
>>   const char *get_system_type(void)
>>   {
>>  -       if (IS_ENABLED(CONFIG_MACH_JZ4780))
>>  -               return "JZ4780";
>>  -
>>  -       return "JZ4740";
>>  +       return mips_get_machine_name();
>>   }
>> 
>>   void __init arch_init_irq(void)
>>   {
>>          irqchip_init();
>>   }
>>  +
>>  +static int __init jz4740_machine_setup(void)
>>  +{
>>  +       mips_machine_setup();
>>  +
>>  +       return 0;
>>  +}
>>  +arch_initcall(jz4740_machine_setup);
>>  --
>>  2.11.0
>> 
>> 
> 
> Why add another file in arch/mips/jz4740/? I think declaring a machine
> and compatible string in dts would suffice. Please feel free to
> correct me if I am wrong.
> 
> Regards,
> PrasannaKumar

The point of this commit is, first, to have a textual description of 
the board
that can then be retrieved in dmesg; then, to properly initialize the
mips_machtype early in the boot process. I think you are right and we 
could
have both things just with "model" and "compatible" nodes in devicetree.

Regards,
-Paul

  reply	other threads:[~2018-01-02 16:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-02 15:08 [PATCH v5 01/15] clk: ingenic: Use const pointer to clk_ops in struct Paul Cercueil
2018-01-02 15:08 ` [PATCH v5 02/15] clk: ingenic: Fix recalc_rate for clocks with fixed divider Paul Cercueil
2018-01-02 15:08 ` [PATCH v5 03/15] clk: ingenic: support PLLs with no bypass bit Paul Cercueil
2018-01-02 15:08 ` [PATCH v5 04/15] clk: ingenic: Add code to enable/disable PLLs Paul Cercueil
2018-01-02 15:08 ` [PATCH v5 05/15] dt-bindings: clock: Add jz4770-cgu.h header Paul Cercueil
     [not found]   ` <20180102150848.11314-5-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
2018-01-05 16:34     ` Rob Herring
2018-01-02 15:08 ` [PATCH v5 06/15] clk: Add Ingenic jz4770 CGU driver Paul Cercueil
2018-01-02 15:08 ` [PATCH v5 07/15] MIPS: Setup boot_command_line before plat_mem_setup Paul Cercueil
2018-01-02 17:05   ` Mathieu Malaterre
2018-01-02 15:08 ` [PATCH v5 08/15] MIPS: ingenic: Use common cmdline handling code Paul Cercueil
     [not found]   ` <20180102150848.11314-8-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
2018-01-02 15:58     ` PrasannaKumar Muralidharan
2018-01-02 15:08 ` [PATCH v5 09/15] MIPS: platform: add machtype IDs for more Ingenic SoCs Paul Cercueil
     [not found]   ` <20180102150848.11314-9-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
2018-01-02 15:59     ` PrasannaKumar Muralidharan
2018-01-02 15:08 ` [PATCH v5 10/15] MIPS: ingenic: Add machine info for supported boards Paul Cercueil
2018-01-02 16:02   ` PrasannaKumar Muralidharan
2018-01-02 16:32     ` Paul Cercueil [this message]
2018-01-02 15:08 ` [PATCH v5 11/15] MIPS: ingenic: Initial JZ4770 support Paul Cercueil
     [not found]   ` <20180102150848.11314-11-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
2018-01-02 16:09     ` PrasannaKumar Muralidharan
2018-01-02 15:08 ` [PATCH v5 12/15] MIPS: JZ4770: Work around config2 misreporting associativity Paul Cercueil
     [not found] ` <20180102150848.11314-1-paul-icTtO2rgO2OTuSrc4Mpeew@public.gmane.org>
2018-01-02 15:08   ` [PATCH v5 13/15] MIPS: JZ4770: Workaround for corrupted DMA transfers Paul Cercueil
2018-01-02 16:45     ` PrasannaKumar Muralidharan
2018-01-05 18:03       ` Paul Cercueil
2018-01-02 15:08 ` [PATCH v5 14/15] devicetree/bindings: Add GCW vendor prefix Paul Cercueil
2018-01-02 15:08 ` [PATCH v5 15/15] MIPS: ingenic: Initial GCW Zero support Paul Cercueil
2018-01-02 17:04   ` Mathieu Malaterre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1514910747.3623.0@smtp.crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=maarten@treewalker.org \
    --cc=prasannatsmkumar@gmail.com \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).