Lines Matching defs:b47s

22 static void bcm47xxsflash_cmd(struct bcm47xxsflash *b47s, u32 opcode)
26 b47s->cc_write(b47s, BCMA_CC_FLASHCTL, BCMA_CC_FLASHCTL_START | opcode);
28 if (!(b47s->cc_read(b47s, BCMA_CC_FLASHCTL) &
36 static int bcm47xxsflash_poll(struct bcm47xxsflash *b47s, int timeout)
41 switch (b47s->type) {
43 bcm47xxsflash_cmd(b47s, OPCODE_ST_RDSR);
44 if (!(b47s->cc_read(b47s, BCMA_CC_FLASHDATA) &
49 bcm47xxsflash_cmd(b47s, OPCODE_AT_STATUS);
50 if (b47s->cc_read(b47s, BCMA_CC_FLASHDATA) &
71 struct bcm47xxsflash *b47s = mtd->priv;
73 switch (b47s->type) {
75 bcm47xxsflash_cmd(b47s, OPCODE_ST_WREN);
76 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, erase->addr);
81 if (b47s->blocksize < (64 * 1024))
82 bcm47xxsflash_cmd(b47s, OPCODE_ST_SSE);
84 bcm47xxsflash_cmd(b47s, OPCODE_ST_SE);
87 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, erase->addr << 1);
88 bcm47xxsflash_cmd(b47s, OPCODE_AT_PAGE_ERASE);
92 return bcm47xxsflash_poll(b47s, HZ);
98 struct bcm47xxsflash *b47s = mtd->priv;
110 memcpy_fromio(buf, b47s->window + from, memcpy_len);
118 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, from++);
119 bcm47xxsflash_cmd(b47s, OPCODE_ST_READ4B);
120 *buf++ = b47s->cc_read(b47s, BCMA_CC_FLASHDATA);
131 struct bcm47xxsflash *b47s = mtd->priv;
135 bcm47xxsflash_cmd(b47s, OPCODE_ST_WREN);
138 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, offset);
139 b47s->cc_write(b47s, BCMA_CC_FLASHDATA, *buf++);
142 if (b47s->bcma_cc->core->id.rev < 20) {
143 bcm47xxsflash_cmd(b47s, OPCODE_ST_PP);
148 bcm47xxsflash_cmd(b47s, OPCODE_ST_CSA | OPCODE_ST_PP);
158 bcm47xxsflash_cmd(b47s, OPCODE_ST_CSA | *buf++);
165 b47s->cc_write(b47s, BCMA_CC_FLASHCTL, 0);
167 if (bcm47xxsflash_poll(b47s, HZ / 10))
176 struct bcm47xxsflash *b47s = mtd->priv;
177 u32 mask = b47s->blocksize - 1;
183 if (byte || (len < b47s->blocksize)) {
186 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, page);
187 bcm47xxsflash_cmd(b47s, OPCODE_AT_BUF1_LOAD);
189 err = bcm47xxsflash_poll(b47s, HZ / 1000);
199 if (byte == b47s->blocksize)
202 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, byte++);
203 b47s->cc_write(b47s, BCMA_CC_FLASHDATA, *buf++);
204 bcm47xxsflash_cmd(b47s, OPCODE_AT_BUF1_WRITE);
210 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, page);
211 bcm47xxsflash_cmd(b47s, OPCODE_AT_BUF1_PROGRAM);
219 struct bcm47xxsflash *b47s = mtd->priv;
226 switch (b47s->type) {
249 static void bcm47xxsflash_fill_mtd(struct bcm47xxsflash *b47s,
252 struct mtd_info *mtd = &b47s->mtd;
254 mtd->priv = b47s;
260 mtd->size = b47s->size;
261 mtd->erasesize = b47s->blocksize;
274 static int bcm47xxsflash_bcma_cc_read(struct bcm47xxsflash *b47s, u16 offset)
276 return bcma_cc_read32(b47s->bcma_cc, offset);
279 static void bcm47xxsflash_bcma_cc_write(struct bcm47xxsflash *b47s, u16 offset,
282 bcma_cc_write32(b47s->bcma_cc, offset, value);
289 struct bcm47xxsflash *b47s;
293 b47s = devm_kzalloc(dev, sizeof(*b47s), GFP_KERNEL);
294 if (!b47s)
308 b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
309 b47s->cc_read = bcm47xxsflash_bcma_cc_read;
310 b47s->cc_write = bcm47xxsflash_bcma_cc_write;
322 if (b47s->bcma_cc->core->id.rev == 54)
323 b47s->window = ioremap(res->start, resource_size(res));
325 b47s->window = ioremap_cache(res->start, resource_size(res));
326 if (!b47s->window) {
331 switch (b47s->bcma_cc->capabilities & BCMA_CC_CAP_FLASHT) {
333 b47s->type = BCM47XXSFLASH_TYPE_ST;
336 b47s->type = BCM47XXSFLASH_TYPE_ATMEL;
340 b47s->blocksize = sflash->blocksize;
341 b47s->numblocks = sflash->numblocks;
342 b47s->size = sflash->size;
343 bcm47xxsflash_fill_mtd(b47s, &pdev->dev);
345 platform_set_drvdata(pdev, b47s);
347 err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
350 iounmap(b47s->window);
354 if (bcm47xxsflash_poll(b47s, HZ / 10))
362 struct bcm47xxsflash *b47s = platform_get_drvdata(pdev);
364 mtd_device_unregister(&b47s->mtd);
365 iounmap(b47s->window);