X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/f8968501098182115a67b4d7bf664aec680cb356..6064cb213dec8dd93e46a6a806879a5a42d247ab:/target/linux/linux-2.6/patches/brcm/001-bcm947xx.patch?ds=sidebyside diff --git a/target/linux/linux-2.6/patches/brcm/001-bcm947xx.patch b/target/linux/linux-2.6/patches/brcm/001-bcm947xx.patch index 3a4f78fc9..649028d89 100644 --- a/target/linux/linux-2.6/patches/brcm/001-bcm947xx.patch +++ b/target/linux/linux-2.6/patches/brcm/001-bcm947xx.patch @@ -1,6 +1,6 @@ diff -Nur linux-2.6.12.5/arch/mips/Kconfig linux-2.6.12.5-brcm/arch/mips/Kconfig --- linux-2.6.12.5/arch/mips/Kconfig 2005-08-15 02:20:18.000000000 +0200 -+++ linux-2.6.12.5-brcm/arch/mips/Kconfig 2005-08-28 16:21:04.700803432 +0200 ++++ linux-2.6.12.5-brcm/arch/mips/Kconfig 2005-09-03 21:53:36.323284896 +0200 @@ -40,6 +40,15 @@ Members include the Acer PICA, MIPS Magnum 4000, MIPS Millenium and Olivetti M700-10 workstations. @@ -22,13 +22,13 @@ diff -Nur linux-2.6.12.5/arch/mips/Kconfig linux-2.6.12.5-brcm/arch/mips/Kconfig config CPU_LITTLE_ENDIAN bool "Generate little endian code" - default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || SOC_AU1X00 || NEC_OSPREY || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA -+ default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || SOC_AU1X00 || NEC_OSPREY || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA || BCM47XX ++ default y if ACER_PICA_61 || CASIO_E55 || DDB5074 || DDB5476 || DDB5477 || MACH_DECSTATION || IBM_WORKPAD || LASAT || MIPS_COBALT || MIPS_ITE8172 || MIPS_IVR || SOC_AU1X00 || NEC_OSPREY || OLIVETTI_M700 || SNI_RM200_PCI || VICTOR_MPC30X || ZAO_CAPCELLA || BCM947XX default n if MIPS_EV64120 || MIPS_EV96100 || MOMENCO_OCELOT || MOMENCO_OCELOT_G || SGI_IP22 || SGI_IP27 || SGI_IP32 || TOSHIBA_JMR3927 help Some MIPS machines can be configured for either little or big endian diff -Nur linux-2.6.12.5/arch/mips/Makefile linux-2.6.12.5-brcm/arch/mips/Makefile --- linux-2.6.12.5/arch/mips/Makefile 2005-08-15 02:20:18.000000000 +0200 -+++ linux-2.6.12.5-brcm/arch/mips/Makefile 2005-08-28 16:39:59.077334424 +0200 ++++ linux-2.6.12.5-brcm/arch/mips/Makefile 2005-09-03 22:24:07.794917120 +0200 @@ -79,7 +79,7 @@ cflags-y += -I $(TOPDIR)/include/asm/gcc cflags-y += -G 0 -mno-abicalls -fno-pic -pipe @@ -38,17 +38,11 @@ diff -Nur linux-2.6.12.5/arch/mips/Makefile linux-2.6.12.5-brcm/arch/mips/Makefi MODFLAGS += -mlong-calls cflags-$(CONFIG_SB1XXX_CORELIS) += -mno-sched-prolog -fno-omit-frame-pointer -@@ -167,9 +167,10 @@ - $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \ +@@ -170,6 +170,7 @@ + cflags-$(CONFIG_CPU_MIPS32) += \ + $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \ -Wa,--trap - --cflags-$(CONFIG_CPU_MIPS32) += \ -- $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \ -- -Wa,--trap -+#cflags-$(CONFIG_CPU_MIPS32) += \ -+# $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \ -+# -Wa,--trap -+cflags-$(CONFIG_CPU_MIPS32) += -mips2 -Wa,--trap ++cflags-$(CONFIG_CPU_MIPS32) += -Wa,--trap cflags-$(CONFIG_CPU_MIPS64) += \ $(call set_gccflags,mips64,mips64,r4600,mips3,mips2) \ @@ -67,14 +61,6 @@ diff -Nur linux-2.6.12.5/arch/mips/Makefile linux-2.6.12.5-brcm/arch/mips/Makefi # SNI RM200 PCI # core-$(CONFIG_SNI_RM200_PCI) += arch/mips/sni/ -@@ -729,6 +738,7 @@ - archclean: - @$(MAKE) $(clean)=arch/mips/boot - @$(MAKE) $(clean)=arch/mips/lasat -+ @$(MAKE) -C arch/mips/bcm47xx/compressed clean - - # Generate -+#include -+ -+/* GPIO based bank selection (1 GPIO bit) */ -+#define SFLASH_MAX_BANKS 1 -+#define SFLASH_GPIO_SHIFT 2 -+#define SFLASH_GPIO_MASK ((SFLASH_MAX_BANKS - 1) << SFLASH_GPIO_SHIFT) -+ -+struct sflash_bank { -+ uint offset; /* Byte offset */ -+ uint erasesize; /* Block size */ -+ uint numblocks; /* Number of blocks */ -+ uint size; /* Total bank size in bytes */ -+}; -+ -+struct sflash { -+ struct sflash_bank banks[SFLASH_MAX_BANKS]; /* GPIO selectable banks */ -+ uint32 type; /* Type */ -+ uint size; /* Total array size in bytes */ -+}; -+ -+/* Utility functions */ -+extern int sflash_poll(chipcregs_t *cc, uint offset); -+extern int sflash_read(chipcregs_t *cc, uint offset, uint len, uchar *buf); -+extern int sflash_write(chipcregs_t *cc, uint offset, uint len, const uchar *buf); -+extern int sflash_erase(chipcregs_t *cc, uint offset); -+extern struct sflash * sflash_init(chipcregs_t *cc); -+ -+#endif /* _sflash_h_ */ diff -Nur linux-2.6.12.5/arch/mips/bcm947xx/include/trxhdr.h linux-2.6.12.5-brcm/arch/mips/bcm947xx/include/trxhdr.h --- linux-2.6.12.5/arch/mips/bcm947xx/include/trxhdr.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.12.5-brcm/arch/mips/bcm947xx/include/trxhdr.h 2005-08-28 11:12:20.474852464 +0200 @@ -12651,7 +12587,7 @@ diff -Nur linux-2.6.12.5/arch/mips/bcm947xx/prom.c linux-2.6.12.5-brcm/arch/mips +} diff -Nur linux-2.6.12.5/arch/mips/bcm947xx/setup.c linux-2.6.12.5-brcm/arch/mips/bcm947xx/setup.c --- linux-2.6.12.5/arch/mips/bcm947xx/setup.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux-2.6.12.5-brcm/arch/mips/bcm947xx/setup.c 2005-08-28 16:57:28.317825624 +0200 ++++ linux-2.6.12.5-brcm/arch/mips/bcm947xx/setup.c 2005-09-11 01:36:10.217667456 +0200 @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org) @@ -12748,7 +12684,7 @@ diff -Nur linux-2.6.12.5/arch/mips/bcm947xx/setup.c linux-2.6.12.5-brcm/arch/mip +static void bcm47xx_machine_restart(char *command) +{ + /* Set the watchdog timer to reset immediately */ -+ cli(); ++ local_irq_disable(); + sb_watchdog(sbh, 1); + while (1); +} @@ -12756,7 +12692,7 @@ diff -Nur linux-2.6.12.5/arch/mips/bcm947xx/setup.c linux-2.6.12.5-brcm/arch/mip +static void bcm47xx_machine_halt(void) +{ + /* Disable interrupts and watchdog and spin forever */ -+ cli(); ++ local_irq_disable(); + sb_watchdog(sbh, 0); + while (1); +} @@ -13123,14 +13059,45 @@ diff -Nur linux-2.6.12.5/drivers/mtd/maps/Makefile linux-2.6.12.5-brcm/drivers/m obj-$(CONFIG_MTD_SBC_GXX) += sbc_gxx.o diff -Nur linux-2.6.12.5/drivers/mtd/maps/bcm47xx-flash.c linux-2.6.12.5-brcm/drivers/mtd/maps/bcm47xx-flash.c --- linux-2.6.12.5/drivers/mtd/maps/bcm47xx-flash.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux-2.6.12.5-brcm/drivers/mtd/maps/bcm47xx-flash.c 2005-08-28 17:01:50.948899632 +0200 -@@ -0,0 +1,131 @@ ++++ linux-2.6.12.5-brcm/drivers/mtd/maps/bcm47xx-flash.c 2005-09-10 22:23:03.178338008 +0200 +@@ -0,0 +1,249 @@ +/* -+ * Flash mapping for BCM947XX boards ++ * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org) ++ * Copyright (C) 2005 Waldemar Brodkorb + * -+ * Copyright (C) 2001 Broadcom Corporation ++ * original functions for finding root filesystem from Mike Baker + * -+ * $Id: bcm47xx-flash.c,v 1.1 2004/10/21 07:18:31 jolt Exp $ ++ * 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 ++ * option) any later version. ++ * ++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN ++ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ++ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ++ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 675 Mass Ave, Cambridge, MA 02139, USA. ++ * ++ * Copyright 2001-2003, Broadcom Corporation ++ * All Rights Reserved. ++ * ++ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY ++ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM ++ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS ++ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. ++ * ++ * $Id: bcm47xx-flash.c,v 1.1 2004/10/21 07:18:31 jolt Exp $ ++ * ++ * Flash mapping for BCM947XX boards + */ + +#include @@ -13142,6 +13109,17 @@ diff -Nur linux-2.6.12.5/drivers/mtd/maps/bcm47xx-flash.c linux-2.6.12.5-brcm/dr +#include +#include +#include ++#include ++#include ++#include ++#include ++ ++#ifdef CONFIG_MTD_PARTITIONS ++extern struct mtd_partition * init_mtd_partitions(struct mtd_info *mtd, size_t size); ++#endif ++ ++#define CFE_SIZE 1024*384 ++#define NVRAM_SIZE 1024*128 + +#define WINDOW_ADDR 0x1c000000 +#define WINDOW_SIZE (0x400000*2) @@ -13176,49 +13154,109 @@ diff -Nur linux-2.6.12.5/drivers/mtd/maps/bcm47xx-flash.c linux-2.6.12.5-brcm/dr + phys: WINDOW_ADDR, +}; + -+#define SECTORS *64*1024 -+ +#ifdef CONFIG_MTD_PARTITIONS -+#if 0 -+static struct mtd_partition bcm947xx_parts[] = { -+// 64 - 4 - 14 - 1 = 45 = 8 + 37 -+ { name: "pmon", offset: 0, size: 4 SECTORS, mask_flags: MTD_WRITEABLE }, -+ { name: "linux", offset: MTDPART_OFS_APPEND, size: 14 SECTORS }, -+ { name: "rescue", offset: MTDPART_OFS_APPEND, size: 8 SECTORS }, -+ { name: "rootfs", offset: MTDPART_OFS_APPEND, size: 37 SECTORS }, -+ { name: "nvram", offset: MTDPART_OFS_APPEND, size: 1 SECTORS, mask_flags: MTD_WRITEABLE }, -+}; -+#else ++ +static struct mtd_partition bcm947xx_parts[] = { -+ { name: "cfe", -+ offset: 0, -+ size: 384*1024, -+ mask_flags: MTD_WRITEABLE -+ }, -+ { name: "config", -+ offset: MTDPART_OFS_APPEND, -+ size: 128*1024 -+ }, -+ { name: "linux", -+ offset: MTDPART_OFS_APPEND, -+ size: 10*128*1024 -+ }, -+ { name: "jffs", -+ offset: MTDPART_OFS_APPEND, -+ size: (8*1024*1024)-((384*1024)+(128*1024)+(10*128*1024)+(128*1024)), -+ }, -+ { name: "nvram", -+ offset: MTDPART_OFS_APPEND, -+ size: 128*1024, -+ mask_flags: MTD_WRITEABLE -+ }, ++ { name: "cfe", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, }, ++ { name: "linux", offset: 0, size: 0, }, ++ { name: "rootfs", offset: 0, size: 0, }, ++ { name: "nvram", offset: 0, size: 0, }, ++ { name: "OpenWrt", offset: 0, size: 0, }, ++ { name: NULL, }, +}; -+#endif ++ ++static int __init ++find_root(struct mtd_info *mtd, size_t size, struct mtd_partition *part) ++{ ++ struct trx_header *trx; ++ unsigned char buf[512]; ++ int off; ++ size_t len; ++ ++ trx = (struct trx_header *) buf; ++ ++ for (off = (512*1024); off < size; off += mtd->erasesize) { ++ memset(buf, 0xe5, sizeof(buf)); ++ ++ /* ++ * Read into buffer ++ */ ++ if (MTD_READ(mtd, off, sizeof(buf), &len, buf) || ++ len != sizeof(buf)) ++ continue; ++ ++ /* found a TRX header */ ++ if (le32_to_cpu(trx->magic) == TRX_MAGIC) { ++ part->offset = le32_to_cpu(trx->offsets[2]) ? : ++ le32_to_cpu(trx->offsets[1]); ++ part->size = le32_to_cpu(trx->len); ++ ++ part->size -= part->offset; ++ part->offset += off; ++ ++ goto done; ++ } ++ } ++ ++ printk(KERN_NOTICE ++ "%s: Couldn't find root filesystem\n", ++ mtd->name); ++ return -1; ++ ++ done: ++ return part->size; ++} ++ ++struct mtd_partition * __init ++init_mtd_partitions(struct mtd_info *mtd, size_t size) ++{ ++ ++ /* boot loader */ ++ bcm947xx_parts[0].offset = 0; ++ bcm947xx_parts[0].size = CFE_SIZE; ++ ++ /* nvram (old config partition) */ ++ bcm947xx_parts[3].offset = bcm947xx_parts[0].size; ++ bcm947xx_parts[3].size = NVRAM_SIZE; ++ ++ /* Size linux (kernel and rootfs) */ ++ /* do not count the elf loader, which is on one sector */ ++ bcm947xx_parts[1].offset = bcm947xx_parts[0].size + bcm947xx_parts[3].size + mtd->erasesize; ++ bcm947xx_parts[1].size = size - NVRAM_SIZE - bcm947xx_parts[0].size - ++ bcm947xx_parts[3].size - mtd->erasesize; ++ ++ /* Find and size rootfs */ ++ if (find_root(mtd,size,&bcm947xx_parts[2])==0) { ++ /* entirely jffs2 */ ++ bcm947xx_parts[2].size = size - bcm947xx_parts[2].offset - NVRAM_SIZE; ++ bcm947xx_parts[4].name = NULL; ++ } else { ++ /* legacy setup */ ++ /* calculate leftover flash, and assign it to the jffs2 partition */ ++ bcm947xx_parts[4].offset = bcm947xx_parts[2].offset + bcm947xx_parts[2].size; ++ if ((bcm947xx_parts[4].offset % mtd->erasesize) > 0) { ++ bcm947xx_parts[4].offset += mtd->erasesize - ++ (bcm947xx_parts[4].offset % mtd->erasesize); ++ } ++ bcm947xx_parts[4].size = size - NVRAM_SIZE - bcm947xx_parts[4].offset; ++ } ++ ++ return bcm947xx_parts; ++} ++ ++EXPORT_SYMBOL(init_mtd_partitions); +#endif + +int __init init_bcm947xx_map(void) +{ -+ bcm947xx_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); ++ size_t size; ++ int ret = 0; ++#ifdef CONFIG_MTD_PARTITIONS ++ struct mtd_partition *parts; ++ int i; ++#endif ++ ++ bcm947xx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); + + if (!bcm947xx_map.virt) { + printk("Failed to ioremap\n"); @@ -13236,13 +13274,29 @@ diff -Nur linux-2.6.12.5/drivers/mtd/maps/bcm47xx-flash.c linux-2.6.12.5-brcm/dr + + bcm947xx_mtd->owner = THIS_MODULE; + -+ printk(KERN_NOTICE "flash device: %x at %x\n", bcm947xx_mtd->size, WINDOW_ADDR); ++ size = bcm947xx_mtd->size; ++ ++ printk(KERN_NOTICE "Flash device: 0x%x at 0x%x\n", bcm947xx_mtd->size, WINDOW_ADDR); + +#ifdef CONFIG_MTD_PARTITIONS -+ return add_mtd_partitions(bcm947xx_mtd, bcm947xx_parts, sizeof(bcm947xx_parts)/sizeof(bcm947xx_parts[0])); -+#else -+ return 0; ++ parts = init_mtd_partitions(bcm947xx_mtd, size); ++ for (i = 0; parts[i].name; i++); ++ ret = add_mtd_partitions(bcm947xx_mtd, parts, i); ++ if (ret) { ++ printk(KERN_ERR "Flash: add_mtd_partitions failed\n"); ++ goto fail; ++ } +#endif ++ ++ return 0; ++ ++ fail: ++ if (bcm947xx_mtd) ++ map_destroy(bcm947xx_mtd); ++ if (bcm947xx_map.map_priv_1) ++ iounmap((void *) bcm947xx_map.map_priv_1); ++ bcm947xx_map.map_priv_1 = 0; ++ return ret; +} + +void __exit cleanup_bcm947xx_map(void)