Skip to contentSkip to conversation

Add support for Realtek Media Player SoCs

PATCH In review [email protected] 3 participants 5 messages Nov 21, 2010 – Nov 22, 2010 1 message not in the archive MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for Realtek Media Player SoCs

Hi,

I added support for at least one of the Realtek "Galaxy" SoCs to recent 2.6.36 kernel. Most of the patch is based on existing linux-mips code and a 2.6.12 kernel source released by some of Realtek customers.

Currently, this allows to start the kernel and setup serial console. Further development/porting will have to be done for additional platform devices.

This code is tested on a Realtek Mars SoC. Commercial product name is rtd1073dd but cpu/soc id is 0x1283. Other SoCs (Venus,Jupiter,Neptune) have not been tested, yet.

Please comment on the patch and feel free to suggest changes that need to be done prior integration.

Sebastian

arch/mips/include/asm/mach-rtd128x/rtd128x-board.h +51 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/include/asm/mach-rtd128x/rtd128x-board.h linux-2.6.36/arch/mips/include/asm/mach-rtd128x/rtd128x-board.h
@@ -0,0 +1,51 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#ifndef _RTD128X_BOARD_H_
+#define _RTD128X_BOARD_H_
+
+#include <linux/types.h>
+
+enum rtd128x_board_type {
+	RTD128X_BOARD_UNKNOWN = -1,
+	RTD128X_BOARD_EM7080 = 0,
+};
+
+struct rtd128x_board {
+	char name[16];
+	u32 ext_freq;
+	unsigned int has_eth0:1;
+	unsigned int has_pci:1;
+	unsigned int has_pccard:1;
+	unsigned int has_ohci0:1;
+	unsigned int has_ehci0:1;
+	unsigned int has_sata0:1;
+	unsigned int has_sata1:1;
+	unsigned int has_uart0:1;
+	unsigned int has_uart1:1;
+	unsigned int has_vfd:1;
+
+	void (*machine_restart) (char *);
+	void (*machine_halt) (void);
+	void (*machine_poweroff) (void);
+
+	/*
+	 * Autodetected / PROM values
+	 */
+
+	phys_t memory_size;
+	char bootrev[16];
+	u16 company_id;
+	u32 board_id;
+	u8 cpu_id;
+	u8 chip_rev;
+	u16 chip_id;
+};
+
+extern struct rtd128x_board rtd128x_board_info;
+
+#endif
arch/mips/include/asm/mach-rtd128x/rtd128x-io.h +276 -0

276 lines not on this page · raw message

arch/mips/include/asm/mach-rtd128x/rtd128x-irq.h +70 -0

70 lines not on this page · raw message

arch/mips/include/asm/mach-rtd128x/rtd128x-soc.h +41 -0

41 lines not on this page · raw message

arch/mips/include/asm/mach-rtd128x/war.h +26 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/include/asm/mach-rtd128x/war.h linux-2.6.36/arch/mips/include/asm/mach-rtd128x/war.h
@@ -0,0 +1,26 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <[email protected]>
+ */
+
+#ifndef __ASM_MIPS_MACH_RTD128x_WAR_H
+#define __ASM_MIPS_MACH_RTD128x_WAR_H
+
+#define R4600_V1_INDEX_ICACHEOP_WAR	0
+#define R4600_V1_HIT_CACHEOP_WAR	0
+#define R4600_V2_HIT_CACHEOP_WAR	0
+#define R5432_CP0_INTERRUPT_WAR		0
+#define BCM1250_M3_WAR			0
+#define SIBYTE_1956_WAR			0
+#define MIPS4K_ICACHE_REFILL_WAR	0
+#define MIPS_CACHE_SYNC_WAR		0
+#define TX49XX_ICACHE_INDEX_INV_WAR	0
+#define RM9000_CDEX_SMP_WAR		0
+#define ICACHE_REFILLS_WORKAROUND_WAR	0
+#define R10000_LLSC_WAR			0
+#define MIPS34K_MISSED_ITLB_WAR		0
+
+#endif /* __ASM_MIPS_MACH_RTD128x_WAR_H */
arch/mips/Kbuild.platforms +1 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/Kbuild.platforms linux-2.6.36/arch/mips/Kbuild.platforms
@@ -18,6 +18,7 @@
 platforms += pnx833x
 platforms += pnx8550
 platforms += powertv
