1#-
2# Copyright (C) 2009-2012 Semihalf
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD$
27
28# NAND chip interface description
29#
30
31#include <sys/bus.h>
32#include <dev/nand/nand.h>
33
34INTERFACE nand;
35
36CODE {
37	static int nand_method_not_supported(device_t dev)
38	{
39		return (ENOENT);
40	}
41};
42
43# Read NAND page
44#
45# Return values:
46# 0: Success
47#
48METHOD int read_page {
49	device_t dev;
50	uint32_t page;
51	void* buf;
52	uint32_t len;
53	uint32_t offset;
54};
55
56# Program NAND page
57#
58# Return values:
59# 0: Success
60#
61METHOD int program_page {
62	device_t dev;
63	uint32_t page;
64	void* buf;
65	uint32_t len;
66	uint32_t offset;
67};
68
69# Program NAND page interleaved
70#
71# Return values:
72# 0: Success
73#
74METHOD int program_page_intlv {
75	device_t dev;
76	uint32_t page;
77	void* buf;
78	uint32_t len;
79	uint32_t offset;
80} DEFAULT nand_method_not_supported;
81
82# Read NAND oob
83#
84# Return values:
85# 0: Success
86#
87METHOD int read_oob {
88	device_t dev;
89	uint32_t page;
90	void* buf;
91	uint32_t len;
92	uint32_t offset;
93};
94
95# Program NAND oob
96#
97# Return values:
98# 0: Success
99#
100METHOD int program_oob {
101	device_t dev;
102	uint32_t page;
103	void* buf;
104	uint32_t len;
105	uint32_t offset;
106};
107
108# Erase NAND block
109#
110# Return values:
111# 0: Success
112#
113METHOD int erase_block {
114	device_t dev;
115	uint32_t block;
116};
117
118# Erase NAND block interleaved
119#
120# Return values:
121# 0: Success
122#
123METHOD int erase_block_intlv {
124	device_t dev;
125	uint32_t block;
126} DEFAULT nand_method_not_supported;
127
128# NAND get status
129#
130# Return values:
131# 0: Success
132#
133METHOD int get_status {
134	device_t dev;
135	uint8_t *status;
136};
137
138# NAND check if block is bad
139#
140# Return values:
141# 0: Success
142#
143METHOD int is_blk_bad {
144	device_t dev;
145	uint32_t block_number;
146	uint8_t  *bad;
147};
148
149# NAND get ECC
150#
151#
152METHOD int get_ecc {
153	device_t dev;
154	void *buf;
155	void *ecc;
156	int *needwrite;
157};
158
159# NAND correct ECC
160#
161#
162METHOD int correct_ecc {
163	device_t dev;
164	void *buf;
165	void *readecc;
166	void *calcecc;
167};
168
169