PERFORCE change 132471 for review
Andrew Turner
andrew at FreeBSD.org
Fri Jan 4 00:43:18 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=132471
Change 132471 by andrew at andrew_hermies on 2008/01/04 08:43:15
Rename the softc to be inline with the filename
Rename p_bug to buf and p_spare to spare in s3c24x0_nand_read_page
Remove s3c24x0_nand_read_spare as it was unused and was merged into s3c24x0_nand_read_page
Affected files ...
.. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_nand.c#2 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c24x0_nand.c#2 (text+ko) ====
@@ -53,7 +53,7 @@
#define NAND_CMD_BLKERASEC 0xd0
#define NAND_CMD_RESET 0xff
-struct s3c2410_nand_softc {
+struct s3c24x0_nand_softc {
struct s3c2xx0_softc sc_sx;
bus_space_handle_t sc_nand_ioh;
@@ -89,10 +89,8 @@
static int s3c24x0_nand_attach(device_t);
/* Internal functions */
-static int s3c24x0_nand_read_page(struct s3c2410_nand_softc*, int,
+static int s3c24x0_nand_read_page(struct s3c24x0_nand_softc*, int,
u_int8_t*, u_int8_t*);
-//static int s3c24x0_nand_read_spare(struct s3c2410_nand_softc*, int,
-// u_int8_t *);
static d_strategy_t s3c24x0_nand_strategy;
@@ -105,7 +103,7 @@
static driver_t nand_s3c2410_driver = {
"nand",
s3c2410_nand_methods,
- sizeof(struct s3c2410_nand_softc),
+ sizeof(struct s3c24x0_nand_softc),
};
static devclass_t nand_devclass;
@@ -121,7 +119,7 @@
static int
s3c24x0_nand_attach(device_t dev)
{
- struct s3c2410_nand_softc *sc = device_get_softc(dev);
+ struct s3c24x0_nand_softc *sc = device_get_softc(dev);
const char *p = NULL;
intrmask_t intr_mask;
bus_space_handle_t ioh;
@@ -229,18 +227,13 @@
for (block = 0; block < sc->blocks_disk; block++) {
page = block * sc->pages_block;
s3c24x0_nand_read_page(sc, page, NULL, spare);
- //s3c24x0_nand_read_spare(sc, page, spare);
if (spare[5] == 0xFF) {
s3c24x0_nand_read_page(sc, page + (sc->data_size >> 8),
NULL, spare);
- //s3c24x0_nand_read_spare(sc, page + (sc->data_size >> 8),
- // spare);
if (spare[5] == 0xFF) {
/* The block is good */
continue;
}
- } else {
- printf("A: %X ", spare[0]);
}
printf("Bad block: %X\n", page);
}
@@ -290,12 +283,12 @@
static void
s3c24x0_nand_strategy(struct bio *bp)
{
- struct s3c2410_nand_softc *sc;
+ struct s3c24x0_nand_softc *sc;
u_long current_lblk, lpage, next_lblk, page, pagei;
u_int8_t *p_data;
long cnt;
- sc = (struct s3c2410_nand_softc*)bp->bio_disk->d_drv1;
+ sc = (struct s3c24x0_nand_softc*)bp->bio_disk->d_drv1;
if (sc == NULL) {
bp->bio_error = EINVAL;
goto bad;
@@ -441,18 +434,17 @@
/*
* Read a page from the NAND
- * TODO: check if p_buf is NULL and skip the page if it is
*/
static int
-s3c24x0_nand_read_page(struct s3c2410_nand_softc *sc, int page,
- u_int8_t *p_buf, u_int8_t *p_spare)
+s3c24x0_nand_read_page(struct s3c24x0_nand_softc *sc, int page,
+ u_int8_t *buf, u_int8_t *spare)
{
bus_space_handle_t ioh;
bus_space_tag_t iot;
intrmask_t intr_mask;
int i;
- KASSERT(p_buf != NULL || p_spare != NULL,
+ KASSERT(buf != NULL || spare != NULL,
("s3c24x0_nand_read_page: nothing to read"));
ioh = sc->sc_nand_ioh;
@@ -463,7 +455,7 @@
/* Issue the command read the page */
bus_space_write_1(iot, ioh, NANDFC_NFCMD,
- (p_buf != NULL) ? NAND_CMD_READ0 : NAND_CMD_READ2);
+ (buf != NULL) ? NAND_CMD_READ0 : NAND_CMD_READ2);
/* Output the address */
bus_space_write_1(iot, ioh, NANDFC_NFADDR, 0x00);
@@ -487,16 +479,16 @@
DELAY(12);
/* Enter a loop to read the bytes from the page */
- if (p_buf != NULL) {
+ if (buf != NULL) {
for (i = 0; i < sc->data_size; i++) {
- p_buf[i] = bus_space_read_1(iot, ioh, NANDFC_NFDATA);
+ buf[i] = bus_space_read_1(iot, ioh, NANDFC_NFDATA);
}
}
/* Check if the spare data area is to be read too */
- if (p_spare != NULL) {
+ if (spare != NULL) {
for (i = 0; i < sc->spare_size; i++) {
- p_spare[i] = bus_space_read_1(iot, ioh, NANDFC_NFDATA);
+ spare[i] = bus_space_read_1(iot, ioh, NANDFC_NFDATA);
}
}
@@ -505,49 +497,4 @@
return(0);
}
-#if 0
-static int
-s3c24x0_nand_read_spare(struct s3c2410_nand_softc *sc, int page,
- u_int8_t *p_buf)
-{
- bus_space_handle_t ioh;
- bus_space_tag_t iot;
- intrmask_t intr_mask;
- int i;
-
- ioh = sc->sc_nand_ioh;
- iot = sc->sc_sx.sc_iot;
-
- intr_mask = splbio();
-
- /* Issue the command to read the spare area */
- bus_space_write_1(iot, ioh, NANDFC_NFCMD, NAND_CMD_READ2);
-
- /* Set the address */
- bus_space_write_1(iot, ioh, NANDFC_NFADDR, 0x00);
- bus_space_write_1(iot, ioh, NANDFC_NFADDR, page & 0xff);
- bus_space_write_1(iot, ioh, NANDFC_NFADDR, (page >> 8) & 0xff);
-
- /* Check if a 4th address cycle is required */
- /* TODO: Fix the if statement */
- //if (sc->device_type >= 64) {
- /* Output the 4th address cycle */
- // bus_space_write_1(iot, ioh, NANDFC_NFADDR, (page >> 16) & 0xff);
- //}
-
- /* The maximum time (tR) for data transfer from the cell to the register is 12 microseconds */
- DELAY(12);
-
- /* Enter a loop to read the bytes from the spare area */
- for (i = 0; i < sc->spare_size; i++) {
- /* Read the next byte */
- p_buf[i] = bus_space_read_1(iot, ioh, NANDFC_NFDATA);
- }
-
- splx(intr_mask);
-
- return (0);
-}
-#endif
-
DRIVER_MODULE(nand, s3c2410, nand_s3c2410_driver, nand_devclass, 0, 0);
More information about the p4-projects
mailing list