Lines Matching +full:write +full:- +full:protect

1 // SPDX-License-Identifier: GPL-2.0+
16 /*-----------------------------------------------------------------------
20 /*-----------------------------------------------------------------------
34 if (!info || info->sector_count == 0 || info->size == 0 || to < from) { in flash_protect()
38 s_end = info->sector_count - 1; /* index of last sector */ in flash_protect()
39 b_end = info->start[0] + info->size - 1; /* bank end address */ in flash_protect()
47 * or the protect range and flash range don't overlap. in flash_protect()
49 if (info->flash_id == FLASH_UNKNOWN || in flash_protect()
50 to < info->start[0] || from > b_end) { in flash_protect()
54 for (i=0; i<info->sector_count; ++i) { in flash_protect()
57 end = (i == s_end) ? b_end : info->start[i + 1] - 1; in flash_protect()
62 if (from <= end && to >= info->start[i]) { in flash_protect()
67 info->protect[i] = 0; in flash_protect()
69 debug ("protect off %d\n", i); in flash_protect()
75 info->protect[i] = 1; in flash_protect()
77 debug ("protect on %d\n", i); in flash_protect()
83 /*-----------------------------------------------------------------------
93 if (info->flash_id != FLASH_UNKNOWN && in addr2info()
94 addr >= info->start[0] && in addr2info()
95 /* WARNING - The '- 1' is needed if the flash in addr2info()
97 * info->start[0] + info->size wraps back to 0. in addr2info()
100 addr <= info->start[0] + info->size - 1) { in addr2info()
108 /*-----------------------------------------------------------------------
113 * ERR_OK 0 - OK
114 * ERR_TIMEOUT 1 - write timeout
115 * ERR_NOT_ERASED 2 - Flash not erased
116 * ERR_PROTECTED 4 - target range includes protected sectors
117 * ERR_INVAL 8 - target address not in Flash memory
118 * ERR_ALIGN 16 - target address not aligned on boundary
125 ulong end = addr + cnt - 1; in flash_write()
142 ulong b_end = info->start[0] + info->size; /* bank end addr */ in flash_write()
143 short s_end = info->sector_count - 1; in flash_write()
144 for (i=0; i<info->sector_count; ++i) { in flash_write()
145 ulong e_addr = (i == s_end) ? b_end : info->start[i + 1]; in flash_write()
147 if ((end >= info->start[i]) && (addr < e_addr) && in flash_write()
148 (info->protect[i] != 0) ) { in flash_write()
154 /* finally write data to flash */ in flash_write()
158 len = info->start[0] + info->size - addr; in flash_write()
164 cnt -= len; in flash_write()
179 /*-----------------------------------------------------------------------
194 puts ("Can't write to protected Flash sectors\n"); in flash_perror()