Remove FSF address from GPL notices
[openocd.git] / src / flash / nand / driver.h
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de> *
3 * Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> *
4 * Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
5 * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
6 * *
7 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
19 ***************************************************************************/
20
21 #ifndef FLASH_NAND_DRIVER_H
22 #define FLASH_NAND_DRIVER_H
23
24 struct nand_device;
25
26 #define __NAND_DEVICE_COMMAND(name) \
27 COMMAND_HELPER(name, struct nand_device *nand)
28
29 /**
30 * Interface for NAND flash controllers. Not all of these functions are
31 * required for full functionality of the NAND driver, but better performance
32 * can be achieved by implementing each function.
33 */
34 struct nand_flash_controller {
35 /** Driver name that is used to select it from configuration files. */
36 const char *name;
37
38 /** Usage of flash command registration. */
39 const char *usage;
40
41 const struct command_registration *commands;
42
43 /** NAND device command called when driver is instantiated during configuration. */
44 __NAND_DEVICE_COMMAND((*nand_device_command));
45
46 /** Initialize the NAND device. */
47 int (*init)(struct nand_device *nand);
48
49 /** Reset the NAND device. */
50 int (*reset)(struct nand_device *nand);
51
52 /** Issue a command to the NAND device. */
53 int (*command)(struct nand_device *nand, uint8_t command);
54
55 /** Write an address to the NAND device. */
56 int (*address)(struct nand_device *nand, uint8_t address);
57
58 /** Write word of data to the NAND device. */
59 int (*write_data)(struct nand_device *nand, uint16_t data);
60
61 /** Read word of data from the NAND device. */
62 int (*read_data)(struct nand_device *nand, void *data);
63
64 /** Write a block of data to the NAND device. */
65 int (*write_block_data)(struct nand_device *nand, uint8_t *data, int size);
66
67 /** Read a block of data from the NAND device. */
68 int (*read_block_data)(struct nand_device *nand, uint8_t *data, int size);
69
70 /** Write a page to the NAND device. */
71 int (*write_page)(struct nand_device *nand, uint32_t page, uint8_t *data,
72 uint32_t data_size, uint8_t *oob, uint32_t oob_size);
73
74 /** Read a page from the NAND device. */
75 int (*read_page)(struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size,
76 uint8_t *oob, uint32_t oob_size);
77
78 /** Check if the NAND device is ready for more instructions with timeout. */
79 int (*nand_ready)(struct nand_device *nand, int timeout);
80 };
81
82 #define NAND_DEVICE_COMMAND_HANDLER(name) static __NAND_DEVICE_COMMAND(name)
83
84 /**
85 * Find a NAND flash controller by name.
86 * @param name Identifies the NAND controller to find.
87 * @returns The nand_flash_controller named @c name, or NULL if not found.
88 */
89 struct nand_flash_controller *nand_driver_find_by_name(const char *name);
90
91 /** Signature for callback functions passed to nand_driver_walk */
92 typedef int (*nand_driver_walker_t)(struct nand_flash_controller *c, void *);
93 /**
94 * Walk the list of drivers, encapsulating the data structure type.
95 * Application state/context can be passed through the @c x pointer.
96 * @param f The callback function to invoke for each function.
97 * @param x For use as private data storate, passed directly to @c f.
98 * @returns ERROR_OK if successful, or the non-zero return value of @c f.
99 * This allows a walker to terminate the loop early.
100 */
101 int nand_driver_walk(nand_driver_walker_t f, void *x);
102
103 #endif /* FLASH_NAND_DRIVER_H */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)