| 1 | --- a/arch/mips/bcm47xx/Makefile |
| 2 | +++ b/arch/mips/bcm47xx/Makefile |
| 3 | @@ -3,5 +3,5 @@ |
| 4 | # under Linux. |
| 5 | # |
| 6 | |
| 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 |
| 10 | --- /dev/null |
| 11 | +++ b/arch/mips/bcm47xx/bus.c |
| 12 | @@ -0,0 +1,86 @@ |
| 13 | +/* |
| 14 | + * BCM947xx nvram variable access |
| 15 | + * |
| 16 | + * Copyright (C) 2011 Hauke Mehrtens <hauke@hauke-m.de> |
| 17 | + * |
| 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. |
| 22 | + */ |
| 23 | + |
| 24 | +#include <bus.h> |
| 25 | + |
| 26 | +#ifdef CONFIG_BCM47XX_BCMA |
| 27 | +static int bcm47xx_sflash_bcma_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf) |
| 28 | +{ |
| 29 | + return bcma_sflash_read(dev->bcc, offset, len, buf); |
| 30 | +} |
| 31 | + |
| 32 | +static int bcm47xx_sflash_bcma_poll(struct bcm47xx_sflash *dev, u32 offset) |
| 33 | +{ |
| 34 | + return bcma_sflash_poll(dev->bcc, offset); |
| 35 | +} |
| 36 | + |
| 37 | +static int bcm47xx_sflash_bcma_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf) |
| 38 | +{ |
| 39 | + return bcma_sflash_write(dev->bcc, offset, len, buf); |
| 40 | +} |
| 41 | + |
| 42 | +static int bcm47xx_sflash_bcma_erase(struct bcm47xx_sflash *dev, u32 offset) |
| 43 | +{ |
| 44 | + return bcma_sflash_erase(dev->bcc, offset); |
| 45 | +} |
| 46 | + |
| 47 | +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc) |
| 48 | +{ |
| 49 | + sflash->sflash_type = BCM47XX_BUS_TYPE_BCMA; |
| 50 | + sflash->bcc = bcc; |
| 51 | + |
| 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; |
| 56 | + |
| 57 | + sflash->blocksize = bcc->sflash.blocksize; |
| 58 | + sflash->numblocks = bcc->sflash.numblocks; |
| 59 | + sflash->size = bcc->sflash.size; |
| 60 | +} |
| 61 | +#endif |
| 62 | + |
| 63 | +#ifdef CONFIG_BCM47XX_SSB |
| 64 | +static int bcm47xx_sflash_ssb_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf) |
| 65 | +{ |
| 66 | + return ssb_sflash_read(dev->scc, offset, len, buf); |
| 67 | +} |
| 68 | + |
| 69 | +static int bcm47xx_sflash_ssb_poll(struct bcm47xx_sflash *dev, u32 offset) |
| 70 | +{ |
| 71 | + return ssb_sflash_poll(dev->scc, offset); |
| 72 | +} |
| 73 | + |
| 74 | +static int bcm47xx_sflash_ssb_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf) |
| 75 | +{ |
| 76 | + return ssb_sflash_write(dev->scc, offset, len, buf); |
| 77 | +} |
| 78 | + |
| 79 | +static int bcm47xx_sflash_ssb_erase(struct bcm47xx_sflash *dev, u32 offset) |
| 80 | +{ |
| 81 | + return ssb_sflash_erase(dev->scc, offset); |
| 82 | +} |
| 83 | + |
| 84 | +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc) |
| 85 | +{ |
| 86 | + sflash->sflash_type = BCM47XX_BUS_TYPE_SSB; |
| 87 | + sflash->scc = scc; |
| 88 | + |
| 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; |
| 93 | + |
| 94 | + sflash->blocksize = scc->sflash.blocksize; |
| 95 | + sflash->numblocks = scc->sflash.numblocks; |
| 96 | + sflash->size = scc->sflash.size; |
| 97 | +} |
| 98 | +#endif |
| 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); |
| 104 | |
| 105 | +struct bcm47xx_sflash bcm47xx_sflash; |
| 106 | + |
| 107 | static void bcm47xx_machine_restart(char *command) |
| 108 | { |
| 109 | printk(KERN_ALERT "Please stand by while rebooting the system...\n"); |
| 110 | @@ -137,6 +139,9 @@ static void __init bcm47xx_register_ssb( |
| 111 | if (err) |
| 112 | panic("Failed to initialize SSB bus (err %d)", err); |
| 113 | |
| 114 | + if (bcm47xx_bus.ssb.chipco.flash_type == SSB_SFLASH) |
| 115 | + bcm47xx_sflash_struct_ssb_init(&bcm47xx_sflash, &bcm47xx_bus.ssb.chipco); |
| 116 | + |
| 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 |
| 121 | if (err) |
| 122 | panic("Failed to initialize BCMA bus (err %d)", err); |
| 123 | |
| 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); |
| 126 | + |
| 127 | bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL); |
| 128 | } |
| 129 | #endif |
| 130 | --- /dev/null |
| 131 | +++ b/arch/mips/include/asm/mach-bcm47xx/bus.h |
| 132 | @@ -0,0 +1,36 @@ |
| 133 | +/* |
| 134 | + * BCM947xx nvram variable access |
| 135 | + * |
| 136 | + * Copyright (C) 2011 Hauke Mehrtens <hauke@hauke-m.de> |
| 137 | + * |
| 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. |
| 142 | + */ |
| 143 | + |
| 144 | +#include <linux/ssb/ssb.h> |
| 145 | +#include <linux/bcma/bcma.h> |
| 146 | +#include <bcm47xx.h> |
| 147 | + |
| 148 | +struct bcm47xx_sflash { |
| 149 | + enum bcm47xx_bus_type sflash_type; |
| 150 | + union { |
| 151 | + struct ssb_chipcommon *scc; |
| 152 | + struct bcma_drv_cc *bcc; |
| 153 | + }; |
| 154 | + |
| 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); |
| 159 | + |
| 160 | + u32 blocksize; /* Block size */ |
| 161 | + u32 numblocks; /* Number of blocks */ |
| 162 | + u32 size; /* Total size in bytes */ |
| 163 | +}; |
| 164 | + |
| 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); |
| 167 | + |
| 168 | +extern struct bcm47xx_sflash bcm47xx_sflash; |
| 169 | |