+platforms += rtd128x
 platforms += rb532
 platforms += sgi-ip22
 platforms += sgi-ip27
arch/mips/Kconfig +17 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/Kconfig linux-2.6.36/arch/mips/Kconfig
@@ -706,6 +706,22 @@
 		Hikari
 	  Say Y here for most Octeon reference boards.
 
+config RTD128X
+	bool "Realtek Galaxy SoC based boards"
+	select CEVT_R4K
+	select CSRC_R4K
+	select IRQ_CPU
+	select GENERIC_ISA_DMA
+	select DMA_NONCOHERENT
+	select SYS_HAS_CPU_MIPS32_R2
+	select SYS_HAS_EARLY_PRINTK
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_LITTLE_ENDIAN
+	select SYS_SUPPORTS_ZBOOT_UART16550
+	help
+	  This options supports Realtek SoC based boards.
+	  Say Y here for Realtek SoC based boards.
+
 endchoice
 
 source "arch/mips/alchemy/Kconfig"
@@ -721,6 +737,7 @@
 source "arch/mips/vr41xx/Kconfig"
 source "arch/mips/cavium-octeon/Kconfig"
 source "arch/mips/loongson/Kconfig"
+source "arch/mips/rtd128x/Kconfig"
 
 endmenu
 
arch/mips/rtd128x/common/board.c +137 -0

137 lines not on this page · raw message

arch/mips/rtd128x/common/irq.c +137 -0

137 lines not on this page · raw message

arch/mips/rtd128x/common/Makefile +10 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/common/Makefile linux-2.6.36/arch/mips/rtd128x/common/Makefile
@@ -0,0 +1,10 @@
+obj-$(CONFIG_RTD128X) += platform.o
+obj-$(CONFIG_RTD128X) += irq.o
+obj-$(CONFIG_RTD128X) += memory.o
+obj-$(CONFIG_RTD128X) += prom.o
+obj-$(CONFIG_RTD128X) += setup.o
+obj-$(CONFIG_RTD128X) += time.o
+obj-$(CONFIG_RTD128X) += board.o
+obj-$(CONFIG_RTD128X) += printk.o
+obj-$(CONFIG_RTD128X) += sb2.o
+
arch/mips/rtd128x/common/memory.c +202 -0

202 lines not on this page · raw message

arch/mips/rtd128x/common/platform.c +103 -0

103 lines not on this page · raw message

arch/mips/rtd128x/common/printk.c +33 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/common/printk.c linux-2.6.36/arch/mips/rtd128x/common/printk.c
@@ -0,0 +1,33 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <linux/init.h>
+#include <asm/io.h>
+#include <rtd128x-io.h>
+
+#define UART_LSR_TEMT		0x40	/* Transmitter empty */
+#define UART_LSR_THRE		0x20	/* Transmit-hold-register empty */
+
+static void __init wait_xfered(void)
+{
+	unsigned int val;
+
+	/* wait for any previous char to be transmitted */
+	do {
+		val = inl(RTD128X_UART_U0LSR);
+		if ((val & (UART_LSR_TEMT | UART_LSR_THRE)) ==
+		    (UART_LSR_TEMT | UART_LSR_THRE))
+			break;
+	} while (1);
+}
+
+void __init prom_putchar(char c)
+{
+	wait_xfered();
+	outl(c, RTD128X_UART_U0RBR_THR_DLL);
+	wait_xfered();
+}
arch/mips/rtd128x/common/prom.c +224 -0

224 lines not on this page · raw message

arch/mips/rtd128x/common/sb2.c +46 -0

46 lines not on this page · raw message

arch/mips/rtd128x/common/setup.c +179 -0

179 lines not on this page · raw message

arch/mips/rtd128x/common/time.c +87 -0

87 lines not on this page · raw message

arch/mips/rtd128x/Kconfig +14 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/Kconfig linux-2.6.36/arch/mips/rtd128x/Kconfig
@@ -0,0 +1,14 @@
+config RTD128X_RECLAIM_BOOT_MEMORY
+        bool "reclaim memory from bootloader"
+
+#
+# FIXME: do we really need this?
+#
+#config RTD128X_EXTERNAL_TIMER
+#        bool "use external timer interrupt"
+
+#
+# TODO
+#
+#config RTD128X_WATCHDOG
+#        bool "use internal watchdog"
arch/mips/rtd128x/Makefile +1 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/Makefile linux-2.6.36/arch/mips/rtd128x/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_RTD128X) += common/
arch/mips/rtd128x/Platform +8 -0
diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/Platform linux-2.6.36/arch/mips/rtd128x/Platform
@@ -0,0 +1,8 @@
+#
+# Realtek Galaxy SoC boards
+#
+
+platform-${CONFIG_RTD128X} += rtd128x/
+cflags-${CONFIG_RTD128X}   += -I$(srctree)/arch/mips/include/asm/mach-rtd128x/
+load-${CONFIG_RTD128X}     := 0xffffffff80100000
+all-$(CONFIG_RTD128X)      := $(COMPRESSION_FNAME).bin
#1 lore raw
Quoted 1 line · [email protected] writes:

