Lines Matching refs:b47s
20 static void bcm47xxsflash_cmd(struct bcm47xxsflash *b47s, u32 opcode) in bcm47xxsflash_cmd() argument
24 b47s->cc_write(b47s, BCMA_CC_FLASHCTL, BCMA_CC_FLASHCTL_START | opcode); in bcm47xxsflash_cmd()
26 if (!(b47s->cc_read(b47s, BCMA_CC_FLASHCTL) & in bcm47xxsflash_cmd()
34 static int bcm47xxsflash_poll(struct bcm47xxsflash *b47s, int timeout) in bcm47xxsflash_poll() argument
39 switch (b47s->type) { in bcm47xxsflash_poll()
41 bcm47xxsflash_cmd(b47s, OPCODE_ST_RDSR); in bcm47xxsflash_poll()
42 if (!(b47s->cc_read(b47s, BCMA_CC_FLASHDATA) & in bcm47xxsflash_poll()
47 bcm47xxsflash_cmd(b47s, OPCODE_AT_STATUS); in bcm47xxsflash_poll()
48 if (b47s->cc_read(b47s, BCMA_CC_FLASHDATA) & in bcm47xxsflash_poll()
69 struct bcm47xxsflash *b47s = mtd->priv; in bcm47xxsflash_erase() local
72 switch (b47s->type) { in bcm47xxsflash_erase()
74 bcm47xxsflash_cmd(b47s, OPCODE_ST_WREN); in bcm47xxsflash_erase()
75 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, erase->addr); in bcm47xxsflash_erase()
80 if (b47s->blocksize < (64 * 1024)) in bcm47xxsflash_erase()
81 bcm47xxsflash_cmd(b47s, OPCODE_ST_SSE); in bcm47xxsflash_erase()
83 bcm47xxsflash_cmd(b47s, OPCODE_ST_SE); in bcm47xxsflash_erase()
86 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, erase->addr << 1); in bcm47xxsflash_erase()
87 bcm47xxsflash_cmd(b47s, OPCODE_AT_PAGE_ERASE); in bcm47xxsflash_erase()
91 err = bcm47xxsflash_poll(b47s, HZ); in bcm47xxsflash_erase()
106 struct bcm47xxsflash *b47s = mtd->priv; in bcm47xxsflash_read() local
112 memcpy_fromio(buf, (void __iomem *)KSEG0ADDR(b47s->window + from), in bcm47xxsflash_read()
122 struct bcm47xxsflash *b47s = mtd->priv; in bcm47xxsflash_write_st() local
126 bcm47xxsflash_cmd(b47s, OPCODE_ST_WREN); in bcm47xxsflash_write_st()
129 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, offset); in bcm47xxsflash_write_st()
130 b47s->cc_write(b47s, BCMA_CC_FLASHDATA, *buf++); in bcm47xxsflash_write_st()
133 if (b47s->bcma_cc->core->id.rev < 20) { in bcm47xxsflash_write_st()
134 bcm47xxsflash_cmd(b47s, OPCODE_ST_PP); in bcm47xxsflash_write_st()
139 bcm47xxsflash_cmd(b47s, OPCODE_ST_CSA | OPCODE_ST_PP); in bcm47xxsflash_write_st()
149 bcm47xxsflash_cmd(b47s, OPCODE_ST_CSA | *buf++); in bcm47xxsflash_write_st()
156 b47s->cc_write(b47s, BCMA_CC_FLASHCTL, 0); in bcm47xxsflash_write_st()
158 if (bcm47xxsflash_poll(b47s, HZ / 10)) in bcm47xxsflash_write_st()
167 struct bcm47xxsflash *b47s = mtd->priv; in bcm47xxsflash_write_at() local
168 u32 mask = b47s->blocksize - 1; in bcm47xxsflash_write_at()
174 if (byte || (len < b47s->blocksize)) { in bcm47xxsflash_write_at()
177 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, page); in bcm47xxsflash_write_at()
178 bcm47xxsflash_cmd(b47s, OPCODE_AT_BUF1_LOAD); in bcm47xxsflash_write_at()
180 err = bcm47xxsflash_poll(b47s, HZ / 1000); in bcm47xxsflash_write_at()
190 if (byte == b47s->blocksize) in bcm47xxsflash_write_at()
193 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, byte++); in bcm47xxsflash_write_at()
194 b47s->cc_write(b47s, BCMA_CC_FLASHDATA, *buf++); in bcm47xxsflash_write_at()
195 bcm47xxsflash_cmd(b47s, OPCODE_AT_BUF1_WRITE); in bcm47xxsflash_write_at()
201 b47s->cc_write(b47s, BCMA_CC_FLASHADDR, page); in bcm47xxsflash_write_at()
202 bcm47xxsflash_cmd(b47s, OPCODE_AT_BUF1_PROGRAM); in bcm47xxsflash_write_at()
210 struct bcm47xxsflash *b47s = mtd->priv; in bcm47xxsflash_write() local
217 switch (b47s->type) { in bcm47xxsflash_write()
240 static void bcm47xxsflash_fill_mtd(struct bcm47xxsflash *b47s, in bcm47xxsflash_fill_mtd() argument
243 struct mtd_info *mtd = &b47s->mtd; in bcm47xxsflash_fill_mtd()
245 mtd->priv = b47s; in bcm47xxsflash_fill_mtd()
251 mtd->size = b47s->size; in bcm47xxsflash_fill_mtd()
252 mtd->erasesize = b47s->blocksize; in bcm47xxsflash_fill_mtd()
265 static int bcm47xxsflash_bcma_cc_read(struct bcm47xxsflash *b47s, u16 offset) in bcm47xxsflash_bcma_cc_read() argument
267 return bcma_cc_read32(b47s->bcma_cc, offset); in bcm47xxsflash_bcma_cc_read()
270 static void bcm47xxsflash_bcma_cc_write(struct bcm47xxsflash *b47s, u16 offset, in bcm47xxsflash_bcma_cc_write() argument
273 bcma_cc_write32(b47s->bcma_cc, offset, value); in bcm47xxsflash_bcma_cc_write()
279 struct bcm47xxsflash *b47s; in bcm47xxsflash_bcma_probe() local
282 b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL); in bcm47xxsflash_bcma_probe()
283 if (!b47s) in bcm47xxsflash_bcma_probe()
285 sflash->priv = b47s; in bcm47xxsflash_bcma_probe()
287 b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash); in bcm47xxsflash_bcma_probe()
288 b47s->cc_read = bcm47xxsflash_bcma_cc_read; in bcm47xxsflash_bcma_probe()
289 b47s->cc_write = bcm47xxsflash_bcma_cc_write; in bcm47xxsflash_bcma_probe()
291 switch (b47s->bcma_cc->capabilities & BCMA_CC_CAP_FLASHT) { in bcm47xxsflash_bcma_probe()
293 b47s->type = BCM47XXSFLASH_TYPE_ST; in bcm47xxsflash_bcma_probe()
296 b47s->type = BCM47XXSFLASH_TYPE_ATMEL; in bcm47xxsflash_bcma_probe()
300 b47s->window = sflash->window; in bcm47xxsflash_bcma_probe()
301 b47s->blocksize = sflash->blocksize; in bcm47xxsflash_bcma_probe()
302 b47s->numblocks = sflash->numblocks; in bcm47xxsflash_bcma_probe()
303 b47s->size = sflash->size; in bcm47xxsflash_bcma_probe()
304 bcm47xxsflash_fill_mtd(b47s, &pdev->dev); in bcm47xxsflash_bcma_probe()
306 err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0); in bcm47xxsflash_bcma_probe()
312 if (bcm47xxsflash_poll(b47s, HZ / 10)) in bcm47xxsflash_bcma_probe()
321 struct bcm47xxsflash *b47s = sflash->priv; in bcm47xxsflash_bcma_remove() local
323 mtd_device_unregister(&b47s->mtd); in bcm47xxsflash_bcma_remove()