Guest User

Untitled

a guest
Jun 26th, 2013
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: sb600spi.c
  2. ===================================================================
  3. --- sb600spi.c  (revision 1671)
  4. +++ sb600spi.c  (working copy)
  5. @@ -56,8 +56,13 @@
  6.  {
  7.     uint8_t tmp;
  8.  
  9. +#ifdef USE_THE_EXTENDED_SPIDataFifoPtr_REGISTER
  10. +   mmio_writeb(7, sb600_spibar + 0x1e);
  11. +   tmp = mmio_readb(sb600_spibar + 0x1f);
  12. +#else
  13.     tmp = mmio_readb(sb600_spibar + 0xd) & 0x07;
  14.     want &= 0x7;
  15. +#endif
  16.     if (want != tmp) {
  17.         msg_perr("SB600 FIFO pointer corruption! Pointer is %d, wanted "
  18.              "%d\n", tmp, want);
  19. @@ -97,8 +102,6 @@
  20.     int count;
  21.     /* First byte is cmd which can not being sent through FIFO. */
  22.     unsigned char cmd = *writearr++;
  23. -   unsigned int readoffby1;
  24. -   unsigned char readwrite;
  25.  
  26.     writecnt--;
  27.  
  28. @@ -117,15 +120,9 @@
  29.         return SPI_INVALID_LENGTH;
  30.     }
  31.  
  32. -   /* This is a workaround for a bug in SB600 and SB700. If we only send
  33. -    * an opcode and no additional data/address, the SPI controller will
  34. -    * read one byte too few from the chip. Basically, the last byte of
  35. -    * the chip response is discarded and will not end up in the FIFO.
  36. -    * It is unclear if the CS# line is set high too early as well.
  37. -    */
  38. -   readoffby1 = (writecnt) ? 0 : 1;
  39. -   readwrite = (readcnt + readoffby1) << 4 | (writecnt);
  40. -   mmio_writeb(readwrite, sb600_spibar + 1);
  41. +   /* Use the extended TxByteCount and RxByteCount register. */
  42. +   mmio_writeb(writecnt, sb600_spibar + 0x48);
  43. +   mmio_writeb(readcnt, sb600_spibar + 0x4b);
  44.     mmio_writeb(cmd, sb600_spibar + 0);
  45.  
  46.     /* Before we use the FIFO, reset it first. */
  47. @@ -170,8 +167,12 @@
  48.         msg_pspew("[%02x]", cmd);
  49.     }
  50.     msg_pspew("\n");
  51. +   /*
  52. +   Reading doesn't advance the FIFO pointer.
  53. +
  54.     if (compare_internal_fifo_pointer(writecnt))
  55.         return SPI_PROGRAMMER_ERROR;
  56. +   */
  57.  
  58.     msg_pspew("Reading: ");
  59.     for (count = 0; count < readcnt; count++, readarr++) {
  60. @@ -179,18 +180,7 @@
  61.         msg_pspew("[%02x]", *readarr);
  62.     }
  63.     msg_pspew("\n");
  64. -   if (reset_compare_internal_fifo_pointer(readcnt + writecnt))
  65. -       return SPI_PROGRAMMER_ERROR;
  66.  
  67. -   if (mmio_readb(sb600_spibar + 1) != readwrite) {
  68. -       msg_perr("Unexpected change in SB600 read/write count!\n");
  69. -       msg_perr("Something else is accessing the flash chip and "
  70. -            "causes random corruption.\nPlease stop all "
  71. -            "applications and drivers and IPMI which access the "
  72. -            "flash chip.\n");
  73. -       return SPI_PROGRAMMER_ERROR;
  74. -   }
  75. -
  76.     return 0;
  77.  }
RAW Paste Data