Hi,

Hi,

Please read Documentation/SubmittingPatches. One big patch is just impossible to review (at least for me), please split it in fewer chunks.

Quoted 8 lines

I added support for at least one of the Realtek "Galaxy" SoCs to recent 2.6.36 kernel. Most of the patch is based on existing linux-mips code and a 2.6.12 kernel source released by some of Realtek customers.

Currently, this allows to start the kernel and setup serial console. Further development/porting will have to be done for additional platform devices.

Do you have an exact status of the different platform device support ? How do you deal with the audio/video support (for instance firmware loading & their rpc stuff) ?

Quoted 4 lines

This code is tested on a Realtek Mars SoC. Commercial product name is rtd1073dd but cpu/soc id is 0x1283. Other SoCs (Venus,Jupiter,Neptune) have not been tested, yet.

Do you know the differences between the different versions and/or have public specs of the SoCs ?
Also, I'm seeing a lot of rtd128x in the file names... Commercial name for the Venus is rtd1261 for instance. I find this really confusing. I would be tempted to use mach-realtek but I don't know enough the realtek mips SoCs to say if it's a good idea.

Arnaud

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 9 lines · [email protected] writes:
Quoted 3 lines · Arnaud Patard (Rtp)

Please read Documentation/SubmittingPatches. One big patch is just impossible to review (at least for me), please split it in fewer chunks.

I already spoke to Ralf about this. I wanted to submit smaller patches but as adding initial support is "one logical change" I stuck to one large patch for now. But I understand the need for a nicer way to review the changes. Although most of them are new files for the mach anyway.

