flash: Add support for Atheros (ath79) SPI interface
[fw/openocd] / src / flash / nor / mdr.c
index c402e64e2fc3a7a1fd7f94f324e0e20488fbc3bd..8ceb1bf46573b8fb9956dcca44a32f00fbeb0f64 100644 (file)
@@ -22,9 +22,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -173,7 +171,8 @@ static int mdr_erase(struct flash_bank *bank, int first, int last)
        if (retval != ERROR_OK)
                goto reset_pg_and_lock;
 
-       if ((first == 0) && (last == (bank->num_sectors - 1))) {
+       if ((first == 0) && (last == (bank->num_sectors - 1)) &&
+               !mdr_info->mem_type) {
                retval = mdr_mass_erase(bank);
                goto reset_pg_and_lock;
        }
@@ -471,6 +470,13 @@ free_buffer:
        if (new_buffer)
                free(new_buffer);
 
+       /* read some bytes bytes to flush buffer in flash accelerator.
+        * See errata for 1986VE1T and 1986VE3. Error 0007 */
+       if ((retval == ERROR_OK) && (!mdr_info->mem_type)) {
+               uint32_t tmp;
+               target_checksum_memory(bank->target, bank->base, 64, &tmp);
+       }
+
        return retval;
 }