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