]> err.no Git - linux-2.6/blobdiff - drivers/scsi/aic7xxx/aic7xxx_93cx6.c
Merge git://git.infradead.org/mtd-2.6
[linux-2.6] / drivers / scsi / aic7xxx / aic7xxx_93cx6.c
index 468d612a44f66a3b0c86165cc89534001e8a217b..dd11999b77b6dd590992671c062ad508b3bcf546 100644 (file)
@@ -28,9 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#17 $
- *
- * $FreeBSD$
+ * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.c#19 $
  */
 
 /*
@@ -64,7 +62,6 @@
  *   is preceded by an initial zero (leading 0, followed by 16-bits, MSB
  *   first).  The clock cycling from low to high initiates the next data
  *   bit to be sent from the chip.
- *
  */
 
 #ifdef __linux__
  * Right now, we only have to read the SEEPROM.  But we make it easier to
  * add other 93Cx6 functions.
  */
-static struct seeprom_cmd {
+struct seeprom_cmd {
        uint8_t len;
-       uint8_t bits[9];
-} seeprom_read = {3, {1, 1, 0}};
+       uint8_t bits[11];
+};
+
+/* Short opcodes for the c46 */
+static const struct seeprom_cmd seeprom_ewen = {9, {1, 0, 0, 1, 1, 0, 0, 0, 0}};
+static const struct seeprom_cmd seeprom_ewds = {9, {1, 0, 0, 0, 0, 0, 0, 0, 0}};
+
+/* Long opcodes for the C56/C66 */
+static const struct seeprom_cmd seeprom_long_ewen = {11, {1, 0, 0, 1, 1, 0, 0, 0, 0}};
+static const struct seeprom_cmd seeprom_long_ewds = {11, {1, 0, 0, 0, 0, 0, 0, 0, 0}};
 
-static struct seeprom_cmd seeprom_ewen = {9, {1, 0, 0, 1, 1, 0, 0, 0, 0}};
-static struct seeprom_cmd seeprom_ewds = {9, {1, 0, 0, 0, 0, 0, 0, 0, 0}};
-static struct seeprom_cmd seeprom_write = {3, {1, 0, 1}};
+/* Common opcodes */
+static const struct seeprom_cmd seeprom_write = {3, {1, 0, 1}};
+static const struct seeprom_cmd seeprom_read  = {3, {1, 1, 0}};
 
 /*
  * Wait for the SEERDY to go high; about 800 ns.
@@ -103,7 +108,7 @@ static struct seeprom_cmd seeprom_write = {3, {1, 0, 1}};
  * Send a START condition and the given command
  */
 static void
-send_seeprom_cmd(struct seeprom_descriptor *sd, struct seeprom_cmd *cmd)
+send_seeprom_cmd(struct seeprom_descriptor *sd, const struct seeprom_cmd *cmd)
 {
        uint8_t temp;
        int i = 0;
@@ -222,12 +227,25 @@ int
 ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
                  u_int start_addr, u_int count)
 {
+       const struct seeprom_cmd *ewen, *ewds;
        uint16_t v;
        uint8_t temp;
        int i, k;
 
        /* Place the chip into write-enable mode */
-       send_seeprom_cmd(sd, &seeprom_ewen);
+       if (sd->sd_chip == C46) {
+               ewen = &seeprom_ewen;
+               ewds = &seeprom_ewds;
+       } else if (sd->sd_chip == C56_66) {
+               ewen = &seeprom_long_ewen;
+               ewds = &seeprom_long_ewds;
+       } else {
+               printf("ahc_write_seeprom: unsupported seeprom type %d\n",
+                      sd->sd_chip);
+               return (0);
+       }
+
+       send_seeprom_cmd(sd, ewen);
        reset_seeprom(sd);
 
        /* Write all requested data out to the seeprom. */
@@ -277,7 +295,7 @@ ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf,
        }
 
        /* Put the chip back into write-protect mode */
-       send_seeprom_cmd(sd, &seeprom_ewds);
+       send_seeprom_cmd(sd, ewds);
        reset_seeprom(sd);
 
        return (1);