Module Name: src Committed By: ahoka Date: Tue Jun 28 07:16:11 UTC 2011
Modified Files: src/sys/dev/nand: nand.c nand.h nand_micron.c Log Message: follow bus_space conventions in naming To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/nand/nand.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/nand/nand.h cvs rdiff -u -r1.4 -r1.5 src/sys/dev/nand/nand_micron.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/nand/nand.c diff -u src/sys/dev/nand/nand.c:1.11 src/sys/dev/nand/nand.c:1.12 --- src/sys/dev/nand/nand.c:1.11 Sun May 1 13:20:28 2011 +++ src/sys/dev/nand/nand.c Tue Jun 28 07:16:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nand.c,v 1.11 2011/05/01 13:20:28 rmind Exp $ */ +/* $NetBSD: nand.c,v 1.12 2011/06/28 07:16:11 ahoka 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.11 2011/05/01 13:20:28 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.12 2011/06/28 07:16:11 ahoka Exp $"); #include "locators.h" @@ -133,7 +133,7 @@ aprint_error("NAND chip is write protected!\n"); return; } - + if (nand_scan_media(self, chip)) { return; } @@ -289,14 +289,14 @@ interface->select = &nand_default_select; interface->command = NULL; interface->address = NULL; - interface->read_buf_byte = NULL; - interface->read_buf_word = NULL; - interface->read_byte = NULL; - interface->read_word = NULL; - interface->write_buf_byte = NULL; - interface->write_buf_word = NULL; - interface->write_byte = NULL; - interface->write_word = NULL; + interface->read_buf_1 = NULL; + interface->read_buf_2 = NULL; + interface->read_1 = NULL; + interface->read_2 = NULL; + interface->write_buf_1 = NULL; + interface->write_buf_2 = NULL; + interface->write_1 = NULL; + interface->write_2 = NULL; interface->busy = NULL; /*- @@ -366,10 +366,10 @@ nand_select(self, true); nand_command(self, ONFI_READ_ID); nand_address(self, 0x20); - nand_read_byte(self, &onfi_signature[0]); - nand_read_byte(self, &onfi_signature[1]); - nand_read_byte(self, &onfi_signature[2]); - nand_read_byte(self, &onfi_signature[3]); + nand_read_1(self, &onfi_signature[0]); + nand_read_1(self, &onfi_signature[1]); + nand_read_1(self, &onfi_signature[2]); + nand_read_1(self, &onfi_signature[3]); nand_select(self, false); if (onfi_signature[0] != 'O' || onfi_signature[1] != 'N' || @@ -423,7 +423,7 @@ PRIu8 "\n", chip->nc_addr_cycles_column, chip->nc_addr_cycles_row); #endif - + ecc = chip->nc_ecc = &sc->nand_if->ecc; /* @@ -488,8 +488,8 @@ nand_command(self, ONFI_READ_ID); nand_address(self, 0x00); - nand_read_byte(self, manf); - nand_read_byte(self, dev); + nand_read_1(self, manf); + nand_read_1(self, dev); nand_select(self, false); } @@ -505,7 +505,7 @@ //read_params: // tries++; - + nand_select(self, true); nand_command(self, ONFI_READ_PARAMETER_PAGE); nand_address(self, 0x00); @@ -517,10 +517,10 @@ bufp = (uint8_t *)params; /* XXX why i am not using read_buf? */ for (i = 0; i < 256; i++) { - nand_read_byte(self, &bufp[i]); + nand_read_1(self, &bufp[i]); } nand_select(self, false); - + /* validate the parameter page with the crc */ crc = nand_crc16(bufp, 254); @@ -639,7 +639,7 @@ nand_command(self, ONFI_READ_STATUS); nand_busy(self); - nand_read_byte(self, &status); + nand_read_1(self, &status); return status; } @@ -682,14 +682,14 @@ if (chip->nc_flags & NC_BUSWIDTH_16) { for (b = 0, e = 0; b < chip->nc_page_size; b += bs, e += cs) { nand_ecc_prepare(self, NAND_ECC_READ); - nand_read_buf_word(self, data + b, bs); + nand_read_buf_2(self, data + b, bs); nand_ecc_compute(self, data + b, chip->nc_ecc_cache + e); } } else { for (b = 0, e = 0; b < chip->nc_page_size; b += bs, e += cs) { nand_ecc_prepare(self, NAND_ECC_READ); - nand_read_buf_byte(self, data + b, bs); + nand_read_buf_1(self, data + b, bs); nand_ecc_compute(self, data + b, chip->nc_ecc_cache + e); } @@ -775,20 +775,20 @@ if (chip->nc_flags & NC_BUSWIDTH_16) { for (b = 0, e = 0; b < chip->nc_page_size; b += bs, e += cs) { nand_ecc_prepare(self, NAND_ECC_WRITE); - nand_write_buf_word(self, data + b, bs); + nand_write_buf_2(self, data + b, bs); nand_ecc_compute(self, data + b, ecc + e); } /* write oob with ecc correction code */ - nand_write_buf_word(self, chip->nc_oob_cache, + nand_write_buf_2(self, chip->nc_oob_cache, chip->nc_spare_size); } else { for (b = 0, e = 0; b < chip->nc_page_size; b += bs, e += cs) { nand_ecc_prepare(self, NAND_ECC_WRITE); - nand_write_buf_byte(self, data + b, bs); + nand_write_buf_1(self, data + b, bs); nand_ecc_compute(self, data + b, ecc + e); } /* write oob with ecc correction code */ - nand_write_buf_byte(self, chip->nc_oob_cache, + nand_write_buf_1(self, chip->nc_oob_cache, chip->nc_spare_size); } @@ -829,9 +829,9 @@ nand_prepare_read(self, page, chip->nc_page_size); if (chip->nc_flags & NC_BUSWIDTH_16) - nand_read_buf_word(self, oob, chip->nc_spare_size); + nand_read_buf_2(self, oob, chip->nc_spare_size); else - nand_read_buf_byte(self, oob, chip->nc_spare_size); + nand_read_buf_1(self, oob, chip->nc_spare_size); /* for debugging drivers */ #if 0 @@ -855,9 +855,9 @@ nand_busy(self); if (chip->nc_flags & NC_BUSWIDTH_16) - nand_write_buf_word(self, oob, chip->nc_spare_size); + nand_write_buf_2(self, oob, chip->nc_spare_size); else - nand_write_buf_byte(self, oob, chip->nc_spare_size); + nand_write_buf_1(self, oob, chip->nc_spare_size); status = nand_get_status(self); KASSERT(status & ONFI_STATUS_RDY); @@ -918,12 +918,12 @@ if (chip->nc_flags & NC_BUSWIDTH_16) { uint16_t word; - nand_read_word(self, &word); + nand_read_2(self, &word); if (word == 0x0000) return true; } else { uint8_t byte; - nand_read_byte(self, &byte); + nand_read_1(self, &byte); if (byte == 0x00) return true; } @@ -949,7 +949,7 @@ nand_prepare_read(self, block, chip->nc_page_size + (chip->nc_badmarker_offs & 0xfe)); - nand_read_word(self, &word); + nand_read_2(self, &word); mark = htole16(word); if (chip->nc_badmarker_offs & 0x01) mark >>= 8; @@ -961,7 +961,7 @@ nand_prepare_read(self, block, chip->nc_page_size + chip->nc_badmarker_offs); - nand_read_byte(self, &byte); + nand_read_1(self, &byte); if (byte != 0xff) return true; } @@ -1115,7 +1115,7 @@ memcpy(chip->nc_page_cache + firstoff, bufp, chip->nc_page_size - firstoff); - + printf("program page: %s: %d\n", __FILE__, __LINE__); error = nand_program_page(self, addr, chip->nc_page_cache); Index: src/sys/dev/nand/nand.h diff -u src/sys/dev/nand/nand.h:1.9 src/sys/dev/nand/nand.h:1.10 --- src/sys/dev/nand/nand.h:1.9 Sun May 1 14:48:11 2011 +++ src/sys/dev/nand/nand.h Tue Jun 28 07:16:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nand.h,v 1.9 2011/05/01 14:48:11 ahoka Exp $ */ +/* $NetBSD: nand.h,v 1.10 2011/06/28 07:16:11 ahoka Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -167,14 +167,14 @@ void (*select) (device_t, bool); /* optional */ void (*command) (device_t, uint8_t); void (*address) (device_t, uint8_t); - void (*read_buf_byte) (device_t, void *, size_t); - void (*read_buf_word) (device_t, void *, size_t); - void (*read_byte) (device_t, uint8_t *); - void (*read_word) (device_t, uint16_t *); - void (*write_buf_byte) (device_t, const void *, size_t); - void (*write_buf_word) (device_t, const void *, size_t); - void (*write_byte) (device_t, uint8_t); - void (*write_word) (device_t, uint16_t); + void (*read_buf_1) (device_t, void *, size_t); + void (*read_buf_2) (device_t, void *, size_t); + void (*read_1) (device_t, uint8_t *); + void (*read_2) (device_t, uint16_t *); + void (*write_buf_1) (device_t, const void *, size_t); + void (*write_buf_2) (device_t, const void *, size_t); + void (*write_1) (device_t, uint8_t); + void (*write_2) (device_t, uint16_t); void (*busy) (device_t); /* "smart" controllers may override read/program functions */ @@ -204,12 +204,12 @@ nand_busy(device_t device) { struct nand_softc *sc = device_private(device); - + KASSERT(sc->nand_if->select != NULL); KASSERT(sc->controller_dev != NULL); - + sc->nand_if->select(sc->controller_dev, true); - + if (sc->nand_if->busy != NULL) { sc->nand_if->busy(sc->controller_dev); } @@ -221,10 +221,10 @@ nand_select(device_t self, bool enable) { struct nand_softc *sc = device_private(self); - + KASSERT(sc->nand_if->select != NULL); KASSERT(sc->controller_dev != NULL); - + sc->nand_if->select(sc->controller_dev, enable); } @@ -232,10 +232,10 @@ nand_address(device_t self, uint32_t address) { struct nand_softc *sc = device_private(self); - + KASSERT(sc->nand_if->address != NULL); KASSERT(sc->controller_dev != NULL); - + sc->nand_if->address(sc->controller_dev, address); } @@ -243,7 +243,7 @@ nand_command(device_t self, uint8_t command) { struct nand_softc *sc = device_private(self); - + KASSERT(sc->nand_if->command != NULL); KASSERT(sc->controller_dev != NULL); @@ -251,91 +251,91 @@ } static inline void -nand_read_byte(device_t self, uint8_t *data) +nand_read_1(device_t self, uint8_t *data) { struct nand_softc *sc = device_private(self); - - KASSERT(sc->nand_if->read_byte != NULL); + + KASSERT(sc->nand_if->read_1 != NULL); KASSERT(sc->controller_dev != NULL); - - sc->nand_if->read_byte(sc->controller_dev, data); + + sc->nand_if->read_1(sc->controller_dev, data); } static inline void -nand_write_byte(device_t self, uint8_t data) +nand_write_1(device_t self, uint8_t data) { struct nand_softc *sc = device_private(self); - - KASSERT(sc->nand_if->write_byte != NULL); + + KASSERT(sc->nand_if->write_1 != NULL); KASSERT(sc->controller_dev != NULL); - - sc->nand_if->write_byte(sc->controller_dev, data); + + sc->nand_if->write_1(sc->controller_dev, data); } static inline void -nand_read_word(device_t self, uint16_t *data) +nand_read_2(device_t self, uint16_t *data) { struct nand_softc *sc = device_private(self); - - KASSERT(sc->nand_if->read_word != NULL); + + KASSERT(sc->nand_if->read_2 != NULL); KASSERT(sc->controller_dev != NULL); - - sc->nand_if->read_word(sc->controller_dev, data); + + sc->nand_if->read_2(sc->controller_dev, data); } static inline void -nand_write_word(device_t self, uint16_t data) +nand_write_2(device_t self, uint16_t data) { struct nand_softc *sc = device_private(self); - - KASSERT(sc->nand_if->write_word != NULL); + + KASSERT(sc->nand_if->write_2 != NULL); KASSERT(sc->controller_dev != NULL); - - sc->nand_if->write_word(sc->controller_dev, data); + + sc->nand_if->write_2(sc->controller_dev, data); } static inline void -nand_read_buf_byte(device_t self, void *buf, size_t size) +nand_read_buf_1(device_t self, void *buf, size_t size) { struct nand_softc *sc = device_private(self); - KASSERT(sc->nand_if->read_buf_byte != NULL); + KASSERT(sc->nand_if->read_buf_1 != NULL); KASSERT(sc->controller_dev != NULL); - - sc->nand_if->read_buf_byte(sc->controller_dev, buf, size); + + sc->nand_if->read_buf_1(sc->controller_dev, buf, size); } static inline void -nand_read_buf_word(device_t self, void *buf, size_t size) +nand_read_buf_2(device_t self, void *buf, size_t size) { struct nand_softc *sc = device_private(self); - KASSERT(sc->nand_if->read_buf_word != NULL); + KASSERT(sc->nand_if->read_buf_2 != NULL); KASSERT(sc->controller_dev != NULL); - - sc->nand_if->read_buf_word(sc->controller_dev, buf, size); + + sc->nand_if->read_buf_2(sc->controller_dev, buf, size); } static inline void -nand_write_buf_byte(device_t self, const void *buf, size_t size) +nand_write_buf_1(device_t self, const void *buf, size_t size) { struct nand_softc *sc = device_private(self); - - KASSERT(sc->nand_if->write_buf_byte != NULL); + + KASSERT(sc->nand_if->write_buf_1 != NULL); KASSERT(sc->controller_dev != NULL); - sc->nand_if->write_buf_byte(sc->controller_dev, buf, size); + sc->nand_if->write_buf_1(sc->controller_dev, buf, size); } static inline void -nand_write_buf_word(device_t self, const void *buf, size_t size) +nand_write_buf_2(device_t self, const void *buf, size_t size) { struct nand_softc *sc = device_private(self); - KASSERT(sc->nand_if->write_buf_word != NULL); + KASSERT(sc->nand_if->write_buf_2 != NULL); KASSERT(sc->controller_dev != NULL); - sc->nand_if->write_buf_word(sc->controller_dev, buf, size); + sc->nand_if->write_buf_2(sc->controller_dev, buf, size); } static inline int @@ -358,7 +358,7 @@ KASSERT(sc->nand_if->ecc_compute != NULL); KASSERT(sc->controller_dev != NULL); - sc->nand_if->ecc_compute(sc->controller_dev, data, code); + sc->nand_if->ecc_compute(sc->controller_dev, data, code); } static inline void @@ -492,11 +492,11 @@ static inline void nand_select(device_t, bool); static inline void nand_command(device_t, uint8_t); static inline void nand_address(device_t, uint32_t); -static inline void nand_read_buf_byte(device_t, void *, size_t); -static inline void nand_read_buf_word(device_t, void *, size_t); -static inline void nand_read_byte(device_t, uint8_t *); -static inline void nand_write_buf_byte(device_t, const void *, size_t); -static inline void nand_write_buf_word(device_t, const void *, size_t); +static inline void nand_read_buf_1(device_t, void *, size_t); +static inline void nand_read_buf_2(device_t, void *, size_t); +static inline void nand_read_1(device_t, uint8_t *); +static inline void nand_write_buf_1(device_t, const void *, size_t); +static inline void nand_write_buf_2(device_t, const void *, size_t); //static inline bool nand_block_isbad(device_t, off_t); //static inline void nand_block_markbad(device_t, off_t); //static inline bool nand_isbusy(device_t); Index: src/sys/dev/nand/nand_micron.c diff -u src/sys/dev/nand/nand_micron.c:1.4 src/sys/dev/nand/nand_micron.c:1.5 --- src/sys/dev/nand/nand_micron.c:1.4 Sun May 1 13:20:28 2011 +++ src/sys/dev/nand/nand_micron.c Tue Jun 28 07:16:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: nand_micron.c,v 1.4 2011/05/01 13:20:28 rmind Exp $ */ +/* $NetBSD: nand_micron.c,v 1.5 2011/06/28 07:16:11 ahoka Exp $ */ /*- * Copyright (c) 2011 Department of Software Engineering, @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nand_micron.c,v 1.4 2011/05/01 13:20:28 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nand_micron.c,v 1.5 2011/06/28 07:16:11 ahoka Exp $"); #include "nand.h" #include "onfi.h" @@ -107,10 +107,10 @@ nand_select(self, true); nand_command(self, ONFI_READ_ID); nand_address(self, 0x00); - nand_read_byte(self, &mfgrid); - nand_read_byte(self, &devid); - nand_read_byte(self, &dontcare); - nand_read_byte(self, ¶ms); + nand_read_1(self, &mfgrid); + nand_read_1(self, &devid); + nand_read_1(self, &dontcare); + nand_read_1(self, ¶ms); nand_select(self, false); KASSERT(chip->nc_manf_id == mfgrid); @@ -137,7 +137,7 @@ dp = nand_micron_device_lookup(devid); if (dp == NULL) { - aprint_error_dev(self, "unknown device id %#x\n", devid); + aprint_error_dev(self, "unknown device id %#x\n", devid); return 1; }