Module Name: src Committed By: ahoka Date: Sat Nov 3 12:45:28 UTC 2012
Modified Files: src/sys/dev/nand: nand.c nandemulator.c Log Message: Endiannes fixes from Brett Slager in ONFI Param page parsing. Similar changes in nandemulator by me. Remove panic about more than one LUNs. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/nand/nand.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/nand/nandemulator.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.21 src/sys/dev/nand/nand.c:1.22 --- src/sys/dev/nand/nand.c:1.21 Sat Nov 3 12:12:48 2012 +++ src/sys/dev/nand/nand.c Sat Nov 3 12:45:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: nand.c,v 1.21 2012/11/03 12:12:48 ahoka Exp $ */ +/* $NetBSD: nand.c,v 1.22 2012/11/03 12:45:28 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.21 2012/11/03 12:12:48 ahoka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.22 2012/11/03 12:45:28 ahoka Exp $"); #include "locators.h" @@ -550,33 +550,29 @@ nand_fill_chip_structure(device_t self, aprint_normal_dev(self, "vendor: %s, model: %s\n", vendor, model); - /* XXX TODO multiple LUNs */ - if (params.param_numluns != 1) { - aprint_error_dev(self, - "more than one LUNs are not supported yet!\n"); - - return 1; - } - - chip->nc_size = params.param_pagesize * params.param_blocksize * - params.param_lunsize * params.param_numluns; - - chip->nc_page_size = params.param_pagesize; - chip->nc_block_size = params.param_blocksize * params.param_pagesize; - chip->nc_spare_size = params.param_sparesize; - chip->nc_lun_blocks = params.param_lunsize; + chip->nc_page_size = le32toh(params.param_pagesize); + chip->nc_block_size = + le32toh(params.param_blocksize) * chip->nc_page_size; + chip->nc_spare_size = le16toh(params.param_sparesize); + chip->nc_lun_blocks = le32toh(params.param_lunsize); chip->nc_num_luns = params.param_numluns; + chip->nc_size = + chip->nc_block_size * chip->nc_lun_blocks * chip->nc_num_luns; + /* the lower 4 bits contain the row address cycles */ chip->nc_addr_cycles_row = params.param_addr_cycles & 0x07; /* the upper 4 bits contain the column address cycles */ chip->nc_addr_cycles_column = (params.param_addr_cycles & ~0x07) >> 4; - if (params.param_features & ONFI_FEATURE_16BIT) + uint16_t features = le16toh(params.param_features); + if (features & ONFI_FEATURE_16BIT) { chip->nc_flags |= NC_BUSWIDTH_16; + } - if (params.param_features & ONFI_FEATURE_EXTENDED_PARAM) + if (features & ONFI_FEATURE_EXTENDED_PARAM) { chip->nc_flags |= NC_EXTENDED_PARAM; + } return 0; } Index: src/sys/dev/nand/nandemulator.c diff -u src/sys/dev/nand/nandemulator.c:1.5 src/sys/dev/nand/nandemulator.c:1.6 --- src/sys/dev/nand/nandemulator.c:1.5 Tue Jun 28 10:32:45 2011 +++ src/sys/dev/nand/nandemulator.c Sat Nov 3 12:45:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: nandemulator.c,v 1.5 2011/06/28 10:32:45 ahoka Exp $ */ +/* $NetBSD: nandemulator.c,v 1.6 2012/11/03 12:45:28 ahoka Exp $ */ /*- * Copyright (c) 2011 Department of Software Engineering, @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nandemulator.c,v 1.5 2011/06/28 10:32:45 ahoka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nandemulator.c,v 1.6 2012/11/03 12:45:28 ahoka Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -235,11 +235,11 @@ nandemulator_attach(device_t parent, dev for (i = 0; i < 4; i++) { opp = &sc->sc_parameter_page[i]; - opp->param_signature = *(uint32_t *)sig; - opp->param_pagesize = sc->sc_page_size; - opp->param_blocksize = sc->sc_block_size; - opp->param_sparesize = sc->sc_spare_size; - opp->param_lunsize = sc->sc_lun_size; + opp->param_signature = htole32(*(uint32_t *)sig); + opp->param_pagesize = htole32(sc->sc_page_size); + opp->param_blocksize = htole32(sc->sc_block_size); + opp->param_sparesize = htole16(sc->sc_spare_size); + opp->param_lunsize = htole32(sc->sc_lun_size); opp->param_numluns = 1; opp->param_manufacturer_id = 0x00; @@ -248,7 +248,8 @@ nandemulator_attach(device_t parent, dev memcpy(opp->param_model, "NANDEMULATOR", strlen("NANDEMULATOR")); - opp->param_features = ONFI_FEATURE_16BIT; + uint16_t features = ONFI_FEATURE_16BIT; + opp->param_features = htole16(features); /* the lower 4 bits contain the row address cycles * the upper 4 bits contain the column address cycles