Add AMD Fam10 B3 default settings to match AMD example code.
[coreboot.git] / util / flashrom / sharplhf00l04.c
index 2616611153ad58d2fe26ad2830621b36790fdd72..da7dc3f214462de125fa85531d58406dce6106af 100644 (file)
@@ -1,71 +1,27 @@
 /*
- * lhf00l04.c: driver for programming JEDEC standard flash parts
+ * This file is part of the flashrom project.
  *
+ * Copyright (C) 2000 Silicon Integrated System Corporation
  *
- * Copyright 2000 Silicon Integrated System Corporation
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- * Reference: http://www.intel.com/design/chipsets/datashts/290658.htm
+ * 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 St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include "flash.h"
 
-void toggle_ready_lhf00l04(volatile uint8_t *dst)
-{
-       unsigned int i = 0;
-       uint8_t tmp1, tmp2;
-
-       tmp1 = *dst & 0x40;
-
-       while (i++ < 0xFFFFFF) {
-               tmp2 = *dst & 0x40;
-               if (tmp1 == tmp2) {
-                       break;
-               }
-               tmp1 = tmp2;
-       }
-}
-
-void data_polling_lhf00l04(volatile uint8_t *dst, uint8_t data)
-{
-       unsigned int i = 0;
-       uint8_t tmp;
-
-       data &= 0x80;
-
-       while (i++ < 0xFFFFFF) {
-               tmp = *dst & 0x80;
-               if (tmp == data) {
-                       break;
-               }
-       }
-}
-
-void protect_lhf00l04(volatile uint8_t *bios)
-{
-       *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
-       *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
-       *(volatile uint8_t *)(bios + 0x5555) = 0xA0;
-
-       usleep(200);
-}
-
 // I need that Berkeley bit-map printer
 void print_lhf00l04_status(uint8_t status)
 {
@@ -117,7 +73,6 @@ int probe_lhf00l04(struct flashchip *flash)
 
 uint8_t wait_lhf00l04(volatile uint8_t *bios)
 {
-
        uint8_t status;
        uint8_t id1, id2;
 
@@ -140,9 +95,10 @@ uint8_t wait_lhf00l04(volatile uint8_t *bios)
        *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
        *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
        *(volatile uint8_t *)(bios + 0x5555) = 0xF0;
-       return status;
 
+       return status;
 }
+
 int erase_lhf00l04_block(struct flashchip *flash, int offset)
 {
        volatile uint8_t *bios = flash->virtual_memory + offset;
@@ -168,8 +124,10 @@ int erase_lhf00l04_block(struct flashchip *flash, int offset)
        status = wait_lhf00l04(flash->virtual_memory);
        print_lhf00l04_status(status);
        printf("DONE BLOCK 0x%x\n", offset);
-       return (0);
+
+       return 0;
 }
+
 int erase_lhf00l04(struct flashchip *flash)
 {
        int i;
@@ -180,7 +138,8 @@ int erase_lhf00l04(struct flashchip *flash)
        for (i = 0; i < total_size; i += flash->page_size)
                erase_lhf00l04_block(flash, i);
        printf("DONE ERASE\n");
-       return (0);
+
+       return 0;
 }
 
 void write_page_lhf00l04(volatile uint8_t *bios, uint8_t *src,
@@ -194,7 +153,6 @@ void write_page_lhf00l04(volatile uint8_t *bios, uint8_t *src,
                *dst++ = *src++;
                wait_lhf00l04(bios);
        }
-
 }
 
 int write_lhf00l04(struct flashchip *flash, uint8_t *buf)
@@ -206,10 +164,10 @@ int write_lhf00l04(struct flashchip *flash, uint8_t *buf)
 
        erase_lhf00l04(flash);
        if (*bios != 0xff) {
-               printf("ERASE FAILED\n");
+               printf("ERASE FAILED!\n");
                return -1;
        }
-       printf("Programming Page: ");
+       printf("Programming page: ");
        for (i = 0; i < total_size / page_size; i++) {
                printf("%04d at address: 0x%08x", i, i * page_size);
                write_page_lhf00l04(bios, buf + i * page_size,
@@ -217,6 +175,7 @@ int write_lhf00l04(struct flashchip *flash, uint8_t *buf)
                printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
        }
        printf("\n");
-       protect_lhf00l04(bios);
-       return (0);
+       protect_jedec(bios);
+
+       return 0;
 }