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