Remove trailing tabs, add RCS IDs.
This commit is contained in:
parent
700486254a
commit
9cc6428e00
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nand.c,v 1.10 2011/04/26 17:31:57 ahoka Exp $ */
|
||||
/* $NetBSD: nand.c,v 1.11 2011/05/01 13:20:28 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
|
@ -34,7 +34,7 @@
|
|||
/* Common driver for NAND chips implementing the ONFI 2.2 specification */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.10 2011/04/26 17:31:57 ahoka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.11 2011/05/01 13:20:28 rmind Exp $");
|
||||
|
||||
#include "locators.h"
|
||||
|
||||
|
@ -343,7 +343,7 @@ nand_fill_chip_structure_legacy(device_t self, struct nand_chip *chip)
|
|||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -375,9 +375,9 @@ nand_scan_media(device_t self, struct nand_chip *chip)
|
|||
if (onfi_signature[0] != 'O' || onfi_signature[1] != 'N' ||
|
||||
onfi_signature[2] != 'F' || onfi_signature[3] != 'I') {
|
||||
chip->nc_isonfi = false;
|
||||
|
||||
|
||||
aprint_normal(": Legacy NAND Flash\n");
|
||||
|
||||
|
||||
nand_read_id(self, &chip->nc_manf_id, &chip->nc_dev_id);
|
||||
|
||||
if (nand_fill_chip_structure_legacy(self, chip)) {
|
||||
|
@ -391,11 +391,10 @@ nand_scan_media(device_t self, struct nand_chip *chip)
|
|||
aprint_normal(": ONFI NAND Flash\n");
|
||||
|
||||
nand_read_id(self, &chip->nc_manf_id, &chip->nc_dev_id);
|
||||
|
||||
|
||||
if (nand_fill_chip_structure(self, chip)) {
|
||||
aprint_error_dev(self,
|
||||
"can't read device parameters\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -488,10 +487,10 @@ nand_read_id(device_t self, uint8_t *manf, uint8_t *dev)
|
|||
nand_select(self, true);
|
||||
nand_command(self, ONFI_READ_ID);
|
||||
nand_address(self, 0x00);
|
||||
|
||||
|
||||
nand_read_byte(self, manf);
|
||||
nand_read_byte(self, dev);
|
||||
|
||||
|
||||
nand_select(self, false);
|
||||
}
|
||||
|
||||
|
@ -1300,9 +1299,7 @@ nand_flash_read_unaligned(device_t self, size_t offset,
|
|||
|
||||
addr += chip->nc_page_size;
|
||||
}
|
||||
|
||||
KASSERT(*retlen == len);
|
||||
|
||||
out:
|
||||
mutex_exit(&sc->sc_device_lock);
|
||||
|
||||
|
@ -1341,7 +1338,6 @@ nand_flash_read(device_t self, flash_off_t offset, size_t len, size_t *retlen,
|
|||
if (len < chip->nc_page_size)
|
||||
panic("TODO page size is larger than read size");
|
||||
#endif
|
||||
|
||||
|
||||
if (len % chip->nc_page_size != 0 ||
|
||||
offset % chip->nc_page_size != 0) {
|
||||
|
@ -1369,7 +1365,6 @@ nand_flash_read(device_t self, flash_off_t offset, size_t len, size_t *retlen,
|
|||
addr += chip->nc_page_size;
|
||||
*retlen += chip->nc_page_size;
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_exit(&sc->sc_device_lock);
|
||||
|
||||
|
@ -1402,7 +1397,7 @@ nand_flash_isbad(device_t self, flash_off_t ofs, bool *isbad)
|
|||
mutex_exit(&sc->sc_device_lock);
|
||||
|
||||
*isbad = result;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1473,7 +1468,6 @@ nand_flash_erase(device_t self,
|
|||
if (nand_isbad(self, addr)) {
|
||||
aprint_error_dev(self, "bad block encountered\n");
|
||||
ei->ei_state = FLASH_ERASE_FAILED;
|
||||
|
||||
error = EIO;
|
||||
goto out;
|
||||
}
|
||||
|
@ -1481,7 +1475,6 @@ nand_flash_erase(device_t self,
|
|||
error = nand_erase_block(self, addr);
|
||||
if (error) {
|
||||
ei->ei_state = FLASH_ERASE_FAILED;
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nand_bbt.c,v 1.3 2011/04/26 13:38:13 ahoka Exp $ */
|
||||
/* $NetBSD: nand_bbt.c,v 1.4 2011/05/01 13:20:28 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 Department of Software Engineering,
|
||||
|
@ -31,7 +31,12 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Support for Bad Block Tables (BBTs) */
|
||||
/*
|
||||
* Implementation of Bad Block Tables (BBTs).
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nand_bbt.c,v 1.4 2011/05/01 13:20:28 rmind Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kmem.h>
|
||||
|
@ -95,9 +100,9 @@ nand_bbt_page_has_bbt(device_t self, flash_off_t addr) {
|
|||
struct nand_softc *sc = device_private(self);
|
||||
struct nand_chip *chip = &sc->sc_chip;
|
||||
uint8_t *oob = chip->nc_oob_cache;
|
||||
|
||||
|
||||
nand_read_oob(self, addr, oob);
|
||||
|
||||
|
||||
if (oob[NAND_BBT_OFFSET] == 'B' &&
|
||||
oob[NAND_BBT_OFFSET + 1] == 'b' &&
|
||||
oob[NAND_BBT_OFFSET + 2] == 't') {
|
||||
|
@ -123,26 +128,26 @@ nand_bbt_get_bbt_from_page(device_t self, flash_off_t addr)
|
|||
if (nand_isbad(self, addr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (nand_bbt_page_has_bbt(self, addr)) {
|
||||
bbtp = bbt->nbbt_bitmap;
|
||||
left = bbt->nbbt_size;
|
||||
|
||||
|
||||
for (i = 0; i < bbt_pages; i++) {
|
||||
nand_read_page(self, addr, buf);
|
||||
|
||||
|
||||
if (i == bbt_pages - 1) {
|
||||
KASSERT(left <= chip->nc_page_size);
|
||||
memcpy(bbtp, buf, left);
|
||||
} else {
|
||||
memcpy(bbtp, buf, chip->nc_page_size);
|
||||
}
|
||||
|
||||
|
||||
bbtp += chip->nc_page_size;
|
||||
left -= chip->nc_page_size;
|
||||
addr += chip->nc_page_size;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nand_io.c,v 1.4 2011/04/26 17:27:52 ahoka Exp $ */
|
||||
/* $NetBSD: nand_io.c,v 1.5 2011/05/01 13:20:28 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 Department of Software Engineering,
|
||||
|
@ -31,10 +31,14 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Inspired by the similar code in the NetBSD SPI driver, but I
|
||||
/*
|
||||
* Inspired by the similar code in the NetBSD SPI driver, but I
|
||||
* decided to do a rewrite from scratch to be suitable for NAND.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nand_io.c,v 1.5 2011/05/01 13:20:28 rmind Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/bufq.h>
|
||||
|
@ -108,11 +112,11 @@ nand_sync_thread_start(device_t self)
|
|||
mutex_init(&sc->sc_io_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
mutex_init(&wc->nwc_lock, MUTEX_DEFAULT, IPL_NONE);
|
||||
cv_init(&sc->sc_io_cv, "nandcv");
|
||||
|
||||
|
||||
error = bufq_alloc(&wc->nwc_bufq, "fcfs", BUFQ_SORT_RAWBLOCK);
|
||||
if (error)
|
||||
goto err_bufq;
|
||||
|
||||
|
||||
sc->sc_io_running = true;
|
||||
wc->nwc_write_pending = false;
|
||||
|
||||
|
@ -122,11 +126,11 @@ nand_sync_thread_start(device_t self)
|
|||
|
||||
if (!error)
|
||||
return 0;
|
||||
|
||||
|
||||
bufq_free(wc->nwc_bufq);
|
||||
err_bufq:
|
||||
cv_destroy(&sc->sc_io_cv);
|
||||
|
||||
|
||||
mutex_destroy(&sc->sc_io_lock);
|
||||
mutex_destroy(&wc->nwc_lock);
|
||||
|
||||
|
@ -182,19 +186,18 @@ nand_io_submit(device_t self, struct buf *bp)
|
|||
|
||||
if (BUF_ISREAD(bp)) {
|
||||
DPRINTF(("we have a read job\n"));
|
||||
|
||||
|
||||
mutex_enter(&wc->nwc_lock);
|
||||
if (wc->nwc_write_pending)
|
||||
nand_io_cache_sync(self);
|
||||
mutex_exit(&wc->nwc_lock);
|
||||
|
||||
|
||||
nand_io_read(self, bp);
|
||||
} else {
|
||||
DPRINTF(("we have a write job\n"));
|
||||
|
||||
nand_io_write(self, bp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -209,12 +212,12 @@ nand_io_cache_write(device_t self, daddr_t block, struct buf *bp)
|
|||
int error;
|
||||
|
||||
KASSERT(chip->nc_block_size != 0);
|
||||
|
||||
|
||||
base = block * chip->nc_block_size;
|
||||
offset = bp->b_rawblkno * DEV_BSIZE - base;
|
||||
|
||||
|
||||
DPRINTF(("io cache write, offset: %jd\n", (intmax_t )offset));
|
||||
|
||||
|
||||
if (!wc->nwc_write_pending) {
|
||||
wc->nwc_block = block;
|
||||
/*
|
||||
|
@ -289,7 +292,7 @@ nand_io_cache_sync(device_t self)
|
|||
out:
|
||||
while ((bp = bufq_get(wc->nwc_bufq)) != NULL)
|
||||
nand_io_done(self, bp, error);
|
||||
|
||||
|
||||
wc->nwc_block = -1;
|
||||
wc->nwc_write_pending = false;
|
||||
}
|
||||
|
@ -309,12 +312,11 @@ nand_sync_thread(void * arg)
|
|||
mutex_exit(&sc->sc_io_lock);
|
||||
|
||||
mutex_enter(&wc->nwc_lock);
|
||||
|
||||
if (!wc->nwc_write_pending) {
|
||||
mutex_exit(&wc->nwc_lock);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* see if the cache is older than 3 seconds (safety limit),
|
||||
* or if we havent touched the cache since more than 1 ms
|
||||
*/
|
||||
|
@ -328,10 +330,9 @@ nand_sync_thread(void * arg)
|
|||
}
|
||||
mutex_exit(&wc->nwc_lock);
|
||||
}
|
||||
|
||||
kthread_exit(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nand_io_read(device_t self, struct buf *bp)
|
||||
{
|
||||
|
@ -342,10 +343,9 @@ nand_io_read(device_t self, struct buf *bp)
|
|||
DPRINTF(("nand io read\n"));
|
||||
|
||||
offset = bp->b_rawblkno * DEV_BSIZE;
|
||||
|
||||
|
||||
error = nand_flash_read(self, offset, bp->b_resid,
|
||||
&retlen, bp->b_data);
|
||||
|
||||
nand_io_done(self, bp, error);
|
||||
}
|
||||
|
||||
|
@ -360,16 +360,13 @@ nand_io_write(device_t self, struct buf *bp)
|
|||
|
||||
block = nand_io_getblock(self, bp);
|
||||
DPRINTF(("write to block %jd\n", (intmax_t )block));
|
||||
|
||||
mutex_enter(&wc->nwc_lock);
|
||||
|
||||
mutex_enter(&wc->nwc_lock);
|
||||
if (wc->nwc_write_pending && wc->nwc_block != block) {
|
||||
DPRINTF(("writing to new block, syncing caches\n"));
|
||||
nand_io_cache_sync(self);
|
||||
}
|
||||
|
||||
nand_io_cache_write(self, block, bp);
|
||||
|
||||
mutex_exit(&wc->nwc_lock);
|
||||
}
|
||||
|
||||
|
@ -377,11 +374,10 @@ void
|
|||
nand_io_done(device_t self, struct buf *bp, int error)
|
||||
{
|
||||
DPRINTF(("io done: %p\n", bp));
|
||||
|
||||
|
||||
if (error == 0)
|
||||
bp->b_resid = 0;
|
||||
|
||||
|
||||
bp->b_error = error;
|
||||
|
||||
biodone(bp);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* $NetBSD: nand_micron.c,v 1.3 2011/03/18 16:46:04 ahoka Exp $ */
|
||||
/* $NetBSD: nand_micron.c,v 1.4 2011/05/01 13:20:28 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 Department of Software Engineering,
|
||||
* University of Szeged, Hungary
|
||||
|
@ -37,6 +38,9 @@
|
|||
* MT29F2G08AACWP, MT29F4G08BACWP, MT29F8G08FACWP
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nand_micron.c,v 1.4 2011/05/01 13:20:28 rmind Exp $");
|
||||
|
||||
#include "nand.h"
|
||||
#include "onfi.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue