Re: [PATCH v2 2/4] mtd: rawnand: Add support Macronix Block Protection function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Miquel,

> > +/*
> > + * Macronix NAND supports Block Protection by Protectoin(PT) pin;
> > + * active high at power-on which protects the entire chip even the 
#WP is
> > + * disabled. Lock/unlock protection area can be partition according 
to
> > + * protection bits, i.e. upper 1/2 locked, upper 1/4 locked and so 
on.
> > + */
> > +static int mxic_nand_lock(struct nand_chip *chip, loff_t ofs, 
uint64_t len)
> > +{
> > +   u8 feature[ONFI_SUBFEATURE_PARAM_LEN];
> > +   int ret;
> > +
> > +   feature[0] = MXIC_BLOCK_PROTECTION_ALL_LOCK;
> > +   nand_select_target(chip, 0);
> > +   ret = nand_set_features(chip, ONFI_FEATURE_ADDR_MXIC_PROTECTION,
> > +            feature);
> > +   nand_deselect_target(chip);
> > +   if (ret)
> > +      pr_err("%s all blocks failed\n", __func__);
> > +
> > +   return ret;
> > +}
> > +
> > +static int mxic_nand_unlock(struct nand_chip *chip, loff_t ofs, 
uint64_t len)
> > +{
> > +   u8 feature[ONFI_SUBFEATURE_PARAM_LEN];
> > +   int ret;
> > +
> > +   feature[0] = MXIC_BLOCK_PROTECTION_ALL_UNLOCK;
> > +   nand_select_target(chip, 0);
> > +   ret = nand_set_features(chip, ONFI_FEATURE_ADDR_MXIC_PROTECTION,
> > +            feature);
> > +   nand_deselect_target(chip);
> > +   if (ret)
> > +      pr_err("%s all blocks failed\n", __func__);
> > +
> > +   return ret;
> >  }
> > 
> > +/*
> > + * Macronix NAND AC series support Block Protection by SET_FEATURES
> > + * to lock/unlock blocks.
> > + */
> >  static int macronix_nand_init(struct nand_chip *chip)
> >  {
> > +   bool blockprotected = false;
> > +
> >     if (nand_is_slc(chip))
> >        chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;
> > 
> > -   macronix_nand_fix_broken_get_timings(chip);
> > +   if (macronix_nand_fix_broken_get_timings(chip))
> > +      blockprotected = true;
> 
> I don't like this at all :)
> 
> Please create a helper which detects which part is broken/protected
> then create helpers to act in this case.

okay, will patch it to read default protected value (after power-on)
for protection function detection.

> 
> If the list is absolutely identical, you can share the detection
> helper. Otherwise, if you think the list can diverge, please only share
> the list for now and create two detection helpers.
> 
> > +
> >     macronix_nand_onfi_init(chip);
> > 
> > +   if (blockprotected) {
> > +      bitmap_set(chip->parameters.set_feature_list,
> > +            ONFI_FEATURE_ADDR_MXIC_PROTECTION, 1);
> > +      bitmap_set(chip->parameters.get_feature_list,
> > +            ONFI_FEATURE_ADDR_MXIC_PROTECTION, 1);
> > +
> > +      chip->_lock = mxic_nand_lock;
> > +      chip->_unlock = mxic_nand_unlock;
> > +   }
> > +
> >     return 0;
> >  }
> > 

thanks for your time & comments.
Mason 


CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information 
and/or personal data, which is protected by applicable laws. Please be 
reminded that duplication, disclosure, distribution, or use of this e-mail 
(and/or its attachments) or any part thereof is prohibited. If you receive 
this e-mail in error, please notify us immediately and delete this mail as 
well as its attachment(s) from your system. In addition, please be 
informed that collection, processing, and/or use of personal data is 
prohibited unless expressly permitted by personal data protection laws. 
Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================



============================================================================

CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux