summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--flashrom.8.tmpl15
-rw-r--r--include/programmer.h2
-rw-r--r--meson.build8
-rw-r--r--meson_options.txt2
-rw-r--r--parade_lspcon.c (renamed from lspcon_i2c_spi.c)228
-rw-r--r--programmer_table.c4
7 files changed, 136 insertions, 135 deletions
diff --git a/Makefile b/Makefile
index 00477a846..0d0c818ed 100644
--- a/Makefile
+++ b/Makefile
@@ -173,7 +173,7 @@ DEPENDS_ON_LIB_NI845X := \
DEPENDS_ON_LINUX_I2C := \
CONFIG_MSTARDDC_SPI \
- CONFIG_LSPCON_I2C_SPI \
+ CONFIG_PARADE_LSPCON \
CONFIG_REALTEK_MST_I2C_SPI \
CONFIG_MEDIATEK_I2C_SPI \
@@ -455,8 +455,8 @@ CONFIG_PICKIT2_SPI ?= yes
# Always enable STLink V3
CONFIG_STLINKV3_SPI ?= yes
-# Disables LSPCON support until the i2c helper supports multiple systems.
-CONFIG_LSPCON_I2C_SPI ?= no
+# Disables Parade LSPCON support until the i2c helper supports multiple systems.
+CONFIG_PARASE_LSPCON ?= no
# Disables MediaTek support until the i2c helper supports multiple systems.
CONFIG_MEDIATEK_I2C_SPI ?= no
@@ -663,9 +663,9 @@ FEATURE_FLAGS += -D'CONFIG_STLINKV3_SPI=1'
PROGRAMMER_OBJS += stlinkv3_spi.o
endif
-ifeq ($(CONFIG_LSPCON_I2C_SPI), yes)
-FEATURE_FLAGS += -D'CONFIG_LSPCON_I2C_SPI=1'
-PROGRAMMER_OBJS += lspcon_i2c_spi.o
+ifeq ($(CONFIG_PARADE_LSPCON), yes)
+FEATURE_FLAGS += -D'CONFIG_PARADE_LSPCON=1'
+PROGRAMMER_OBJS += parade_lspcon.o
endif
ifeq ($(CONFIG_MEDIATEK_I2C_SPI), yes)
diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl
index b3d44636b..362b14a79 100644
--- a/flashrom.8.tmpl
+++ b/flashrom.8.tmpl
@@ -427,7 +427,7 @@ bitbanging adapter)
.sp
.BR "* realtek_mst_i2c_spi" " (for SPI flash ROMs attached to Realtek DisplayPort hubs accessible through I2C)"
.sp
-.BR "* lspcon_i2c_spi" " (for SPI flash ROMs attached to Parade Technologies LSPCONs)"
+.BR "* parade_lspcon" " (for SPI flash ROMs attached to Parade Technologies LSPCONs (PS175))"
.sp
Some programmers have optional or mandatory parameters which are described
in detail in the
@@ -1521,7 +1521,7 @@ syntax where \fBfrequency\fP is the SPI clock frequency in kHz.
If the passed frequency is not supported by the adapter the nearest lower
supported frequency will be used.
.SS
-.BR "realtek_mst_i2c_spi " and " lspcon_i2c_spi " programmers
+.BR "realtek_mst_i2c_spi " and " parade_lspcon " programmers
.IP
These programmers tunnel SPI commands through I2C-connected devices. The I2C
bus over which communication occurs must be specified either by device path
@@ -1532,7 +1532,7 @@ with the \fBdevpath\fP option:
or by a bus number with the \fBbus\fP option, which implies a device path like
/dev/i2c-N where N is the specified bus number:
.sp
-.B " flashrom \-p lspcon_i2c_spi:bus=8"
+.B " flashrom \-p parade_lspcon:bus=8"
.SS
.BR "realtek_mst_i2c_spi " programmer
@@ -1565,11 +1565,12 @@ flash):
.br
.B " flashrom -p realtek_mst_i2c_spi:bus=0,enter-isp=0,reset-mcu=1 -w new.bin"
.SS
-.BR "lspcon_i2c_spi " programmer
+.BR "parade_lspcon " programmer
.IP
This programmer supports SPI flash programming for chips attached to Parade
-Technologies DisplayPort-to-HDMI level shifter/protocol converters (LSPCONs).
-Communication to the SPI flash is tunneled through the LSPCON over I2C.
+Technologies DisplayPort-to-HDMI level shifter/protocol converters (LSPCONs),
+e.g. the PS175. Communication to the SPI flash is tunneled through the LSPCON
+over I2C.
.SH EXAMPLES
To back up and update your BIOS, run
@@ -1651,7 +1652,7 @@ permissions are set.
.B ogp
needs PCI configuration space read access and raw memory access.
.sp
-.BR realtek_mst_i2c_spi " and " lspcon_i2c_spi
+.BR realtek_mst_i2c_spi " and " parade_lspcon
need userspace access to the selected I2C bus.
.sp
On OpenBSD, you can obtain raw access permission by setting
diff --git a/include/programmer.h b/include/programmer.h
index 38a176102..b7b128f3f 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -75,7 +75,7 @@ extern const struct programmer_entry programmer_it8212;
extern const struct programmer_entry programmer_jlink_spi;
extern const struct programmer_entry programmer_linux_mtd;
extern const struct programmer_entry programmer_linux_spi;
-extern const struct programmer_entry programmer_lspcon_i2c_spi;
+extern const struct programmer_entry programmer_parade_lspcon;
extern const struct programmer_entry programmer_mediatek_i2c_spi;
extern const struct programmer_entry programmer_mstarddc_spi;
extern const struct programmer_entry programmer_ni845x_spi;
diff --git a/meson.build b/meson.build
index 914b8896a..83e175cec 100644
--- a/meson.build
+++ b/meson.build
@@ -71,7 +71,7 @@ config_satasii = get_option('config_satasii')
config_serprog = get_option('config_serprog')
config_usbblaster_spi = get_option('config_usbblaster_spi')
config_stlinkv3_spi = get_option('config_stlinkv3_spi')
-config_lspcon_i2c_spi = get_option('config_lspcon_i2c_spi')
+config_parade_lspcon = get_option('config_parade_lspcon')
config_mediatek_i2c_spi = get_option('config_mediatek_i2c_spi')
config_realtek_mst_i2c_spi = get_option('config_realtek_mst_i2c_spi')
config_print_wiki= get_option('print_wiki')
@@ -359,9 +359,9 @@ if config_stlinkv3_spi
srcs += files('stlinkv3_spi.c')
cargs += '-DCONFIG_STLINKV3_SPI=1'
endif
-if config_lspcon_i2c_spi
- srcs += files('lspcon_i2c_spi.c')
- cargs += '-DCONFIG_LSPCON_I2C_SPI=1'
+if config_parade_lspcon
+ srcs += files('parade_lspcon.c')
+ cargs += '-DCONFIG_PARADE_LSPCON=1'
endif
if config_mediatek_i2c_spi
srcs += files('mediatek_i2c_spi.c')
diff --git a/meson_options.txt b/meson_options.txt
index 46ac763a3..3d37914ba 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -39,7 +39,7 @@ option('config_satasii', type : 'boolean', value : true, description : 'SiI SATA
option('config_serprog', type : 'boolean', value : true, description : 'serprog')
option('config_usbblaster_spi', type : 'boolean', value : true, description : 'Altera USB-Blaster dongles')
option('config_stlinkv3_spi', type : 'boolean', value : true, description : 'STMicroelectronics STLINK-V3')
-option('config_lspcon_i2c_spi', type : 'boolean', value : false, description : 'Parade lspcon USB-C to HDMI protocol translator')
+option('config_parade_lspcon', type : 'boolean', value : false, description : 'Parade USB-C to HDMI protocol translator')
option('config_mediatek_i2c_spi', type : 'boolean', value : false, description : 'MediaTek LCD controller')
option('config_realtek_mst_i2c_spi', type : 'boolean', value : true, description : 'Realtek MultiStream Transport MST')
option('tests', type : 'feature', value : 'auto', description : 'Build unit tests')
diff --git a/lspcon_i2c_spi.c b/parade_lspcon.c
index 6e1d65ef8..06da2d583 100644
--- a/lspcon_i2c_spi.c
+++ b/parade_lspcon.c
@@ -27,7 +27,7 @@
#define REGISTER_ADDRESS (0x94 >> 1)
#define PAGE_ADDRESS (0x9e >> 1)
-#define LSPCON_PAGE_SIZE 256
+#define PAGE_SIZE 256
#define MAX_SPI_WAIT_RETRIES 1000
#define CLT2_SPI 0x82
@@ -69,7 +69,7 @@
#define PAGE_HW_COFIG_REGISTER 0xaa
#define PAGE_HW_WRITE_ENABLE 0x55
-struct lspcon_i2c_spi_data {
+struct parade_lspcon_data {
int fd;
};
@@ -80,7 +80,7 @@ typedef struct {
uint8_t control;
} packet_t;
-static int lspcon_i2c_spi_write_data(int fd, uint16_t addr, void *buf, uint16_t len)
+static int parade_lspcon_write_data(int fd, uint16_t addr, void *buf, uint16_t len)
{
i2c_buffer_t data;
if (i2c_buffer_t_fill(&data, buf, len))
@@ -89,7 +89,7 @@ static int lspcon_i2c_spi_write_data(int fd, uint16_t addr, void *buf, uint16_t
return i2c_write(fd, addr, &data) == len ? 0 : SPI_GENERIC_ERROR;
}
-static int lspcon_i2c_spi_read_data(int fd, uint16_t addr, void *buf, uint16_t len)
+static int parade_lspcon_read_data(int fd, uint16_t addr, void *buf, uint16_t len)
{
i2c_buffer_t data;
if (i2c_buffer_t_fill(&data, buf, len))
@@ -104,53 +104,53 @@ static int get_fd_from_context(const struct flashctx *flash)
msg_perr("Unable to extract fd from flash context.\n");
return SPI_GENERIC_ERROR;
}
- const struct lspcon_i2c_spi_data *data =
- (const struct lspcon_i2c_spi_data *)flash->mst->spi.data;
+ const struct parade_lspcon_data *data =
+ (const struct parade_lspcon_data *)flash->mst->spi.data;
return data->fd;
}
-static int lspcon_i2c_spi_write_register(int fd, uint8_t i2c_register, uint8_t value)
+static int parade_lspcon_write_register(int fd, uint8_t i2c_register, uint8_t value)
{
uint8_t command[] = { i2c_register, value };
- return lspcon_i2c_spi_write_data(fd, REGISTER_ADDRESS, command, 2);
+ return parade_lspcon_write_data(fd, REGISTER_ADDRESS, command, 2);
}
-static int lspcon_i2c_spi_read_register(int fd, uint8_t i2c_register, uint8_t *value)
+static int parade_lspcon_read_register(int fd, uint8_t i2c_register, uint8_t *value)
{
uint8_t command[] = { i2c_register };
- int ret = lspcon_i2c_spi_write_data(fd, REGISTER_ADDRESS, command, 1);
- ret |= lspcon_i2c_spi_read_data(fd, REGISTER_ADDRESS, value, 1);
+ int ret = parade_lspcon_write_data(fd, REGISTER_ADDRESS, command, 1);
+ ret |= parade_lspcon_read_data(fd, REGISTER_ADDRESS, value, 1);
return ret ? SPI_GENERIC_ERROR : 0;
}
-static int lspcon_i2c_spi_register_control(int fd, packet_t *packet)
+static int parade_lspcon_register_control(int fd, packet_t *packet)
{
int i;
- int ret = lspcon_i2c_spi_write_register(fd, SWSPI_WDATA, packet->command);
+ int ret = parade_lspcon_write_register(fd, SWSPI_WDATA, packet->command);
if (ret)
return ret;
/* Higher 4 bits are read size. */
int write_size = packet->data_size & 0x0f;
for (i = 0; i < write_size; ++i) {
- ret |= lspcon_i2c_spi_write_register(fd, SWSPI_WDATA, packet->data[i]);
+ ret |= parade_lspcon_write_register(fd, SWSPI_WDATA, packet->data[i]);
}
- ret |= lspcon_i2c_spi_write_register(fd, SWSPI_LEN, packet->data_size);
- ret |= lspcon_i2c_spi_write_register(fd, SWSPICTL, packet->control);
+ ret |= parade_lspcon_write_register(fd, SWSPI_LEN, packet->data_size);
+ ret |= parade_lspcon_write_register(fd, SWSPICTL, packet->control);
return ret;
}
-static int lspcon_i2c_spi_wait_command_done(int fd, unsigned int offset, int mask)
+static int parade_lspcon_wait_command_done(int fd, unsigned int offset, int mask)
{
uint8_t val;
int tried = 0;
int ret = 0;
do {
- ret |= lspcon_i2c_spi_read_register(fd, offset, &val);
+ ret |= parade_lspcon_read_register(fd, offset, &val);
} while (!ret && (val & mask) && ++tried < MAX_SPI_WAIT_RETRIES);
if (tried == MAX_SPI_WAIT_RETRIES) {
@@ -161,21 +161,21 @@ static int lspcon_i2c_spi_wait_command_done(int fd, unsigned int offset, int mas
return (val & mask) ? SPI_GENERIC_ERROR : ret;
}
-static int lspcon_i2c_spi_wait_rom_free(int fd)
+static int parade_lspcon_wait_rom_free(int fd)
{
uint8_t val;
int tried = 0;
int ret = 0;
- ret |= lspcon_i2c_spi_wait_command_done(fd, SPISTATUS,
+ ret |= parade_lspcon_wait_command_done(fd, SPISTATUS,
SPISTATUS_SECTOR_ERASE_IN_IF | SPISTATUS_SECTOR_ERASE_SEND_DONE);
if (ret)
return ret;
do {
packet_t packet = { SWSPI_WDATA_READ_REGISTER, NULL, 0, SWSPICTL_ACCESS_TRIGGER };
- ret |= lspcon_i2c_spi_register_control(fd, &packet);
- ret |= lspcon_i2c_spi_wait_command_done(fd, SWSPICTL, SWSPICTL_ACCESS_TRIGGER);
- ret |= lspcon_i2c_spi_read_register(fd, SWSPI_RDATA, &val);
+ ret |= parade_lspcon_register_control(fd, &packet);
+ ret |= parade_lspcon_wait_command_done(fd, SWSPICTL, SWSPICTL_ACCESS_TRIGGER);
+ ret |= parade_lspcon_read_register(fd, SWSPI_RDATA, &val);
} while (!ret && (val & SWSPICTL_ACCESS_TRIGGER) && ++tried < MAX_SPI_WAIT_RETRIES);
if (tried == MAX_SPI_WAIT_RETRIES) {
@@ -186,72 +186,72 @@ static int lspcon_i2c_spi_wait_rom_free(int fd)
return (val & SWSPICTL_ACCESS_TRIGGER) ? SPI_GENERIC_ERROR : ret;
}
-static int lspcon_i2c_spi_toggle_register_protection(int fd, int toggle)
+static int parade_lspcon_toggle_register_protection(int fd, int toggle)
{
- return lspcon_i2c_spi_write_register(fd, WRITE_PROTECTION,
+ return parade_lspcon_write_register(fd, WRITE_PROTECTION,
toggle ? WRITE_PROTECTION_OFF : WRITE_PROTECTION_ON);
}
-static int lspcon_i2c_spi_enable_write_status_register(int fd)
+static int parade_lspcon_enable_write_status_register(int fd)
{
- int ret = lspcon_i2c_spi_toggle_register_protection(fd, 1);
+ int ret = parade_lspcon_toggle_register_protection(fd, 1);
packet_t packet = {
SWSPI_WDATA_ENABLE_REGISTER, NULL, 0, SWSPICTL_ACCESS_TRIGGER | SWSPICTL_NO_READ };
- ret |= lspcon_i2c_spi_register_control(fd, &packet);
- ret |= lspcon_i2c_spi_toggle_register_protection(fd, 0);
+ ret |= parade_lspcon_register_control(fd, &packet);
+ ret |= parade_lspcon_toggle_register_protection(fd, 0);
return ret;
}
-static int lspcon_i2c_spi_enable_write_status_register_protection(int fd)
+static int parade_lspcon_enable_write_status_register_protection(int fd)
{
- int ret = lspcon_i2c_spi_toggle_register_protection(fd, 1);
+ int ret = parade_lspcon_toggle_register_protection(fd, 1);
uint8_t data[] = { SWSPI_WDATA_PROTECT_BP };
packet_t packet = {
SWSPI_WDATA_WRITE_REGISTER, data, 1, SWSPICTL_ACCESS_TRIGGER | SWSPICTL_NO_READ };
- ret |= lspcon_i2c_spi_register_control(fd, &packet);
- ret |= lspcon_i2c_spi_toggle_register_protection(fd, 0);
+ ret |= parade_lspcon_register_control(fd, &packet);
+ ret |= parade_lspcon_toggle_register_protection(fd, 0);
return ret;
}
-static int lspcon_i2c_spi_disable_protection(int fd)
+static int parade_lspcon_disable_protection(int fd)
{
- int ret = lspcon_i2c_spi_toggle_register_protection(fd, 1);
+ int ret = parade_lspcon_toggle_register_protection(fd, 1);
uint8_t data[] = { SWSPI_WDATA_CLEAR_STATUS };
packet_t packet = {
SWSPI_WDATA_WRITE_REGISTER, data, 1, SWSPICTL_ACCESS_TRIGGER | SWSPICTL_NO_READ };
- ret |= lspcon_i2c_spi_register_control(fd, &packet);
- ret |= lspcon_i2c_spi_toggle_register_protection(fd, 0);
+ ret |= parade_lspcon_register_control(fd, &packet);
+ ret |= parade_lspcon_toggle_register_protection(fd, 0);
return ret;
}
-static int lspcon_i2c_spi_disable_hw_write(int fd)
+static int parade_lspcon_disable_hw_write(int fd)
{
- return lspcon_i2c_spi_write_register(fd, PAGE_HW_WRITE, PAGE_HW_WRITE_DISABLE);
+ return parade_lspcon_write_register(fd, PAGE_HW_WRITE, PAGE_HW_WRITE_DISABLE);
}
-static int lspcon_i2c_spi_enable_write_protection(int fd)
+static int parade_lspcon_enable_write_protection(int fd)
{
- int ret = lspcon_i2c_spi_enable_write_status_register(fd);
- ret |= lspcon_i2c_spi_enable_write_status_register_protection(fd);
- ret |= lspcon_i2c_spi_wait_rom_free(fd);
- ret |= lspcon_i2c_spi_disable_hw_write(fd);
+ int ret = parade_lspcon_enable_write_status_register(fd);
+ ret |= parade_lspcon_enable_write_status_register_protection(fd);
+ ret |= parade_lspcon_wait_rom_free(fd);
+ ret |= parade_lspcon_disable_hw_write(fd);
return ret;
}
-static int lspcon_i2c_spi_disable_all_protection(int fd)
+static int parade_lspcon_disable_all_protection(int fd)
{
- int ret = lspcon_i2c_spi_enable_write_status_register(fd);
- ret |= lspcon_i2c_spi_disable_protection(fd);
- ret |= lspcon_i2c_spi_wait_rom_free(fd);
+ int ret = parade_lspcon_enable_write_status_register(fd);
+ ret |= parade_lspcon_disable_protection(fd);
+ ret |= parade_lspcon_wait_rom_free(fd);
return ret;
}
-static int lspcon_i2c_spi_send_command(const struct flashctx *flash,
+static int parade_lspcon_send_command(const struct flashctx *flash,
unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr,
unsigned char *readarr)
@@ -267,9 +267,9 @@ static int lspcon_i2c_spi_send_command(const struct flashctx *flash,
if (fd < 0)
return SPI_GENERIC_ERROR;
- int ret = lspcon_i2c_spi_disable_all_protection(fd);
- ret |= lspcon_i2c_spi_enable_write_status_register(fd);
- ret |= lspcon_i2c_spi_toggle_register_protection(fd, 1);
+ int ret = parade_lspcon_disable_all_protection(fd);
+ ret |= parade_lspcon_enable_write_status_register(fd);
+ ret |= parade_lspcon_toggle_register_protection(fd, 1);
/* First byte of writearr should be the command value, followed by the value to write.
Read length occupies 4 bit and represents 16 level, thus if read 1 byte,
@@ -279,67 +279,67 @@ static int lspcon_i2c_spi_send_command(const struct flashctx *flash,
SWSPICTL_ACCESS_TRIGGER | (readcnt ? 0 : SWSPICTL_NO_READ),
};
- ret |= lspcon_i2c_spi_register_control(fd, &packet);
- ret |= lspcon_i2c_spi_wait_command_done(fd, SWSPICTL, SWSPICTL_ACCESS_TRIGGER);
- ret |= lspcon_i2c_spi_toggle_register_protection(fd, 0);
+ ret |= parade_lspcon_register_control(fd, &packet);
+ ret |= parade_lspcon_wait_command_done(fd, SWSPICTL, SWSPICTL_ACCESS_TRIGGER);
+ ret |= parade_lspcon_toggle_register_protection(fd, 0);
if (ret)
return ret;
for (i = 0; i < readcnt; ++i) {
- ret |= lspcon_i2c_spi_read_register(fd, SWSPI_RDATA, &readarr[i]);
+ ret |= parade_lspcon_read_register(fd, SWSPI_RDATA, &readarr[i]);
}
- ret |= lspcon_i2c_spi_wait_rom_free(fd);
+ ret |= parade_lspcon_wait_rom_free(fd);
return ret;
}
-static int lspcon_i2c_spi_enable_hw_write(int fd)
+static int parade_lspcon_enable_hw_write(int fd)
{
int ret = 0;
- ret |= lspcon_i2c_spi_write_register(fd, PAGE_HW_WRITE, PAGE_HW_COFIG_REGISTER);
- ret |= lspcon_i2c_spi_write_register(fd, PAGE_HW_WRITE, PAGE_HW_WRITE_ENABLE);
- ret |= lspcon_i2c_spi_write_register(fd, PAGE_HW_WRITE, 0x50);
- ret |= lspcon_i2c_spi_write_register(fd, PAGE_HW_WRITE, 0x41);
- ret |= lspcon_i2c_spi_write_register(fd, PAGE_HW_WRITE, 0x52);
- ret |= lspcon_i2c_spi_write_register(fd, PAGE_HW_WRITE, 0x44);
+ ret |= parade_lspcon_write_register(fd, PAGE_HW_WRITE, PAGE_HW_COFIG_REGISTER);
+ ret |= parade_lspcon_write_register(fd, PAGE_HW_WRITE, PAGE_HW_WRITE_ENABLE);
+ ret |= parade_lspcon_write_register(fd, PAGE_HW_WRITE, 0x50);
+ ret |= parade_lspcon_write_register(fd, PAGE_HW_WRITE, 0x41);
+ ret |= parade_lspcon_write_register(fd, PAGE_HW_WRITE, 0x52);
+ ret |= parade_lspcon_write_register(fd, PAGE_HW_WRITE, 0x44);
return ret;
}
-static int lspcon_i2c_clt2_spi_reset(int fd)
+static int parade_lspcon_i2c_clt2_spi_reset(int fd)
{
int ret = 0;
- ret |= lspcon_i2c_spi_write_register(fd, CLT2_SPI, 0x20);
+ ret |= parade_lspcon_write_register(fd, CLT2_SPI, 0x20);
struct timespec wait_100ms = { 0, (unsigned)1e8 };
nanosleep(&wait_100ms, NULL);
- ret |= lspcon_i2c_spi_write_register(fd, CLT2_SPI, 0x00);
+ ret |= parade_lspcon_write_register(fd, CLT2_SPI, 0x00);
return ret;
}
-static int lspcon_i2c_spi_set_mpu_active(int fd, int running)
+static int parade_lspcon_set_mpu_active(int fd, int running)
{
int ret = 0;
// Cmd mode
- ret |= lspcon_i2c_spi_write_register(fd, MPU, 0xc0);
+ ret |= parade_lspcon_write_register(fd, MPU, 0xc0);
// Stop or release MPU
- ret |= lspcon_i2c_spi_write_register(fd, MPU, running ? 0 : 0x40);
+ ret |= parade_lspcon_write_register(fd, MPU, running ? 0 : 0x40);
return ret;
}
-static int lspcon_i2c_spi_map_page(int fd, unsigned int offset)
+static int parade_lspcon_map_page(int fd, unsigned int offset)
{
int ret = 0;
- /* Page number byte, need to / LSPCON_PAGE_SIZE. */
- ret |= lspcon_i2c_spi_write_register(fd, ROMADDR_BYTE1, (offset >> 8) & 0xff);
- ret |= lspcon_i2c_spi_write_register(fd, ROMADDR_BYTE2, (offset >> 16));
+ /* Page number byte, need to / PAGE_SIZE. */
+ ret |= parade_lspcon_write_register(fd, ROMADDR_BYTE1, (offset >> 8) & 0xff);
+ ret |= parade_lspcon_write_register(fd, ROMADDR_BYTE2, (offset >> 16));
return ret ? SPI_GENERIC_ERROR : 0;
}
-static int lspcon_i2c_spi_read(struct flashctx *flash, uint8_t *buf,
+static int parade_lspcon_read(struct flashctx *flash, uint8_t *buf,
unsigned int start, unsigned int len)
{
unsigned int i;
@@ -351,32 +351,32 @@ static int lspcon_i2c_spi_read(struct flashctx *flash, uint8_t *buf,
if (fd < 0)
return SPI_GENERIC_ERROR;
- for (i = 0; i < len; i += LSPCON_PAGE_SIZE) {
- ret |= lspcon_i2c_spi_map_page(fd, start + i);
- ret |= lspcon_i2c_spi_read_data(fd, PAGE_ADDRESS, buf + i, min(len - i, LSPCON_PAGE_SIZE));
- update_progress(flash, FLASHROM_PROGRESS_READ, i + LSPCON_PAGE_SIZE, len);
+ for (i = 0; i < len; i += PAGE_SIZE) {
+ ret |= parade_lspcon_map_page(fd, start + i);
+ ret |= parade_lspcon_read_data(fd, PAGE_ADDRESS, buf + i, min(len - i, PAGE_SIZE));
+ update_progress(flash, FLASHROM_PROGRESS_READ, i + PAGE_SIZE, len);
}
return ret;
}
-static int lspcon_i2c_spi_write_page(int fd, const uint8_t *buf, unsigned int len)
+static int parade_lspcon_write_page(int fd, const uint8_t *buf, unsigned int len)
{
/**
* Using static buffer with maximum possible size,
* extra byte is needed for prefixing zero at index 0.
*/
- uint8_t write_buffer[LSPCON_PAGE_SIZE + 1] = { 0 };
- if (len > LSPCON_PAGE_SIZE)
+ uint8_t write_buffer[PAGE_SIZE + 1] = { 0 };
+ if (len > PAGE_SIZE)
return SPI_GENERIC_ERROR;
/* First byte represents the writing offset and should always be zero. */
memcpy(&write_buffer[1], buf, len);
- return lspcon_i2c_spi_write_data(fd, PAGE_ADDRESS, write_buffer, len + 1);
+ return parade_lspcon_write_data(fd, PAGE_ADDRESS, write_buffer, len + 1);
}
-static int lspcon_i2c_spi_write_256(struct flashctx *flash, const uint8_t *buf,
+static int parade_lspcon_write_256(struct flashctx *flash, const uint8_t *buf,
unsigned int start, unsigned int len)
{
int ret = 0;
@@ -387,24 +387,24 @@ static int lspcon_i2c_spi_write_256(struct flashctx *flash, const uint8_t *buf,
if (fd < 0)
return SPI_GENERIC_ERROR;
- ret |= lspcon_i2c_spi_disable_all_protection(fd);
+ ret |= parade_lspcon_disable_all_protection(fd);
/* Enable hardware write and reset clt2SPI interface. */
- ret |= lspcon_i2c_spi_enable_hw_write(fd);
- ret |= lspcon_i2c_clt2_spi_reset(fd);
+ ret |= parade_lspcon_enable_hw_write(fd);
+ ret |= parade_lspcon_i2c_clt2_spi_reset(fd);
- for (unsigned int i = 0; i < len; i += LSPCON_PAGE_SIZE) {
- ret |= lspcon_i2c_spi_map_page(fd, start + i);
- ret |= lspcon_i2c_spi_write_page(fd, buf + i, min(len - i, LSPCON_PAGE_SIZE));
- update_progress(flash, FLASHROM_PROGRESS_WRITE, i + LSPCON_PAGE_SIZE, len);
+ for (unsigned int i = 0; i < len; i += PAGE_SIZE) {
+ ret |= parade_lspcon_map_page(fd, start + i);
+ ret |= parade_lspcon_write_page(fd, buf + i, min(len - i, PAGE_SIZE));
+ update_progress(flash, FLASHROM_PROGRESS_WRITE, i + PAGE_SIZE, len);
}
- ret |= lspcon_i2c_spi_enable_write_protection(fd);
- ret |= lspcon_i2c_spi_disable_hw_write(fd);
+ ret |= parade_lspcon_enable_write_protection(fd);
+ ret |= parade_lspcon_disable_hw_write(fd);
return ret;
}
-static int lspcon_i2c_spi_write_aai(struct flashctx *flash, const uint8_t *buf,
+static int parade_lspcon_write_aai(struct flashctx *flash, const uint8_t *buf,
unsigned int start, unsigned int len)
{
msg_perr("%s: AAI write function is not supported.\n",
@@ -412,48 +412,48 @@ static int lspcon_i2c_spi_write_aai(struct flashctx *flash, const uint8_t *buf,
return SPI_GENERIC_ERROR;
}
-static int lspcon_i2c_spi_shutdown(void *data)
+static int parade_lspcon_shutdown(void *data)
{
int ret = 0;
- struct lspcon_i2c_spi_data *lspcon_data =
- (struct lspcon_i2c_spi_data *)data;
- int fd = lspcon_data->fd;
+ struct parade_lspcon_data *parade_lspcon_data =
+ (struct parade_lspcon_data *)data;
+ int fd = parade_lspcon_data->fd;
- ret |= lspcon_i2c_spi_enable_write_protection(fd);
- ret |= lspcon_i2c_spi_toggle_register_protection(fd, 0);
- ret |= lspcon_i2c_spi_set_mpu_active(fd, 1);
+ ret |= parade_lspcon_enable_write_protection(fd);
+ ret |= parade_lspcon_toggle_register_protection(fd, 0);
+ ret |= parade_lspcon_set_mpu_active(fd, 1);
i2c_close(fd);
free(data);
return ret;
}
-static const struct spi_master spi_master_i2c_lspcon = {
+static const struct spi_master spi_master_parade_lspcon = {
.max_data_read = 16,
.max_data_write = 12,
- .command = lspcon_i2c_spi_send_command,
+ .command = parade_lspcon_send_command,
.multicommand = default_spi_send_multicommand,
- .read = lspcon_i2c_spi_read,
- .write_256 = lspcon_i2c_spi_write_256,
- .write_aai = lspcon_i2c_spi_write_aai,
- .shutdown = lspcon_i2c_spi_shutdown,
+ .read = parade_lspcon_read,
+ .write_256 = parade_lspcon_write_256,
+ .write_aai = parade_lspcon_write_aai,
+ .shutdown = parade_lspcon_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
-static int lspcon_i2c_spi_init(void)
+static int parade_lspcon_init(void)
{
int fd = i2c_open_from_programmer_params(REGISTER_ADDRESS, 0);
if (fd < 0)
return fd;
- int ret = lspcon_i2c_spi_set_mpu_active(fd, 0);
+ int ret = parade_lspcon_set_mpu_active(fd, 0);
if (ret) {
msg_perr("%s: call to set_mpu_active failed.\n", __func__);
i2c_close(fd);
return ret;
}
- struct lspcon_i2c_spi_data *data = calloc(1, sizeof(*data));
+ struct parade_lspcon_data *data = calloc(1, sizeof(*data));
if (!data) {
msg_perr("Unable to allocate space for extra SPI master data.\n");
i2c_close(fd);
@@ -462,14 +462,14 @@ static int lspcon_i2c_spi_init(void)
data->fd = fd;
- return register_spi_master(&spi_master_i2c_lspcon, data);
+ return register_spi_master(&spi_master_parade_lspcon, data);
}
-const struct programmer_entry programmer_lspcon_i2c_spi = {
- .name = "lspcon_i2c_spi",
+const struct programmer_entry programmer_parade_lspcon = {
+ .name = "parade_lspcon",
.type = OTHER,
.devs.note = "Device files /dev/i2c-*.\n",
- .init = lspcon_i2c_spi_init,
+ .init = parade_lspcon_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
diff --git a/programmer_table.c b/programmer_table.c
index 2a06c30d0..818cea724 100644
--- a/programmer_table.c
+++ b/programmer_table.c
@@ -124,8 +124,8 @@ const struct programmer_entry *const programmer_table[] = {
&programmer_linux_spi,
#endif
-#if CONFIG_LSPCON_I2C_SPI == 1
- &programmer_lspcon_i2c_spi,
+#if CONFIG_PARADE_LSPCON == 1
+ &programmer_parade_lspcon,
#endif
#if CONFIG_MEDIATEK_I2C_SPI == 1