Beispiel #1
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(nand->target, "read block"))
		return ERROR_NAND_OPERATION_FAILED;

	io->chunk_size = nand->page_size;
	status = arm_nandread(io, data, size);

	return status;
}
Beispiel #2
0
static int nuc910_nand_read_block_data(struct nand_device *nand,
		uint8_t *data, int data_size)
{
	struct nuc910_nand_controller *nuc910_nand = nand->controller_priv;
	int result;

	if ((result = validate_target_state(nand)) != ERROR_OK)
		return result;

	nuc910_nand->io.chunk_size = nand->page_size;

	/* try the fast way first */
	result = arm_nandread(&nuc910_nand->io, data, data_size);
	if (result != ERROR_NAND_NO_BUFFER)
		return result;

	/* else do it slowly */
	while (data_size--)
		nuc910_nand_read(nand, data++);

	return ERROR_OK;
}