sst49lfxxxc.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * This file is part of the flashrom project.
  3. *
  4. * Copyright (C) 2000 Silicon Integrated System Corporation
  5. * Copyright (C) 2005-2007 coresystems GmbH
  6. * Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "flash.h"
  23. #include "chipdrivers.h"
  24. static int write_lockbits_block_49lfxxxc(struct flashctx *flash, unsigned long address, unsigned char bits)
  25. {
  26. unsigned long lock = flash->virtual_registers + address + 2;
  27. msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n", lock, chip_readb(flash, lock));
  28. chip_writeb(flash, bits, lock);
  29. return 0;
  30. }
  31. static int write_lockbits_49lfxxxc(struct flashctx *flash, unsigned char bits)
  32. {
  33. chipaddr registers = flash->virtual_registers;
  34. unsigned int i, left = flash->total_size * 1024;
  35. unsigned long address;
  36. msg_cdbg("\nbios=0x%08lx\n", registers);
  37. for (i = 0; left > 65536; i++, left -= 65536) {
  38. write_lockbits_block_49lfxxxc(flash, i * 65536, bits);
  39. }
  40. address = i * 65536;
  41. write_lockbits_block_49lfxxxc(flash, address, bits);
  42. address += 32768;
  43. write_lockbits_block_49lfxxxc(flash, address, bits);
  44. address += 8192;
  45. write_lockbits_block_49lfxxxc(flash, address, bits);
  46. address += 8192;
  47. write_lockbits_block_49lfxxxc(flash, address, bits);
  48. return 0;
  49. }
  50. int unlock_49lfxxxc(struct flashctx *flash)
  51. {
  52. return write_lockbits_49lfxxxc(flash, 0);
  53. }
  54. int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size)
  55. {
  56. uint8_t status;
  57. chipaddr bios = flash->virtual_memory;
  58. chip_writeb(flash, 0x30, bios);
  59. chip_writeb(flash, 0xD0, bios + address);
  60. status = wait_82802ab(flash);
  61. print_status_82802ab(status);
  62. /* FIXME: Check the status register for errors. */
  63. return 0;
  64. }