Esempio n. 1
0
static int virtual_info(struct flash_bank *bank, char *buf, int buf_size)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);

	if (master_bank == NULL)
		return ERROR_FLASH_OPERATION_FAILED;

	snprintf(buf, buf_size, "%s driver for flash bank %s at 0x%8.8" PRIx32 "",
			bank->driver->name, master_bank->name, master_bank->base);

	return ERROR_OK;
}
Esempio n. 2
0
static int virtual_protect_check(struct flash_bank *bank)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);
	int retval;

	if (master_bank == NULL) {
		return ERROR_FLASH_OPERATION_FAILED;
	}

	/* call master handler */
	if ((retval = master_bank->driver->protect_check(master_bank)) != ERROR_OK)
		return retval;

	return ERROR_OK;
}
Esempio n. 3
0
static void virtual_update_bank_info(struct flash_bank *bank)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);

	if (master_bank == NULL) {
		return;
	}

	/* update the info we do not have */
	bank->size = master_bank->size;
	bank->chip_width = master_bank->chip_width;
	bank->bus_width = master_bank->bus_width;
	bank->num_sectors = master_bank->num_sectors;
	bank->sectors = master_bank->sectors;
}
Esempio n. 4
0
static int virtual_protect(struct flash_bank *bank, int set, int first, int last)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);
	int retval;

	if (master_bank == NULL)
		return ERROR_FLASH_OPERATION_FAILED;

	/* call master handler */
	retval = master_bank->driver->protect(master_bank, set, first, last);
	if (retval != ERROR_OK)
		return retval;

	return ERROR_OK;
}
Esempio n. 5
0
static int virtual_blank_check(struct flash_bank *bank)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);
	int retval;

	if (master_bank == NULL)
		return ERROR_FLASH_OPERATION_FAILED;

	/* call master handler */
	retval = master_bank->driver->erase_check(master_bank);
	if (retval != ERROR_OK)
		return retval;

	return ERROR_OK;
}
Esempio n. 6
0
static int virtual_erase(struct flash_bank *bank, int first, int last)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);
	int retval;

	if (master_bank == NULL) {
		return ERROR_FLASH_OPERATION_FAILED;
	}

	/* call master handler */
	if ((retval = master_bank->driver->erase(master_bank,
			first, last)) != ERROR_OK)
		return retval;

	return ERROR_OK;
}
Esempio n. 7
0
static int virtual_flash_read(struct flash_bank *bank,
		uint8_t *buffer, uint32_t offset, uint32_t count)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);
	int retval;

	if (master_bank == NULL)
		return ERROR_FLASH_OPERATION_FAILED;

	/* call master handler */
	retval = master_bank->driver->read(master_bank, buffer, offset, count);
	if (retval != ERROR_OK)
		return retval;

	return ERROR_OK;
}
Esempio n. 8
0
static int virtual_auto_probe(struct flash_bank *bank)
{
	struct flash_bank *master_bank = virtual_get_master_bank(bank);
	int retval;

	if (master_bank == NULL) {
		return ERROR_FLASH_OPERATION_FAILED;
	}

	/* call master handler */
	if ((retval = master_bank->driver->auto_probe(master_bank)) != ERROR_OK)
		return retval;

	/* update the info we do not have */
	virtual_update_bank_info(bank);

	return ERROR_OK;
}