zte's code,first commit

Change-Id: I9a04da59e459a9bc0d67f101f700d9d7dc8d681b
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/Makefile b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/Makefile
new file mode 100644
index 0000000..45be9b0
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/Makefile
@@ -0,0 +1,12 @@
+#
+# Makefile for the linux kernel.
+#
+
+# Object file lists.
+
+obj-y			:= core.o dma.o irq.o pci.o
+obj-m			:=
+obj-n			:=
+obj-			:=
+
+obj-$(CONFIG_LEDS)	+= leds.o
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/Makefile.boot b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/Makefile.boot
new file mode 100644
index 0000000..e40e24e
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/Makefile.boot
@@ -0,0 +1,2 @@
+   zreladdr-y	+= 0x08008000
+
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/core.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/core.c
new file mode 100644
index 0000000..2704bcd
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/core.c
@@ -0,0 +1,167 @@
+/*
+ *  linux/arch/arm/mach-shark/arch.c
+ *
+ *  Architecture specific stuff.
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/sched.h>
+#include <linux/serial_8250.h>
+#include <linux/io.h>
+
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/leds.h>
+#include <asm/param.h>
+#include <asm/system_misc.h>
+
+#include <asm/mach/map.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/time.h>
+
+#define IO_BASE                 0xe0000000
+#define IO_SIZE                 0x08000000
+#define IO_START                0x40000000
+#define ROMCARD_SIZE            0x08000000
+#define ROMCARD_START           0x10000000
+
+static void shark_restart(char mode, const char *cmd)
+{
+        short temp;
+        /* Reset the Machine via pc[3] of the sequoia chipset */
+        outw(0x09,0x24);
+        temp=inw(0x26);
+        temp = temp | (1<<3) | (1<<10);
+        outw(0x09,0x24);
+        outw(temp,0x26);
+}
+
+static struct plat_serial8250_port serial_platform_data[] = {
+	{
+		.iobase		= 0x3f8,
+		.irq		= 4,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{
+		.iobase		= 0x2f8,
+		.irq		= 3,
+		.uartclk	= 1843200,
+		.regshift	= 0,
+		.iotype		= UPIO_PORT,
+		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+	},
+	{ },
+};
+
+static struct platform_device serial_device = {
+	.name			= "serial8250",
+	.id			= PLAT8250_DEV_PLATFORM,
+	.dev			= {
+		.platform_data	= serial_platform_data,
+	},
+};
+
+static struct resource rtc_resources[] = {
+	[0] = {
+		.start	= 0x70,
+		.end	= 0x73,
+		.flags	= IORESOURCE_IO,
+	},
+	[1] = {
+		.start	= IRQ_ISA_RTC_ALARM,
+		.end	= IRQ_ISA_RTC_ALARM,
+		.flags	= IORESOURCE_IRQ,
+	}
+};
+
+static struct platform_device rtc_device = {
+	.name		= "rtc_cmos",
+	.id		= -1,
+	.resource	= rtc_resources,
+	.num_resources	= ARRAY_SIZE(rtc_resources),
+};
+
+static int __init shark_init(void)
+{
+	int ret;
+
+	if (machine_is_shark())
+	{
+	        ret = platform_device_register(&rtc_device);
+		if (ret) printk(KERN_ERR "Unable to register RTC device: %d\n", ret);
+		ret = platform_device_register(&serial_device);
+		if (ret) printk(KERN_ERR "Unable to register Serial device: %d\n", ret);
+	}
+	return 0;
+}
+
+arch_initcall(shark_init);
+
+extern void shark_init_irq(void);
+
+static struct map_desc shark_io_desc[] __initdata = {
+	{
+		.virtual	= IO_BASE,
+		.pfn		= __phys_to_pfn(IO_START),
+		.length		= IO_SIZE,
+		.type		= MT_DEVICE
+	}
+};
+
+static void __init shark_map_io(void)
+{
+	iotable_init(shark_io_desc, ARRAY_SIZE(shark_io_desc));
+}
+
+#define IRQ_TIMER 0
+#define HZ_TIME ((1193180 + HZ/2) / HZ)
+
+static irqreturn_t
+shark_timer_interrupt(int irq, void *dev_id)
+{
+	timer_tick();
+	return IRQ_HANDLED;
+}
+
+static struct irqaction shark_timer_irq = {
+	.name		= "Shark Timer Tick",
+	.flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
+	.handler	= shark_timer_interrupt,
+};
+
+/*
+ * Set up timer interrupt, and return the current time in seconds.
+ */
+static void __init shark_timer_init(void)
+{
+	outb(0x34, 0x43);               /* binary, mode 0, LSB/MSB, Ch 0 */
+	outb(HZ_TIME & 0xff, 0x40);     /* LSB of count */
+	outb(HZ_TIME >> 8, 0x40);
+
+	setup_irq(IRQ_TIMER, &shark_timer_irq);
+}
+
+static struct sys_timer shark_timer = {
+	.init		= shark_timer_init,
+};
+
+static void shark_init_early(void)
+{
+	disable_hlt();
+}
+
+MACHINE_START(SHARK, "Shark")
+	/* Maintainer: Alexander Schulz */
+	.atag_offset	= 0x3000,
+	.map_io		= shark_map_io,
+	.init_early	= shark_init_early,
+	.init_irq	= shark_init_irq,
+	.timer		= &shark_timer,
+	.dma_zone_size	= SZ_4M,
+	.restart	= shark_restart,
+MACHINE_END
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/dma.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/dma.c
new file mode 100644
index 0000000..10b5b8b
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/dma.c
@@ -0,0 +1,23 @@
+/*
+ *  linux/arch/arm/mach-shark/dma.c
+ *
+ *  by Alexander Schulz
+ *
+ *  derived from:
+ *  arch/arm/kernel/dma-ebsa285.c
+ *  Copyright (C) 1998 Phil Blundell
+ */
+
+#include <linux/init.h>
+
+#include <asm/dma.h>
+#include <asm/mach/dma.h>
+
+static int __init shark_dma_init(void)
+{
+#ifdef CONFIG_ISA_DMA
+	isa_init_dma();
+#endif
+	return 0;
+}
+core_initcall(shark_dma_init);
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/debug-macro.S b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/debug-macro.S
new file mode 100644
index 0000000..20eb2bf
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/debug-macro.S
@@ -0,0 +1,33 @@
+/* arch/arm/mach-shark/include/mach/debug-macro.S
+ *
+ * Debugging macro include header
+ *
+ *  Copyright (C) 1994-1999 Russell King
+ *  Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+*/
+
+		.macro	addruart, rp, rv, tmp
+		mov	\rp, #0xe0000000
+		orr	\rp, \rp, #0x000003f8
+		mov	\rv, \rp
+		.endm
+
+		.macro	senduart,rd,rx
+		strb	\rd, [\rx]
+		.endm
+
+		.macro waituart,rd,rx
+		.endm
+
+		.macro	busyuart,rd,rx
+		mov	\rd, #0
+1001:		add	\rd, \rd, #1
+		teq	\rd, #0x10000
+		bne	1001b
+		.endm
+
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/entry-macro.S b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/entry-macro.S
new file mode 100644
index 0000000..5901b09
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/entry-macro.S
@@ -0,0 +1,35 @@
+/*
+ * arch/arm/mach-shark/include/mach/entry-macro.S
+ *
+ * Low-level IRQ helper macros for Shark platform
+ *
+ * This file is licensed under  the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+		.macro  get_irqnr_preamble, base, tmp
+		mov	\base, #0xe0000000
+		.endm
+
+		.macro	get_irqnr_and_base, irqnr, irqstat, base, tmp
+
+		mov	\irqstat, #0x0C
+		strb	\irqstat, [\base, #0x20]	@outb(0x0C, 0x20) /* Poll command */
+		ldrb	\irqnr, [\base, #0x20]		@irq = inb(0x20) & 7
+		and	\irqstat, \irqnr, #0x80
+		teq	\irqstat, #0
+		beq	43f
+		and	\irqnr, \irqnr, #7
+		teq	\irqnr, #2
+		bne	44f
+43:		mov	\irqstat, #0x0C
+		strb	\irqstat, [\base, #0xa0]	@outb(0x0C, 0xA0) /* Poll command */
+		ldrb	\irqnr, [\base, #0xa0]		@irq = (inb(0xA0) & 7) + 8
+		and	\irqstat, \irqnr, #0x80
+		teq	\irqstat, #0
+		beq	44f
+		and	\irqnr, \irqnr, #7
+		add	\irqnr, \irqnr, #8
+44:		teq	\irqstat, #0
+		.endm
+
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/framebuffer.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/framebuffer.h
new file mode 100644
index 0000000..84a5bf6
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/framebuffer.h
@@ -0,0 +1,16 @@
+/*
+ * arch/arm/mach-shark/include/mach/framebuffer.h
+ *
+ * by Alexander Schulz
+ *
+ */
+
+#ifndef __ASM_ARCH_FRAMEBUFFER_H
+#define __ASM_ARCH_FRAMEBUFFER_H
+
+/* defines for the Framebuffer */
+#define FB_START		0x06000000
+#define FB_SIZE			0x01000000
+
+#endif
+
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/hardware.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/hardware.h
new file mode 100644
index 0000000..663f952
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/hardware.h
@@ -0,0 +1,16 @@
+/*
+ * arch/arm/mach-shark/include/mach/hardware.h
+ *
+ * by Alexander Schulz
+ *
+ * derived from:
+ * arch/arm/mach-ebsa110/include/mach/hardware.h
+ * Copyright (C) 1996-1999 Russell King.
+ */
+#ifndef __ASM_ARCH_HARDWARE_H
+#define __ASM_ARCH_HARDWARE_H
+
+#define UNCACHEABLE_ADDR        0xdf010000
+
+#endif
+
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/io.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/io.h
new file mode 100644
index 0000000..1a45fc0
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/io.h
@@ -0,0 +1,18 @@
+/*
+ * arch/arm/mach-shark/include/mach/io.h
+ *
+ * by Alexander Schulz
+ *
+ * derived from:
+ * arch/arm/mach-ebsa110/include/mach/io.h
+ * Copyright (C) 1997,1998 Russell King
+ */
+
+#ifndef __ASM_ARM_ARCH_IO_H
+#define __ASM_ARM_ARCH_IO_H
+
+#define IO_SPACE_LIMIT 0xffffffff
+
+#define __io(a)                 ((void __iomem *)(0xe0000000 + (a)))
+
+#endif
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/irqs.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/irqs.h
new file mode 100644
index 0000000..c8e8a4e
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/irqs.h
@@ -0,0 +1,13 @@
+/*
+ * arch/arm/mach-shark/include/mach/irqs.h
+ *
+ * by Alexander Schulz
+ */
+
+#define NR_IRQS			16
+
+#define IRQ_ISA_KEYBOARD	 1
+#define IRQ_ISA_RTC_ALARM	 8
+#define I8042_KBD_IRQ		 1
+#define I8042_AUX_IRQ		12
+#define IRQ_HARDDISK            14
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/isa-dma.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/isa-dma.h
new file mode 100644
index 0000000..96c43b8
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/isa-dma.h
@@ -0,0 +1,13 @@
+/*
+ * arch/arm/mach-shark/include/mach/isa-dma.h
+ *
+ * by Alexander Schulz
+ */
+#ifndef __ASM_ARCH_DMA_H
+#define __ASM_ARCH_DMA_H
+
+#define MAX_DMA_CHANNELS	8
+#define DMA_ISA_CASCADE         4
+
+#endif /* _ASM_ARCH_DMA_H */
+
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/memory.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/memory.h
new file mode 100644
index 0000000..1cf8d69
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/memory.h
@@ -0,0 +1,26 @@
+/*
+ * arch/arm/mach-shark/include/mach/memory.h
+ *
+ * by Alexander Schulz
+ *
+ * derived from:
+ * arch/arm/mach-ebsa110/include/mach/memory.h
+ * Copyright (c) 1996-1999 Russell King.
+ */
+#ifndef __ASM_ARCH_MEMORY_H
+#define __ASM_ARCH_MEMORY_H
+
+#include <asm/sizes.h>
+
+/*
+ * Physical DRAM offset.
+ */
+#define PLAT_PHYS_OFFSET     UL(0x08000000)
+
+/*
+ * Cache flushing area
+ */
+#define FLUSH_BASE_PHYS		0x80000000
+#define FLUSH_BASE		0xdf000000
+
+#endif
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/timex.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/timex.h
new file mode 100644
index 0000000..bb6eeae
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/timex.h
@@ -0,0 +1,7 @@
+/*
+ * arch/arm/mach-shark/include/mach/timex.h
+ *
+ * by Alexander Schulz
+ */
+
+#define CLOCK_TICK_RATE 1193180
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/uncompress.h b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/uncompress.h
new file mode 100644
index 0000000..22ccab4
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/include/mach/uncompress.h
@@ -0,0 +1,51 @@
+/*
+ * arch/arm/mach-shark/include/mach/uncompress.h
+ * by Alexander Schulz
+ *
+ * derived from:
+ * arch/arm/mach-footbridge/include/mach/uncompress.h
+ * Copyright (C) 1996,1997,1998 Russell King
+ */
+
+#define SERIAL_BASE ((volatile unsigned char *)0x400003f8)
+
+static inline void putc(int c)
+{
+	volatile int t;
+
+	SERIAL_BASE[0] = c;
+	t=0x10000;
+	while (t--);
+}
+
+static inline void flush(void)
+{
+}
+
+#ifdef DEBUG
+static void putn(unsigned long z)
+{
+	int i;
+	char x;
+
+	putc('0');
+	putc('x');
+	for (i=0;i<8;i++) {
+		x='0'+((z>>((7-i)*4))&0xf);
+		if (x>'9') x=x-'0'+'A'-10;
+		putc(x);
+	}
+}
+
+static void putr()
+{
+	putc('\n');
+	putc('\r');
+}
+#endif
+
+/*
+ * nothing to do
+ */
+#define arch_decomp_setup()
+#define arch_decomp_wdog()
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/irq.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/irq.c
new file mode 100644
index 0000000..5dce13e
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/irq.c
@@ -0,0 +1,108 @@
+/*
+ *  linux/arch/arm/mach-shark/irq.c
+ *
+ * by Alexander Schulz
+ *
+ * derived from linux/arch/ppc/kernel/i8259.c and:
+ * arch/arm/mach-ebsa110/include/mach/irq.h
+ * Copyright (C) 1996-1998 Russell King
+ */
+
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+
+#include <asm/irq.h>
+#include <asm/mach/irq.h>
+
+/*
+ * 8259A PIC functions to handle ISA devices:
+ */
+
+/*
+ * This contains the irq mask for both 8259A irq controllers,
+ * Let through the cascade-interrupt no. 2 (ff-(1<<2)==fb)
+ */
+static unsigned char cached_irq_mask[2] = { 0xfb, 0xff };
+
+/*
+ * These have to be protected by the irq controller spinlock
+ * before being called.
+ */
+static void shark_disable_8259A_irq(struct irq_data *d)
+{
+	unsigned int mask;
+	if (d->irq<8) {
+	  mask = 1 << d->irq;
+	  cached_irq_mask[0] |= mask;
+	  outb(cached_irq_mask[1],0xA1);
+	} else {
+	  mask = 1 << (d->irq-8);
+	  cached_irq_mask[1] |= mask;
+	  outb(cached_irq_mask[0],0x21);
+	}
+}
+
+static void shark_enable_8259A_irq(struct irq_data *d)
+{
+	unsigned int mask;
+	if (d->irq<8) {
+	  mask = ~(1 << d->irq);
+	  cached_irq_mask[0] &= mask;
+	  outb(cached_irq_mask[0],0x21);
+	} else {
+	  mask = ~(1 << (d->irq-8));
+	  cached_irq_mask[1] &= mask;
+	  outb(cached_irq_mask[1],0xA1);
+	}
+}
+
+static void shark_ack_8259A_irq(struct irq_data *d){}
+
+static irqreturn_t bogus_int(int irq, void *dev_id)
+{
+	printk("Got interrupt %i!\n",irq);
+	return IRQ_NONE;
+}
+
+static struct irqaction cascade;
+
+static struct irq_chip fb_chip = {
+	.name		= "XT-PIC",
+	.irq_ack	= shark_ack_8259A_irq,
+	.irq_mask	= shark_disable_8259A_irq,
+	.irq_unmask	= shark_enable_8259A_irq,
+};
+
+void __init shark_init_irq(void)
+{
+	int irq;
+
+	for (irq = 0; irq < NR_IRQS; irq++) {
+		irq_set_chip_and_handler(irq, &fb_chip, handle_edge_irq);
+		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
+	}
+
+	/* init master interrupt controller */
+	outb(0x11, 0x20); /* Start init sequence, edge triggered (level: 0x19)*/
+	outb(0x00, 0x21); /* Vector base */
+	outb(0x04, 0x21); /* Cascade (slave) on IRQ2 */
+	outb(0x03, 0x21); /* Select 8086 mode , auto eoi*/
+	outb(0x0A, 0x20);
+	/* init slave interrupt controller */
+	outb(0x11, 0xA0); /* Start init sequence, edge triggered */
+	outb(0x08, 0xA1); /* Vector base */
+	outb(0x02, 0xA1); /* Cascade (slave) on IRQ2 */
+	outb(0x03, 0xA1); /* Select 8086 mode, auto eoi */
+	outb(0x0A, 0xA0);
+	outb(cached_irq_mask[1],0xA1);
+	outb(cached_irq_mask[0],0x21);
+	//request_region(0x20,0x2,"pic1");
+	//request_region(0xA0,0x2,"pic2");
+
+	cascade.handler = bogus_int;
+	cascade.name = "cascade";
+	setup_irq(2,&cascade);
+}
+
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/leds.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/leds.c
new file mode 100644
index 0000000..2560907
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/leds.c
@@ -0,0 +1,165 @@
+/*
+ * arch/arm/mach-shark/leds.c
+ * by Alexander Schulz
+ *
+ * derived from:
+ * arch/arm/kernel/leds-footbridge.c
+ * Copyright (C) 1998-1999 Russell King
+ *
+ * DIGITAL Shark LED control routines.
+ *
+ * The leds use is as follows:
+ *  - Green front - toggles state every 50 timer interrupts
+ *  - Amber front - Unused, this is a dual color led (Amber/Green)
+ *  - Amber back  - On if system is not idle
+ *
+ * Changelog:
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/ioport.h>
+#include <linux/io.h>
+
+#include <asm/leds.h>
+
+#define LED_STATE_ENABLED	1
+#define LED_STATE_CLAIMED	2
+
+#define SEQUOIA_LED_GREEN       (1<<6)
+#define SEQUOIA_LED_AMBER       (1<<5)
+#define SEQUOIA_LED_BACK        (1<<7)
+
+static char led_state;
+static short hw_led_state;
+static short saved_state;
+
+static DEFINE_RAW_SPINLOCK(leds_lock);
+
+short sequoia_read(int addr) {
+  outw(addr,0x24);
+  return inw(0x26);
+}
+
+void sequoia_write(short value,short addr) {
+  outw(addr,0x24);
+  outw(value,0x26);
+}
+
+static void sequoia_leds_event(led_event_t evt)
+{
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&leds_lock, flags);
+
+	hw_led_state = sequoia_read(0x09);
+
+	switch (evt) {
+	case led_start:
+		hw_led_state |= SEQUOIA_LED_GREEN;
+		hw_led_state |= SEQUOIA_LED_AMBER;
+#ifdef CONFIG_LEDS_CPU
+		hw_led_state |= SEQUOIA_LED_BACK;
+#else
+		hw_led_state &= ~SEQUOIA_LED_BACK;
+#endif
+		led_state |= LED_STATE_ENABLED;
+		break;
+
+	case led_stop:
+		hw_led_state &= ~SEQUOIA_LED_BACK;
+		hw_led_state |= SEQUOIA_LED_GREEN;
+		hw_led_state |= SEQUOIA_LED_AMBER;
+		led_state &= ~LED_STATE_ENABLED;
+		break;
+
+	case led_claim:
+		led_state |= LED_STATE_CLAIMED;
+		saved_state = hw_led_state;
+		hw_led_state &= ~SEQUOIA_LED_BACK;
+		hw_led_state |= SEQUOIA_LED_GREEN;
+		hw_led_state |= SEQUOIA_LED_AMBER;
+		break;
+
+	case led_release:
+		led_state &= ~LED_STATE_CLAIMED;
+		hw_led_state = saved_state;
+		break;
+
+#ifdef CONFIG_LEDS_TIMER
+	case led_timer:
+		if (!(led_state & LED_STATE_CLAIMED))
+			hw_led_state ^= SEQUOIA_LED_GREEN;
+		break;
+#endif
+
+#ifdef CONFIG_LEDS_CPU
+	case led_idle_start:
+		if (!(led_state & LED_STATE_CLAIMED))
+			hw_led_state &= ~SEQUOIA_LED_BACK;
+		break;
+
+	case led_idle_end:
+		if (!(led_state & LED_STATE_CLAIMED))
+			hw_led_state |= SEQUOIA_LED_BACK;
+		break;
+#endif
+
+	case led_green_on:
+		if (led_state & LED_STATE_CLAIMED)
+			hw_led_state &= ~SEQUOIA_LED_GREEN;
+		break;
+
+	case led_green_off:
+		if (led_state & LED_STATE_CLAIMED)
+			hw_led_state |= SEQUOIA_LED_GREEN;
+		break;
+
+	case led_amber_on:
+		if (led_state & LED_STATE_CLAIMED)
+			hw_led_state &= ~SEQUOIA_LED_AMBER;
+		break;
+
+	case led_amber_off:
+		if (led_state & LED_STATE_CLAIMED)
+			hw_led_state |= SEQUOIA_LED_AMBER;
+		break;
+
+	case led_red_on:
+		if (led_state & LED_STATE_CLAIMED)
+			hw_led_state |= SEQUOIA_LED_BACK;
+		break;
+
+	case led_red_off:
+		if (led_state & LED_STATE_CLAIMED)
+			hw_led_state &= ~SEQUOIA_LED_BACK;
+		break;
+
+	default:
+		break;
+	}
+
+	if  (led_state & LED_STATE_ENABLED)
+		sequoia_write(hw_led_state,0x09);
+
+	raw_spin_unlock_irqrestore(&leds_lock, flags);
+}
+
+static int __init leds_init(void)
+{
+	extern void (*leds_event)(led_event_t);
+	short temp;
+	
+	leds_event = sequoia_leds_event;
+
+	/* Make LEDs independent of power-state */
+	request_region(0x24,4,"sequoia");
+	temp = sequoia_read(0x09);
+	temp |= 1<<10;
+	sequoia_write(temp,0x09);
+	leds_event(led_start);
+	return 0;
+}
+
+__initcall(leds_init);
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/pci.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/pci.c
new file mode 100644
index 0000000..7cb79a0
--- /dev/null
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-shark/pci.c
@@ -0,0 +1,53 @@
+/*
+ *  linux/arch/arm/mach-shark/pci.c
+ *
+ *  PCI bios-type initialisation for PCI machines
+ *
+ *  Bits taken from various places.
+ */
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <video/vga.h>
+
+#include <asm/irq.h>
+#include <asm/mach/pci.h>
+#include <asm/mach-types.h>
+
+static int __init shark_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+	if (dev->bus->number == 0)
+		if (dev->devfn == 0)
+			return 255;
+		else
+			return 11;
+	else
+		return 255;
+}
+
+extern void __init via82c505_preinit(void);
+
+static struct hw_pci shark_pci __initdata = {
+	.setup		= via82c505_setup,
+	.swizzle	= pci_std_swizzle,
+	.map_irq	= shark_map_irq,
+	.nr_controllers = 1,
+	.scan		= via82c505_scan_bus,
+	.preinit	= via82c505_preinit,
+};
+
+static int __init shark_pci_init(void)
+{
+	if (!machine_is_shark())
+		return;
+
+	pcibios_min_io = 0x6000;
+	pcibios_min_mem = 0x50000000;
+	vga_base = 0xe8000000;
+
+	pci_common_init(&shark_pci);
+
+	return 0;
+}
+
+subsys_initcall(shark_pci_init);