From b89040cc6537ab21a86e9481c41d46d8babe9a9f Mon Sep 17 00:00:00 2001
From: kaloz <kaloz@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Fri, 30 Jan 2009 11:38:46 +0000
Subject: [PATCH] upgrade ppc44x to 2.6.28.2, add basic support for the AMCC
 Canyonlands

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@14280 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 target/linux/generic-2.6/config-2.6.28        |   4 +-
 target/linux/ppc44x/Makefile                  |   8 +-
 target/linux/ppc44x/base-files/etc/inittab    |   3 +-
 target/linux/ppc44x/config-default            |   8 +-
 target/linux/ppc44x/image/Makefile            |  12 +-
 .../001-taishan_openwrt_flashmap.patch        |   5 +-
 .../003-canyonlands_openwrt_flashmap.patch    |  31 +++++
 .../patches/004-canyonlands_dts_sync.patch    | 108 ++++++++++++++++++
 ...canyonlands_remove_nonexisting_uarts.patch |  31 +++++
 .../patches/100-openwrt_dts_cmdline.patch     |   9 ++
 10 files changed, 203 insertions(+), 16 deletions(-)
 create mode 100644 target/linux/ppc44x/patches/003-canyonlands_openwrt_flashmap.patch
 create mode 100644 target/linux/ppc44x/patches/004-canyonlands_dts_sync.patch
 create mode 100644 target/linux/ppc44x/patches/005-canyonlands_remove_nonexisting_uarts.patch
 create mode 100644 target/linux/ppc44x/patches/100-openwrt_dts_cmdline.patch

diff --git a/target/linux/generic-2.6/config-2.6.28 b/target/linux/generic-2.6/config-2.6.28
index e67297a6c..98bbb3477 100644
--- a/target/linux/generic-2.6/config-2.6.28
+++ b/target/linux/generic-2.6/config-2.6.28
@@ -416,13 +416,14 @@ CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_GENERIC_TIME=y
 # CONFIG_GFS2_FS is not set
 CONFIG_GPIO_DEVICE=m
+# CONFIG_GPIO_BT8XX is not set
 # CONFIG_GPIO_MAX7301 is not set
 # CONFIG_GPIO_MCP23S08 is not set
 # CONFIG_GPIO_PCA953X is not set
 # CONFIG_GPIO_PCF857X is not set
 # CONFIG_GPIO_SYSFS is not set
+# CONFIG_GPIO_XILINX is not set
 # CONFIG_GPIOLIB is not set
-# CONFIG_GPIO_BT8XX is not set
 # CONFIG_GROUP_SCHED is not set
 # CONFIG_HAMACHI is not set
 CONFIG_HAMRADIO=y
@@ -1241,6 +1242,7 @@ CONFIG_PLX_HERMES=m
 # CONFIG_PMIC_DA903X is not set
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_POWER_SUPPLY is not set
+CONFIG_PPC4xx_GPIO=y
 CONFIG_PPP=m
 CONFIG_PPPOATM=m
 CONFIG_PPPOE=m
diff --git a/target/linux/ppc44x/Makefile b/target/linux/ppc44x/Makefile
index 1571142a7..4f023a38d 100644
--- a/target/linux/ppc44x/Makefile
+++ b/target/linux/ppc44x/Makefile
@@ -1,5 +1,5 @@
-# 
-# Copyright (C) 2007 OpenWrt.org
+#
+# Copyright (C) 2007-2009 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -11,13 +11,11 @@ BOARD:=ppc44x
 BOARDNAME:=AMCC/IBM PPC44x
 FEATURES:=squashfs
 
-LINUX_VERSION:=2.6.27.13
+LINUX_VERSION:=2.6.28.2
 LINUX_KARCH:=powerpc
 
 include $(INCLUDE_DIR)/target.mk
 
-KERNELNAME:="zImage"
-
 define Target/Description
 	Build firmware images for the AMCC Taishan evaluation board
 endef
diff --git a/target/linux/ppc44x/base-files/etc/inittab b/target/linux/ppc44x/base-files/etc/inittab
index 859dc530c..7989a7f60 100644
--- a/target/linux/ppc44x/base-files/etc/inittab
+++ b/target/linux/ppc44x/base-files/etc/inittab
@@ -1,5 +1,4 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K stop
-tts/0::askfirst:/bin/ash --login
+ttyS0::askfirst:/bin/ash --login
 ttyS1::askfirst:/bin/ash --login
-tty1::askfirst:/bin/ash --login
diff --git a/target/linux/ppc44x/config-default b/target/linux/ppc44x/config-default
index 1b2ddbebd..c3516a9c1 100644
--- a/target/linux/ppc44x/config-default
+++ b/target/linux/ppc44x/config-default
@@ -11,6 +11,7 @@ CONFIG_ARCH_HAS_ILOG2_U32=y
 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
 CONFIG_ARCH_MAY_HAVE_PC_FDC=y
 CONFIG_ARCH_POPULATES_NODE_MAP=y
