Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751040AbeABQDA (ORCPT + 1 other); Tue, 2 Jan 2018 11:03:00 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:34096 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750749AbeABQC6 (ORCPT ); Tue, 2 Jan 2018 11:02:58 -0500 X-Google-Smtp-Source: ACJfBot7BBDLUt1RVV33TbFFNr55JLd9TgLNm6A18ZwGflRUF8D4T83LwhEJrn4zpJM6wfKDBz1v7FwYX8uDrvj0QeA= MIME-Version: 1.0 In-Reply-To: <20180102150848.11314-10-paul@crapouillou.net> References: <20180102150848.11314-1-paul@crapouillou.net> <20180102150848.11314-10-paul@crapouillou.net> From: PrasannaKumar Muralidharan Date: Tue, 2 Jan 2018 21:32:57 +0530 Message-ID: Subject: Re: [PATCH v5 10/15] MIPS: ingenic: Add machine info for supported boards To: Paul Cercueil Cc: Ralf Baechle , Maarten ter Huurne , devicetree@vger.kernel.org, open list , linux-mips@linux-mips.org, linux-clk@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Paul, On 2 January 2018 at 20:38, Paul Cercueil wrote: > This makes sure that 'mips_machtype' will be initialized to the SoC > version used on the board. > > Signed-off-by: Paul Cercueil > --- > 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 > + */ > + > +#include > +#include > + > +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 > > #include > +#include > #include > > #include > @@ -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