Ok, will harder to look at it, then. At least, that should not prevent you to follow SubmittingPatches way (For instance, there's no signed-off-by in your patch submission).

At least, I will try to find time to test it on my rtd1261 board.

Quoted 11 lines
Quoted 4 lines

Do you have an exact status of the different platform device support ? How do you deal with the audio/video support (for instance firmware loading & their rpc stuff) ?

I have no exact status except the 2.6.12 source that is delivered with most (all?) of the media players. As far as I checked the a/v code everything interesting is done in userspace by ioctls. I don't like it that way but for a first shot it would be easier to keep it that way and then start to port it to common kernel interfaces. Can't tell now if this will be possible at all without any documentation available.

yeah, afaik it's ioctl but the code is horrible which makes it hard to understand (see RPCpoll.c, RPCintr.c, se* for instance) and is not necessary the best way to handle that. I've only given a brief look at the realtek 2.6.12.6 tree so I may be missing some stuff.

Quoted 4 lines

The firmware for the Lexras gets copied to reserved mem areas by the bootloader.

Quoted 1 line

From the debug messages of the original bootloader and kernel I would guess

you can halt, reset and run the Lexras by writing into some registers.

ok.

Quoted 5 lines

Other devices include sata, usb, and eth. The eth is a rtl8139c+ where there is a driver available already but relies on pci. Realtek itself took this code and modified it for bus accesses. Usb and sata drivers are there from the 2.6.12 but again I did no in-depth study of the code, yet.

yeah but the realtek way of duplicating 8139 code is not really a good path to follow. finding a better way would be nice. I was thinking about a phy driver. I don't know if it's a good idea.

Getting ethernet and sata would be first thing to do. This would help testing/developing imho.

Quoted 7 lines
Quoted 3 lines

Do you know the differences between the different versions and/or have public specs of the SoCs ?

I cannot tell you the exact differences between the SoCs and I have no documentation at all.

too bad. This means we're stuck at parsing the realtek code :/

Quoted 9 lines
Quoted 4 lines

Also, I'm seeing a lot of rtd128x in the file names... Commercial name for the Venus is rtd1261 for instance. I find this really confusing. I would be tempted to use mach-realtek but I don't know enough the realtek mips SoCs to say if it's a good idea.

Yeah, this is confusing but may be caused by the confusing way realtek calls their chips. I always thought the rtd1261 is Mars and rtd1071 is Venus (so the other way round). But the chip id of the rtd1071 tells me it is Mars and I have no other SoC available.

The boot logs of my board are saying "cpu id: 0". In the 2.6.12.6 code I have, it maps to

typedef enum {
       realtek_venus_cpu       =0x0,
       realtek_venus2_cpu      =0x10,
       realtek_neptune_cpu     =0x1,
       realtek_neptuneB_cpu    =0x11
} cpu_id_t;

So I have a Venus and on it, it's written rtd1261.

Quoted 4 lines

I chose rtd128x because the chip id register for all SoCs named by planets is 0x1281, 0x1282, 0x1283, aso. Therefore, I thought using value-based naming would be nicer than weird commercial names.

Finding good naming is hard. At least, I wouldn't look for rtd1261 support in something called rtd128x.

Quoted 3 lines

I guess mach-realtek would be to generic (think of rtl8181) but maybe galaxy could be used because of the planet names of the SoCs.

I see. So, maybe galaxy as you're suggesting is better. Ralf, any opinion ?

Arnaud

#4 lore raw
In reply to Arnaud Patard (Rtp)
Quoted 3 lines · Arnaud Patard

Please read Documentation/SubmittingPatches. One big patch is just impossible to review (at least for me), please split it in fewer chunks.

This is not outrageously huge and actually well smaller than the "atoms" some other patches were split into. Ideally patches should be split such that each patch fixes one bug or adds one feature and such that applying only a part of a patch series does not result in a regression. The absolute size or number of patches at least to me is a secondary consideration.

Ralf

#5 lore raw
In reply to [email protected]
Quoted 3 lines · On Sun, Nov 21, 2010 at 01:15:11AM +0100, [email protected] wrote:

I added support for at least one of the Realtek "Galaxy" SoCs to recent 2.6.36 kernel. Most of the patch is based on existing linux-mips code and a 2.6.12 kernel source released by some of Realtek customers.

For submission please use the latest linux-queue git tree or at least the linux-mips tree.

Quoted 10 lines

Currently, this allows to start the kernel and setup serial console. Further development/porting will have to be done for additional platform devices.

This code is tested on a Realtek Mars SoC. Commercial product name is rtd1073dd but cpu/soc id is 0x1283. Other SoCs (Venus,Jupiter,Neptune) have not been tested, yet.

Please comment on the patch and feel free to suggest changes that need to be done prior integration.

Let the flaming begin :-)

First, when submitting patches, please include a Signed-off-by: line. For details on that, see Documentation/SubmittingPatches in the kernel sources. Strictly seen this is not needed to get a patch reviewed but only for the actual submission of a patch but it's good style to always include it. Other people might grab a patch and base their work on it and even hell might freeze over and a patch might be applied right away.

Also please include a diffstat of a patch so everybody can see right away what a particular patch touches.

 arch/mips/Kbuild.platforms                         |    1 
 arch/mips/Kconfig                                  |   17 +
 arch/mips/include/asm/mach-rtd128x/rtd128x-board.h |   51 +++
 arch/mips/include/asm/mach-rtd128x/rtd128x-io.h    |  276 +++++++++++++++++++++
 arch/mips/include/asm/mach-rtd128x/rtd128x-irq.h   |   70 +++++
 arch/mips/include/asm/mach-rtd128x/rtd128x-soc.h   |   41 +++
 arch/mips/include/asm/mach-rtd128x/war.h           |   26 +
 arch/mips/rtd128x/Kconfig                          |   14 +
 arch/mips/rtd128x/Makefile                         |    1 
 arch/mips/rtd128x/Platform                         |    8 
 arch/mips/rtd128x/common/Makefile                  |   10 
 arch/mips/rtd128x/common/board.c                   |  137 ++++++++++
 arch/mips/rtd128x/common/irq.c                     |  137 ++++++++++
 arch/mips/rtd128x/common/memory.c                  |  202 +++++++++++++++
 arch/mips/rtd128x/common/platform.c                |  103 +++++++
 arch/mips/rtd128x/common/printk.c                  |   33 ++
 arch/mips/rtd128x/common/prom.c                    |  224 +++++++++++++++++
 arch/mips/rtd128x/common/sb2.c                     |   46 +++
 arch/mips/rtd128x/common/setup.c                   |  179 +++++++++++++
 arch/mips/rtd128x/common/time.c                    |   87 ++++++
 20 files changed, 1663 insertions(+)

