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

1 // SPDX-License-Identifier: GPL-2.0+
4 * Reinhard Meyer, EMK Elektronik, reinhard.meyer@emk-elektronik.de
17 * Regions can be write/erase protected.
21 * The flash is presented to u-boot with each region being a sector,
23 * Each sector can be hardware protected (protect on/off).
27 * by u-Boot commands.
43 * do a read-modify-write for partially programmed pages
73 if ((readl(&dbu->cidr) & AT91_DBU_CID_ARCH_MASK) != AT91_DBU_CID_ARCH_9XExx) { in flash_init()
79 writel(AT91_EEFC_FCR_KEY | AT91_EEFC_FCR_FCMD_GETD, &eefc->fcr); in flash_init()
80 while ((readl(&eefc->fsr) & AT91_EEFC_FSR_FRDY) == 0) in flash_init()
82 id = readl(&eefc->frr); /* word 0 */ in flash_init()
83 size = readl(&eefc->frr); /* word 1 */ in flash_init()
84 pagesize = readl(&eefc->frr); /* word 2 */ in flash_init()
85 nplanes = readl(&eefc->frr); /* word 3 */ in flash_init()
86 planesize = readl(&eefc->frr); /* word 4 */ in flash_init()
90 tmp = readl(&eefc->frr); /* words 5..4+nplanes-1 */ in flash_init()
92 nlocks = readl(&eefc->frr); /* word 4+nplanes */ in flash_init()
107 tmp = readl(&eefc->frr); /* words 4+nplanes+1.. */ in flash_init()
109 flash_info[0].protect[i] = 0; in flash_init()
114 writel(AT91_EEFC_FCR_KEY | AT91_EEFC_FCR_FCMD_GLB, &eefc->fcr); in flash_init()
115 while ((readl(&eefc->fsr) & AT91_EEFC_FSR_FRDY) == 0) in flash_init()
119 tmp = readl(&eefc->frr); in flash_init()
120 flash_info[0].protect[i] = (tmp >> (i%32)) & 1; in flash_init()
123 flash_info[0].protect[i] = 1; in flash_init()
135 print_size(info->size, " in "); in flash_print_info()
136 printf("%d Sectors\n", info->sector_count); in flash_print_info()
139 for (i=0; i<info->sector_count; ++i) { in flash_print_info()
143 info->start[i], in flash_print_info()
144 info->protect[i] ? " (RO)" : " " in flash_print_info()
154 u32 pagenum = (info->start[sector]-ATMEL_BASE_FLASH)/pagesize; in flash_real_protect()
157 debug("protect sector=%ld prot=%d\n", sector, prot); in flash_real_protect()
170 (pagenum << AT91_EEFC_FCR_FARG_SHIFT), &eefc->fcr); in flash_real_protect()
173 (pagenum << AT91_EEFC_FCR_FARG_SHIFT), &eefc->fcr); in flash_real_protect()
175 while ((readl(&eefc->fsr) & AT91_EEFC_FSR_FRDY) == 0) in flash_real_protect()
177 /* now re-read the protection information for all regions */ in flash_real_protect()
178 writel(AT91_EEFC_FCR_KEY | AT91_EEFC_FCR_FCMD_GLB, &eefc->fcr); in flash_real_protect()
179 while ((readl(&eefc->fsr) & AT91_EEFC_FSR_FRDY) == 0) in flash_real_protect()
181 for (i=0; i<info->sector_count; i++) { in flash_real_protect()
183 tmp = readl(&eefc->frr); in flash_real_protect()
184 info->protect[i] = (tmp >> (i%32)) & 1; in flash_real_protect()
193 debug("erase+write page=%u\n", pagenum); in erase_write_page()
195 /* give erase and write page command */ in erase_write_page()
197 (pagenum << AT91_EEFC_FCR_FARG_SHIFT), &eefc->fcr); in erase_write_page()
198 while ((readl(&eefc->fsr) & AT91_EEFC_FSR_FRDY) == 0) in erase_write_page()
201 return readl(&eefc->fsr) in erase_write_page()
214 * 0 - OK
215 * 1 - write timeout
224 debug("write src=%08lx addr=%08lx cnt=%lx\n", in write_buff()
230 " write aborted\n", addr); in write_buff()
235 pagenum = (addr-ATMEL_BASE_FLASH)/pagesize; in write_buff()
241 while (i--) in write_buff()
243 /* write page */ in write_buff()
248 cnt -= pagesize; in write_buff()