summaryrefslogtreecommitdiffstats
path: root/jedec.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2008-05-14 12:03:06 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2008-05-14 12:03:06 +0000
commita758f5100dd6266af29d63302e745b1a3ad89bed (patch)
tree96e3402473e7630b467b7befe97e0a03ecdc21f4 /jedec.c
parent4e84dfb7849b1d1de298c4f5212348a3c96b5b2f (diff)
downloadast2050-flashrom-a758f5100dd6266af29d63302e745b1a3ad89bed.zip
ast2050-flashrom-a758f5100dd6266af29d63302e745b1a3ad89bed.tar.gz
Check the JEDEC vendor ID for correct parity
Flash chips which can be detected by JEDEC probe routines all have vendor IDs with correct parity. Use a parity check as additional hint whether a vendor ID makes sense. Note: Device IDs have no parity requirements whatsoever. Corresponding to flashrom svn r231 and coreboot v2 svn r3308. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Peter Stuge <peter@stuge.se>
Diffstat (limited to 'jedec.c')
-rw-r--r--jedec.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/jedec.c b/jedec.c
index 9588751..e818294 100644
--- a/jedec.c
+++ b/jedec.c
@@ -27,6 +27,14 @@
#define MAX_REFLASH_TRIES 0x10
+/* Check one byte for odd parity */
+uint8_t oddparity(uint8_t val)
+{
+ val = (val ^ (val >> 4)) & 0xf;
+ val = (val ^ (val >> 2)) & 0x3;
+ return (val ^ (val >> 1)) & 0x1;
+}
+
void toggle_ready_jedec(volatile uint8_t *dst)
{
unsigned int i = 0;
@@ -123,7 +131,10 @@ int probe_jedec(struct flashchip *flash)
*(volatile uint8_t *)(bios + 0x5555) = 0xF0;
myusec_delay(40);
- printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, largeid1, largeid2);
+ printf_debug("%s: id1 0x%x, id2 0x%x", __FUNCTION__, largeid1, largeid2);
+ if (!oddparity(id1))
+ printf_debug(", id1 parity violation");
+ printf_debug("\n");
if (largeid1 == flash->manufacture_id && largeid2 == flash->model_id)
return 1;
OpenPOWER on IntegriCloud