• Home
  • Raw
  • Download

Lines Matching +full:pull +full:- +full:downs

1 // SPDX-License-Identifier: GPL-2.0
9 #include <linux/mtd/spi-nor.h>
17 if (nor->flags & SNOR_F_HAS_SR_BP3_BIT6) in spi_nor_get_sr_bp_mask()
20 if (nor->flags & SNOR_F_HAS_4BIT_BP) in spi_nor_get_sr_bp_mask()
28 if (nor->flags & SNOR_F_HAS_SR_TB_BIT6) in spi_nor_get_sr_tb_mask()
40 bp_slots = (1 << hweight8(mask)) - 2; in spi_nor_get_min_prot_length_sr()
41 bp_slots_needed = ilog2(nor->info->n_sectors); in spi_nor_get_min_prot_length_sr()
44 return nor->info->sector_size << in spi_nor_get_min_prot_length_sr()
45 (bp_slots_needed - bp_slots); in spi_nor_get_min_prot_length_sr()
47 return nor->info->sector_size; in spi_nor_get_min_prot_length_sr()
53 struct mtd_info *mtd = &nor->mtd; in spi_nor_get_locked_range_sr()
59 if (nor->flags & SNOR_F_HAS_SR_BP3_BIT6 && val & SR_BP3_BIT6) in spi_nor_get_locked_range_sr()
72 *len = min_prot_len << (bp - 1); in spi_nor_get_locked_range_sr()
74 if (*len > mtd->size) in spi_nor_get_locked_range_sr()
75 *len = mtd->size; in spi_nor_get_locked_range_sr()
77 if (nor->flags & SNOR_F_HAS_SR_TB && sr & tb_mask) in spi_nor_get_locked_range_sr()
80 *ofs = mtd->size - *len; in spi_nor_get_locked_range_sr()
102 /* Requested range is a sub-range of locked range */ in spi_nor_check_lock_status_sr()
126 * - SEC: sector/block protect - only handle SEC=0 (block protect)
127 * - CMP: complement protect - only support CMP=0 (range is not complemented)
130 * - TB: top/bottom protect
135 * --------------------------------------------------------------------------
144 * ------|-------|-------|-------|-------|---------------|-------------------
156 struct mtd_info *mtd = &nor->mtd; in spi_nor_sr_lock()
163 bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB; in spi_nor_sr_lock()
166 ret = spi_nor_read_sr(nor, nor->bouncebuf); in spi_nor_sr_lock()
170 status_old = nor->bouncebuf[0]; in spi_nor_sr_lock()
181 if (!spi_nor_is_locked_sr(nor, ofs + len, mtd->size - (ofs + len), in spi_nor_sr_lock()
186 return -EINVAL; in spi_nor_sr_lock()
193 lock_len = mtd->size - ofs; in spi_nor_sr_lock()
197 if (lock_len == mtd->size) { in spi_nor_sr_lock()
201 pow = ilog2(lock_len) - ilog2(min_prot_len) + 1; in spi_nor_sr_lock()
204 if (nor->flags & SNOR_F_HAS_SR_BP3_BIT6 && val & SR_BP3) in spi_nor_sr_lock()
208 return -EINVAL; in spi_nor_sr_lock()
212 return -EINVAL; in spi_nor_sr_lock()
219 * wrongly tied to GND (that includes internal pull-downs). in spi_nor_sr_lock()
222 if (!(nor->flags & SNOR_F_NO_WP)) in spi_nor_sr_lock()
234 return -EINVAL; in spi_nor_sr_lock()
246 struct mtd_info *mtd = &nor->mtd; in spi_nor_sr_unlock()
253 bool can_be_top = true, can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB; in spi_nor_sr_unlock()
256 ret = spi_nor_read_sr(nor, nor->bouncebuf); in spi_nor_sr_unlock()
260 status_old = nor->bouncebuf[0]; in spi_nor_sr_unlock()
271 if (!spi_nor_is_unlocked_sr(nor, ofs + len, mtd->size - (ofs + len), in spi_nor_sr_unlock()
276 return -EINVAL; in spi_nor_sr_unlock()
283 lock_len = mtd->size - (ofs + len); in spi_nor_sr_unlock()
291 pow = ilog2(lock_len) - ilog2(min_prot_len) + 1; in spi_nor_sr_unlock()
294 if (nor->flags & SNOR_F_HAS_SR_BP3_BIT6 && val & SR_BP3) in spi_nor_sr_unlock()
297 /* Some power-of-two sizes are not supported */ in spi_nor_sr_unlock()
299 return -EINVAL; in spi_nor_sr_unlock()
317 return -EINVAL; in spi_nor_sr_unlock()
333 ret = spi_nor_read_sr(nor, nor->bouncebuf); in spi_nor_sr_is_locked()
337 return spi_nor_is_locked_sr(nor, ofs, len, nor->bouncebuf[0]); in spi_nor_sr_is_locked()
348 nor->params->locking_ops = &spi_nor_sr_locking_ops; in spi_nor_init_default_locking_ops()
360 ret = nor->params->locking_ops->lock(nor, ofs, len); in spi_nor_lock()
375 ret = nor->params->locking_ops->unlock(nor, ofs, len); in spi_nor_unlock()
390 ret = nor->params->locking_ops->is_locked(nor, ofs, len); in spi_nor_is_locked()
397 * spi_nor_try_unlock_all() - Tries to unlock the entire flash memory array.
400 * Some SPI NOR flashes are write protected by default after a power-on reset
401 * cycle, in order to avoid inadvertent writes during power-up. Backward
402 * compatibility imposes to unlock the entire flash memory array at power-up
406 * write-protected. Thus any errors are ignored.
412 if (!(nor->flags & SNOR_F_HAS_LOCK)) in spi_nor_try_unlock_all()
415 dev_dbg(nor->dev, "Unprotecting entire flash array\n"); in spi_nor_try_unlock_all()
417 ret = spi_nor_unlock(&nor->mtd, 0, nor->params->size); in spi_nor_try_unlock_all()
419 dev_dbg(nor->dev, "Failed to unlock the entire flash memory array\n"); in spi_nor_try_unlock_all()
424 struct mtd_info *mtd = &nor->mtd; in spi_nor_set_mtd_locking_ops()
426 if (!nor->params->locking_ops) in spi_nor_set_mtd_locking_ops()
429 mtd->_lock = spi_nor_lock; in spi_nor_set_mtd_locking_ops()
430 mtd->_unlock = spi_nor_unlock; in spi_nor_set_mtd_locking_ops()
431 mtd->_is_locked = spi_nor_is_locked; in spi_nor_set_mtd_locking_ops()