From d756ab6289aef5f8a3c125381ab379935e922ed6 Mon Sep 17 00:00:00 2001
From: blogic <blogic@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Wed, 26 May 2010 15:53:05 +0000
Subject: [PATCH 1/1] [ramips] update to 2.6.34, signed of by russiane39, thx

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21573 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 target/linux/ramips/Makefile                  |   2 +-
 ...01-mips-add-cp0-compare-irq-function.patch |  33 +++++
 ...x_cfi_cmdset_0002_erase_status_check.patch |  20 +++
 .../patches-2.6.34/100-mips-ralink-core.patch |  58 ++++++++
 .../101-rt288x_serial_driver_hack.patch       | 118 +++++++++++++++
 .../102-rt288x-pci-driver-hook.patch          |  10 ++
 .../ramips/patches-2.6.34/103-ethernet.patch  |  25 ++++
 .../ramips/patches-2.6.34/104-clsize.patch    |  11 ++
 .../ramips/patches-2.6.34/105-slab.patch      |  19 +++
 .../400-mips-multi-machine-update.patch       | 135 ++++++++++++++++++
 10 files changed, 430 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/ramips/patches-2.6.34/001-mips-add-cp0-compare-irq-function.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/010-mtd_fix_cfi_cmdset_0002_erase_status_check.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/100-mips-ralink-core.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/101-rt288x_serial_driver_hack.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/102-rt288x-pci-driver-hook.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/103-ethernet.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/104-clsize.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/105-slab.patch
 create mode 100644 target/linux/ramips/patches-2.6.34/400-mips-multi-machine-update.patch

diff --git a/target/linux/ramips/Makefile b/target/linux/ramips/Makefile
index e7e76a5be..0d375b596 100644
--- a/target/linux/ramips/Makefile
+++ b/target/linux/ramips/Makefile
@@ -13,7 +13,7 @@ SUBTARGETS:=rt288x rt305x
 CFLAGS:=-Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time
 FEATURES:=squashfs
 
-LINUX_VERSION:=2.6.32.13
+LINUX_VERSION:=2.6.34
 
 include $(INCLUDE_DIR)/target.mk
 DEFAULT_PACKAGES+=kmod-leds-gpio wpad-mini
