annotate loadtools/flashops.c @ 675:8b1e86dcc3ac

loadtool.help: new flash e-program-* commands documented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 08 Mar 2020 05:46:42 +0000
parents 77a0001d8849
children 44cdfc4fed4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements those flash operations which are dependent
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * on the AMD vs. Intel command set style.
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <time.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "flash.h"
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 /* common stub functions */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 static
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 noop()
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 static
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
22 amd_invalid()
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 fprintf(stderr,
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
25 "This operation is not applicable to AMD-style flash\n");
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /* AMD flash functions */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 amd_reset_cmd(bi)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (do_w16(bi->base_addr + 0xAAA, 0xF0)) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 fprintf(stderr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 "unexpected response to w16 when resetting flash to read mode!\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 amd_sector_erase(bi, sp)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 struct sector_info *sp;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 int stat;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 uint16_t flstat;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 time_t start_time, curtime;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 stat = do_w16(bi->base_addr + sp->start + 0xAAA, 0xAA);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 if (stat) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 bad_w16: fprintf(stderr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 "unexpected response to w16 in erase cmd sequence - aborting\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 stat = do_w16(bi->base_addr + sp->start + 0x554, 0x55);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 stat = do_w16(bi->base_addr + sp->start + 0xAAA, 0x80);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 stat = do_w16(bi->base_addr + sp->start + 0xAAA, 0xAA);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 stat = do_w16(bi->base_addr + sp->start + 0x554, 0x55);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 stat = do_w16(bi->base_addr + sp->start + 0xAAA, 0x30);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 start_time = time(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 for (;;) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 stat = do_r16(bi->base_addr + sp->start, &flstat);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 return(stat); /* error msg already printed */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 if (flstat == 0xFFFF)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 curtime = time(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 if (curtime >= start_time + 20) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 fprintf(stderr, "erase timeout, aborting\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 struct flash_cmdset flash_cmdset_amd = {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 .cmdset_name = "AMD",
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 .reset_cmd = amd_reset_cmd,
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
89 .status_cmd = amd_invalid,
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
90 .unlock_sector = amd_invalid,
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 .erase_sector = amd_sector_erase,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 .prep_for_program = noop,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 .loadagent_setbase_cmd = "AMFB",
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 .loadagent_program_cmd = "AMFW",
664
77a0001d8849 fc-loadtool: prep for binary flash programming
Mychaela Falconia <falcon@freecalypso.org>
parents: 506
diff changeset
95 .loadagent_binmode_cmd = "AMFWB",
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 .needs_unlock = 0,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 };
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 /* Intel flash functions */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 intel_reset_cmd(bi)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 if (do_w16(bi->base_addr, 0xFF)) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 fprintf(stderr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 "unexpected response to w16 when resetting flash to read mode!\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111
325
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
112 intel_w30_reset_cmd(bi)
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
113 struct flash_bank_info *bi;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
114 {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
115 uint32_t part;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
116
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
117 for (part = 0; part < bi->geom->total_size; part += 0x80000) {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
118 if (do_w16(bi->base_addr + part, 0xFF)) {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
119 fprintf(stderr,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
120 "unexpected response to w16 when resetting flash to read mode!\n");
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
121 return(-1);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
122 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
123 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
124 return(0);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
125 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
126
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 intel_status_cmd(bi)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 int stat;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 uint16_t sr;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 /* issue Read SR command */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 stat = do_w16(bi->base_addr, 0x70);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 if (stat) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 fprintf(stderr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 "unexpected response to w16 for Read SR command\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 stat = do_r16(bi->base_addr, &sr);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 return(stat); /* error msg already printed */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 sr &= 0xFF;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 printf("Status Register: %02X\n", sr);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147
325
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
148 intel_w30_status_cmd(bi)
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
149 struct flash_bank_info *bi;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
150 {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
151 uint32_t part;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
152 int stat;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
153 uint16_t sr;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
154
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
155 for (part = 0; part < bi->geom->total_size; part += 0x80000) {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
156 /* issue Read SR command */
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
157 stat = do_w16(bi->base_addr + part, 0x70);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
158 if (stat) {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
159 fprintf(stderr,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
160 "unexpected response to w16 for Read SR command\n");
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
161 return(-1);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
162 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
163 stat = do_r16(bi->base_addr + part, &sr);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
164 if (stat)
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
165 return(stat); /* error msg already printed */
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
166 sr &= 0xFF;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
167 printf("Status Register for partition %08lX: %02X\n",
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
168 (u_long) part, sr);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
169 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
170 return(0);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
171 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
172
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 intel_sector_unlock(bi, sp)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 struct sector_info *sp;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 int stat;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 stat = do_w16(bi->base_addr + sp->start, 0x60);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 if (stat) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 bad_w16: fprintf(stderr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 "unexpected response to w16 in block unlock cmd sequence - aborting\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 stat = do_w16(bi->base_addr + sp->start, 0xD0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 intel_sector_erase(bi, sp)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 struct sector_info *sp;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 int stat;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 uint16_t flstat;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 time_t start_time, curtime;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 stat = intel_sector_unlock(bi, sp);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 return(stat); /* error msg already printed */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 /* clear SR */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 stat = do_w16(bi->base_addr + sp->start, 0x50);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 if (stat) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 bad_w16: fprintf(stderr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 "unexpected response to w16 in erase cmd sequence - aborting\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 /* send the actual block erase command */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 stat = do_w16(bi->base_addr + sp->start, 0x20);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 stat = do_w16(bi->base_addr + sp->start, 0xD0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 goto bad_w16;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 /* wait for completion */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 start_time = time(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 for (;;) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 stat = do_r16(bi->base_addr + sp->start, &flstat);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 if (stat)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 return(stat); /* error msg already printed */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 if (flstat & 0x80)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 break;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 curtime = time(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 if (curtime >= start_time + 20) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 fprintf(stderr, "erase timeout, aborting\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 if (flstat & 0x20) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 fprintf(stderr, "block erase failed!\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 } else
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 intel_clear_sr(bi)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 printf("Clearing Intel flash SR\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 if (do_w16(bi->base_addr, 0x50)) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 fprintf(stderr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 "unexpected response to w16 for Clear SR command\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248
325
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
249 intel_w30_clear_sr(bi)
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
250 struct flash_bank_info *bi;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
251 {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
252 uint32_t part;
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
253
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
254 printf("Clearing Intel flash SR\n");
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
255 for (part = 0; part < bi->geom->total_size; part += 0x80000) {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
256 if (do_w16(bi->base_addr + part, 0x50)) {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
257 fprintf(stderr,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
258 "unexpected response to w16 for Clear SR command\n");
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
259 return(-1);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
260 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
261 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
262 return(0);
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
263 }
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
264
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 struct flash_cmdset flash_cmdset_intel = {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 .cmdset_name = "Intel",
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 .reset_cmd = intel_reset_cmd,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 .status_cmd = intel_status_cmd,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 .unlock_sector = intel_sector_unlock,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 .erase_sector = intel_sector_erase,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 .prep_for_program = intel_clear_sr,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 .loadagent_setbase_cmd = "INFB",
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 .loadagent_program_cmd = "INFW",
664
77a0001d8849 fc-loadtool: prep for binary flash programming
Mychaela Falconia <falcon@freecalypso.org>
parents: 506
diff changeset
274 .loadagent_binmode_cmd = "INFWB",
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 .needs_unlock = 1,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 };
325
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
277
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
278 struct flash_cmdset flash_cmdset_intel_w30 = {
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
279 .cmdset_name = "Intel",
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
280 .reset_cmd = intel_w30_reset_cmd,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
281 .status_cmd = intel_w30_status_cmd,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
282 .unlock_sector = intel_sector_unlock,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
283 .erase_sector = intel_sector_erase,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
284 .prep_for_program = intel_w30_clear_sr,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
285 .loadagent_setbase_cmd = "INFB",
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
286 .loadagent_program_cmd = "INFW",
664
77a0001d8849 fc-loadtool: prep for binary flash programming
Mychaela Falconia <falcon@freecalypso.org>
parents: 506
diff changeset
287 .loadagent_binmode_cmd = "INFWB",
325
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
288 .needs_unlock = 1,
545e1718f5fb fc-loadtool: support for 28F640W30B flash chip with partition quirks
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
289 };