FreeCalypso > hg > freecalypso-tools
annotate loadtools/flashid.c @ 983:0407d14fb854
PL-J flash PPB ops: rework for full verification of lock state
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 02 Dec 2023 08:22:00 +0000 |
parents | ff4ce8d5ece4 |
children |
rev | line source |
---|---|
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Flash device detection code lives here |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdint.h> |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "flash.h" |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 extern struct flash_device flashdev_28F160C3T; |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
12 extern struct flash_device flashdev_28F160C3B; |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern struct flash_device flashdev_28F320C3T; |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
14 extern struct flash_device flashdev_28F320C3B; |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern struct flash_device flashdev_28F640C3T; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern struct flash_device flashdev_28F640C3B; |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
17 extern struct flash_device flashdev_28F320W30T; |
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
18 extern struct flash_device flashdev_28F320W30B; |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 extern struct flash_device flashdev_28F640W30T; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern struct flash_device flashdev_28F640W30B; |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
21 |
553
3886a8a40809
fc-loadtool: added support for old Am29DL640G flash chip
Mychaela Falconia <falcon@freecalypso.org>
parents:
523
diff
changeset
|
22 extern struct flash_device flashdev_Am29DL640G; |
559
f229efbfd581
fc-loadtool: added support for S29PL032J/S71PL032J flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
553
diff
changeset
|
23 extern struct flash_device flashdev_PL032J; |
976
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
24 extern struct flash_device flashdev_PL064J; |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 extern struct flash_device flashdev_PL129J; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 extern struct flash_device flashdev_PL129N; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 extern struct flash_device flashdev_K5A32xx_T; |
523
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
28 extern struct flash_device flashdev_K5L33xx_A; |
916
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
29 extern struct flash_device flashdev_K5L29xx_A; |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 extern int flash_global_config; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 extern struct flash_bank_info flash_bank_info[2]; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 static |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 run_cfi_check(bi, table) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 struct flash_bank_info *bi; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 struct cfi_check *table; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 struct cfi_check *tp; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 uint16_t rdword; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 for (tp = table; tp->offset >= 0; tp++) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (do_r16(bi->base_addr + (tp->offset << 1), &rdword) < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (rdword != tp->expect_val) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(0); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 return(1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 static |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 try_device(bi, dev) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 struct flash_bank_info *bi; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 struct flash_device *dev; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 int rc; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 printf("Appears to be %s or compatible, checking CFI\n", dev->name); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (do_w16(bi->base_addr + 0xAA, 0x98)) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 fprintf(stderr, "unexpected response to w16 - aborting\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 rc = run_cfi_check(bi, dev->cfi_table); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 if (rc < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 return(rc); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 if (!rc) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 fprintf(stderr, "Error: CFI mismatch, unsafe to continue\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 printf("Confirmed %s or compatible\n", dev->name); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 bi->device = dev; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 return(0); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 static |
916
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
76 try_device_amdreset(bi, dev) |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
77 struct flash_bank_info *bi; |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
78 struct flash_device *dev; |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
79 { |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
80 int rc; |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
81 |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
82 printf("Appears to be %s or compatible, checking CFI\n", dev->name); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
83 /* need to go back to read array first, CFI cmd ignored otherwise */ |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
84 if (do_w16(bi->base_addr + 0xAAA, 0xF0)) { |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
85 bad_w16: fprintf(stderr, "unexpected response to w16 - aborting\n"); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
86 return(-1); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
87 } |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
88 if (do_w16(bi->base_addr + 0xAA, 0x98)) |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
89 goto bad_w16; |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
90 rc = run_cfi_check(bi, dev->cfi_table); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
91 if (rc < 0) |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
92 return(rc); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
93 if (!rc) { |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
94 fprintf(stderr, "Error: CFI mismatch, unsafe to continue\n"); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
95 return(-1); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
96 } |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
97 printf("Confirmed %s or compatible\n", dev->name); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
98 bi->device = dev; |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
99 return(0); |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
100 } |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
101 |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
102 static |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 spansion_pl129j_or_n(bi) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 struct flash_bank_info *bi; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 int rc; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 printf("Spansion PL129J or PL129N, looking at CFI\n"); |
507
c942be3c7997
new flash support works for PL129N on the Pirelli
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
109 /* need to go back to read array first, CFI cmd ignored otherwise */ |
c942be3c7997
new flash support works for PL129N on the Pirelli
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
110 if (do_w16(bi->base_addr + 0xAAA, 0xF0)) { |
c942be3c7997
new flash support works for PL129N on the Pirelli
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
111 bad_w16: fprintf(stderr, "unexpected response to w16 - aborting\n"); |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
507
c942be3c7997
new flash support works for PL129N on the Pirelli
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
114 if (do_w16(bi->base_addr + 0xAAA, 0x98)) |
c942be3c7997
new flash support works for PL129N on the Pirelli
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
115 goto bad_w16; |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 rc = run_cfi_check(bi, flashdev_PL129N.cfi_table); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 if (rc < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 return(rc); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 if (rc) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 printf("Found PL129N\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 bi->device = &flashdev_PL129N; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 return(0); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 rc = run_cfi_check(bi, flashdev_PL129J.cfi_table); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (rc < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 return(rc); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 if (rc) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 printf("Found PL129J\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 bi->device = &flashdev_PL129J; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 return(0); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 fprintf(stderr, "Error: no matching CFI found\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 static |
976
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
137 spansion_pl064j_or_oldamd(bi) |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
138 struct flash_bank_info *bi; |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
139 { |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
140 int rc; |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
141 |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
142 printf("Am29DL640G or PL064J, looking at CFI\n"); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
143 if (do_w16(bi->base_addr + 0xAA, 0x98)) { |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
144 fprintf(stderr, "unexpected response to w16 - aborting\n"); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
145 return(-1); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
146 } |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
147 rc = run_cfi_check(bi, flashdev_PL064J.cfi_table); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
148 if (rc < 0) |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
149 return(rc); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
150 if (rc) { |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
151 printf("Found PL064J\n"); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
152 bi->device = &flashdev_PL064J; |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
153 return(0); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
154 } |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
155 rc = run_cfi_check(bi, flashdev_Am29DL640G.cfi_table); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
156 if (rc < 0) |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
157 return(rc); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
158 if (rc) { |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
159 printf("Found Am29DL640G\n"); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
160 bi->device = &flashdev_Am29DL640G; |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
161 return(0); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
162 } |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
163 fprintf(stderr, "Error: no matching CFI found\n"); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
164 return(-1); |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
165 } |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
166 |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
167 static |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 amd_extended_id(bi) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 struct flash_bank_info *bi; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 uint16_t ext1, ext2; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 |
507
c942be3c7997
new flash support works for PL129N on the Pirelli
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
173 printf("AMD-style extended ID device, reading extended ID\n"); |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 if (do_r16(bi->base_addr + 0x1C, &ext1) < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 if (do_r16(bi->base_addr + 0x1E, &ext2) < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 printf("Extended ID: %04X %04X\n", ext1, ext2); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 if (ext1 == 0x2221 && ext2 == 0x2200) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 return spansion_pl129j_or_n(bi); |
553
3886a8a40809
fc-loadtool: added support for old Am29DL640G flash chip
Mychaela Falconia <falcon@freecalypso.org>
parents:
523
diff
changeset
|
181 if (ext1 == 0x2202 && ext2 == 0x2201) |
976
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
182 return spansion_pl064j_or_oldamd(bi); |
559
f229efbfd581
fc-loadtool: added support for S29PL032J/S71PL032J flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
553
diff
changeset
|
183 if (ext1 == 0x220A && ext2 == 0x2201) |
f229efbfd581
fc-loadtool: added support for S29PL032J/S71PL032J flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
553
diff
changeset
|
184 return try_device(bi, &flashdev_PL032J); |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 fprintf(stderr, "Error: unknown device ID\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 |
523
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
189 static |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
190 samsung_extended_id(bi) |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
191 struct flash_bank_info *bi; |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
192 { |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
193 uint16_t ext1, ext2; |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
194 |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
195 printf("Samsung extended ID device, reading extended ID\n"); |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
196 if (do_r16(bi->base_addr + 0x1C, &ext1) < 0) |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
197 return(-1); |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
198 if (do_r16(bi->base_addr + 0x1E, &ext2) < 0) |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
199 return(-1); |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
200 printf("Extended ID: %04X %04X\n", ext1, ext2); |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
201 if (ext1 == 0x2503 && ext2 == 0x2501) |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
202 return try_device(bi, &flashdev_K5L33xx_A); |
916
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
203 if (ext1 == 0x2508 && ext2 == 0x2501) |
54a0bc149d9c
fc-loadtool: add support for Samsung K5L29xx_A flash
Mychaela Falconia <falcon@freecalypso.org>
parents:
559
diff
changeset
|
204 return try_device_amdreset(bi, &flashdev_K5L29xx_A); |
523
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
205 fprintf(stderr, "Error: unknown device ID\n"); |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
206 return(-1); |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
207 } |
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
208 |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 static struct idmap { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 uint16_t manuf_id; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 uint16_t dev_id; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 int (*handler)(); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 void *extra_arg; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 } device_id_table[] = { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 /* AMD/Spansion devices */ |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 {0x0001, 0x227E, amd_extended_id, 0}, |
511
0212edcec4d2
loadtools/flashid.c: added alt ID for 28F320C3T equiv in Mot C139
Mychaela Falconia <falcon@freecalypso.org>
parents:
507
diff
changeset
|
217 /* 28F160C3T and 28F320C3T equivalents found in some Mot C1xx phones */ |
0212edcec4d2
loadtools/flashid.c: added alt ID for 28F320C3T equiv in Mot C139
Mychaela Falconia <falcon@freecalypso.org>
parents:
507
diff
changeset
|
218 {0x0020, 0x88BA, try_device, &flashdev_28F320C3T}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 {0x0020, 0x88CE, try_device, &flashdev_28F160C3T}, |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
220 /* Intel W30 flash family */ |
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
221 {0x0089, 0x8852, try_device, &flashdev_28F320W30T}, |
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
222 {0x0089, 0x8853, try_device, &flashdev_28F320W30B}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 {0x0089, 0x8854, try_device, &flashdev_28F640W30T}, |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 {0x0089, 0x8855, try_device, &flashdev_28F640W30B}, |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
225 /* Intel W18 flash family: same as W30, but different ID codes */ |
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
226 {0x0089, 0x8862, try_device, &flashdev_28F320W30T}, |
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
227 {0x0089, 0x8863, try_device, &flashdev_28F320W30B}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 {0x0089, 0x8864, try_device, &flashdev_28F640W30T}, |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
229 {0x0089, 0x8865, try_device, &flashdev_28F640W30B}, |
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
230 /* Intel C3 flash family */ |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 {0x0089, 0x88C2, try_device, &flashdev_28F160C3T}, |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
232 {0x0089, 0x88C3, try_device, &flashdev_28F160C3B}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 {0x0089, 0x88C4, try_device, &flashdev_28F320C3T}, |
973
7c18eac91457
loadtools: round out support for Intel flash families
Mychaela Falconia <falcon@freecalypso.org>
parents:
916
diff
changeset
|
234 {0x0089, 0x88C5, try_device, &flashdev_28F320C3B}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 {0x0089, 0x88CC, try_device, &flashdev_28F640C3T}, |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 {0x0089, 0x88CD, try_device, &flashdev_28F640C3B}, |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 /* Samsung flash */ |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 {0x00EC, 0x22A0, try_device, &flashdev_K5A32xx_T}, |
523
9a478d33b3ca
fc-loadtool: added Samsung K5L33xx_A flash support for GTM900
Mychaela Falconia <falcon@freecalypso.org>
parents:
511
diff
changeset
|
239 {0x00EC, 0x257E, samsung_extended_id, 0}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 /* table search terminator */ |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 {0, 0, 0, 0} |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 }; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 flash_detect(bank, repeat) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 struct flash_bank_info *bi; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 uint16_t manuf_id, dev_id; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 struct idmap *tp; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 int rc; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 bi = flash_bank_info + bank; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 if (bi->detect_done && !repeat) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 return(0); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 printf("Autodetecting flash chip type\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 if (do_w16(bi->base_addr + 0xAAA, 0xAA)) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 bad_w16: fprintf(stderr, |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 "unexpected response to w16 in read ID cmd sequence - aborting\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 if (do_w16(bi->base_addr + 0x554, 0x55)) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 goto bad_w16; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 if (do_w16(bi->base_addr + 0xAAA, 0x90)) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 goto bad_w16; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 if (do_r16(bi->base_addr, &manuf_id) < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 if (do_r16(bi->base_addr + 2, &dev_id) < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 printf("Basic device ID: %04X %04X\n", manuf_id, dev_id); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 for (tp = device_id_table; tp->handler; tp++) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 if (tp->manuf_id == manuf_id && tp->dev_id == dev_id) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 break; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 if (!tp->handler) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 fprintf(stderr, "Error: unknown device ID\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 rc = tp->handler(bi, tp->extra_arg); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 if (rc < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 return(rc); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 /* got the device, see if it is compatible with global config */ |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 if (bi->device->required_global_config > flash_global_config) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 fprintf(stderr, |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 "Error: detected flash device is not compatible with the configured mapping\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 /* good to go */ |
976
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
286 if (bi->device->bank_geom[1] && bank) { |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 bi->geom = bi->device->bank_geom[1]; |
976
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
288 bi->amd_lock = bi->device->lock_info[1]; |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
289 } else { |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 bi->geom = bi->device->bank_geom[0]; |
976
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
291 bi->amd_lock = bi->device->lock_info[0]; |
ff4ce8d5ece4
fc-loadtool flash: definitions for AMD sector lock architecture
Mychaela Falconia <falcon@freecalypso.org>
parents:
973
diff
changeset
|
292 } |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 bi->ops = bi->device->cmdset; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 bi->detect_done = 1; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 /* return device to read array mode */ |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 return bi->ops->reset_cmd(bi); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 } |