summaryrefslogtreecommitdiff
path: root/src/flash/nand
diff options
context:
space:
mode:
Diffstat (limited to 'src/flash/nand')
-rw-r--r--src/flash/nand/Makefile.am3
-rw-r--r--src/flash/nand/at91sam9.c750
-rw-r--r--src/flash/nand/driver.c2
3 files changed, 754 insertions, 1 deletions
diff --git a/src/flash/nand/Makefile.am b/src/flash/nand/Makefile.am
index f3033b85..bb9998e5 100644
--- a/src/flash/nand/Makefile.am
+++ b/src/flash/nand/Makefile.am
@@ -24,7 +24,8 @@ NAND_DRIVERS = \
s3c2410.c \
s3c2412.c \
s3c2440.c \
- s3c2443.c
+ s3c2443.c \
+ at91sam9.c
noinst_HEADERS = \
arm_io.h \
diff --git a/src/flash/nand/at91sam9.c b/src/flash/nand/at91sam9.c
new file mode 100644
index 00000000..7cfd763a
--- /dev/null
+++ b/src/flash/nand/at91sam9.c
@@ -0,0 +1,750 @@
+/*
+ * Copyright (C) 2009 by Dean Glazeski
+ * dnglaze@gmail.com
+ *
+ * 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 <target/arm.h>
+#include <helper/log.h>
+#include "imp.h"
+#include "arm_io.h"
+
+#define AT91C_PIOx_SODR (0x30) /**< Offset to PIO SODR. */
+#define AT91C_PIOx_CODR (0x34) /**< Offset to PIO CODR. */
+#define AT91C_PIOx_PDSR (0x3C) /**< Offset to PIO PDSR. */
+#define AT91C_ECCx_CR (0x00) /**< Offset to ECC CR. */
+#define AT91C_ECCx_SR (0x08) /**< Offset to ECC SR. */
+#define AT91C_ECCx_PR (0x0C) /**< Offset to ECC PR. */
+#define AT91C_ECCx_NPR (0x10) /**< Offset to ECC NPR. */
+
+/**
+ * Representation of a pin on an AT91SAM9 chip.
+ */
+struct at91sam9_pin {
+ /** Target this pin is on. */
+ struct target *target;
+
+ /** Address of the PIO controller. */
+ uint32_t pioc;
+
+ /** Pin number. */
+ uint32_t num;
+};
+
+/**
+ * Private data for the controller that is stored in the NAND device structure.
+ */
+struct at91sam9_nand {
+ /** Target the NAND is attached to. */
+ struct target *target;
+
+ /** Address of the ECC controller for NAND. */
+ uint32_t ecc;
+
+ /** Address data is written to. */
+ uint32_t data;
+
+ /** Address commands are written to. */
+ uint32_t cmd;
+
+ /** Address addresses are written to. */
+ uint32_t addr;
+
+ /** I/O structure for hosted reads/writes. */
+ struct arm_nand_data io;
+
+ /** Pin representing the ready/~busy line. */
+ struct at91sam9_pin busy;
+
+ /** Pin representing the chip enable. */
+ struct at91sam9_pin ce;
+};
+
+/**
+ * Checks if the target is halted and prints an error message if it isn't.
+ *
+ * @param target Target to be checked.
+ * @param label String label for where function is called from.
+ * @return True if the target is halted.
+ */
+static int at91sam9_halted(struct target *target, const char *label)
+{
+ if (target->state == TARGET_HALTED)
+ return true;
+
+ LOG_ERROR("Target must be halted to use NAND controller (%s)", label);
+ return false;
+}
+
+/**
+ * Initialize the AT91SAM9 NAND controller.
+ *
+ * @param nand NAND device the controller is attached to.
+ * @return Success or failure of initialization.
+ */
+static int at91sam9_init(struct nand_device *nand)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+
+ if (!at91sam9_halted(target, "init")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ return ERROR_OK;
+}
+
+/**
+ * Enable NAND device attached to a controller.
+ *
+ * @param info NAND controller information for controlling NAND device.
+ * @return Success or failure of the enabling.
+ */
+static int at91sam9_enable(struct at91sam9_nand *info)
+{
+ struct target *target = info->target;
+
+ return target_write_u32(target, info->ce.pioc + AT91C_PIOx_CODR, 1 << info->ce.num);
+}
+
+/**
+ * Disable NAND device attached to a controller.
+ *
+ * @param info NAND controller information for controlling NAND device.
+ * @return Success or failure of the disabling.
+ */
+static int at91sam9_disable(struct at91sam9_nand *info)
+{
+ struct target *target = info->target;
+
+ return target_write_u32(target, info->ce.pioc + AT91C_PIOx_SODR, 1 << info->ce.num);
+}
+
+/**
+ * Send a command to the NAND device.
+ *
+ * @param nand NAND device to write the command to.
+ * @param command Command to be written.
+ * @return Success or failure of writing the command.
+ */
+static int at91sam9_command(struct nand_device *nand, uint8_t command)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+
+ if (!at91sam9_halted(target, "command")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ at91sam9_enable(info);
+
+ return target_write_u8(target, info->cmd, command);
+}
+
+/**
+ * Reset the AT91SAM9 NAND controller.
+ *
+ * @param nand NAND device to be reset.
+ * @return Success or failure of reset.
+ */
+static int at91sam9_reset(struct nand_device *nand)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+
+ if (!at91sam9_halted(info->target, "reset")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ return at91sam9_disable(info);
+}
+
+/**
+ * Send an address to the NAND device attached to an AT91SAM9 NAND controller.
+ *
+ * @param nand NAND device to send the address to.
+ * @param address Address to be sent.
+ * @return Success or failure of sending the address.
+ */
+static int at91sam9_address(struct nand_device *nand, uint8_t address)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+
+ if (!at91sam9_halted(info->target, "address")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ return target_write_u8(target, info->addr, address);
+}
+
+/**
+ * Read data directly from the NAND device attached to an AT91SAM9 NAND
+ * controller.
+ *
+ * @param nand NAND device to read from.
+ * @param data Pointer to where the data should be put.
+ * @return Success or failure of reading the data.
+ */
+static int at91sam9_read_data(struct nand_device *nand, void *data)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+
+ if (!at91sam9_halted(info->target, "read data")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ return target_read_u8(target, info->data, data);
+}
+
+/**
+ * Write data directly to the NAND device attached to an AT91SAM9 NAND
+ * controller.
+ *
+ * @param nand NAND device to be written to.
+ * @param data Data to be written.
+ * @return Success or failure of the data write.
+ */
+static int at91sam9_write_data(struct nand_device *nand, uint16_t data)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+
+ if (!at91sam9_halted(target, "write data")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ return target_write_u8(target, info->data, data);
+}
+
+/**
+ * Determine if the NAND device is ready by looking at the ready/~busy pin.
+ *
+ * @param nand NAND device to check.
+ * @param timeout Time in milliseconds to wait for NAND to be ready.
+ * @return True if the NAND is ready in the timeout period.
+ */
+static int at91sam9_nand_ready(struct nand_device *nand, int timeout)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+ uint32_t status;
+
+ if (!at91sam9_halted(target, "nand ready")) {
+ return 0;
+ }
+
+ do {
+ target_read_u32(target, info->busy.pioc + AT91C_PIOx_PDSR, &status);
+
+ if (status & (1 << info->busy.num)) {
+ return 1;
+ }
+
+ alive_sleep(1);
+ } while (timeout-- > 0);
+
+ return 0;
+}
+
+/**
+ * Read a block of data from the NAND device attached to an AT91SAM9. This
+ * utilizes the ARM hosted NAND read function.
+ *
+ * @param nand NAND device to read from.
+ * @param data Pointer to where the read data should be placed.
+ * @param size Size of the data being read.
+ * @return Success or failure of the hosted read.
+ */
+static int at91sam9_read_block_data(struct nand_device *nand, uint8_t *data, int size)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct arm_nand_data *io = &info->io;
+ int status;
+
+ if (!at91sam9_halted(info->target, "read block")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ io->chunk_size = nand->page_size;
+ status = arm_nandread(io, data, size);
+
+ return status;
+}
+
+/**
+ * Write a block of data to a NAND device attached to an AT91SAM9. This uses
+ * the ARM hosted write function to write the data.
+ *
+ * @param nand NAND device to write to.
+ * @param data Data to be written to device.
+ * @param size Size of the data being written.
+ * @return Success or failure of the hosted write.
+ */
+static int at91sam9_write_block_data(struct nand_device *nand, uint8_t *data, int size)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct arm_nand_data *io = &info->io;
+ int status;
+
+ if (!at91sam9_halted(info->target, "write block")) {
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ io->chunk_size = nand->page_size;
+ status = arm_nandwrite(io, data, size);
+
+ return status;
+}
+
+/**
+ * Initialize the ECC controller on the AT91SAM9.
+ *
+ * @param target Target to configure ECC on.
+ * @param info NAND controller information for where the ECC is.
+ * @return Success or failure of initialization.
+ */
+static int at91sam9_ecc_init(struct target *target, struct at91sam9_nand *info)
+{
+ if (!info->ecc) {
+ LOG_ERROR("ECC controller address must be set when not reading raw NAND data");
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ // reset ECC parity registers
+ return target_write_u32(target, info->ecc + AT91C_ECCx_CR, 1);
+}
+
+/**
+ * Initialize an area for the OOB based on whether a user is requesting the OOB
+ * data. This determines the size of the OOB and allocates the space in case
+ * the user has not requested the OOB data.
+ *
+ * @param nand NAND device we are creating an OOB for.
+ * @param oob Pointer to the user supplied OOB area.
+ * @param size Size of the OOB.
+ * @return Pointer to an area to store OOB data.
+ */
+static uint8_t * at91sam9_oob_init(struct nand_device *nand, uint8_t *oob, uint32_t *size)
+{
+ if (!oob) {
+ // user doesn't want OOB, allocate it
+ if (nand->page_size == 512) {
+ *size = 16;
+ } else if (nand->page_size == 2048) {
+ *size = 64;
+ }
+
+ oob = malloc(*size);
+ if (!oob) {
+ LOG_ERROR("Unable to allocate space for OOB");
+ }
+
+ memset(oob, 0xFF, *size);
+ }
+
+ return oob;
+}
+
+/**
+ * Reads a page from an AT91SAM9 NAND controller and verifies using 1-bit ECC
+ * controller on chip. This makes an attempt to correct any errors that are
+ * encountered while reading the page of data.
+ *
+ * @param nand NAND device to read from
+ * @param page Page to be read.
+ * @param data Pointer to where data should be read to.
+ * @param data_size Size of the data to be read.
+ * @param oob Pointer to where OOB data should be read to.
+ * @param oob_size Size of the OOB data to be read.
+ * @return Success or failure of reading the NAND page.
+ */
+static int at91sam9_read_page(struct nand_device *nand, uint32_t page,
+ uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
+{
+ int retval;
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+ uint8_t *oob_data;
+ uint32_t status;
+
+ retval = at91sam9_ecc_init(target, info);
+ if (ERROR_OK != retval) {
+ return retval;
+ }
+
+ retval = nand_page_command(nand, page, NAND_CMD_READ0, !data);
+ if (ERROR_OK != retval) {
+ return retval;
+ }
+
+ if (data) {
+ retval = nand_read_data_page(nand, data, data_size);
+ if (ERROR_OK != retval) {
+ return retval;
+ }
+ }
+
+ oob_data = at91sam9_oob_init(nand, oob, &oob_size);
+ retval = nand_read_data_page(nand, oob_data, oob_size);
+ if (ERROR_OK == retval && data) {
+ target_read_u32(target, info->ecc + AT91C_ECCx_SR, &status);
+ if (status & 1) {
+ LOG_ERROR("Error detected!");
+ if (status & 4) {
+ LOG_ERROR("Multiple errors encountered; unrecoverable!");
+ } else {
+ // attempt recovery
+ uint32_t parity;
+
+ target_read_u32(target, info->ecc + AT91C_ECCx_PR, &parity);
+ uint32_t word = (parity & 0x0000FFF0) >> 4;
+ uint32_t bit = parity & 0x0F;
+
+ data[word] ^= (0x1) << bit;
+ LOG_INFO("Data word %d, bit %d corrected.", word, bit);
+ }
+ }
+
+ if (status & 2) {
+ // we could write back correct ECC data
+ LOG_ERROR("Error in ECC bytes detected");
+ }
+ }
+
+ if (!oob) {
+ // if it wasn't asked for, free it
+ free(oob_data);
+ }
+
+ return retval;
+}
+
+/**
+ * Write a page of data including 1-bit ECC information to a NAND device
+ * attached to an AT91SAM9 controller. If there is OOB data to be written,
+ * this will ignore the computed ECC from the ECC controller.
+ *
+ * @param nand NAND device to write to.
+ * @param page Page to write.
+ * @param data Pointer to data being written.
+ * @param data_size Size of the data being written.
+ * @param oob Pointer to OOB data being written.
+ * @param oob_size Size of the OOB data.
+ * @return Success or failure of the page write.
+ */
+static int at91sam9_write_page(struct nand_device *nand, uint32_t page,
+ uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
+{
+ struct at91sam9_nand *info = nand->controller_priv;
+ struct target *target = info->target;
+ int retval;
+ uint8_t *oob_data = oob;
+ uint32_t parity, nparity;
+
+ retval = at91sam9_ecc_init(target, info);
+ if (ERROR_OK != retval) {
+ return retval;
+ }
+
+ retval = nand_page_command(nand, page, NAND_CMD_SEQIN, !data);
+ if (ERROR_OK != retval) {
+ return retval;
+ }
+
+ if (data) {
+ retval = nand_write_data_page(nand, data, data_size);
+ if (ERROR_OK != retval) {
+ LOG_ERROR("Unable to write data to NAND device");
+ return retval;
+ }
+ }
+
+ oob_data = at91sam9_oob_init(nand, oob, &oob_size);
+
+ if (!oob) {
+ // no OOB given, so read in the ECC parity from the ECC controller
+ target_read_u32(target, info->ecc + AT91C_ECCx_PR, &parity);
+ target_read_u32(target, info->ecc + AT91C_ECCx_NPR, &nparity);
+
+ oob_data[0] = (uint8_t) parity;
+ oob_data[1] = (uint8_t) (parity >> 8);
+ oob_data[2] = (uint8_t) nparity;
+ oob_data[3] = (uint8_t) (nparity >> 8);
+ }
+
+ retval = nand_write_data_page(nand, oob_data, oob_size);
+
+ if (!oob) {
+ free(oob_data);
+ }
+
+ if (ERROR_OK != retval) {
+ LOG_ERROR("Unable to write OOB data to NAND");
+ return retval;
+ }
+
+ retval = nand_write_finish(nand);
+
+ return retval;
+}
+
+/**
+ * Handle the initial NAND device command for AT91SAM9 controllers. This
+ * initializes much of the controller information struct to be ready for future
+ * reads and writes.
+ */
+NAND_DEVICE_COMMAND_HANDLER(at91sam9_nand_device_command)
+{
+ struct target *target = NULL;
+ unsigned long chip = 0, ecc = 0;
+ struct at91sam9_nand *info = NULL;
+
+ LOG_DEBUG("AT91SAM9 NAND Device Command\n");
+
+ if (CMD_ARGC < 3 || CMD_ARGC > 4) {
+ LOG_ERROR("parameters: %s target chip_addr", CMD_ARGV[0]);
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ target = get_target(CMD_ARGV[1]);
+ if (!target) {
+ LOG_ERROR("invalid target: %s", CMD_ARGV[1]);
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], chip);
+ if (chip == 0) {
+ LOG_ERROR("invalid NAND chip address: %s", CMD_ARGV[2]);
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ if (CMD_ARGC == 4) {
+ COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[3], ecc);
+ if (ecc == 0) {
+ LOG_ERROR("invalid ECC controller address: %s", CMD_ARGV[3]);
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+ }
+
+ info = calloc(1, sizeof(*info));
+ if (!info) {
+ LOG_ERROR("unable to allocate space for controller private data");
+ return ERROR_NAND_OPERATION_FAILED;
+ }
+
+ info->target = target;
+ info->data = chip;
+ info->cmd = chip | (1 << 22);
+ info->addr = chip | (1 << 21);
+ info->ecc = ecc;
+
+ nand->controller_priv = info;
+ info->io.target = target;
+ info->io.data = info->data;
+ info->io.op = ARM_NAND_NONE;
+
+ return ERROR_OK;
+}
+
+/**
+ * Handle the AT91SAM9 CLE command for specifying the address line to use for
+ * writing commands to a NAND device.
+ */
+COMMAND_HANDLER(handle_at91sam9_cle_command)
+{
+ struct nand_device *nand = NULL;
+ struct at91sam9_nand *info = NULL;
+ unsigned num, address_line;
+
+ if (CMD_ARGC != 2) {
+ command_print(CMD_CTX, "incorrect number of arguments for 'at91sam9 cle' command");
+ return ERROR_OK;
+ }
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
+ nand = get_nand_device_by_num(num);
+ if (!nand) {
+ command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
+ return ERROR_OK;
+ }
+
+ info = nand->controller_priv;
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], address_line);
+ info->cmd = info->data | (1 << address_line);
+
+ return ERROR_OK;
+}
+
+/**
+ * Handle the AT91SAM9 ALE command for specifying the address line to use for
+ * writing addresses to the NAND device.
+ */
+COMMAND_HANDLER(handle_at91sam9_ale_command)
+{
+ struct nand_device *nand = NULL;
+ struct at91sam9_nand *info = NULL;
+ unsigned num, address_line;
+
+ if (CMD_ARGC != 2) {
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
+ nand = get_nand_device_by_num(num);
+ if (!nand) {
+ command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+
+ info = nand->controller_priv;
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], address_line);
+ info->addr = info->data | (1 << address_line);
+
+ return ERROR_OK;
+}
+
+/**
+ * Handle the AT91SAM9 RDY/~BUSY command for specifying the pin that watches the
+ * RDY/~BUSY line from the NAND device.
+ */
+COMMAND_HANDLER(handle_at91sam9_rdy_busy_command)
+{
+ struct nand_device *nand = NULL;
+ struct at91sam9_nand *info = NULL;
+ unsigned num, base_pioc, pin_num;
+
+ if (CMD_ARGC != 3) {
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
+ nand = get_nand_device_by_num(num);
+ if (!nand) {
+ command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+
+ info = nand->controller_priv;
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], base_pioc);
+ info->busy.pioc = base_pioc;
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], pin_num);
+ info->busy.num = pin_num;
+
+ return ERROR_OK;
+}
+
+/**
+ * Handle the AT91SAM9 CE command for specifying the pin that is used to enable
+ * or disable the NAND device.
+ */
+COMMAND_HANDLER(handle_at91sam9_ce_command)
+{
+ struct nand_device *nand = NULL;
+ struct at91sam9_nand *info = NULL;
+ unsigned num, base_pioc, pin_num;
+
+ if (CMD_ARGC != 3) {
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num);
+ nand = get_nand_device_by_num(num);
+ if (!nand) {
+ command_print(CMD_CTX, "invalid nand device number: %s", CMD_ARGV[0]);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
+ }
+
+ info = nand->controller_priv;
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], base_pioc);
+ info->ce.pioc = base_pioc;
+
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], pin_num);
+ info->ce.num = pin_num;
+
+ return ERROR_OK;
+}
+
+static const struct command_registration at91sam9_sub_command_handlers[] = {
+ {
+ .name = "cle",
+ .handler = handle_at91sam9_cle_command,
+ .mode = COMMAND_CONFIG,
+ .help = "set command latch enable address line (default is 22)",
+ .usage = "<device_id> <address_line>",
+ },
+ {
+ .name = "ale",
+ .handler = handle_at91sam9_ale_command,
+ .mode = COMMAND_CONFIG,
+ .help = "set address latch enable address line (default is 21)",
+ .usage = "<device_id> <address_line>",
+ },
+ {
+ .name = "rdy_busy",
+ .handler = handle_at91sam9_rdy_busy_command,
+ .mode = COMMAND_CONFIG,
+ .help = "set the input pin connected to RDY/~BUSY signal (no default)",
+ .usage = "<device_id> <base_pioc> <pin_num>",
+ },
+ {
+ .name = "ce",
+ .handler = handle_at91sam9_ce_command,
+ .mode = COMMAND_CONFIG,
+ .help = "set the output pin connected to chip enable signal (no default)",
+ .usage = "<device_id> <base_pioc> <pin_num>",
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+static const struct command_registration at91sam9_command_handler[] = {
+ {
+ .name = "at91sam9",
+ .mode = COMMAND_ANY,
+ .help = "AT91SAM9 NAND flash controller commands",
+ .chain = at91sam9_sub_command_handlers,
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+/**
+ * Structure representing the AT91SAM9 NAND controller.
+ */
+struct nand_flash_controller at91sam9_nand_controller = {
+ .name = "at91sam9",
+ .nand_device_command = at91sam9_nand_device_command,
+ .commands = at91sam9_command_handler,
+ .init = at91sam9_init,
+ .command = at91sam9_command,
+ .reset = at91sam9_reset,
+ .address = at91sam9_address,
+ .read_data = at91sam9_read_data,
+ .write_data = at91sam9_write_data,
+ .nand_ready = at91sam9_nand_ready,
+ .read_block_data = at91sam9_read_block_data,
+ .write_block_data = at91sam9_write_block_data,
+ .read_page = at91sam9_read_page,
+ .write_page = at91sam9_write_page,
+};
diff --git a/src/flash/nand/driver.c b/src/flash/nand/driver.c
index 1ccc4f44..0e174b23 100644
--- a/src/flash/nand/driver.c
+++ b/src/flash/nand/driver.c
@@ -37,6 +37,7 @@ 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 at91sam9_nand_controller;
/* extern struct nand_flash_controller boundary_scan_nand_controller; */
@@ -51,6 +52,7 @@ static struct nand_flash_controller *nand_flash_controllers[] =
&s3c2440_nand_controller,
&s3c2443_nand_controller,
&imx31_nand_flash_controller,
+ &at91sam9_nand_controller,
/* &boundary_scan_nand_controller, */
NULL
};
1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577