nand_micron.c revision 1.1 1 /*-
2 * Copyright (c) 2011 Department of Software Engineering,
3 * University of Szeged, Hungary
4 * Copyright (c) 2011 Adam Hoka <ahoka (at) NetBSD.org>
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by the Department of Software Engineering, University of Szeged, Hungary
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 /*
33 * Device specific functions for legacy Micron NAND chips
34 *
35 * Currently supported:
36 * MT29F2G08AACWP, MT29F4G08BACWP, MT29F8G08FACWP
37 */
38
39 #include "nand.h"
40 #include "onfi.h"
41
42 int
43 nand_read_parameters_micron(device_t self, struct nand_chip *chip)
44 {
45 uint8_t byte;
46
47 KASSERT(chip->nc_manf_id == NAND_MFR_MICRON);
48
49 nand_select(self, true);
50 nand_command(self, ONFI_READ_ID);
51 nand_address(self, 0x00);
52
53 switch (chip->nc_manf_id) {
54 /* three dummy reads */
55 nand_read_byte(self, &byte); /* vendor */
56 nand_read_byte(self, &byte); /* device */
57 nand_read_byte(self, &byte); /* unused */
58
59 /* this is the interesting one */
60 nand_read_byte(self, &byte);
61 /* TODO actually get info */
62 nand_select(self, false);
63 return 1;
64
65 break;
66 default:
67 nand_select(self, false);
68 return 1;
69 }
70
71 chip->nc_num_luns = 1;
72 chip->nc_lun_blocks = chip->nc_size / chip->nc_block_size;
73
74 nand_select(self, false);
75
76 return 0;
77 }
78