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

5  * SPDX-License-Identifier:	GPL-2.0+
17 /*-----------------------------------------------------------------------
21 /*-----------------------------------------------------------------------
35 if (!info || info->sector_count == 0 || info->size == 0 || to < from) { in flash_protect()
39 s_end = info->sector_count - 1; /* index of last sector */ in flash_protect()
40 b_end = info->start[0] + info->size - 1; /* bank end address */ in flash_protect()
48 * or the protect range and flash range don't overlap. in flash_protect()
50 if (info->flash_id == FLASH_UNKNOWN || in flash_protect()
51 to < info->start[0] || from > b_end) { in flash_protect()
55 for (i=0; i<info->sector_count; ++i) { in flash_protect()
58 end = (i == s_end) ? b_end : info->start[i + 1] - 1; in flash_protect()
63 if (from <= end && to >= info->start[i]) { in flash_protect()
68 info->protect[i] = 0; in flash_protect()
70 debug ("protect off %d\n", i); in flash_protect()
76 info->protect[i] = 1; in flash_protect()
78 debug ("protect on %d\n", i); in flash_protect()
84 /*-----------------------------------------------------------------------
94 if (info->flash_id != FLASH_UNKNOWN && in addr2info()
95 addr >= info->start[0] && in addr2info()
96 /* WARNING - The '- 1' is needed if the flash in addr2info()
98 * info->start[0] + info->size wraps back to 0. in addr2info()
101 addr <= info->start[0] + info->size - 1) { in addr2info()
109 /*-----------------------------------------------------------------------
114 * ERR_OK 0 - OK
115 * ERR_TIMEOUT 1 - write timeout
116 * ERR_NOT_ERASED 2 - Flash not erased
117 * ERR_PROTECTED 4 - target range includes protected sectors
118 * ERR_INVAL 8 - target address not in Flash memory
119 * ERR_ALIGN 16 - target address not aligned on boundary
126 ulong end = addr + cnt - 1; in flash_write()
143 ulong b_end = info->start[0] + info->size; /* bank end addr */ in flash_write()
144 short s_end = info->sector_count - 1; in flash_write()
145 for (i=0; i<info->sector_count; ++i) { in flash_write()
146 ulong e_addr = (i == s_end) ? b_end : info->start[i + 1]; in flash_write()
148 if ((end >= info->start[i]) && (addr < e_addr) && in flash_write()
149 (info->protect[i] != 0) ) { in flash_write()
155 /* finally write data to flash */ in flash_write()
159 len = info->start[0] + info->size - addr; in flash_write()
165 cnt -= len; in flash_write()
180 /*-----------------------------------------------------------------------
195 puts ("Can't write to protected Flash sectors\n"); in flash_perror()