Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/nand Endiannes fixes from Brett Slager in ONFI Param...
details: https://anonhg.NetBSD.org/src/rev/86d736190543
branches: trunk
changeset: 782453:86d736190543
user: ahoka <ahoka%NetBSD.org@localhost>
date: Sat Nov 03 12:45:28 2012 +0000
description:
Endiannes fixes from Brett Slager in ONFI Param page parsing.
Similar changes in nandemulator by me.
Remove panic about more than one LUNs.
diffstat:
sys/dev/nand/nand.c | 34 +++++++++++++++-------------------
sys/dev/nand/nandemulator.c | 17 +++++++++--------
2 files changed, 24 insertions(+), 27 deletions(-)
diffs (110 lines):
diff -r efccfe601cf4 -r 86d736190543 sys/dev/nand/nand.c
--- a/sys/dev/nand/nand.c Sat Nov 03 12:12:48 2012 +0000
+++ b/sys/dev/nand/nand.c Sat Nov 03 12:45:28 2012 +0000
@@ -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 @@
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_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 = 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_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;
}
diff -r efccfe601cf4 -r 86d736190543 sys/dev/nand/nandemulator.c
--- a/sys/dev/nand/nandemulator.c Sat Nov 03 12:12:48 2012 +0000
+++ b/sys/dev/nand/nandemulator.c Sat Nov 03 12:45:28 2012 +0000
@@ -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 @@
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 @@
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
Home |
Main Index |
Thread Index |
Old Index