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

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

	return status;
}
Beispiel #2
0
static int nuc910_nand_write_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_nandwrite(&nuc910_nand->io, data, data_size);
	if (result != ERROR_NAND_NO_BUFFER)
		return result;

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

	return ERROR_OK;
}