+# CONFIG_ARCHES is not set
 # CONFIG_BAMBOO is not set
 CONFIG_BASE_SMALL=0
 CONFIG_BITREVERSE=y
@@ -18,25 +19,26 @@ CONFIG_BOOKE=y
 # CONFIG_BOOKE_WDT is not set
 CONFIG_BOOT_LOAD=0x01000000
 # CONFIG_BT is not set
-CONFIG_CMDLINE="console=ttyS1,115200 root=/dev/mtdblock1 rootfstype=squashfs,jffs2 noinitrd init=/etc/preinit"
+CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock1 rootfstype=squashfs,jffs2 noinitrd init=/etc/preinit"
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CONSISTENT_SIZE=0x00200000
 CONFIG_CONSISTENT_START=0xff100000
-# CONFIG_CANYONLANDS is not set
+CONFIG_CANYONLANDS=y
 # CONFIG_CPU_FREQ is not set
 # CONFIG_DEBUG_BUGVERBOSE is not set
-CONFIG_DEVICE_TREE="taishan.dts"
 # CONFIG_DMADEVICES is not set
 # CONFIG_E200 is not set
 # CONFIG_E500 is not set
 # CONFIG_EBONY is not set
 # CONFIG_EDAC is not set
+CONFIG_EXTRA_TARGETS="uImage"
 CONFIG_FORCE_MAX_ZONEORDER=11
 CONFIG_FS_POSIX_ACL=y
 CONFIG_GENERIC_BUG=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_NVRAM=y
 # CONFIG_GEN_RTC is not set
+# CONFIG_GLACIER is not set
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 # CONFIG_HIGHMEM is not set
diff --git a/target/linux/ppc44x/image/Makefile b/target/linux/ppc44x/image/Makefile
index 5c1d023cb..b8d5e9510 100644
--- a/target/linux/ppc44x/image/Makefile
+++ b/target/linux/ppc44x/image/Makefile
@@ -1,5 +1,5 @@
-# 
-# Copyright (C) 2007 OpenWrt.org
+#
+# Copyright (C) 2007-2009 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -11,6 +11,7 @@ JFFS2_BLOCKSIZE=256k
 
 define Image/Prepare
 	cp $(LINUX_DIR)/arch/powerpc/boot/cuImage.taishan $(KDIR)/uImage
+		dtc -O dtb -R 4 -S 0x20000 $(LINUX_DIR)/arch/powerpc/boot/dts/canyonlands.dts > $(KDIR)/openwrt-canyonlands.dtb
 endef
 
 define Image/BuildKernel
@@ -33,7 +34,12 @@ define Image/Build/squashfs
 	( \
 		dd if=$(KDIR)/uImage bs=2048k conv=sync; \
 		dd if=$(KDIR)/root.$(1) bs=256k conv=sync; \
-	) > $(BIN_DIR)/openwrt-$(BOARD)-$(1).img
+	) > $(BIN_DIR)/openwrt-$(BOARD)-taishan-$(1).img
+	( \
+		dd if=$(LINUX_DIR)/arch/powerpc/boot/uImage bs=1920k conv=sync; \
+		dd if=$(KDIR)/openwrt-canyonlands.dtb bs=128k conv=sync; \
+		dd if=$(KDIR)/root.$(1) bs=256k conv=sync; \
+	) > $(BIN_DIR)/openwrt-$(BOARD)-canyonlands-$(1).img
 endef
 
 $(eval $(call BuildImage))