diff --git a/target/linux/ramips/patches-2.6.34/001-mips-add-cp0-compare-irq-function.patch b/target/linux/ramips/patches-2.6.34/001-mips-add-cp0-compare-irq-function.patch
new file mode 100644
index 000000000..1eff47b56
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/001-mips-add-cp0-compare-irq-function.patch
@@ -0,0 +1,33 @@
+Index: linux-2.6.34/arch/mips/kernel/traps.c
+===================================================================
+--- linux-2.6.34.orig/arch/mips/kernel/traps.c	2010-05-17 01:17:36.000000000 +0400
++++ linux-2.6.34/arch/mips/kernel/traps.c	2010-05-22 14:22:35.000000000 +0400
+@@ -51,6 +51,7 @@
+ #include <asm/stacktrace.h>
+ #include <asm/irq.h>
+ #include <asm/uasm.h>
++#include <asm/time.h>
+ 
+ extern void check_wait(void);
+ extern asmlinkage void r4k_wait(void);
+@@ -1506,6 +1507,8 @@
+ 	if (cpu_has_mips_r2) {
+ 		cp0_compare_irq_shift = CAUSEB_TI - CAUSEB_IP;
+ 		cp0_compare_irq = (read_c0_intctl() >> INTCTLB_IPTI) & 7;
++		if (get_c0_compare_irq)
++			cp0_compare_irq = get_c0_compare_irq();
+ 		cp0_perfcount_irq = (read_c0_intctl() >> INTCTLB_IPPCI) & 7;
+ 		if (cp0_perfcount_irq == cp0_compare_irq)
+ 			cp0_perfcount_irq = -1;
+Index: linux-2.6.34/arch/mips/include/asm/time.h
+===================================================================
+--- linux-2.6.34.orig/arch/mips/include/asm/time.h	2010-05-17 01:17:36.000000000 +0400
++++ linux-2.6.34/arch/mips/include/asm/time.h	2010-05-21 11:32:22.000000000 +0400
+@@ -52,6 +52,7 @@
+  */
+ #ifdef CONFIG_CEVT_R4K_LIB
+ extern unsigned int __weak get_c0_compare_int(void);
++extern unsigned int __weak get_c0_compare_irq(void);
+ extern int r4k_clockevent_init(void);
+ #endif
+ 
diff --git a/target/linux/ramips/patches-2.6.34/010-mtd_fix_cfi_cmdset_0002_erase_status_check.patch b/target/linux/ramips/patches-2.6.34/010-mtd_fix_cfi_cmdset_0002_erase_status_check.patch
new file mode 100644
index 000000000..a4fb2352f
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/010-mtd_fix_cfi_cmdset_0002_erase_status_check.patch
@@ -0,0 +1,20 @@
+--- a/drivers/mtd/chips/cfi_cmdset_0002.c
++++ b/drivers/mtd/chips/cfi_cmdset_0002.c
+@@ -1557,7 +1557,7 @@ static int __xipram do_erase_chip(struct
+ 			chip->erase_suspended = 0;
+ 		}
+ 
+-		if (chip_ready(map, adr))
++		if (chip_good(map, adr, map_word_ff(map)))
+ 			break;
+ 
+ 		if (time_after(jiffies, timeo)) {
+@@ -1645,7 +1645,7 @@ static int __xipram do_erase_oneblock(st
+ 			chip->erase_suspended = 0;
+ 		}
+ 
+-		if (chip_ready(map, adr)) {
++		if (chip_good(map, adr, map_word_ff(map))) {
+ 			xip_enable(map, chip, adr);
+ 			break;
+ 		}
diff --git a/target/linux/ramips/patches-2.6.34/100-mips-ralink-core.patch b/target/linux/ramips/patches-2.6.34/100-mips-ralink-core.patch
new file mode 100644
index 000000000..598a1556d
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/100-mips-ralink-core.patch
@@ -0,0 +1,58 @@
+--- a/arch/mips/Makefile
++++ b/arch/mips/Makefile
+@@ -181,6 +181,26 @@ ifeq (,$(findstring march=octeon, $(cfla
+ cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon
+ endif
+ 
++#
++# Ralink SoC common stuff
++#
++core-$(CONFIG_MIPS_RALINK)	+= arch/mips/ralink/common/
++cflags-$(CONFIG_MIPS_RALINK)	+= -I$(srctree)/arch/mips/include/asm/mach-ralink
++
++#
++# Ralink RT288x
++#
++core-$(CONFIG_RALINK_RT288X)	+= arch/mips/ralink/rt288x/
++cflags-$(CONFIG_RALINK_RT288X)	+= -I$(srctree)//arch/mips/include/asm/mach-ralink/rt288x
++load-$(CONFIG_RALINK_RT288X)	+= 0xffffffff88000000
++
++#
++# Ralink RT305x
++#
++core-$(CONFIG_RALINK_RT305X)	+= arch/mips/ralink/rt305x/
++cflags-$(CONFIG_RALINK_RT305X)	+= -I$(srctree)/arch/mips/include/asm/mach-ralink/rt305x
++load-$(CONFIG_RALINK_RT305X)	+= 0xffffffff80000000
++
+ cflags-$(CONFIG_CPU_R4000_WORKAROUNDS)	+= $(call cc-option,-mfix-r4000,)
+ cflags-$(CONFIG_CPU_R4400_WORKAROUNDS)	+= $(call cc-option,-mfix-r4400,)
+ cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS)	+= $(call cc-option,-mno-daddi,)
+--- a/arch/mips/Kconfig
++++ b/arch/mips/Kconfig
+@@ -48,6 +48,9 @@ config AR7
+ 	  Support for the Texas Instruments AR7 System-on-a-Chip
+ 	  family: TNETD7100, 7200 and 7300.
+ 
++config MIPS_RALINK
++	bool "Ralink MIPS SoC based boards"
++
+ config BCM47XX
+ 	bool "Broadcom BCM47XX based boards"
+ 	select CEVT_R4K
+@@ -688,6 +691,7 @@ source "arch/mips/bcm63xx/Kconfig"
+ source "arch/mips/jazz/Kconfig"
+ source "arch/mips/lasat/Kconfig"
+ source "arch/mips/pmc-sierra/Kconfig"
++source "arch/mips/ralink/Kconfig"
+ source "arch/mips/powertv/Kconfig"
+ source "arch/mips/sgi-ip27/Kconfig"
+ source "arch/mips/sibyte/Kconfig"
+@@ -1044,7 +1048,7 @@ config BOOT_ELF32
+ 
+ config MIPS_L1_CACHE_SHIFT
+ 	int
+-	default "4" if MACH_DECSTATION || MIKROTIK_RB532 || PMC_MSP4200_EVAL
++	default "4" if MACH_DECSTATION || MIKROTIK_RB532 || PMC_MSP4200_EVAL || RALINK_RT288X
+ 	default "6" if MIPS_CPU_SCACHE
+ 	default "7" if SGI_IP22 || SGI_IP27 || SGI_IP28 || SNI_RM || CPU_CAVIUM_OCTEON
+ 	default "5"
diff --git a/target/linux/ramips/patches-2.6.34/101-rt288x_serial_driver_hack.patch b/target/linux/ramips/patches-2.6.34/101-rt288x_serial_driver_hack.patch
new file mode 100644
index 000000000..9cf0ebfac
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/101-rt288x_serial_driver_hack.patch
@@ -0,0 +1,118 @@
+--- a/drivers/serial/8250.c
++++ b/drivers/serial/8250.c
+@@ -302,9 +302,9 @@ static const struct serial8250_config ua
+ 	},
+ };
+ 
+-#if defined (CONFIG_SERIAL_8250_AU1X00)
++#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
+ 
+-/* Au1x00 UART hardware has a weird register layout */
++/* Au1x00 and RT288x UART hardware has a weird register layout */
+ static const u8 au_io_in_map[] = {
+ 	[UART_RX]  = 0,
+ 	[UART_IER] = 2,
+@@ -422,7 +422,7 @@ static unsigned int mem32_serial_in(stru
+ 	return readl(p->membase + offset);
+ }
+ 
+-#ifdef CONFIG_SERIAL_8250_AU1X00
++#if defined(CONFIG_SERIAL_8250_AU1X00) || defined(CONFIG_SERIAL_8250_RT288X)
+ static unsigned int au_serial_in(struct uart_port *p, int offset)
+ {
+ 	offset = map_8250_in_reg(p, offset) << p->regshift;
+@@ -503,7 +503,7 @@ static void set_io_from_upio(struct uart
+ 		p->serial_out = mem32_serial_out;
+ 		break;
+ 
+-#ifdef CONFIG_SERIAL_8250_AU1X00
++#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
+ 	case UPIO_AU:
+ 		p->serial_in = au_serial_in;
+ 		p->serial_out = au_serial_out;
+@@ -535,7 +535,7 @@ serial_out_sync(struct uart_8250_port *u
+ 	switch (p->iotype) {
+ 	case UPIO_MEM:
+ 	case UPIO_MEM32:
+-#ifdef CONFIG_SERIAL_8250_AU1X00
++#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
+ 	case UPIO_AU:
+ #endif
+ 	case UPIO_DWAPB:
+@@ -573,8 +573,8 @@ static inline void _serial_dl_write(stru
+ 	serial_outp(up, UART_DLM, value >> 8 & 0xff);
+ }
+ 
+-#if defined(CONFIG_SERIAL_8250_AU1X00)
+-/* Au1x00 haven't got a standard divisor latch */
++#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
++/* Au1x00 and RT288x haven't got a standard divisor latch */
+ static int serial_dl_read(struct uart_8250_port *up)
+ {
+ 	if (up->port.iotype == UPIO_AU)
+@@ -781,22 +781,19 @@ static int size_fifo(struct uart_8250_po
+  */
+ static unsigned int autoconfig_read_divisor_id(struct uart_8250_port *p)
+ {
+-	unsigned char old_dll, old_dlm, old_lcr;
++	unsigned char old_lcr;
++	unsigned int old_dl;
+ 	unsigned int id;
+ 
+ 	old_lcr = serial_inp(p, UART_LCR);
+ 	serial_outp(p, UART_LCR, UART_LCR_DLAB);
+ 
+-	old_dll = serial_inp(p, UART_DLL);
+-	old_dlm = serial_inp(p, UART_DLM);
++	old_dl = serial_dl_read(p);
+ 
+-	serial_outp(p, UART_DLL, 0);
+-	serial_outp(p, UART_DLM, 0);
++	serial_dl_write(p, 0);
++	id = serial_dl_read(p);
+ 
+-	id = serial_inp(p, UART_DLL) | serial_inp(p, UART_DLM) << 8;
+-
+-	serial_outp(p, UART_DLL, old_dll);
+-	serial_outp(p, UART_DLM, old_dlm);
++	serial_dl_write(p, old_dl);
+ 	serial_outp(p, UART_LCR, old_lcr);
+ 
+ 	return id;
+@@ -2596,7 +2593,7 @@ static void serial8250_config_port(struc
+ 	if (flags & UART_CONFIG_TYPE)
+ 		autoconfig(up, probeflags);
+ 
+-#ifdef CONFIG_SERIAL_8250_AU1X00
++#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
+ 	/* if access method is AU, it is a 16550 with a quirk */
+ 	if (up->port.type == PORT_16550A && up->port.iotype == UPIO_AU)
+ 		up->bugs |= UART_BUG_NOMSR;
+--- a/drivers/serial/Kconfig
++++ b/drivers/serial/Kconfig
+@@ -266,6 +266,14 @@ config SERIAL_8250_AU1X00
+ 	  say Y to this option. The driver can handle up to 4 serial ports,
+ 	  depending on the SOC. If unsure, say N.
+ 
++config SERIAL_8250_RT288X
++	bool "Ralink RT288x/RT305x serial port support"
++	depends on SERIAL_8250 != n && (SOC_RT288X || SOC_RT305X)
++	help
++	  If you have a Ralink RT288x/RT305x SoC based board and want to use the 
++	  serial port, say Y to this option. The driver can handle up to 2 serial 
++	  ports. If unsure, say N.
++
+ config SERIAL_8250_RM9K
+ 	bool "Support for MIPS RM9xxx integrated serial port"
+ 	depends on SERIAL_8250 != n && SERIAL_RM9000
+--- a/include/linux/serial_core.h
++++ b/include/linux/serial_core.h
+@@ -284,7 +284,7 @@ struct uart_port {
+ #define UPIO_HUB6		(1)
+ #define UPIO_MEM		(2)
+ #define UPIO_MEM32		(3)
+-#define UPIO_AU			(4)			/* Au1x00 type IO */
++#define UPIO_AU			(4)			/* Au1x00 and RT288x type IO */
+ #define UPIO_TSI		(5)			/* Tsi108/109 type IO */
+ #define UPIO_DWAPB		(6)			/* DesignWare APB UART */
+ #define UPIO_RM9000		(7)			/* RM9000 type IO */
diff --git a/target/linux/ramips/patches-2.6.34/102-rt288x-pci-driver-hook.patch b/target/linux/ramips/patches-2.6.34/102-rt288x-pci-driver-hook.patch
new file mode 100644
index 000000000..d2056c646
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/102-rt288x-pci-driver-hook.patch
@@ -0,0 +1,10 @@
+--- a/arch/mips/pci/Makefile
++++ b/arch/mips/pci/Makefile
+@@ -55,6 +55,7 @@ obj-$(CONFIG_ZAO_CAPCELLA)	+= fixup-capc
+ obj-$(CONFIG_WR_PPMC)		+= fixup-wrppmc.o
+ obj-$(CONFIG_MIKROTIK_RB532)	+= pci-rc32434.o ops-rc32434.o fixup-rc32434.o
+ obj-$(CONFIG_CPU_CAVIUM_OCTEON)	+= pci-octeon.o pcie-octeon.o
++obj-$(CONFIG_SOC_RT288X)	+= pci-rt288x.o
+ 
+ ifdef CONFIG_PCI_MSI
+ obj-$(CONFIG_CPU_CAVIUM_OCTEON)	+= msi-octeon.o
diff --git a/target/linux/ramips/patches-2.6.34/103-ethernet.patch b/target/linux/ramips/patches-2.6.34/103-ethernet.patch
new file mode 100644
index 000000000..404f88595
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/103-ethernet.patch
@@ -0,0 +1,25 @@
+--- a/drivers/net/Kconfig
++++ b/drivers/net/Kconfig
+@@ -614,6 +614,12 @@ config MIPS_AU1X00_ENET
+ 	  If you have an Alchemy Semi AU1X00 based system
+ 	  say Y.  Otherwise, say N.
+ 
++config MIPS_RAMIPS_NET
++	tristate "Ethernet driver for rt288x/rt305x"
++	depends on MIPS_RALINK
++	help
++	  This driver supports the etehrnet mac inside the ralink wisocs
++
+ config SGI_IOC3_ETH
+ 	bool "SGI IOC3 Ethernet"
+ 	depends on PCI && SGI_IP27
+--- a/drivers/net/Makefile
++++ b/drivers/net/Makefile
+@@ -222,6 +222,7 @@ obj-$(CONFIG_KORINA) += korina.o
+ obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o
+ obj-$(CONFIG_MIPS_AU1X00_ENET) += au1000_eth.o
+ obj-$(CONFIG_MIPS_SIM_NET) += mipsnet.o
++obj-$(CONFIG_MIPS_RAMIPS_NET) += ramips.o
+ obj-$(CONFIG_SGI_IOC3_ETH) += ioc3-eth.o
+ obj-$(CONFIG_DECLANCE) += declance.o
+ obj-$(CONFIG_ATARILANCE) += atarilance.o
diff --git a/target/linux/ramips/patches-2.6.34/104-clsize.patch b/target/linux/ramips/patches-2.6.34/104-clsize.patch
new file mode 100644
index 000000000..96465b22e
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/104-clsize.patch
@@ -0,0 +1,11 @@
+--- linux-2.6.34.orig/arch/mips/include/asm/bootinfo.h  2010-05-21 09:54:15.000000000 +0400
++++ linux-2.6.34/arch/mips/include/asm/bootinfo.h       2010-05-21 09:55:09.000000000 +0400
+@@ -12,6 +12,8 @@
+ #ifndef _ASM_BOOTINFO_H
+ #define _ASM_BOOTINFO_H
+ 
++#define CL_SIZE                COMMAND_LINE_SIZE
++
+ #include <linux/types.h>
+ #include <asm/setup.h>
+
diff --git a/target/linux/ramips/patches-2.6.34/105-slab.patch b/target/linux/ramips/patches-2.6.34/105-slab.patch
new file mode 100644
index 000000000..8b4c8dc9b
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/105-slab.patch
@@ -0,0 +1,19 @@
+--- linux-2.6.34.orig/arch/mips/ralink/common/dev-gpio-buttons.c        2010-05-21 09:59:26.000000000 +0400
++++ linux-2.6.34/arch/mips/ralink/common/dev-gpio-buttons.c     2010-05-21 10:00:05.000000000 +0400
+@@ -10,6 +10,7 @@
+ 
+ #include "linux/init.h"
+ #include <linux/platform_device.h>
++#include <linux/slab.h>
+ 
+ #include <asm/mach-ralink/dev-gpio-buttons.h>
+ 
+--- linux-2.6.34.orig/arch/mips/ralink/common/dev-gpio-leds.c   2010-05-21 09:59:22.000000000 +0400
++++ linux-2.6.34/arch/mips/ralink/common/dev-gpio-leds.c        2010-05-21 09:59:44.000000000 +0400
+@@ -10,6 +10,7 @@
+ 
+ #include <linux/init.h>
+ #include <linux/platform_device.h>
++#include <linux/slab.h>
+ 
+ #include <asm/mach-ralink/dev-gpio-leds.h>
diff --git a/target/linux/ramips/patches-2.6.34/400-mips-multi-machine-update.patch b/target/linux/ramips/patches-2.6.34/400-mips-multi-machine-update.patch
new file mode 100644
index 000000000..60fe04fdc
--- /dev/null
+++ b/target/linux/ramips/patches-2.6.34/400-mips-multi-machine-update.patch
@@ -0,0 +1,135 @@
+--- a/arch/mips/kernel/mips_machine.c
++++ b/arch/mips/kernel/mips_machine.c
+@@ -7,12 +7,14 @@
+  *
+  */
+ #include <linux/mm.h>
++#include <linux/string.h>
++#include <linux/slab.h>
+ 
+ #include <asm/mips_machine.h>
+-#include <asm/bootinfo.h>
+ 
+ static struct list_head mips_machines __initdata =
+ 		LIST_HEAD_INIT(mips_machines);
++static char *mips_machid __initdata;
+ 
+ char *mips_machine_name = "Unknown";
+ 
+@@ -55,20 +56,65 @@ void __init mips_machine_set_name(char *
+ 	}
+ }
+ 
+-void __init mips_machine_setup(unsigned long machtype)
++void __init mips_machine_setup(void)
+ {
+ 	struct mips_machine *mach;
+ 
+-	mach = mips_machine_find(machtype);
++	mach = mips_machine_find(mips_machtype);
+ 	if (!mach) {
+-		printk(KERN_ALERT "MIPS: no machine registered for "
+-			"machtype %lu\n", machtype);
++		printk(KERN_WARNING "MIPS: no machine registered for "
++			"machtype %lu\n", mips_machtype);
+ 		return;
+ 	}
+ 
+ 	mips_machine_set_name(mach->mach_name);
+-	printk(KERN_INFO "MIPS: machine is %s\n", mips_machine_name);
++	printk(KERN_NOTICE "MIPS: machine is %s\n", mips_machine_name);
+ 
+ 	if (mach->mach_setup)
+ 		mach->mach_setup();
+ }
++
++int __init mips_machtype_setup(char *id)
++{
++	if (mips_machid == NULL)
++		mips_machid = id;
++
++	return 1;
++}
++
++__setup("machtype=", mips_machtype_setup);
++
++static int __init mips_machtype_init(void)
++{
++	struct list_head *this;
++	struct mips_machine *mach;
++
++	if (mips_machid == NULL)
++		return 0;
++
++	list_for_each(this, &mips_machines) {
++		mach = list_entry(this, struct mips_machine, list);
++		if (mach->mach_id == NULL)
++			continue;
++
++		if (strcmp(mach->mach_id, mips_machid) == 0) {
++			mips_machtype = mach->mach_type;
++			return 0;
++		}
++	}
++
++	printk(KERN_WARNING
++	       "MIPS: no machine found for id: '%s', registered machines:\n",
++	       mips_machid);
++	printk(KERN_WARNING "%32s %s\n", "id", "name");
++
++	list_for_each(this, &mips_machines) {
++		mach = list_entry(this, struct mips_machine, list);
++		printk(KERN_WARNING "%32s %s\n",
++		       mach->mach_id ? mach->mach_id : "", mach->mach_name);
++	}
++
++	return 0;
++}
++
++core_initcall(mips_machtype_init);
+--- a/arch/mips/include/asm/mips_machine.h
++++ b/arch/mips/include/asm/mips_machine.h
+@@ -13,25 +13,33 @@
+ #include <linux/init.h>
+ #include <linux/list.h>
+ 
++#include <asm/bootinfo.h>
++
+ struct mips_machine {
+ 	unsigned long		mach_type;
+-	void			(*mach_setup)(void);
++	char			*mach_id;
+ 	char			*mach_name;
++	void			(*mach_setup)(void);
+ 	struct list_head	list;
+ };
+ 
+ void mips_machine_register(struct mips_machine *) __init;
+-void mips_machine_setup(unsigned long machtype) __init;
++void mips_machine_setup(void) __init;
++int  mips_machtype_setup(char *id) __init;
+ void mips_machine_set_name(char *name) __init;
+ 
+ extern char *mips_machine_name;
+ 
+-#define MIPS_MACHINE(_type, _name, _setup) 			\
+-static char machine_name_##_type[] __initdata = _name;		\
++#define MIPS_MACHINE(_type, _id, _name, _setup) 		\
++static const char machine_name_##_type[] __initconst		\
++			__aligned(1) = _name;			\
++static const char machine_id_##_type[] __initconst		\
++			__aligned(1) = _id;			\
+ static struct mips_machine machine_##_type __initdata =		\
+ {								\
+ 	.mach_type	= _type,				\
+-	.mach_name	= machine_name_##_type,			\
++	.mach_id	= (char *) machine_id_##_type,		\
++	.mach_name	= (char *) machine_name_##_type,	\
+ 	.mach_setup	= _setup,				\
+ };								\
+ 								\
+@@ -44,4 +52,3 @@ static int __init register_machine_##_ty
+ pure_initcall(register_machine_##_type)
+ 
+ #endif /* __ASM_MIPS_MACHINE_H */
+-
-- 
2.20.1