From: Wu Zhangjin <wuzhangjin@gmail.com>
To: Zhang Le <r0bertz@gentoo.org>
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org,
Yan Hua <yanh@lemote.com>, Philippe Vachon <philippe@cowpig.ca>,
Zhang Fuxin <zhangfx@lemote.com>,
loongson-dev <loongson-dev@googlegroups.com>,
Liu Junliang <liujl@lemote.com>, Erwan Lerale <erwan@thiscow.com>,
Arnaud Patard <apatard@mandriva.com>
Subject: Re: [loongson-dev] Re: [loongson-PATCH-v3 17/25] add a machtype kernel command line argument
Date: Thu, 11 Jun 2009 22:28:38 +0800 [thread overview]
Message-ID: <1244730518.10475.38.camel@falcon> (raw)
In-Reply-To: <20090610203123.GA20906@adriano.hkcable.com.hk>
Hi,
Applied, thanks!
but before you sending this patch, I have tuned the machtype
implementation(mainly remove the duplicated MACHNAME defined in
machine.h) and merged some patches, so, this patch can not be applied
directly, but i have applied it manually. and also, i will merge it to
my previous machtype patches.
thanks!
Wu Zhangjin
On Thu, 2009-06-11 at 04:31 +0800, Zhang Le wrote:
> So this is the patch. I should say this patch is a bit intrusive againt your
> verion. But I think I could justify the changes.
>
> 1. MACHNAME macro seems to be a little over engineered. And with MACHNAME,
> system type becomes "lemote-fuloong-2f-unknowninch" which does not make much
> sense. So I removed it. As a result, include/asm/mach-loongson/machtype.h is
> not needed anymore. I also modified loongson/yeeloong-2f/{init,reset}.c,
> because _89INCH and _7INCH no longer exist.
>
> 2. 3 machine names are defined twice, once in loongson/common/machtype.c, once
> in include/asm/mach-loongson/machine.h. In my patch, all the system types are
> defined in loongson/common/machtype.c, as an array called system_types. Other
> loongson based machine, like Gdium, could add their system type to this array.
>
> 3. I defined symbolic names for the system_types array's index. In
> include/asm/mach-loongson/machine.h, I defined macro MACHTYPE using these
> symbolic names, so that we can get system type from system_types array
> using MACHTYPE as index.
>
> 4. Add NULL to the end of system_types array, so MACHTYPE_TOTAL is not needed.
>
> 5. mips_machtype already has initial value MACH_UNKNOWN, so MACHTYPE_DEFAULT is
> not needed.
>
> 6. modified the for loop in machtype_setup accordingly.
>
> Signed-off-by: Zhang Le <r0bertz@gentoo.org>
> ---
> arch/mips/include/asm/bootinfo.h | 11 +++++
> arch/mips/include/asm/mach-loongson/machine.h | 8 ++--
> arch/mips/include/asm/mach-loongson/machtype.h | 32 ---------------
> arch/mips/loongson/common/machtype.c | 50 ++++++++++-------------
> arch/mips/loongson/yeeloong-2f/init.c | 3 +-
> arch/mips/loongson/yeeloong-2f/reset.c | 7 ++-
> 6 files changed, 42 insertions(+), 69 deletions(-)
> delete mode 100644 arch/mips/include/asm/mach-loongson/machtype.h
>
> diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
> index 610fe3a..0d9c7ff 100644
> --- a/arch/mips/include/asm/bootinfo.h
> +++ b/arch/mips/include/asm/bootinfo.h
> @@ -7,6 +7,7 @@
> * Copyright (C) 1995, 1996 Andreas Busse
> * Copyright (C) 1995, 1996 Stoned Elipot
> * Copyright (C) 1995, 1996 Paul M. Antoine.
> + * Copyright (C) 2009 Zhang Le
> */
> #ifndef _ASM_BOOTINFO_H
> #define _ASM_BOOTINFO_H
> @@ -57,6 +58,16 @@
> #define MACH_MIKROTIK_RB532 0 /* Mikrotik RouterBoard 532 */
> #define MACH_MIKROTIK_RB532A 1 /* Mikrotik RouterBoard 532A */
>
> +/*
> + * Valid machtype for group Loongson
> + */
> +#define MACH_LOONGSON_UNKNOWN 0
> +#define MACH_LEMOTE_FL2E 1
> +#define MACH_LEMOTE_FL2F 2
> +#define MACH_LEMOTE_YL2F89 3
> +#define MACH_LEMOTE_YL2F7 4
> +#define MACH_LOONGSON_END 5
> +
> #define CL_SIZE COMMAND_LINE_SIZE
>
> extern char *system_type;
> diff --git a/arch/mips/include/asm/mach-loongson/machine.h b/arch/mips/include/asm/mach-loongson/machine.h
> index 8109a9e..e168625 100644
> --- a/arch/mips/include/asm/mach-loongson/machine.h
> +++ b/arch/mips/include/asm/mach-loongson/machine.h
> @@ -2,6 +2,7 @@
> * board-specific header file
> *
> * Copyright (c) 2009 Wu Zhangjin <wuzj@lemote.com>
> + * Copyright (c) 2009 Zhang Le <r0bertz@gentoo.org>
> *
> * This program is free software; you can redistribute it
> * and/or modify it under the terms of the GNU General
> @@ -15,7 +16,7 @@
>
> #ifdef CONFIG_LEMOTE_FULOONG2E
>
> -#define MACH_NAME MACHNAME(LEMOTE, FULOONG, LOONGSON_2E, UNKNOWN)
> +#define MACHTYPE MACH_LEMOTE_FL2E
>
> #define LOONGSON_UART_BASE (LOONGSON_PCIIO_BASE + 0x3f8)
> #define LOONGSON_UART_BAUD 1843200
> @@ -29,7 +30,7 @@
>
> #elif defined(CONFIG_LEMOTE_FULOONG2F)
>
> -#define MACH_NAME MACHNAME(LEMOTE, FULOONG, LOONGSON_2F, UNKNOWN)
> +#define MACHTYPE MACH_LEMOTE_FL2F
>
> #define LOONGSON_UART_BASE (LOONGSON_PCIIO_BASE + 0x2f8)
> #define LOONGSON_UART_BAUD 1843200
> @@ -37,8 +38,7 @@
>
> #else /* CONFIG_CPU_YEELOONG2F */
>
> -/* by default, set it as 8.9INCH? or UNKNOWN? */
> -#define MACH_NAME MACHNAME(LEMOTE, YEELOONG, LOONGSON_2F, _89INCH)
> +#define MACHTYPE MACH_LEMOTE_YL2F89
>
> /* yeeloong use the CPU serial port of Loongson2F */
> #define LOONGSON_UART_BASE (LOONGSON_LIO1_BASE + 0x3f8)
> diff --git a/arch/mips/include/asm/mach-loongson/machtype.h b/arch/mips/include/asm/mach-loongson/machtype.h
> deleted file mode 100644
> index 9f96926..0000000
> --- a/arch/mips/include/asm/mach-loongson/machtype.h
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/*
> - * machine type header file
> - */
> -
> -#ifndef _MACHTYPE_H
> -#define _MACHTYPE_H
> -
> -#define UNKNOWN "unknown"
> -
> -/* company */
> -#define LEMOTE "lemote"
> -#define DEXOON "dexoon"
> -
> -/* product */
> -#define FULOONG "fuloong"
> -#define YEELOONG "yeeloong"
> -#define GDIUM "gdium"
> -
> -/* cpu revision */
> -#define LOONGSON_2E "2e"
> -#define LOONGSON_2F "2f"
> -
> -/* size */
> -#define _7INCH "7"
> -#define _89INCH "8.9"
> -
> -#define MACHNAME_LEN 50
> -
> -#define MACHNAME(company, product, cpu, size) \
> - (company "-" product "-" cpu "-" size "inch\0")
> -
> -#endif /* ! _MACHTYPE_H */
> diff --git a/arch/mips/loongson/common/machtype.c b/arch/mips/loongson/common/machtype.c
> index d469dc7..34417cf 100644
> --- a/arch/mips/loongson/common/machtype.c
> +++ b/arch/mips/loongson/common/machtype.c
> @@ -2,6 +2,8 @@
> * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
> * Author: Wu Zhangjin, wuzj@lemote.com
> *
> + * Copyright (c) 2009 Zhang Le <r0bertz@gentoo.org>
> + *
> * This program is free software; you can redistribute it and/or modify it
> * under the terms of the GNU General Public License as published by the
> * Free Software Foundation; either version 2 of the License, or (at your
> @@ -10,49 +12,41 @@
>
> #include <linux/errno.h>
> #include <asm/cpu.h>
> -
> #include <asm/bootinfo.h>
>
> #include <loongson.h>
> -#include <machtype.h>
> #include <machine.h>
>
> -static char machname[][MACHNAME_LEN] = {
> - MACHNAME(LEMOTE, FULOONG, LOONGSON_2E, UNKNOWN),
> - MACHNAME(LEMOTE, FULOONG, LOONGSON_2F, UNKNOWN),
> - MACHNAME(LEMOTE, YEELOONG, LOONGSON_2F, _89INCH),
> - MACHNAME(LEMOTE, YEELOONG, LOONGSON_2F, _7INCH),
> +static const char *system_types[] = {
> + [MACH_LOONGSON_UNKNOWN] "unknown loongson machine",
> + [MACH_LEMOTE_FL2E] "lemote-fuloong-2e-box",
> + [MACH_LEMOTE_FL2F] "lemote-fuloong-2f-box",
> + [MACH_LEMOTE_YL2F89] "lemote-yeeloong-2f-8.9inches",
> + [MACH_LEMOTE_YL2F7] "lemote-yeeloong-2f-7inches",
> + [MACH_LOONGSON_END] NULL,
> };
>
> -#define MACHTYPE_TOTAL (sizeof(machname)/MACHNAME_LEN)
> -#define MACHTYPE_DEFAULT -1
> -
> const char *get_system_type(void)
> {
> - if (mips_machtype == MACHTYPE_DEFAULT)
> - return MACH_NAME;
> - else
> - return machname[mips_machtype];
> + if (mips_machtype == MACH_UNKNOWN)
> + mips_machtype = MACHTYPE;
> +
> + return system_types[mips_machtype];
> }
>
> -static __init int machname_setup(char *str)
> +static __init int machtype_setup(char *str)
> {
> - int index;
> + int machtype = MACH_LEMOTE_FL2E;
>
> if (!str)
> - return -EINVAL;
> -
> - mips_machtype = MACHTYPE_DEFAULT;
> + return -EINVAL;
>
> - for (index = 0;
> - index < MACHTYPE_TOTAL;
> - index++) {
> - if (strstr(str, machname[index]) != NULL) {
> - mips_machtype = index;
> - return 0;
> + for (; system_types[machtype]; machtype++)
> + if (strstr(str, system_types[machtype])) {
> + mips_machtype = machtype;
> + break;
> }
> - }
> - return -1;
> + return 0;
> }
>
> -__setup("machtype=", machname_setup);
> +__setup("machtype=", machtype_setup);
> diff --git a/arch/mips/loongson/yeeloong-2f/init.c b/arch/mips/loongson/yeeloong-2f/init.c
> index 80f8c5e..5d16e66 100644
> --- a/arch/mips/loongson/yeeloong-2f/init.c
> +++ b/arch/mips/loongson/yeeloong-2f/init.c
> @@ -18,7 +18,6 @@
> #include <asm/bootinfo.h>
>
> #include <cs5536/cs5536.h>
> -#include <machtype.h>
>
> void __init mach_prom_init_cmdline(void)
> {
> @@ -77,6 +76,6 @@ void __init mach_prom_init_cmdline(void)
>
> if ((strstr(arcs_cmdline, "vga") == NULL)
> && (strstr(arcs_cmdline, "machtype") != NULL)
> - && (strstr(arcs_cmdline, _7INCH) != NULL))
> + && (strstr(arcs_cmdline, "7inch") != NULL))
> strcat(arcs_cmdline, " vga=800x480x24");
> }
> diff --git a/arch/mips/loongson/yeeloong-2f/reset.c b/arch/mips/loongson/yeeloong-2f/reset.c
> index 124cf99..46394c2 100644
> --- a/arch/mips/loongson/yeeloong-2f/reset.c
> +++ b/arch/mips/loongson/yeeloong-2f/reset.c
> @@ -15,7 +15,6 @@
>
> #include <loongson.h>
> #include <machine.h>
> -#include <machtype.h>
>
> /*
> * The following registers are determined by the EC index configuration.
> @@ -59,12 +58,14 @@ void mach_prepare_reboot(void)
>
> void mach_prepare_shutdown(void)
> {
> - if (strstr(get_system_type(), _89INCH)) {
> + char *system_type = get_system_type();
> +
> + if (strstr(system_type, "8.9inch")) {
> /* cpu-gpio0 output low */
> LOONGSON_GPIODATA &= ~0x00000001;
> /* cpu-gpio0 as output */
> LOONGSON_GPIOIE &= ~0x00000001;
> - } else if (strstr(get_system_type(), _7INCH)) {
> + } else if (strstr(system_type, "7inch")) {
> u8 val;
> u64 i;
>
> --
> 1.6.3.1
>
>
next prev parent reply other threads:[~2009-06-11 15:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1244120575.git.wuzj@lemote.com>
2009-06-04 13:03 ` [loongson-PATCH-v3 04/25] change the naming methods wuzhangjin
2009-06-04 13:04 ` [loongson-PATCH-v3 05/25] remove reference to bonito64.h wuzhangjin
2009-06-04 13:04 ` [loongson-PATCH-v3 06/25] divide the files to the smallest logic unit wuzhangjin
2009-06-04 13:04 ` [loongson-PATCH-v3 07/25] replace tons of magic numbers by understandable symbols wuzhangjin
2009-06-04 13:05 ` [loongson-PATCH-v3 08/25] clean up the early printk support for fuloong(2e) wuzhangjin
2009-06-04 13:05 ` [loongson-PATCH-v3 09/25] enable Real Time Clock Support " wuzhangjin
2009-06-04 13:05 ` [loongson-PATCH-v3 10/25] split the loongson-specific part out wuzhangjin
2009-06-09 17:51 ` Zhang Le
2009-06-10 12:39 ` Wu Zhangjin
2009-06-04 13:06 ` [loongson-PATCH-v3 11/25] split env out of cmdline.c wuzhangjin
2009-06-04 13:06 ` [loongson-PATCH-v3 12/25] add basic loongson-2f support wuzhangjin
2009-06-04 13:06 ` [loongson-PATCH-v3 13/25] add basic fuloong(2f) support wuzhangjin
2009-06-04 13:07 ` [loongson-PATCH-v3 14/25] enable serial port support of loongson-based machines wuzhangjin
2009-06-04 13:07 ` [loongson-PATCH-v3 15/25] add basic yeeloong(2f) laptop support wuzhangjin
2009-06-09 17:23 ` Zhang Le
2009-06-10 12:37 ` Wu Zhangjin
2009-06-04 13:07 ` [loongson-PATCH-v3 16/25] enable halt command for yeeloong-7inch laptop wuzhangjin
2009-06-04 13:08 ` [loongson-PATCH-v3 17/25] add a machtype kernel command line argument wuzhangjin
2009-06-04 13:51 ` Arnaud Patard
2009-06-04 16:04 ` Wu Zhangjin
2009-06-10 15:40 ` Zhang Le
2009-06-10 20:31 ` [loongson-dev] " Zhang Le
2009-06-11 11:09 ` Zhang Le
2009-06-11 15:16 ` Wu Zhangjin
2009-06-11 14:28 ` Wu Zhangjin [this message]
2009-06-04 13:08 ` [loongson-PATCH-v3 18/25] Add Siliconmotion 712 framebuffer driver wuzhangjin
2009-06-04 17:18 ` Simon Braunschmidt
2009-06-04 13:09 ` [loongson-PATCH-v3 19/25] define Loongson2F arch specific phys prot access wuzhangjin
2009-06-04 13:09 ` [loongson-PATCH-v3 20/25] Loongson2 specific OProfile driver wuzhangjin
2009-06-04 13:10 ` [loongson-PATCH-v3 21/25] flush posted write to irq wuzhangjin
2009-06-04 13:10 ` [loongson-PATCH-v3 22/25] CS5536 MFGPT as system clock source support wuzhangjin
2009-06-04 13:10 ` [loongson-PATCH-v3 23/25] Loongson2F cpufreq support wuzhangjin
2009-06-04 13:11 ` [loongson-PATCH-v3 24/25] add gcc 4.4 support for MIPS and loongson wuzhangjin
2009-06-04 13:11 ` [loongson-PATCH-v3 25/25] add default kernel config file for loongson-based machines wuzhangjin
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=1244730518.10475.38.camel@falcon \
--to=wuzhangjin@gmail.com \
--cc=apatard@mandriva.com \
--cc=erwan@thiscow.com \
--cc=linux-mips@linux-mips.org \
--cc=liujl@lemote.com \
--cc=loongson-dev@googlegroups.com \
--cc=philippe@cowpig.ca \
--cc=r0bertz@gentoo.org \
--cc=ralf@linux-mips.org \
--cc=yanh@lemote.com \
--cc=zhangfx@lemote.com \
/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