diff --git a/target/linux/ppc44x/patches/001-taishan_openwrt_flashmap.patch b/target/linux/ppc44x/patches/001-taishan_openwrt_flashmap.patch
index be4270068..b0201fbc0 100644
--- a/target/linux/ppc44x/patches/001-taishan_openwrt_flashmap.patch
+++ b/target/linux/ppc44x/patches/001-taishan_openwrt_flashmap.patch
@@ -8,9 +8,10 @@
 +						reg = <0x0 0x200000>;
  					};
 -					partition@180000 {
-+					partition@200000 {
- 						label = "root";
+-						label = "root";
 -						reg = <0x180000 0x200000>;
++					partition@200000 {
++						label = "rootfs";
 +						reg = <0x200000 0x3c00000>;
  					};
 -					partition@380000 {
diff --git a/target/linux/ppc44x/patches/003-canyonlands_openwrt_flashmap.patch b/target/linux/ppc44x/patches/003-canyonlands_openwrt_flashmap.patch
new file mode 100644
index 000000000..83c0dd292
--- /dev/null
+++ b/target/linux/ppc44x/patches/003-canyonlands_openwrt_flashmap.patch
@@ -0,0 +1,31 @@
+--- a/arch/powerpc/boot/dts/canyonlands.dts
++++ b/arch/powerpc/boot/dts/canyonlands.dts
+@@ -155,24 +155,12 @@
+ 					#address-cells = <1>;
+ 					#size-cells = <1>;
+ 					partition@0 {
+-						label = "kernel";
+-						reg = <0x00000000 0x001e0000>;
+-					};
+-					partition@1e0000 {
+-						label = "dtb";
+-						reg = <0x001e0000 0x00020000>;
++						label = "kernel+dtb";
++						reg = <0x00000000 0x00200000>;
+ 					};
+ 					partition@200000 {
+-						label = "ramdisk";
+-						reg = <0x00200000 0x01400000>;
+-					};
+-					partition@1600000 {
+-						label = "jffs2";
+-						reg = <0x01600000 0x00400000>;
+-					};
+-					partition@1a00000 {
+-						label = "user";
+-						reg = <0x01a00000 0x02560000>;
++						label = "rootfs";
++						reg = <0x00200000 0x03d60000>;
+ 					};
+ 					partition@3f60000 {
+ 						label = "env";
diff --git a/target/linux/ppc44x/patches/004-canyonlands_dts_sync.patch b/target/linux/ppc44x/patches/004-canyonlands_dts_sync.patch
new file mode 100644
index 000000000..83e6c74e1
--- /dev/null
+++ b/target/linux/ppc44x/patches/004-canyonlands_dts_sync.patch
@@ -0,0 +1,108 @@
+--- a/arch/powerpc/boot/dts/canyonlands.dts
++++ b/arch/powerpc/boot/dts/canyonlands.dts
+@@ -40,6 +40,7 @@
+ 			d-cache-size = <32768>;
+ 			dcr-controller;
+ 			dcr-access-method = "native";
++			next-level-cache = <&L2C0>;
+ 		};
+ 	};
+ 
+@@ -104,6 +105,16 @@
+ 		dcr-reg = <0x00c 0x002>;
+ 	};
+ 
++	L2C0: l2c {
++		compatible = "ibm,l2-cache-460ex", "ibm,l2-cache";
++		dcr-reg = <0x020 0x008		/* Internal SRAM DCR's */
++			   0x030 0x008>;	/* L2 cache DCR's */
++		cache-line-size = <32>;		/* 32 bytes */
++		cache-size = <262144>;		/* L2, 256K */
++		interrupt-parent = <&UIC1>;
++		interrupts = <11 1>;
++	};
++
+ 	plb {
+ 		compatible = "ibm,plb-460ex", "ibm,plb4";
+ 		#address-cells = <2>;
+@@ -131,6 +142,43 @@
+ 					/*RXDE*/  0x5 0x4>;
+ 		};
+ 
++		USB0: ehci@bffd0400 {
++			compatible = "ibm,usb-ehci-460ex", "usb-ehci";
++			interrupt-parent = <&UIC2>;
++			interrupts = <0x1d 4>;
++			reg = <4 0xbffd0400 0x90 4 0xbffd0490 0x70>;
++		};
++
++		USB1: usb@bffd0000 {
++			compatible = "ohci-le";
++			reg = <4 0xbffd0000 0x60>;
++			interrupt-parent = <&UIC2>;
++			interrupts = <0x1e 4>;
++		};
++
++		USBOTG0: usbotg@bff80000 {
++			compatible = "amcc,usb-otg-460ex";
++			reg = <4 0xbff80000 0x10000>;
++			interrupt-parent = <&USBOTG0>;
++			interrupts = <0 1 2>;
++			#interrupt-cells = <1>;
++			#address-cells = <0>;
++			#size-cells = <0>;
++			interrupt-map = </* USB-OTG */ 0 &UIC2 0x1c 4
++					 /* HIGH-POWER */ 1 &UIC1 0x1a 8
++					 /* DMA */ 2 &UIC0 0xc 4>;
++			interrupt-map-mask = <0xffffffff>;
++		};
++
++		SATA0: sata@bffd1000 {
++			compatible = "amcc,sata-460ex";
++			reg = <4 0xbffd1000 0x800	/* SATA */
++			       4 0xbffd0800 0x400>;	/* AHBDMA */
++			interrupt-parent = <&UIC3>;
++			interrupts = <0 4		/* SATA */
++				      5 4>;		/* AHBDMA */
++		};
++
+ 		POB0: opb {
+ 			compatible = "ibm,opb-460ex", "ibm,opb";
+ 			#address-cells = <1>;
+@@ -222,6 +282,12 @@
+ 				reg = <0xef600700 0x00000014>;
+ 				interrupt-parent = <&UIC0>;
+ 				interrupts = <0x2 0x4>;
++				#address-cells = <1>;
++				#size-cells = <0>;
++				rtc@68 {
++					compatible = "stm,m41t80";
++					reg = <68>;
++				};
+ 			};
+ 
+ 			IIC1: i2c@ef600800 {
+@@ -331,6 +397,7 @@
+ 			 * later cannot be changed
+ 			 */
+ 			ranges = <0x02000000 0x00000000 0x80000000 0x0000000d 0x80000000 0x00000000 0x80000000
++				  0x02000000 0x00000000 0x00000000 0x0000000c 0x0ee00000 0x00000000 0x00100000
+ 				  0x01000000 0x00000000 0x00000000 0x0000000c 0x08000000 0x00000000 0x00010000>;
+ 
+ 			/* Inbound 2GB range starting at 0 */
+@@ -361,6 +428,7 @@
+ 			 * later cannot be changed
+ 			 */
+ 			ranges = <0x02000000 0x00000000 0x80000000 0x0000000e 0x00000000 0x00000000 0x80000000
++				  0x02000000 0x00000000 0x00000000 0x0000000f 0x00000000 0x00000000 0x00100000
+ 				  0x01000000 0x00000000 0x00000000 0x0000000f 0x80000000 0x00000000 0x00010000>;
+ 
+ 			/* Inbound 2GB range starting at 0 */
+@@ -402,6 +470,7 @@
+ 			 * later cannot be changed
+ 			 */
+ 			ranges = <0x02000000 0x00000000 0x80000000 0x0000000e 0x80000000 0x00000000 0x80000000
++				  0x02000000 0x00000000 0x00000000 0x0000000f 0x00100000 0x00000000 0x00100000
+ 				  0x01000000 0x00000000 0x00000000 0x0000000f 0x80010000 0x00000000 0x00010000>;
+ 
+ 			/* Inbound 2GB range starting at 0 */
diff --git a/target/linux/ppc44x/patches/005-canyonlands_remove_nonexisting_uarts.patch b/target/linux/ppc44x/patches/005-canyonlands_remove_nonexisting_uarts.patch
new file mode 100644
index 000000000..e05278cf2
--- /dev/null
+++ b/target/linux/ppc44x/patches/005-canyonlands_remove_nonexisting_uarts.patch
@@ -0,0 +1,31 @@
+--- a/arch/powerpc/boot/dts/canyonlands.dts
++++ b/arch/powerpc/boot/dts/canyonlands.dts
+@@ -195,28 +195,6 @@
+ 				interrupts = <0x1 0x4>;
+ 			};
+ 
+-			UART2: serial@ef600500 {
+-				device_type = "serial";
+-				compatible = "ns16550";
+-				reg = <0xef600500 0x00000008>;
+-				virtual-reg = <0xef600500>;
+-				clock-frequency = <0>; /* Filled in by U-Boot */
+-				current-speed = <0>; /* Filled in by U-Boot */
+-				interrupt-parent = <&UIC1>;
+-				interrupts = <0x1d 0x4>;
+-			};
+-
+-			UART3: serial@ef600600 {
+-				device_type = "serial";
+-				compatible = "ns16550";
+-				reg = <0xef600600 0x00000008>;
+-				virtual-reg = <0xef600600>;
+-				clock-frequency = <0>; /* Filled in by U-Boot */
+-				current-speed = <0>; /* Filled in by U-Boot */
+-				interrupt-parent = <&UIC1>;
+-				interrupts = <0x1e 0x4>;
+-			};
+-
+ 			IIC0: i2c@ef600700 {
+ 				compatible = "ibm,iic-460ex", "ibm,iic";
+ 				reg = <0xef600700 0x00000014>;
diff --git a/target/linux/ppc44x/patches/100-openwrt_dts_cmdline.patch b/target/linux/ppc44x/patches/100-openwrt_dts_cmdline.patch
new file mode 100644
index 000000000..3ab51d8db
--- /dev/null
+++ b/target/linux/ppc44x/patches/100-openwrt_dts_cmdline.patch
@@ -0,0 +1,9 @@
+--- a/arch/powerpc/boot/dts/taishan.dts	2009-01-18 19:45:37.000000000 +0100
++++ b/arch/powerpc/boot/dts/taishan.dts	2009-01-29 18:55:40.000000000 +0100
+@@ -423,5 +423,6 @@
+ 
+ 	chosen {
+ 		linux,stdout-path = "/plb/opb/serial@40000300";
++		bootargs = "console=ttyS1,115200 root=/dev/mtdblock1 rootfstype=squashfs noinitrd init=/etc/preinit";
+ 	};
+ };
-- 
2.20.1