Attention is currently required from: Thomas Heijligen, Nicholas Chin.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/70573 )
Change subject: ch347_spi.c: Initial support for the WCH CH347 ......................................................................
Patch Set 2: Code-Review+1
(6 comments)
File ch347_spi.c:
https://review.coreboot.org/c/flashrom/+/70573/comment/d4d56a34_ec6727d6 PS2, Line 24: #define CH347_CMD_SPI_CFG 0xC0 : #define CH347_CMD_SPI_CS_CTRL 0xC1 : #define CH347_CMD_SPI_OUT_IN 0xC2 : #define CH347_CMD_SPI_IN 0xC3 : #define CH347_CMD_SPI_OUT 0xC4 Suggestion: use tabs to align the hex values?
``` #define CH347_CMD_SPI_CFG 0xC0 #define CH347_CMD_SPI_CS_CTRL 0xC1 #define CH347_CMD_SPI_OUT_IN 0xC2 #define CH347_CMD_SPI_IN 0xC3 #define CH347_CMD_SPI_OUT 0xC4 ```
https://review.coreboot.org/c/flashrom/+/70573/comment/63330009_bb1e3c85 PS2, Line 48: static struct libusb_device_handle *handle = NULL; There have been changes to other programmers to pass this kind of data around through the flashctx. It'd be nice to do so here as well.
https://review.coreboot.org/c/flashrom/+/70573/comment/70c9c377_3f928e2e PS2, Line 51: 1 Do you need to specify the array size? Or is this hardcoded because the code below only tries opening a device with this ID?
https://review.coreboot.org/c/flashrom/+/70573/comment/668a20d3_272d8b52 PS2, Line 71: uint8_t cmd[13] = {0}; : cmd[0] = CH347_CMD_SPI_CS_CTRL; : /* payload length, uint16 LSB: 10 */ : cmd[1] = 10; : : cmd[3] = cs1; : cmd[8] = cs2; How about:
``` uint8_t cmd[13] = { [0] = CH347_CMD_SPI_CS_CTRL, /* payload length, uint16 LSB: 10 */ [1] = 10, [3] = cs1, [8] = cs2, }; ```
https://review.coreboot.org/c/flashrom/+/70573/comment/d3e14433_b2a08e5d PS2, Line 221: nit: trailing space
https://review.coreboot.org/c/flashrom/+/70573/comment/455c3f1a_f0b22586 PS2, Line 287: uint16_t vid = devs_ch347_spi[0].vendor_id; : uint16_t pid = devs_ch347_spi[0].device_id; : handle = libusb_open_device_with_vid_pid(NULL, vid, pid); : if (handle == NULL) { : msg_perr("Couldn't open device %04x:%04x.\n", vid, pid); : return -1; : } Does the CH341A code do the same? It should be fine as long as there's only one VID/DID in the list.