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
8 +obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.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 +static int bcm47xx_sflash_bcma_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf)
28 + return bcma_sflash_read(dev->bcc, offset, len, buf);
31 +static int bcm47xx_sflash_bcma_poll(struct bcm47xx_sflash *dev, u32 offset)
33 + return bcma_sflash_poll(dev->bcc, offset);
36 +static int bcm47xx_sflash_bcma_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)
38 + return bcma_sflash_write(dev->bcc, offset, len, buf);
41 +static int bcm47xx_sflash_bcma_erase(struct bcm47xx_sflash *dev, u32 offset)
43 + return bcma_sflash_erase(dev->bcc, offset);
46 +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc)
48 + sflash->sflash_type = BCM47XX_BUS_TYPE_BCMA;
51 + sflash->read = bcm47xx_sflash_bcma_read;
52 + sflash->poll = bcm47xx_sflash_bcma_poll;
53 + sflash->write = bcm47xx_sflash_bcma_write;
54 + sflash->erase = bcm47xx_sflash_bcma_erase;
56 + sflash->blocksize = bcc->sflash.blocksize;
57 + sflash->numblocks = bcc->sflash.numblocks;
58 + sflash->size = bcc->sflash.size;
61 +static int bcm47xx_sflash_ssb_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf)
63 + return ssb_sflash_read(dev->scc, offset, len, buf);
66 +static int bcm47xx_sflash_ssb_poll(struct bcm47xx_sflash *dev, u32 offset)
68 + return ssb_sflash_poll(dev->scc, offset);
71 +static int bcm47xx_sflash_ssb_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)
73 + return ssb_sflash_write(dev->scc, offset, len, buf);
76 +static int bcm47xx_sflash_ssb_erase(struct bcm47xx_sflash *dev, u32 offset)
78 + return ssb_sflash_erase(dev->scc, offset);
81 +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc)
83 + sflash->sflash_type = BCM47XX_BUS_TYPE_SSB;
86 + sflash->read = bcm47xx_sflash_ssb_read;
87 + sflash->poll = bcm47xx_sflash_ssb_poll;
88 + sflash->write = bcm47xx_sflash_ssb_write;
89 + sflash->erase = bcm47xx_sflash_ssb_erase;
91 + sflash->blocksize = scc->sflash.blocksize;
92 + sflash->numblocks = scc->sflash.numblocks;
93 + sflash->size = scc->sflash.size;
95 --- a/arch/mips/bcm47xx/setup.c
96 +++ b/arch/mips/bcm47xx/setup.c
97 @@ -43,6 +43,8 @@ EXPORT_SYMBOL(bcm47xx_bus);
98 enum bcm47xx_bus_type bcm47xx_bus_type;
99 EXPORT_SYMBOL(bcm47xx_bus_type);
101 +struct bcm47xx_sflash bcm47xx_sflash;
103 static void bcm47xx_machine_restart(char *command)
105 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
106 @@ -291,6 +293,9 @@ static void __init bcm47xx_register_ssb(
108 panic("Failed to initialize SSB bus (err %d)", err);
110 + if (bcm47xx_bus.ssb.chipco.flash_type == SSB_SFLASH)
111 + bcm47xx_sflash_struct_ssb_init(&bcm47xx_sflash, &bcm47xx_bus.ssb.chipco);
113 mcore = &bcm47xx_bus.ssb.mipscore;
114 if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
115 if (strstr(buf, "console=ttyS1")) {
116 @@ -315,6 +320,9 @@ static void __init bcm47xx_register_bcma
117 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
119 panic("Failed to initialize BCMA bus (err %d)", err);
121 + if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_SFLASH)
122 + bcm47xx_sflash_struct_bcma_init(&bcm47xx_sflash, &bcm47xx_bus.bcma.bus.drv_cc);
127 +++ b/arch/mips/include/asm/mach-bcm47xx/bus.h
130 + * BCM947xx nvram variable access
132 + * Copyright (C) 2011 Hauke Mehrtens <hauke@hauke-m.de>
134 + * This program is free software; you can redistribute it and/or modify it
135 + * under the terms of the GNU General Public License as published by the
136 + * Free Software Foundation; either version 2 of the License, or (at your
137 + * option) any later version.
140 +#include <linux/ssb/ssb.h>
141 +#include <linux/bcma/bcma.h>
142 +#include <bcm47xx.h>
144 +struct bcm47xx_sflash {
145 + enum bcm47xx_bus_type sflash_type;
147 + struct ssb_chipcommon *scc;
148 + struct bcma_drv_cc *bcc;
151 + int (*read)(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf);
152 + int (*poll)(struct bcm47xx_sflash *dev, u32 offset);
153 + int (*write)(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf);
154 + int (*erase)(struct bcm47xx_sflash *dev, u32 offset);
156 + u32 blocksize; /* Block size */
157 + u32 numblocks; /* Number of blocks */
158 + u32 size; /* Total size in bytes */
161 +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc);
162 +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc);
164 +extern struct bcm47xx_sflash bcm47xx_sflash;