summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-08-13 09:13:25 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-16 10:00:34 +0000
commitece6cde90cfec4c42c4d9851c85db3b3f76bd661 (patch)
tree673142cb757e2d2530e11e9f32b7418733ca8c92
parentc5f38f5cae150f82803c669c639a48960bfbb809 (diff)
downloadchrome-ec-ece6cde90cfec4c42c4d9851c85db3b3f76bd661.tar.gz
bmi260: back out support for compressed config file
Now that the BMI260 config file can be moved to the .init_rom section, the simple compression scheme is no longer needed. BUG=b:160330682 BRANCH=none TEST=make buildall TEST=Verify BMI260 operation on both volteer and volteer_tcpmv1 builds using "ectool motionsense lid_angle". Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I83bbaadcd3dade2d585b771b6b9ebae7e9fdc0cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2354194 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org> (cherry picked from commit 863a28e1c874d95853ae50900f3226e11b05cec9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3214010 Tested-by: Rong Chang <rongchang@chromium.org> Auto-Submit: Rong Chang <rongchang@chromium.org> Commit-Queue: Rong Chang <rongchang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3631910 Tested-by: Zick Wei <zick.wei@quanta.corp-partner.google.com> Commit-Queue: Henry Sun <henrysun@google.com> Reviewed-by: Henry Sun <henrysun@google.com>
-rw-r--r--driver/accelgyro_bmi260.c171
-rw-r--r--include/config.h10
2 files changed, 6 insertions, 175 deletions
diff --git a/driver/accelgyro_bmi260.c b/driver/accelgyro_bmi260.c
index 4fc1b4dbda..a0fa04b7b4 100644
--- a/driver/accelgyro_bmi260.c
+++ b/driver/accelgyro_bmi260.c
@@ -376,8 +376,11 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
}
#endif /* CONFIG_ACCEL_INTERRUPTS */
-#if defined(CONFIG_ACCELGYRO_BMI160_COMPRESSED_CONFIG) || \
- defined(CONFIG_CHIP_INIT_ROM_REGION)
+/*
+ * If the .init_rom section is not memory mapped, we need a static
+ * buffer in RAM to access the BMI configuration data.
+ */
+#ifdef CONFIG_CHIP_INIT_ROM_REGION
#define BMI_RAM_BUFFER_SIZE 256
static uint8_t bmi_ram_buffer[BMI_RAM_BUFFER_SIZE];
#else
@@ -385,163 +388,6 @@ static uint8_t bmi_ram_buffer[BMI_RAM_BUFFER_SIZE];
static uint8_t *bmi_ram_buffer;
#endif
-/*
- * TODO(b/160330682): Eliminate or reduce size of BMI260 initialization file.
- * Remove this option once the BMI260 initialization file is moved to the
- * kernel rootfs.
- */
-#ifdef CONFIG_ACCELGYRO_BMI160_COMPRESSED_CONFIG
-
-#define INCBIN_STYLE INCBIN_STYLE_SNAKE
-#define INCBIN_PREFIX
-#include "third_party/incbin/incbin.h"
-INCBIN(bmi260_config,
- "third_party/bmi260/accelgyro_bmi260_config_compressed.bin");
-
-#define COMPRESS_KEY 0xE9EA
-static int bmi_buffer_bytes;
-static int bmi_config_offset;
-
-static int write_bmi_data(const struct motion_sensor_t *s)
-{
- uint8_t addr[2];
- int ret;
-
- if (bmi_buffer_bytes == 0)
- return EC_SUCCESS;
-
- addr[0] = (bmi_config_offset / 2) & 0xF;
- addr[1] = (bmi_config_offset / 2) >> 4;
- ret = bmi_write_n(s->port, s->addr,
- BMI260_INIT_ADDR_0, addr, 2);
- if (ret)
- return ret;
-
- ret = bmi_write_n(s->port, s->addr,
- BMI260_INIT_DATA, bmi_buffer,
- bmi_buffer_bytes);
- if (ret)
- return ret;
-
- bmi_config_offset += bmi_buffer_bytes;
- bmi_buffer_bytes = 0;
-
- return EC_SUCCESS;
-}
-
-/*
- * Stores 4 bytes of BMI configuration data into a static buffer. If the buffer
- * is filled, write the buffer contents over I2C.
- */
-static int enqueue_bmi_data(const struct motion_sensor_t *s, uint32_t *data)
-{
- int ret;
-
- memcpy(&bmi_ram_buffer[bmi_buffer_bytes], data, 4);
- bmi_buffer_bytes += 4;
-
- if (bmi_buffer_bytes >= BMI_RAM_BUFFER_SIZE) {
- ret = write_bmi_data(s);
- if (ret)
- return ret;
- }
-
- return EC_SUCCESS;
-}
-
-/*
- * Load the BMI configuration data from a compressed buffer.
- *
- * Compression scheme:
- * Repeated 32-bit words are replaced by a 16-bit key, 16-bit count, and
- * the 32-bit data word. All values stored big-endian.
- *
- * For example, if the uncompressed file had the following data words:
- * 0x89ABCDEF 0x89ABCDEF 0x89ABCDEF
- *
- * This is represented compressed as (key 0xE9EA):
- * 0xE9EA0003 0x89ABCDEF
- *
- * Key value (0xE9EA) chosen as it wasn't found in the BMI configuration
- * data.
- */
-int bmi_compressed_config_load(const struct motion_sensor_t *s)
-{
- uint32_t *bmi_compressed_config = (uint32_t *)bmi260_config_data;
- int length = bmi260_config_size;
- int i;
- int output_offset;
- uint16_t *buf16;
- uint16_t key;
- uint16_t repeat_count;
- uint32_t *data32;
- int ret;
-
- length /= sizeof(uint32_t);
-
- bmi_buffer_bytes = 0;
- bmi_config_offset = 0;
-
- output_offset = 0;
-
- for (i = 0; i < length; i++) {
- buf16 = (uint16_t *)&bmi_compressed_config[i];
- key = be16toh(*buf16);
-
- if (key == COMPRESS_KEY) {
- repeat_count = be16toh(*++buf16);
-
- if (repeat_count == 0) {
- CPRINTF("BMI260 config: invalid repeat count "
- "found at word offset %d\n",
- i);
- return EC_ERROR_UNKNOWN;
- }
-
- /*
- * Advance to the next word in the buffer, which
- * contains the actual data to write.
- */
- if (++i >= length) {
- CPRINTF("BMI260 config: "
- "Unexpected end of file\n");
- return EC_ERROR_UNKNOWN;
- }
-
- data32 = &bmi_compressed_config[i];
-
- while (repeat_count-- > 0) {
- ret = enqueue_bmi_data(s, data32);
- if (ret)
- return ret;
-
- output_offset += 4;
- }
- } else {
- data32 = &bmi_compressed_config[i];
- ret = enqueue_bmi_data(s, data32);
- if (ret)
- return ret;
-
- output_offset += 4;
- }
- }
-
- ret = write_bmi_data(s);
-
- return ret;
-}
-
-static int bmi_config_load(const struct motion_sensor_t *s)
-{
- return EC_ERROR_UNKNOWN;
-}
-#else /* !CONFIG_ACCELGYRO_BMI160_COMPRESSED_CONFIG */
-static int bmi_compressed_config_load(const struct motion_sensor_t *s)
-{
- return EC_ERROR_UNKNOWN;
-}
-
static int bmi_config_load(const struct motion_sensor_t *s)
{
int ret = EC_SUCCESS;
@@ -617,8 +463,6 @@ static int bmi_config_load(const struct motion_sensor_t *s)
return ret;
}
-#endif /* CONFIG_ACCELGYRO_BMI160_COMPRESSED_CONFIG */
-
static int init_config(const struct motion_sensor_t *s)
{
int init_status, ret;
@@ -631,10 +475,7 @@ static int init_config(const struct motion_sensor_t *s)
bmi_write8(s->port, s->addr, BMI260_INIT_CTRL, 0);
/* load config file to INIT_DATA */
- if (IS_ENABLED(CONFIG_ACCELGYRO_BMI160_COMPRESSED_CONFIG))
- ret = bmi_compressed_config_load(s);
- else
- ret = bmi_config_load(s);
+ ret = bmi_config_load(s);
/* finish config load */
bmi_write8(s->port, s->addr, BMI260_INIT_CTRL, 1);
diff --git a/include/config.h b/include/config.h
index 4741b1e7e0..7467a0fe9e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -146,16 +146,6 @@
#undef CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT
#undef CONFIG_ACCELGYRO_BMI260_INT2_OUTPUT
-/*
- * If defined, use a compressed version of the BMI260 configuration file.
- * Saves a net of about 900 bytes of flash space.
- *
- * TODO(b/160330682): Eliminate or reduce size of BMI260 initialization file.
- * Remove this option once the BMI260 initialization file is moved to the
- * kernel rootfs.
- */
-#undef CONFIG_ACCELGYRO_BMI160_COMPRESSED_CONFIG
-
/* Specify type of Gyrometers attached. */
#undef CONFIG_GYRO_L3GD20H