switch (b47s->type) { case BCM47XXSFLASH_TYPE_ST:
bcm47xxsflash_cmd(b47s, OPCODE_ST_WREN);
b47s->cc_write(b47s, BCMA_CC_FLASHADDR, erase->addr); /* Newer flashes have "sub-sectors" which can be erased * independently with a new command: ST_SSE. The ST_SE command * erases 64KB just as before.
*/ if (b47s->blocksize < (64 * 1024))
bcm47xxsflash_cmd(b47s, OPCODE_ST_SSE); else
bcm47xxsflash_cmd(b47s, OPCODE_ST_SE); break; case BCM47XXSFLASH_TYPE_ATMEL:
b47s->cc_write(b47s, BCMA_CC_FLASHADDR, erase->addr << 1);
bcm47xxsflash_cmd(b47s, OPCODE_AT_PAGE_ERASE); break;
}
/* Use indirect access for content out of the window */ for (; len; len--) {
b47s->cc_write(b47s, BCMA_CC_FLASHADDR, from++);
bcm47xxsflash_cmd(b47s, OPCODE_ST_READ4B);
*buf++ = b47s->cc_read(b47s, BCMA_CC_FLASHDATA);
}
/* Program page */ if (b47s->bcma_cc->core->id.rev < 20) {
bcm47xxsflash_cmd(b47s, OPCODE_ST_PP); return 1; /* 1B written */
}
/* Program page and set CSA (on newer chips we can continue writing) */
bcm47xxsflash_cmd(b47s, OPCODE_ST_CSA | OPCODE_ST_PP);
offset++;
len--;
written++;
while (len > 0) { /* Page boundary, another function call is needed */ if ((offset & 0xFF) == 0) break;
/* Writing functions can return without writing all passed data, for * example when the hardware is too old or when we git page boundary.
*/ while (len > 0) { switch (b47s->type) { case BCM47XXSFLASH_TYPE_ST:
written = bcm47xxsflash_write_st(mtd, to, len, buf); break; case BCM47XXSFLASH_TYPE_ATMEL:
written = bcm47xxsflash_write_at(mtd, to, len, buf); break; default:
BUG_ON(1);
} if (written < 0) {
pr_err("Error writing at offset 0x%llX\n", to); return written;
}
to += (loff_t)written;
len -= written;
*retlen += written;
buf += written;
}
/* * On old MIPS devices cache was magically invalidated when needed, * allowing us to use cached access and gain some performance. Trying * the same on ARM based BCM53573 results in flash corruptions, we need * to use uncached access for it. * * It may be arch specific, but right now there is only 1 ARM SoC using * this driver, so let's follow Broadcom's reference code and check * ChipCommon revision.
*/ if (b47s->bcma_cc->core->id.rev == 54)
b47s->window = ioremap(res->start, resource_size(res)); else
b47s->window = ioremap_cache(res->start, resource_size(res)); if (!b47s->window) {
dev_err(dev, "ioremap failed for resource %pR\n", res); return -ENOMEM;
}
switch (b47s->bcma_cc->capabilities & BCMA_CC_CAP_FLASHT) { case BCMA_CC_FLASHT_STSER:
b47s->type = BCM47XXSFLASH_TYPE_ST; break; case BCMA_CC_FLASHT_ATSER:
b47s->type = BCM47XXSFLASH_TYPE_ATMEL; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.