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