1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #pragma once
3 
4 /*
5  * Copyright © 2010 - Maxim Levitsky
6  *
7  * mtd_probe is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * mtd_probe is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with mtd_probe; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA  02110-1301  USA
21  */
22 
23 #include <mtd/mtd-user.h>
24 
25 #include "macro.h"
26 
27 /* Full oob structure as written on the flash */
28 struct sm_oob {
29         uint32_t reserved;
30         uint8_t data_status;
31         uint8_t block_status;
32         uint8_t lba_copy1[2];
33         uint8_t ecc2[3];
34         uint8_t lba_copy2[2];
35         uint8_t ecc1[3];
36 } _packed_;
37 
38 /* one sector is always 512 bytes, but it can consist of two nand pages */
39 #define SM_SECTOR_SIZE                512
40 
41 /* oob area is also 16 bytes, but might be from two pages */
42 #define SM_OOB_SIZE                16
43 
44 /* This is maximum zone size, and all devices that have more that one zone
45    have this size */
46 #define SM_MAX_ZONE_SIZE         1024
47 
48 /* support for small page nand */
49 #define SM_SMALL_PAGE                 256
50 #define SM_SMALL_OOB_SIZE        8
51 
52 int probe_smart_media(int mtd_fd, mtd_info_t *info);
53