+// SPDX-License-Identifier: GPL-2.0-or-later
+
/***************************************************************************
* Copyright (C) 2015 by Ivan Buliev *
* i.buliev@mikrosistemi.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. *
- * *
***************************************************************************/
/***************************************************************************
/* ----------------------------------------------------------------------- */
static int aducm360_build_sector_list(struct flash_bank *bank)
{
- int i = 0;
uint32_t offset = 0;
/* sector size is 512 */
bank->num_sectors = bank->size / FLASH_SECTOR_SIZE;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (i = 0; i < bank->num_sectors; ++i) {
+ for (unsigned i = 0; i < bank->num_sectors; ++i) {
bank->sectors[i].offset = offset;
bank->sectors[i].size = FLASH_SECTOR_SIZE;
offset += bank->sectors[i].size;
return ERROR_OK;
}
-/* ----------------------------------------------------------------------- */
-static int aducm360_protect_check(struct flash_bank *bank)
-{
- LOG_WARNING("aducm360_protect_check not implemented.");
- return ERROR_OK;
-}
-
/* ----------------------------------------------------------------------- */
static int aducm360_mass_erase(struct target *target)
{
}
/* ----------------------------------------------------------------------- */
-static int aducm360_erase(struct flash_bank *bank, int first, int last)
+static int aducm360_erase(struct flash_bank *bank, unsigned int first,
+ unsigned int last)
{
int res = ERROR_OK;
int i;
return res;
}
-/* ----------------------------------------------------------------------- */
-static int aducm360_protect(struct flash_bank *bank, int set, int first, int last)
-{
- LOG_ERROR("aducm360_protect not implemented.");
- return ERROR_FLASH_OPERATION_FAILED;
-}
-
/* ----------------------------------------------------------------------- */
static int aducm360_write_block_sync(
struct flash_bank *bank,
res = buf_get_u32(reg_params[4].value, 0, 32);
if (res) {
- LOG_ERROR("aducm360 fast sync algorithm reports an error (%02X)", res);
+ LOG_ERROR("aducm360 fast sync algorithm reports an error (%02" PRIX32 ")", res);
retval = ERROR_FAIL;
break;
}
} else {
res = buf_get_u32(reg_params[4].value, 0, 32); /*RESULT*/
if (res) {
- LOG_ERROR("aducm360 fast async algorithm reports an error (%02X)", res);
+ LOG_ERROR("aducm360 fast async algorithm reports an error (%02" PRIX32 ")", res);
retval = ERROR_FAIL;
}
}
switch (choice) {
case 0:
return aducm360_write_block_sync(bank, buffer, offset, count);
- break;
case 1:
return aducm360_write_block_async(bank, buffer, offset, count);
- break;
default:
LOG_ERROR("aducm360_write_block was cancelled (no writing method was chosen)!");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
{
uint32_t v = 1;
- long long endtime = timeval_ms() + timeout_ms;
+ int64_t endtime = timeval_ms() + timeout_ms;
while (1) {
target_read_u32(target, ADUCM360_FLASH_BASE+ADUCM360_FLASH_FEESTA, &v);
if ((v & 0x00000001) == 0)
}
/* ----------------------------------------------------------------------- */
-struct flash_driver aducm360_flash = {
+const struct flash_driver aducm360_flash = {
.name = "aducm360",
.flash_bank_command = aducm360_flash_bank_command,
.erase = aducm360_erase,
- .protect = aducm360_protect,
.write = aducm360_write,
.read = default_flash_read,
.probe = aducm360_probe,
.auto_probe = aducm360_probe,
.erase_check = default_flash_blank_check,
- .protect_check = aducm360_protect_check,
};