summaryrefslogtreecommitdiff
path: root/release/src/linux/linux/arch/mips/brcm-boards/bcm947xx/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'release/src/linux/linux/arch/mips/brcm-boards/bcm947xx/setup.c')
-rw-r--r--release/src/linux/linux/arch/mips/brcm-boards/bcm947xx/setup.c245
1 files changed, 70 insertions, 175 deletions
diff --git a/release/src/linux/linux/arch/mips/brcm-boards/bcm947xx/setup.c b/release/src/linux/linux/arch/mips/brcm-boards/bcm947xx/setup.c
index c4983dc2..dc55be85 100644
--- a/release/src/linux/linux/arch/mips/brcm-boards/bcm947xx/setup.c
+++ b/release/src/linux/linux/arch/mips/brcm-boards/bcm947xx/setup.c
@@ -3,7 +3,7 @@
*
* Copyright 2005, 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
@@ -38,8 +38,6 @@
#include <sbutils.h>
#include <trxhdr.h>
-#include <cy_conf.h>
-
extern void bcm947xx_time_init(void);
extern void bcm947xx_timer_setup(struct irqaction *irq);
@@ -53,9 +51,6 @@ extern void breakpoint(void);
extern struct ide_ops std_ide_ops;
#endif
-#ifdef MULTILANG_SUPPORT
-#endif
-
/* Global SB handle */
void *bcm947xx_sbh = NULL;
spinlock_t bcm947xx_sbh_lock = SPIN_LOCK_UNLOCKED;
@@ -139,9 +134,9 @@ brcm_setup(void)
/* Initialize clocks and interrupts */
sb_mips_init(sbh);
- /*
- * Now that the sbh is inited set the proper PFC value
- */
+ /*
+ * Now that the sbh is inited set the proper PFC value
+ */
pfc_val = sb_mips_get_pfc(sbh);
printk("Setting the PFC value as 0x%x\n", pfc_val);
check_enable_mips_pfc(pfc_val);
@@ -184,197 +179,97 @@ bus_error_init(void)
#ifdef CONFIG_MTD_PARTITIONS
+
+/*
+ new layout -- zzz 04/2006
+
+ +--------------+
+ | boot |
+ +---+----------+ < search for HDR0
+ | | |
+ | | (kernel) |
+ | l | |
+ | i +----------+ < + trx->offset[1]
+ | n | |
+ | u | rootfs |
+ | x | |
+ + +----------+ < + trx->len
+ | | jffs2 |
+ +--------------+ < size - NVRAM_SPACE
+ | nvram |
+ +--------------+ < size
+*/
+
static struct mtd_partition bcm947xx_parts[] = {
- //{ name: "pmon", offset: 0, size: 0, /*mask_flags: MTD_WRITEABLE,*/ },
- { name: "boot", offset: 0, size: 0, /*mask_flags: MTD_WRITEABLE,*/ },
- { name: "linux", offset: 0, size: 0, },
- { name: "rootfs", offset: 0, size: 0, /*mask_flags: MTD_WRITEABLE,*/ },
-#ifdef MULTILANG_SUPPORT
- { name: "lang", offset: 0, size: 0, /*mask_flags: MTD_WRITEABLE,*/ }, /* for multilang*/
-#endif
- { name: "nvram", offset: 0, size: 0, },
+ { name: "pmon", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
+ { name: "linux", offset: 0, size: 0, },
+ { name: "rootfs", offset: 0, size: 0, mask_flags: MTD_WRITEABLE, },
+ { name: "jffs2", offset: 0, size: 0, },
+ { name: "nvram", offset: 0, size: 0, },
{ name: NULL, },
};
+#define PART_BOOT 0
+#define PART_LINUX 1
+#define PART_ROOTFS 2
+#define PART_JFFS2 3
+#define PART_NVRAM 4
+
struct mtd_partition * __init
init_mtd_partitions(struct mtd_info *mtd, size_t size)
{
- struct minix_super_block *minixsb;
- struct ext2_super_block *ext2sb;
- struct romfs_super_block *romfsb;
- struct cramfs_super *cramfsb;
- struct squashfs_super_block *squashfsb;
struct trx_header *trx;
unsigned char buf[512];
- int off;
-#ifdef MULTILANG_SUPPORT
- struct lang_header *lang; /* for multilang */
- int off1;
-#endif
+ size_t off;
size_t len;
+ size_t trxsize;
- minixsb = (struct minix_super_block *) buf;
- ext2sb = (struct ext2_super_block *) buf;
- romfsb = (struct romfs_super_block *) buf;
- cramfsb = (struct cramfs_super *) buf;
- squashfsb = (struct squashfs_super_block *) buf;
- trx = (struct trx_header *) buf;
-#ifdef MULTILANG_SUPPORT
- lang = (struct lang_header *) buf; /* for multilang */
-#endif
-
- /* Look at every 64 KB boundary */
- for (off = 0; off < size; off += (64 * 1024)) {
- memset(buf, 0xe5, sizeof(buf));
+ bcm947xx_parts[PART_NVRAM].offset = size - ROUNDUP(NVRAM_SPACE, mtd->erasesize);
+ bcm947xx_parts[PART_NVRAM].size = size - bcm947xx_parts[PART_NVRAM].offset;
- /*
- * Read block 0 to test for romfs and cramfs superblock
- */
- if (MTD_READ(mtd, off, sizeof(buf), &len, buf) ||
- len != sizeof(buf))
- continue;
+ trxsize = 0;
+ trx = (struct trx_header *) buf;
+ for (off = 0; off < size; off += mtd->erasesize) {
+ if ((MTD_READ(mtd, off, sizeof(buf), &len, buf)) || (len != sizeof(buf))) continue;
- /* Try looking at TRX header for rootfs offset */
if (le32_to_cpu(trx->magic) == TRX_MAGIC) {
- bcm947xx_parts[1].offset = off;
- if (le32_to_cpu(trx->offsets[1]) > off)
- off = le32_to_cpu(trx->offsets[1]);
- continue;
- }
-
- /* romfs is at block zero too */
- if (romfsb->word0 == ROMSB_WORD0 &&
- romfsb->word1 == ROMSB_WORD1) {
- printk(KERN_NOTICE
- "%s: romfs filesystem found at block %d\n",
- mtd->name, off / BLOCK_SIZE);
- goto done;
- }
-
- /* so is cramfs */
- if (cramfsb->magic == CRAMFS_MAGIC) {
- printk(KERN_NOTICE
- "%s: cramfs filesystem found at block %d\n",
- mtd->name, off / BLOCK_SIZE);
- goto done;
- }
-
- /* squashfs is at block zero too */
- if (squashfsb->s_magic == SQUASHFS_MAGIC) {
- printk(KERN_NOTICE
- "%s: squashfs filesystem found at block %d\n",
- mtd->name, off / BLOCK_SIZE);
- goto done;
- }
-
- /*
- * Read block 1 to test for minix and ext2 superblock
- */
- if (MTD_READ(mtd, off + BLOCK_SIZE, sizeof(buf), &len, buf) ||
- len != sizeof(buf))
- continue;
-
- /* Try minix */
- if (minixsb->s_magic == MINIX_SUPER_MAGIC ||
- minixsb->s_magic == MINIX_SUPER_MAGIC2) {
- printk(KERN_NOTICE
- "%s: Minix filesystem found at block %d\n",
- mtd->name, off / BLOCK_SIZE);
- goto done;
- }
-
- /* Try ext2 */
- if (ext2sb->s_magic == cpu_to_le16(EXT2_SUPER_MAGIC)) {
- printk(KERN_NOTICE
- "%s: ext2 filesystem found at block %d\n",
- mtd->name, off / BLOCK_SIZE);
- goto done;
+ bcm947xx_parts[PART_BOOT].size = off;
+
+ bcm947xx_parts[PART_LINUX].offset = off;
+ bcm947xx_parts[PART_LINUX].size = bcm947xx_parts[PART_NVRAM].offset - off;
+
+ trxsize = ROUNDUP(le32_to_cpu(trx->len), mtd->erasesize); // kernel + rootfs
+
+ bcm947xx_parts[PART_ROOTFS].offset = trx->offsets[1] + off;
+ bcm947xx_parts[PART_ROOTFS].size = trxsize - trx->offsets[1];
+
+ bcm947xx_parts[PART_JFFS2].offset = off + trxsize;
+ bcm947xx_parts[PART_JFFS2].size = bcm947xx_parts[PART_NVRAM].offset - bcm947xx_parts[PART_JFFS2].offset;
+ break;
}
}
- printk(KERN_NOTICE
- "%s: Couldn't find valid ROM disk image\n",
- mtd->name);
-
- done:
-#if MULTILANG_SUPPORT
-/* below for multilang */
- /* Look at every 64 KB boundary */
- for (off1 = 0; off1 < size; off1 += (64 * 1024)) {
- memset(buf, 0xe5, sizeof(buf));
-
- /*
- * Read block 0 to test for romfs and cramfs superblock
- */
- if (MTD_READ(mtd, off1, sizeof(buf), &len, buf) ||
- len != sizeof(buf))
- continue;
-
- /* Try looking at TRX header for rootfs offset */
- if (le32_to_cpu(trx->magic) == TRX_MAGIC) {
- printk("le32_to_cpu(trx->magic)=0x%lx trx->magic=0x%lx\n", le32_to_cpu(trx->magic), trx->magic);
- //bcm947xx_parts[1].offset = off1;
- printk("bcm947xx_parts[1].offset=0x%lx trx->offsets[1]=0x%lx off\n", bcm947xx_parts[2].offset);
- if (le32_to_cpu(trx->offsets[2]) > off1) {
- off1 = le32_to_cpu(trx->offsets[2]);
- printk("ok1 off1=0x%lx\n", off1);
- }
- continue;
- }
-
- /* so is cramfs */
- if (cramfsb->magic == CRAMFS_MAGIC) {
- printk(KERN_NOTICE
- "%s: lang cramfs filesystem found at block %d (0x%lx)\n",
- mtd->name, off1 / BLOCK_SIZE, off1);
- goto done1;
- }
-
- /* squashfs is at block zero too */
- if (squashfsb->s_magic == SQUASHFS_MAGIC) {
- printk(KERN_NOTICE
- "%s: lang squashfs filesystem found at block %d (0x%lx)\n",
- mtd->name, off1 / BLOCK_SIZE, off1);
- goto done1;
- }
-
+ if (trxsize == 0) {
+ // uh, now what...
+ printk(KERN_NOTICE "%s: Unable to find a valid linux partition\n", mtd->name);
}
-done1:
- printk("off=0x%lx off1=0x%lx size=0x%lx\n", off, off1, size);
- if(off1 == 0 || off1 == size )
- {
- off1 = size - 0x60000; // 0x3d0000 only lang.js
- printk("(Not Found Lang Block)off=0x%lx off1=0x%lx size=0x%lx\n", off, off1, size);
+
+#if 0
+ int i;
+ for (i = 0; bcm947xx_parts[i].name; ++i) {
+ printk(KERN_NOTICE "%8x %8x (%8x) %s\n",
+ bcm947xx_parts[i].offset,
+ (bcm947xx_parts[i].offset + bcm947xx_parts[i].size) - 1,
+ bcm947xx_parts[i].size,
+ bcm947xx_parts[i].name);
}
-/* for multilang -> */
- bcm947xx_parts[4].offset = size - ROUNDUP(NVRAM_SPACE, mtd->erasesize);
- bcm947xx_parts[4].size = size - bcm947xx_parts[4].offset;
- printk("nvram: offset=0x%lx size=0x%lx\n", bcm947xx_parts[4].offset, bcm947xx_parts[4].size);
-
- bcm947xx_parts[3].offset = off1;
- bcm947xx_parts[3].size = bcm947xx_parts[4].offset - bcm947xx_parts[3].offset;
-/* <- for multilang */
-#else
- /* Find and size nvram */
- bcm947xx_parts[3].offset = size - ROUNDUP(NVRAM_SPACE, mtd->erasesize);
- bcm947xx_parts[3].size = size - bcm947xx_parts[3].offset;
#endif
- /* Find and size rootfs */
- if (off < size) {
- bcm947xx_parts[2].offset = off;
- bcm947xx_parts[2].size = bcm947xx_parts[3].offset - bcm947xx_parts[2].offset;
- }
-
- /* Size linux (kernel and rootfs) */
- bcm947xx_parts[1].size = bcm947xx_parts[3].offset - bcm947xx_parts[1].offset;
-
- /* Size pmon */
- bcm947xx_parts[0].size = bcm947xx_parts[1].offset - bcm947xx_parts[0].offset;
return bcm947xx_parts;
}
+
EXPORT_SYMBOL(init_mtd_partitions);
#endif