And the diffstat raises the question why the common directory if the entire code ends up there?

Also you want to add a arch/mips/include/asm/mach-rtd128x/cpu-feature- overrides.h file for better performance and significantly smaller kernel code.

So let's see ...

Quoted 10 lines

diff -uNr linux-2.6.36-vanilla/arch/mips/include/asm/mach-rtd128x/rtd128x-board.h linux-2.6.36/arch/mips/include/asm/mach-rtd128x/rtd128x-board.h

arch/mips/include/asm/mach-rtd128x/rtd128x-board.h +6 -0
@@ -0,0 +1,51 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */

arch/mips/include/asm/mach-rtd128x/rtd128x-board.h line 16

Quoted 10 lines
arch/mips/include/asm/mach-rtd128x/rtd128x-board.h +10 -0
+
+#ifndef _RTD128X_BOARD_H_
+#define _RTD128X_BOARD_H_
+
+#include <linux/types.h>
+
+enum rtd128x_board_type {
+	RTD128X_BOARD_UNKNOWN = -1,
+	RTD128X_BOARD_EM7080 = 0,
+};

You probably want to have RTD128X_BOARD_UNKNOWN = 0 such that an un- initialized variable of type enum rtd128x_board_type will be treated as unknown platform type and not RTD128X_BOARD_EM7080.

[...]

arch/mips/include/asm/mach-rtd128x/rtd128x-board.h line 18

Quoted 2 lines
arch/mips/include/asm/mach-rtd128x/rtd128x-board.h +2 -0
+#define RTD128X_SYS_BASE_OFFSET     0x0000
+#define RTD128X_EHCI_BASE_OFFSET    0x3000
                                   ^^^^

Format with tabs, please.

arch/mips/include/asm/mach-rtd128x/rtd128x-board.h line 21

Quoted 3 lines
arch/mips/include/asm/mach-rtd128x/rtd128x-board.h +3 -0
+/*
+ * UART0/UART1 (8250 compatible)
+ */

[37 lines of UART definitions deleted.]

You may want to use the <linux/serial_reg.h> definitions instead. A simple wrapper macro to do writes into the UART should do the job.

arch/mips/Kbuild.platforms line 21

Quoted 7 lines
arch/mips/Kbuild.platforms +1 -0
@@ -18,6 +18,7 @@
 platforms += pnx833x
 platforms += pnx8550
 platforms += powertv
+platforms += rtd128x

Read the comment at line 1 of this file!

arch/mips/rtd128x/common/board.c line 10

Quoted 13 lines
arch/mips/rtd128x/common/board.c +10 -0
@@ -0,0 +1,137 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <asm/io.h>

Use <linux/io.h> - or scripts/checkpatch.pl will moan loudly.

arch/mips/rtd128x/common/board.c line 42

Quoted 3 lines
arch/mips/rtd128x/common/board.c +3 -0
+static void rtd128x_common_machine_restart(char *cmd)
+{
+#ifdef CONFIG_RTD128X_WATCHDOG

CONFIG_RTD128X_WATCHDOG is meant to control building the driver in drivers/watchdog? The kernel should still work ok even if it was build without support for a particular driver, then the driver later compiled and be loaded into the previously built kernel. Iow, this #ifdef should go.

arch/mips/rtd128x/common/board.c line 51

Quoted 7 lines
arch/mips/rtd128x/common/board.c +7 -0
+	 */
+	kill_watchdog();
+#else
+	/*
+	 * TODO: Find a way to reset the SoC
+	 */
+	outl(0x0, RTD128X_TIMR_TCWCR);

MIPS doesn't have an I/O port address space. That's pure x86 legacy and even there it's deprecated. in, out and their whole clan are meant to be exclusively used to access for I/O port accesses, that is (E)ISA or PCI port addresses.

arch/mips/rtd128x/common/board.c line 22

Quoted 2 lines
arch/mips/rtd128x/common/board.c +2 -0
+#endif
+	msleep(5000);

Just make this "while (1);"

arch/mips/rtd128x/common/board.c line 108

Quoted 11 lines
arch/mips/rtd128x/common/board.c +11 -0
+
+static enum rtd128x_board_type rtd128x_detect_board(void)
+{
+	return RTD128X_BOARD_EM7080;
+
+	/*
+	 * TODO: Detect different board types
+	 */
+
+	return RTD128X_BOARD_UNKNOWN;
+}

I see dead code :)

