summaryrefslogtreecommitdiff
path: root/src/flash/nand/driver.c
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-12-04 18:24:14 -0800
committerZachary T Welch <zw@superlucidity.net>2009-12-04 21:41:23 -0800
commita7fd30c07fb9c2b7662ffaa48287b1997dc60796 (patch)
tree8f937fdbec9fd1e55d864a435553b72e3ce1df15 /src/flash/nand/driver.c
parentaf1d7590edf04077aa8f22fba9097e0c68431f68 (diff)
downloadopenocd+libswd-a7fd30c07fb9c2b7662ffaa48287b1997dc60796.tar.gz
openocd+libswd-a7fd30c07fb9c2b7662ffaa48287b1997dc60796.tar.bz2
openocd+libswd-a7fd30c07fb9c2b7662ffaa48287b1997dc60796.tar.xz
openocd+libswd-a7fd30c07fb9c2b7662ffaa48287b1997dc60796.zip
split NAND driver handling into nand/driver.[ch]
This work parallels the NOR directory, encapsulating the NAND drivers into a separate file. This takes an extra step by encapsulating the type of data structure used to manage the drivers, allowing it to be changed from an array to a dynamic list in the future.
Diffstat (limited to 'src/flash/nand/driver.c')
-rw-r--r--src/flash/nand/driver.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/flash/nand/driver.c b/src/flash/nand/driver.c
new file mode 100644
index 00000000..717f5aaa
--- /dev/null
+++ b/src/flash/nand/driver.c
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de> *
+ * Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> *
+ * Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
+ * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <flash/nand.h>
+#include "driver.h"
+
+/* NAND flash controller
+ */
+extern struct nand_flash_controller nonce_nand_controller;
+extern struct nand_flash_controller davinci_nand_controller;
+extern struct nand_flash_controller lpc3180_nand_controller;
+extern struct nand_flash_controller orion_nand_controller;
+extern struct nand_flash_controller s3c2410_nand_controller;
+extern struct nand_flash_controller s3c2412_nand_controller;
+extern struct nand_flash_controller s3c2440_nand_controller;
+extern struct nand_flash_controller s3c2443_nand_controller;
+extern struct nand_flash_controller imx31_nand_flash_controller;
+
+/* extern struct nand_flash_controller boundary_scan_nand_controller; */
+
+static struct nand_flash_controller *nand_flash_controllers[] =
+{
+ &nonce_nand_controller,
+ &davinci_nand_controller,
+ &lpc3180_nand_controller,
+ &orion_nand_controller,
+ &s3c2410_nand_controller,
+ &s3c2412_nand_controller,
+ &s3c2440_nand_controller,
+ &s3c2443_nand_controller,
+ &imx31_nand_flash_controller,
+/* &boundary_scan_nand_controller, */
+ NULL
+};
+
+struct nand_flash_controller *nand_driver_find_by_name(const char *name)
+{
+ for (unsigned i = 0; nand_flash_controllers[i]; i++)
+ {
+ struct nand_flash_controller *controller = nand_flash_controllers[i];
+ if (strcmp(name, controller->name) == 0)
+ return controller;
+ }
+ return NULL;
+}
+int nand_driver_walk(nand_driver_walker_t f, void *x)
+{
+ for (unsigned i = 0; nand_flash_controllers[i]; i++)
+ {
+ int retval = (*f)(nand_flash_controllers[i], x);
+ if (ERROR_OK != retval)
+ return retval;
+ }
+ return ERROR_OK;
+}
+
+