<div dir="ltr">Thanks for your contribution! I know nothing about sb600, so I'll leave code review to those who know, but for the patch itself, we need a sign-off before we can commit any patches, see this: <a href="http://www.coreboot.org/Development_Guidelines#Sign-off_Procedure">http://www.coreboot.org/Development_Guidelines#Sign-off_Procedure</a> Please repost with your sign off, I assume this applies to your other patch too.<br>
<br>Thanks!<br>Corey<br><br><div class="gmail_quote">2008/10/15 Sean Nelson <span dir="ltr"><<a href="mailto:snelson@nmt.edu">snelson@nmt.edu</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
sb600 spi driver file for flashrom<br>
<br>Index: sb600spi.c<br>
===================================================================<br>
--- sb600spi.c  (revision 0)<br>
+++ sb600spi.c  (revision 0)<br>
@@ -0,0 +1,126 @@<br>
+/*<br>
+ * This file is part of the flashrom project.<br>
+ *<br>
+ * Copyright (C) 2008 Sean Nelson <<a href="mailto:snelson@nmt.edu">snelson@nmt.edu</a>><br>
+ *<br>
+ * This program is free software; you can redistribute it and/or modify<br>
+ * it under the terms of the GNU General Public License as published by<br>
+ * the Free Software Foundation; version 2 of the License.<br>
+ *<br>
+ * This program is distributed in the hope that it will be useful,<br>
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
+ * GNU General Public License for more details.<br>
+ *<br>
+ * You should have received a copy of the GNU General Public License<br>
+ * along with this program; if not, write to the Free Software<br>
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA<br>
+ */<br>
+<br>
+/*<br>
+ * SPI interface for SB600<br>
+ */<br>
+<br>
+#include <stdio.h><br>
+#include <pci/pci.h><br>
+#include <stdint.h><br>
+#include <string.h><br>
+#include "flash.h"<br>
+#include "spi.h"<br>
+<br>
+uint16_t sb600_flashport = 0;<br>
+<br>
+/* use fast 33MHz SPI (<>0) or slow 16MHz (0) */<br>
+int fast_spi = 1;<br>
+<br>
+static uint16_t find_sb600_spi_flash_port(uint16_t device_id)<br>
+{<br>
+       struct pci_dev *dev;<br>
+       uint16_t flashport = 0;<br>
+<br>
+       /* sb600's LPC ISA Bridge */<br>
+       dev = pci_dev_find(0x1002, device_id);<br>
+<br>
+       /* SPI Base Address (A0h) */<br>
+       flashport = pci_read_word(dev, 0xa0);<br>
+<br>
+       return flashport;<br>
+}<br>
+<br>
+int sb600_probe_spi_flash(const char *name)<br>
+{<br>
+       sb600_flashport = find_ite_spi_flash_port(0x438d);<br>
+<br>
+       if (sb600_flashport)<br>
+               flashbus = BUS_TYPE_SB600_SPI;<br>
+<br>
+       return (!it8716f_flashport);<br>
+}<br>
+<br>
+int sb600_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr)<br>
+{<br>
+       uint8_t busy, speed;<br>
+       int i;<br>
+<br>
+       if (readcnt > 8) {<br>
+               printf("%s called with unsupported readcnt %i.\n",<br>
+                       __FUNCTION__, readcnt);<br>
+               return 1;<br>
+       }<br>
+<br>
+       OUTB(writearr[0], sb600_flashport + 0x00);<br>
+       for(i=1; i < (writecnt-1); i++)<br>
+       {<br>
+               OUTB(writearr[i], sb600_flashport + 0x0c);<br>
+       }<br>
+<br>
+       /*<br>
+        * set the SPI clock speed (0x0D)<br>
+        * NormSpeed: bit 5 & 4<br>
+        * FastSpeed: bit 7 & 6<br>
+        *<br>
+        * 33MHz - 01b<br>
+        * 16.5MHz - 11b<br>
+        */<br>
+       speed = (fast_spi ? 1 : 3)<<6;<br>
+       speed = (fast_spi ? 1 : 3)<<4;<br>
+       OUTB(speed, sb600_flashport);<br>
+<br>
+       /*<br>
+        * set the TxByte and RxBytes (0x01)<br>
+        * TxByteCount: bit 3-0<br>
+        * RxByteCount: bit 7-4<br>
+        */<br>
+       OUTB(((writecnt-1)<<4)|(readcnt), sb600_flashport)<br>
+<br>
+       /*<br>
+        * start the command execution (0x02)<br>
+        * ExecuteOpCode: bit 0; start off the SPI command<br>
+        * Reserved: bit 1&2<br>
+        * SpiArbEnable: bit 3; 0 to speed up SPI ROM Access<br>
+        */<br>
+       OUTB((1<<3)|(1<<0), sb600_flashport);<br>
+<br>
+       if (readcnt > 0) {<br>
+               for (i = 0; i < readcnt; i++) {<br>
+                       readarr[i] = INB(sb600_flashport + 0x0c);<br>
+               }<br>
+       }<br>
+<br>
+       return 0;<br>
+}<br>
+<br>
+int sb600_spi_chip_read(struct flashchip *flash, uint8_t *buf)<br>
+{<br>
+       int total_size = 1024 * flash->total_size;<br>
+       memcpy(buf, (const char *)flash->virtual_memory, total_size);<br>
+       return 0;<br>
+}<br>
+<br>
+int sb600_spi_chip_write(struct flashchip *flash, uint8_t *buf)<br>
+{<br>
+       int total_size = 1024 * flash->total_size;<br>
+       memcpy((const char*)flash->virtual_memory, buf, total_size);<br>
+       return 0;<br>
+}<br>
+<br>
<br>--<br>
coreboot mailing list: <a href="mailto:coreboot@coreboot.org">coreboot@coreboot.org</a><br>
<a href="http://www.coreboot.org/mailman/listinfo/coreboot" target="_blank">http://www.coreboot.org/mailman/listinfo/coreboot</a><br></blockquote></div><br></div>