Commit 0870b025 authored by Urja Rannikko's avatar Urja Rannikko Committed by Stefan Tauner

Add support for WCH CH341A as an SPI programmer

Corresponding to flashrom svn r1921.
Signed-off-by: default avatarUrja Rannikko <urjaman@gmail.com>
Signed-off-by: default avatarStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: default avatarUrja Rannikko <urjaman@gmail.com>
parent e49edbb8
......@@ -157,7 +157,7 @@ UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
else
override CONFIG_PONY_SPI = no
endif
# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported under DOS (missing USB support).
# Dediprog, USB-Blaster, PICkit2, CH341A and FT2232 are not supported under DOS (missing USB support).
ifeq ($(CONFIG_DEDIPROG), yes)
UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
else
......@@ -178,6 +178,11 @@ UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
else
override CONFIG_PICKIT2_SPI = no
endif
ifeq ($(CONFIG_CH341A_SPI), yes)
UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
else
override CONFIG_CH341A_SPI = no
endif
endif
# FIXME: Should we check for Cygwin/MSVC as well?
......@@ -303,7 +308,7 @@ UNSUPPORTED_FEATURES += CONFIG_PONY_SPI=yes
else
override CONFIG_PONY_SPI = no
endif
# Dediprog, USB-Blaster, PICkit2 and FT2232 are not supported with libpayload (missing libusb support)
# Dediprog, USB-Blaster, PICkit2, CH341A and FT2232 are not supported with libpayload (missing libusb support)
ifeq ($(CONFIG_DEDIPROG), yes)
UNSUPPORTED_FEATURES += CONFIG_DEDIPROG=yes
else
......@@ -324,6 +329,11 @@ UNSUPPORTED_FEATURES += CONFIG_PICKIT2_SPI=yes
else
override CONFIG_PICKIT2_SPI = no
endif
ifeq ($(CONFIG_CH341A_SPI), yes)
UNSUPPORTED_FEATURES += CONFIG_CH341A_SPI=yes
else
override CONFIG_CH341A_SPI = no
endif
endif
ifneq ($(TARGET_OS), Linux)
......@@ -505,6 +515,9 @@ CONFIG_LINUX_SPI ?= yes
# Always enable ITE IT8212F PATA controllers for now.
CONFIG_IT8212 ?= yes
# Winchiphead CH341A
CONFIG_CH341A_SPI ?= yes
# Disable wiki printing by default. It is only useful if you have wiki access.
CONFIG_PRINT_WIKI ?= no
......@@ -751,6 +764,12 @@ NEED_LINUX_I2C := yes
PROGRAMMER_OBJS += mstarddc_spi.o
endif
ifeq ($(CONFIG_CH341A_SPI), yes)
FEATURE_CFLAGS += -D'CONFIG_CH341A_SPI=1'
PROGRAMMER_OBJS += ch341a_spi.o
NEED_LIBUSB1 := yes
endif
ifeq ($(NEED_SERIAL), yes)
LIB_OBJS += serial.o
endif
......
This diff is collapsed.
......@@ -271,6 +271,8 @@ bitbanging adapter)
.sp
.BR "* pickit2_spi" " (for SPI flash ROMs accessible via Microchip PICkit2)"
.sp
.BR "* ch341a_spi" " (for SPI flash ROMs attached to WCH CH341A)"
.sp
Some programmers have optional or mandatory parameters which are described
in detail in the
.B PROGRAMMER-SPECIFIC INFORMATION
......@@ -1019,6 +1021,10 @@ an operation), without the
parameter, once the flash read/write operation you intended to perform has completed successfully.
.sp
Please also note that the mstarddc_spi driver only works on Linux.
.SS
.BR "ch341a_spi " programmer
The WCH CH341A programmer does not support any parameters currently. SPI frequency is fixed at 2 MHz, and CS0 is
used as per the device.
.SH EXAMPLES
To back up and update your BIOS, run
.sp
......@@ -1078,6 +1084,9 @@ needs userspace access to a serial port.
.BR dediprog ", " ft2232_spi ", " usbblaster_spi " and " pickit2_spi
need access to the respective USB device via libusb API version 0.1.
.sp
.BR ch341a_spi
needs access to the respective USB device via libusb API version 1.0.
.sp
.B dummy
needs no access permissions at all.
.sp
......@@ -1085,7 +1094,8 @@ needs no access permissions at all.
.BR gfxnvidia ", " drkaiser ", " satasii ", " satamv ", " atahpt ", " atavia " and " atapromise
have to be run as superuser/root, and need additional raw access permission.
.sp
.BR serprog ", " buspirate_spi ", " dediprog ", " usbblaster_spi ", " ft2232_spi " and " pickit2_spi
.BR serprog ", " buspirate_spi ", " dediprog ", " usbblaster_spi ", " ft2232_spi ", " pickit2_spi " and " \
ch341a_spi
can be run as normal user on most operating systems if appropriate device
permissions are set.
.sp
......
......@@ -392,6 +392,18 @@ const struct programmer_entry programmer_table[] = {
},
#endif
#if CONFIG_CH341A_SPI == 1
{
.name = "ch341a_spi",
.type = USB,
.devs.dev = devs_ch341a_spi,
.init = ch341a_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = ch341a_spi_delay,
},
#endif
{0}, /* This entry corresponds to PROGRAMMER_INVALID. */
};
......
......@@ -107,6 +107,9 @@ enum programmer {
#endif
#if CONFIG_PICKIT2_SPI == 1
PROGRAMMER_PICKIT2_SPI,
#endif
#if CONFIG_CH341A_SPI == 1
PROGRAMMER_CH341A_SPI,
#endif
PROGRAMMER_INVALID /* This must always be the last entry. */
};
......@@ -526,6 +529,13 @@ int linux_spi_init(void);
int dediprog_init(void);
#endif
/* ch341a_spi.c */
#if CONFIG_CH341A_SPI == 1
int ch341a_spi_init(void);
void ch341a_spi_delay(unsigned int usecs);
extern const struct dev_entry devs_ch341a_spi[];
#endif
/* flashrom.c */
struct decode_sizes {
uint32_t parallel;
......@@ -585,6 +595,9 @@ enum spi_controller {
#if CONFIG_PICKIT2_SPI == 1
SPI_CONTROLLER_PICKIT2,
#endif
#if CONFIG_CH341A_SPI == 1
SPI_CONTROLLER_CH341A_SPI,
#endif
};
#define MAX_DATA_UNSPECIFIED 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment