Jes Klinke has uploaded this change for review.
raiden: Support target index with generic REQ_ENABLE
Some devices such as the GSC knows how it is wired to AP and EC flash
chips, and can be told which specific device to talk to. Other devices
such as Servo Micro and HyperDebug are generic, and do not know how they
are wired, the caller is responsible for first configure the appropriate
MUXes or buffers, and then tell the debugger which port to use (Servo
Micro has just one SPI port, HyperDebug is the first that has multiple).
The Raiden protocol allows both the cases of USB devices knowing their
wiring and not.
If I were to declare the protocol in Rust, this is how the information
of the "enable request" would be encoded:
```
enum {
EnableGeneric(u8),
EnableAp,
EnableEc,
...
}
```
The first label `EnableGeneric(u8)` is to be used with HyperDebug that
does not know how its ports are wired, and allow access by index.
The other labels `EnableAp` and `EnableEc` are to be used with the GSC.
The actual transmission of the enum above uses the bRequest and low byte
of wValue of a USB control request, but that is a detail and not
conceptually important.
Until now, `target=AP` or `target=EC` could be used to make flashrom use
`EnableAp` or `EnableEc`, and if neither was given, it would default to
`EnableGeneric`, which now that wValue is used means `EnableGeneric(0)`.
I find it rather straight-forward, that `target=1`, `target=2`,
etc. should translate to `EnableGeneric(1)`, etc.
This CL archieves this, by encoding the parameter to `EnableGeneric` as
the second byte of the request_enable integer value.
TEST=run flashrom with HyperDebug
Signed-off-by: Jes B. Klinke <jbk@chromium.org>
Change-Id: I03bf4f3210186fb5937b42e298761907b03e08b7
---
M raiden_debug_spi.c
1 file changed, 10 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/99/77999/1
diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c
index c5642ff..4f2e35b 100644
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -1460,7 +1460,11 @@
char *target_str = extract_programmer_param_str(cfg, "target");
if (target_str) {
- if (!strcasecmp(target_str, "ap"))
+ char *endptr;
+ int index = strtol(target_str, &endptr, 0);
+ if (*target_str && !*endptr && index >= 0 && index < 256) {
+ request_enable = RAIDEN_DEBUG_SPI_REQ_ENABLE | (index << 8);
+ } else if (!strcasecmp(target_str, "ap"))
request_enable = get_ap_request_type(cfg);
else if (!strcasecmp(target_str, "ec"))
request_enable = RAIDEN_DEBUG_SPI_REQ_ENABLE_EC;
@@ -1470,7 +1474,9 @@
}
}
free(target_str);
- msg_pinfo("Raiden target: %d\n", request_enable);
+ if (request_enable >= 0)
+ msg_pinfo("Raiden target: %d,%d\n",
+ request_enable & 0xFF, (request_enable >> 8) & 0xFF);
return request_enable;
}
@@ -1587,8 +1593,8 @@
LIBUSB_ENDPOINT_OUT |
LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_RECIPIENT_INTERFACE,
- request_enable,
- 0,
+ request_enable & 0xFF,
+ (request_enable >> 8) & 0xFF,
device->interface_descriptor->bInterfaceNumber,
NULL,
0,
To view, visit change 77999. To unsubscribe, or for help writing mail filters, visit settings.