arch/mips/rtd128x/common/board.c line 115

Quoted 6 lines
arch/mips/rtd128x/common/board.c +6 -0
+void rtd128x_board_setup(void)
+{
+	switch (rtd128x_detect_board()) {
+	case RTD128X_BOARD_EM7080:
+		memcpy(&rtd128x_board_info, &rtd128x_em7080_info,
+		       sizeof(struct rtd128x_board));

You probably want to turn rtd128x_board_info into a pointer which would turn this into a simple pointer assignment:

	rtd128x_board_info = &rtd128x_em7080_info;

And many other places would get a little more elegant also.

arch/mips/rtd128x/common/board.c line 118

Quoted 3 lines
arch/mips/rtd128x/common/board.c +3 -0
+		break;
+	default:
+		printk("Unknown rtd128x board.");

I guess as early as this not even early prinkt is working yet so maybe just BUG() would do?

Quoted 21 lines
arch/mips/rtd128x/common/board.c +20 -0
+++ linux-2.6.36/arch/mips/rtd128x/common/memory.c	2010-11-19 18:10:26.000000000 +0100
@@ -0,0 +1,202 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/bootmem.h>
+#include <linux/pfn.h>
+#include <linux/string.h>
+
+#include <asm/bootinfo.h>
+#include <asm/page.h>
+#include <asm/sections.h>
+
+#include <asm/mips-boards/prom.h>
+#include <rtd128x-board.h>

arch/mips/rtd128x/common/board.c line 29

Quoted 10 lines
arch/mips/rtd128x/common/board.c +10 -0
+#include <rtd128x-soc.h>
+
+//#define DEBUG
+
+enum yamon_memtypes {
+	yamon_dontuse,
+	yamon_prom,
+	yamon_free,
+};
+static struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];

Ah, the 3rd copy of YAMON support code. No fucking way. Please extract the code from the other copies to a shared place and use those definitions for the rtd128x.

arch/mips/rtd128x/common/board.c line 34

Quoted 5 lines
arch/mips/rtd128x/common/board.c +5 -0
+#ifdef CONFIG_CPU_BIG_ENDIAN
+	/* SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last
+	   word of physical memory */
+	physical_memsize -= PAGE_SIZE;
+#endif

But you most likely don't have SOC-it (a system controller from MIPS). And your Kconfig is setup to hardwire endianess to little endian so this is doubly dead code.

arch/mips/rtd128x/common/board.c line 35

Quoted 1 line
arch/mips/rtd128x/common/board.c +1 -0
+#ifdef CONFIG_RTD128X_RECLAIM_BOOT_MEMORY

Is there a good reason why CONFIG_RTD128X_RECLAIM_BOOT_MEMORY is configurable? This probably should always be abled.

Quoted 5 lines
arch/mips/rtd128x/common/board.c +1 -0
+device_initcall(rtd128x_devinit);

diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/common/printk.c linux-2.6.36/arch/mips/rtd128x/common/printk.c

arch/mips/rtd128x/common/printk.c line 9

Quoted 9 lines
arch/mips/rtd128x/common/printk.c +9 -0
@@ -0,0 +1,33 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <linux/init.h>
+#include <asm/io.h>

Again, use <linux/io.h>.

arch/mips/rtd128x/common/printk.c line 13

Quoted 4 lines
arch/mips/rtd128x/common/printk.c +4 -0
+#include <rtd128x-io.h>
+
+#define UART_LSR_TEMT		0x40	/* Transmitter empty */
+#define UART_LSR_THRE		0x20	/* Transmit-hold-register empty */

This duplicates definitions from <linux/serial_reg.h>.

arch/mips/rtd128x/common/printk.c line 33

Quoted 6 lines
arch/mips/rtd128x/common/printk.c +6 -0
+void __init prom_putchar(char c)
+{
+	wait_xfered();
+	outl(c, RTD128X_UART_U0RBR_THR_DLL);
+	wait_xfered();
+}

Should be ok to only wait only before writing the character into the output register. UART accesses are terribly slow and that way you can at least overlap some of the I/O with other activity.

arch/mips/rtd128x/common/printk.c line 24

Quoted 5 lines
arch/mips/rtd128x/common/printk.c +5 -0
+void prom_puts(char *s)
+{
+	while (*s != '\0') {
+		if (*s == '\n') {
+			prom_putchar(*s++);

What's wrong with prm_putchar('\n');

arch/mips/rtd128x/common/printk.c line 29

Quoted 5 lines
arch/mips/rtd128x/common/printk.c +5 -0
+
+void prom_puthex(unsigned long l)
+{
+	char n;
+	int i;

Insert blank line here.

arch/mips/rtd128x/common/printk.c

Quoted 5 lines
arch/mips/rtd128x/common/printk.c +4 -0
+	prom_putchar('0');
+	prom_putchar('x');
 
+int prom_argc;
+int *_prom_argv, *_prom_envp;

Consider making these static and __init. I assume these variables are not being used after kernel initialization?

arch/mips/rtd128x/common/printk.c

Quoted 3 lines
arch/mips/rtd128x/common/printk.c +3 -0
+
+/* TODO: Verify on linux-mips mailing list that the following two  */
+/* functions are correct                                           */

Ah, comments copied from PowerTV :)

arch/mips/rtd128x/common/printk.c

Quoted 9 lines
arch/mips/rtd128x/common/printk.c +9 -0
+/* TODO: Copy NMI and EJTAG exception vectors to memory from the   */
+/* BootROM exception vectors. Flush their cache entries. test it.  */
+
+static void __init mips_nmi_setup(void)
+{
+	void *base;
+#if defined(CONFIG_CPU_MIPS32_R1)
+	base = cpu_has_veic ?
+	    (void *)(CAC_BASE + 0xa80) : (void *)(CAC_BASE + 0x380);

Won't fly for NMI. NMIs set BEV = 1 which means all your nice vectors will be bypassed and the processor will jump straight to 0xbfc00000. The average firmware will reininitialize the system but some is slightly nicer and allows the OS to regain control.

Quoted 9 lines
arch/mips/rtd128x/common/printk.c +6 -0
+#elif defined(CONFIG_CPU_MIPS32_R2)
+	base = (void *)0xbfc00000;
+#else
+#error NMI exception handler address not defined
+#endif
+}

arch/mips/rtd128x/common/sb2.c line 21

Quoted 5 lines
arch/mips/rtd128x/common/sb2.c +4 -0
 
+	if (!(inl(RTD128X_SB2_INV_INTSTAT) & 0x2))
+		return IRQ_NONE;
+
+	/* 
        ^^^^

remove the trailing space, please.

arch/mips/rtd128x/common/setup.c line 9

Quoted 13 lines

diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/common/setup.c linux-2.6.36/arch/mips/rtd128x/common/setup.c

arch/mips/rtd128x/common/setup.c +9 -0
@@ -0,0 +1,179 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/sched.h>

Do you really need sched.h?

Quoted 70 lines
arch/mips/rtd128x/common/setup.c +70 -0
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/screen_info.h>
+#include <linux/notifier.h>
+#include <linux/etherdevice.h>
+#include <linux/if_ether.h>
+#include <linux/ctype.h>
+#include <linux/cpu.h>
+#include <linux/time.h>
+
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/mips-boards/generic.h>
+#include <asm/mips-boards/prom.h>
+#include <asm/dma.h>
+#include <asm/time.h>
+#include <asm/asm.h>
+#include <asm/traps.h>
+#include <asm/reboot.h>
+#include <asm/asm-offsets.h>
+
+#include <rtd128x-board.h>
+
+extern void rtd128x_board_setup(void);
+
+#define VAL(n)		STR(n)
+
+/*
+ * Macros for loading addresses and storing registers:
+ * LONG_L_	Stringified version of LONG_L for use in asm() statement
+ * LONG_S_	Stringified version of LONG_S for use in asm() statement
+ * PTR_LA_	Stringified version of PTR_LA for use in asm() statement
+ * REG_SIZE	Number of 8-bit bytes in a full width register
+ */
+#define LONG_L_		VAL(LONG_L) " "
+#define LONG_S_		VAL(LONG_S) " "
+#define PTR_LA_		VAL(PTR_LA) " "
+
+#ifdef CONFIG_64BIT
+#warning TODO: 64-bit code needs to be verified
+#define REG_SIZE	"8"	/* In bytes */
+#endif
+
+#ifdef CONFIG_32BIT
+#define REG_SIZE	"4"	/* In bytes */
+#endif
+
+static void register_panic_notifier(void);
+static int panic_handler(struct notifier_block *notifier_block,
+			 unsigned long event, void *cause_string);
+
+/*
+ * Install a panic notifier for platform-specific diagnostics
+ */
+static void register_panic_notifier()
+{
+	static struct notifier_block panic_notifier = {
+		.notifier_call = panic_handler,
+		.next = NULL,
+		.priority = INT_MAX
+	};
+	atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier);
+}
+
+static int panic_handler(struct notifier_block *notifier_block,
+			 unsigned long event, void *cause_string)
+{
+	struct pt_regs my_regs;
+
+	/* Save all of the registers */

arch/mips/rtd128x/common/setup.c line 89

Quoted 10 lines
arch/mips/rtd128x/common/setup.c +10 -0
+	{
+		unsigned long at, v0, v1;	/* Must be on the stack */
+
+		/* Start by saving $at and v0 on the stack. We use $at
+		 * ourselves, but it looks like the compiler may use v0 or v1
+		 * to load the address of the pt_regs structure. We'll come
+		 * back later to store the registers in the pt_regs
+		 * structure. */
+		__asm__ __volatile__(".set	noat\n"
+				     LONG_S_ "$at, %[at]\n"

Copied from PowerTV :) I somehow doubt saving registers at this late stage provides much useful information.

arch/mips/rtd128x/common/setup.c line 159

Quoted 2 lines
arch/mips/rtd128x/common/setup.c +2 -0
+	pr_crit("I'm feeling a bit sleepy. hmmmmm... perhaps a nap would... "
+		"zzzz... \n");

This is a panic so pr_emerg() would see more apropriate to express the urgency of this nap :-)

Quoted 11 lines
arch/mips/rtd128x/common/time.c +8 -0
@@ -0,0 +1,87 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ */
+
+#include <linux/types.h>

arch/mips/rtd128x/common/time.c line 18

Quoted 10 lines
arch/mips/rtd128x/common/time.c +10 -0
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/time.h>
+#include <linux/timex.h>
+
+#include <asm/mipsregs.h>
+#include <asm/mipsmtregs.h>

Eh... You said you have a 24K. There is no way you then could use any of the definitions in this file.

arch/mips/rtd128x/common/time.c line 29

Quoted 11 lines
arch/mips/rtd128x/common/time.c +11 -0
+#include <asm/hardirq.h>
+#include <asm/irq.h>
+#include <asm/div64.h>
+#include <asm/cpu.h>
+#include <asm/time.h>
+
+#include <rtd128x-io.h>
+#include <rtd128x-irq.h>
+#include <rtd128x-board.h>
+
+extern void platform_setup(void);

Declaration but the symbol platform_setup() is not being used anywhere. And another file also declared platform_setup() without using it ...

arch/mips/rtd128x/common/time.c line 31

Quoted 2 lines
arch/mips/rtd128x/common/time.c +2 -0
+
+unsigned long cpu_khz;

Unused junk.

arch/mips/rtd128x/Kconfig line 8

Quoted 12 lines

diff -uNr linux-2.6.36-vanilla/arch/mips/rtd128x/Kconfig linux-2.6.36/arch/mips/rtd128x/Kconfig

arch/mips/rtd128x/Kconfig +8 -0
@@ -0,0 +1,14 @@
+config RTD128X_RECLAIM_BOOT_MEMORY
+        bool "reclaim memory from bootloader"
+
+#
+# FIXME: do we really need this?
+#
+#config RTD128X_EXTERNAL_TIMER
+#        bool "use external timer interrupt"

You certainly don't want to expose such stuff to the Kconfig user who most likely has no clue whatsoever what this option means. Especially not without a help text but that's besides the point. The option should simply not exist.

arch/mips/rtd128x/Platform line 8

Quoted 11 lines
arch/mips/rtd128x/Platform +8 -0
@@ -0,0 +1,8 @@
+#
+# Realtek Galaxy SoC boards
+#
+
+platform-${CONFIG_RTD128X} += rtd128x/
+cflags-${CONFIG_RTD128X}   += -I$(srctree)/arch/mips/include/asm/mach-rtd128x/
+load-${CONFIG_RTD128X}     := 0xffffffff80100000
+all-$(CONFIG_RTD128X)      := $(COMPRESSION_FNAME).bin

Ralf