1 --- a/arch/mips/bcm47xx/Makefile
2 +++ b/arch/mips/bcm47xx/Makefile
7 -obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
8 +obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o sprom.o bus.o
9 obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o
11 +++ b/arch/mips/bcm47xx/bus.c
14 + * BCM947xx nvram variable access
16 + * Copyright (C) 2011 Hauke Mehrtens <hauke@hauke-m.de>
18 + * This program is free software; you can redistribute it and/or modify it
19 + * under the terms of the GNU General Public License as published by the
20 + * Free Software Foundation; either version 2 of the License, or (at your
21 + * option) any later version.
26 +#ifdef CONFIG_BCM47XX_BCMA
27 +static int bcm47xx_sflash_bcma_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf)
29 + return bcma_sflash_read(dev->bcc, offset, len, buf);
32 +static int bcm47xx_sflash_bcma_poll(struct bcm47xx_sflash *dev, u32 offset)
34 + return bcma_sflash_poll(dev->bcc, offset);
37 +static int bcm47xx_sflash_bcma_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)
39 + return bcma_sflash_write(dev->bcc, offset, len, buf);
42 +static int bcm47xx_sflash_bcma_erase(struct bcm47xx_sflash *dev, u32 offset)
44 + return bcma_sflash_erase(dev->bcc, offset);
47 +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc)
49 + sflash->sflash_type = BCM47XX_BUS_TYPE_BCMA;
52 + sflash->read = bcm47xx_sflash_bcma_read;
53 + sflash->poll = bcm47xx_sflash_bcma_poll;
54 + sflash->write = bcm47xx_sflash_bcma_write;
55 + sflash->erase = bcm47xx_sflash_bcma_erase;
57 + sflash->blocksize = bcc->sflash.blocksize;
58 + sflash->numblocks = bcc->sflash.numblocks;
59 + sflash->size = bcc->sflash.size;
63 +#ifdef CONFIG_BCM47XX_SSB
64 +static int bcm47xx_sflash_ssb_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf)
66 + return ssb_sflash_read(dev->scc, offset, len, buf);
69 +static int bcm47xx_sflash_ssb_poll(struct bcm47xx_sflash *dev, u32 offset)
71 + return ssb_sflash_poll(dev->scc, offset);
74 +static int bcm47xx_sflash_ssb_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)
76 + return ssb_sflash_write(dev->scc, offset, len, buf);
79 +static int bcm47xx_sflash_ssb_erase(struct bcm47xx_sflash *dev, u32 offset)
81 + return ssb_sflash_erase(dev->scc, offset);
84 +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc)
86 + sflash->sflash_type = BCM47XX_BUS_TYPE_SSB;
89 + sflash->read = bcm47xx_sflash_ssb_read;
90 + sflash->poll = bcm47xx_sflash_ssb_poll;
91 + sflash->write = bcm47xx_sflash_ssb_write;
92 + sflash->erase = bcm47xx_sflash_ssb_erase;
94 + sflash->blocksize = scc->sflash.blocksize;
95 + sflash->numblocks = scc->sflash.numblocks;
96 + sflash->size = scc->sflash.size;
99 --- a/arch/mips/bcm47xx/setup.c
100 +++ b/arch/mips/bcm47xx/setup.c
101 @@ -43,6 +43,8 @@ EXPORT_SYMBOL(bcm47xx_bus);
102 enum bcm47xx_bus_type bcm47xx_bus_type;
103 EXPORT_SYMBOL(bcm47xx_bus_type);
105 +struct bcm47xx_sflash bcm47xx_sflash;
107 static void bcm47xx_machine_restart(char *command)
109 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
110 @@ -137,6 +139,9 @@ static void __init bcm47xx_register_ssb(
112 panic("Failed to initialize SSB bus (err %d)", err);
114 + if (bcm47xx_bus.ssb.chipco.flash_type == SSB_SFLASH)
115 + bcm47xx_sflash_struct_ssb_init(&bcm47xx_sflash, &bcm47xx_bus.ssb.chipco);
117 mcore = &bcm47xx_bus.ssb.mipscore;
118 if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
119 if (strstr(buf, "console=ttyS1")) {
120 @@ -195,6 +200,9 @@ static void __init bcm47xx_register_bcma
122 panic("Failed to initialize BCMA bus (err %d)", err);
124 + if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_SFLASH)
125 + bcm47xx_sflash_struct_bcma_init(&bcm47xx_sflash, &bcm47xx_bus.bcma.bus.drv_cc);
127 bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL);
131 +++ b/arch/mips/include/asm/mach-bcm47xx/bus.h
134 + * BCM947xx nvram variable access
136 + * Copyright (C) 2011 Hauke Mehrtens <hauke@hauke-m.de>
138 + * This program is free software; you can redistribute it and/or modify it
139 + * under the terms of the GNU General Public License as published by the
140 + * Free Software Foundation; either version 2 of the License, or (at your
141 + * option) any later version.
144 +#include <linux/ssb/ssb.h>
145 +#include <linux/bcma/bcma.h>
146 +#include <bcm47xx.h>
148 +struct bcm47xx_sflash {
149 + enum bcm47xx_bus_type sflash_type;
151 + struct ssb_chipcommon *scc;
152 + struct bcma_drv_cc *bcc;
155 + int (*read)(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf);
156 + int (*poll)(struct bcm47xx_sflash *dev, u32 offset);
157 + int (*write)(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf);
158 + int (*erase)(struct bcm47xx_sflash *dev, u32 offset);
160 + u32 blocksize; /* Block size */
161 + u32 numblocks; /* Number of blocks */
162 + u32 size; /* Total size in bytes */
165 +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc);
166 +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc);
168 +extern struct bcm47xx_sflash bcm47xx_sflash;