summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--baseboard/grunt/baseboard.c20
-rw-r--r--baseboard/grunt/baseboard.h18
-rw-r--r--board/careena/board.c7
-rw-r--r--common/spi_flash_reg.c26
-rw-r--r--include/math_util.h2
5 files changed, 44 insertions, 29 deletions
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index f2251639f4..ded1c6ac19 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -310,21 +310,9 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
-/*
- * Matrix to rotate accelerators into the standard reference frame. The default
- * is the identity which is correct for the reference design. Variations of
- * Grunt may need to change it for manufacturability.
- * For the lid:
- * +x to the right
- * +y up
- * +z out of the page
- *
- * The principle axes of the body are aligned with the lid when the lid is in
- * the 180 degree position (open, flat).
- */
-matrix_3x3_t base_standard_ref = {
+matrix_3x3_t grunt_base_standard_ref = {
{ FLOAT_TO_FP(1), 0, 0},
- { 0, FLOAT_TO_FP(1), 0},
+ { 0, FLOAT_TO_FP(1), 0},
{ 0, 0, FLOAT_TO_FP(1)}
};
@@ -375,7 +363,7 @@ struct motion_sensor_t motion_sensors[] = {
.port = I2C_PORT_SENSOR,
.addr = BMI160_ADDR0,
.default_range = 2, /* g, enough for laptop */
- .rot_standard_ref = (const matrix_3x3_t *)&base_standard_ref,
+ .rot_standard_ref = (const matrix_3x3_t *)&grunt_base_standard_ref,
.min_frequency = BMI160_ACCEL_MIN_FREQ,
.max_frequency = BMI160_ACCEL_MAX_FREQ,
.config = {
@@ -403,7 +391,7 @@ struct motion_sensor_t motion_sensors[] = {
.port = I2C_PORT_SENSOR,
.addr = BMI160_ADDR0,
.default_range = 1000, /* dps */
- .rot_standard_ref = (const matrix_3x3_t *)&base_standard_ref,
+ .rot_standard_ref = (const matrix_3x3_t *)&grunt_base_standard_ref,
.min_frequency = BMI160_GYRO_MIN_FREQ,
.max_frequency = BMI160_GYRO_MAX_FREQ,
},
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index 5520affed1..106620f3be 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -180,6 +180,7 @@
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
+#include "math_util.h"
#include "registers.h"
enum adc_channel {
@@ -212,6 +213,23 @@ enum sensor_id {
BASE_GYRO,
};
+/*
+ * Matrix to rotate accelerators into the standard reference frame. The default
+ * is the identity which is correct for the reference design. Variations of
+ * Grunt may need to change it for manufacturability.
+ * For the lid:
+ * +x to the right
+ * +y up
+ * +z out of the page
+ *
+ * The principle axes of the body are aligned with the lid when the lid is in
+ * the 180 degree position (open, flat).
+ *
+ * Boards within the Grunt family may need to modify this definition at
+ * board_init() time.
+ */
+extern matrix_3x3_t grunt_base_standard_ref;
+
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL)
diff --git a/board/careena/board.c b/board/careena/board.c
index afa9c18637..1bae162930 100644
--- a/board/careena/board.c
+++ b/board/careena/board.c
@@ -124,6 +124,13 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
static void board_init(void)
{
+ /*
+ * Careena's baseboard is rotated 180 degrees about the +y axis relative
+ * to the Grunt reference design.
+ */
+ grunt_base_standard_ref[0][0] = FLOAT_TO_FP(-1);
+ grunt_base_standard_ref[2][2] = FLOAT_TO_FP(-1);
+
/* Enable Gyro interrupts */
gpio_enable_interrupt(GPIO_6AXIS_INT_L);
}
diff --git a/common/spi_flash_reg.c b/common/spi_flash_reg.c
index 569bbd5072..3cee0f3bd4 100644
--- a/common/spi_flash_reg.c
+++ b/common/spi_flash_reg.c
@@ -14,7 +14,7 @@
enum bit_state {
OFF = 0,
ON = 1,
- X = -1, /* Don't care */
+ IGN = -1, /* Don't care / Ignore */
};
struct protect_range {
@@ -26,10 +26,10 @@ struct protect_range {
uint32_t protect_len;
};
-/* Compare macro for (x =? b) for 'X' comparison */
-#define COMPARE_BIT(a, b) ((a) != X && (a) != !!(b))
-/* Assignment macro where 'X' = 0 */
-#define GET_BIT(a) ((a) == X ? 0 : (a))
+/* Compare macro for (x =? b) for 'IGN' comparison */
+#define COMPARE_BIT(a, b) ((a) != IGN && (a) != !!(b))
+/* Assignment macro where 'IGN' = 0 */
+#define GET_BIT(a) ((a) == IGN ? 0 : (a))
/*
* Define flags and protect table for each SPI ROM part. It's not necessary
@@ -39,9 +39,9 @@ struct protect_range {
*/
#if defined(CONFIG_SPI_FLASH_W25X40) || defined(CONFIG_SPI_FLASH_GD25Q41B)
static const struct protect_range spi_flash_protect_ranges[] = {
- { X, X, X, { 0, 0, 0 }, 0, 0 }, /* No protection */
- { X, X, 1, { 0, 1, 1 }, 0, 0x40000 }, /* Lower 1/2 */
- { X, X, 1, { 0, 1, 0 }, 0, 0x20000 }, /* Lower 1/4 */
+ { IGN, IGN, IGN, { 0, 0, 0 }, 0, 0 }, /* No protection */
+ { IGN, IGN, 1, { 0, 1, 1 }, 0, 0x40000 }, /* Lower 1/2 */
+ { IGN, IGN, 1, { 0, 1, 0 }, 0, 0x20000 }, /* Lower 1/4 */
};
#elif defined(CONFIG_SPI_FLASH_W25Q40) || defined(CONFIG_SPI_FLASH_GD25LQ40)
@@ -49,17 +49,17 @@ static const struct protect_range spi_flash_protect_ranges[] = {
/* For GD25LQ40, BP3 and BP4 have same meaning as TB and SEC */
static const struct protect_range spi_flash_protect_ranges[] = {
/* CMP = 0 */
- { 0, X, X, { 0, 0, 0 }, 0, 0 }, /* No protection */
+ { 0, IGN, IGN, { 0, 0, 0 }, 0, 0 }, /* No protection */
{ 0, 0, 1, { 0, 1, 0 }, 0, 0x20000 }, /* Lower 1/4 */
{ 0, 0, 1, { 0, 1, 1 }, 0, 0x40000 }, /* Lower 1/2 */
/* CMP = 1 */
{ 1, 0, 0, { 0, 1, 1 }, 0, 0x40000 }, /* Lower 1/2 */
- { 1, 0, X, { 1, X, X }, 0, 0 }, /* None (W25Q40EW only) */
+ { 1, 0, IGN, { 1, IGN, IGN }, 0, 0 }, /* None (W25Q40EW only) */
};
#elif defined(CONFIG_SPI_FLASH_W25Q64)
static const struct protect_range spi_flash_protect_ranges[] = {
- { 0, X, X, { 0, 0, 0 }, 0, 0 }, /* No protection */
+ { 0, IGN, IGN, { 0, 0, 0 }, 0, 0 }, /* No protection */
{ 0, 0, 1, { 1, 1, 0 }, 0, 0x400000 }, /* Lower 1/2 */
{ 0, 0, 1, { 1, 0, 1 }, 0, 0x200000 }, /* Lower 1/4 */
};
@@ -67,7 +67,7 @@ static const struct protect_range spi_flash_protect_ranges[] = {
#elif defined(CONFIG_SPI_FLASH_W25Q80)
static const struct protect_range spi_flash_protect_ranges[] = {
/* CMP = 0 */
- { 0, X, X, { 0, 0, 0 }, 0, 0 }, /* No protection */
+ { 0, IGN, IGN, { 0, 0, 0 }, 0, 0 }, /* No protection */
{ 0, 0, 1, { 0, 1, 0 }, 0, 0x20000 }, /* Lower 1/8 */
{ 0, 0, 1, { 0, 1, 1 }, 0, 0x40000 }, /* Lower 1/4 */
{ 0, 0, 1, { 1, 0, 0 }, 0, 0x80000 }, /* Lower 1/2 */
@@ -75,7 +75,7 @@ static const struct protect_range spi_flash_protect_ranges[] = {
#elif defined(CONFIG_SPI_FLASH_W25Q128)
static const struct protect_range spi_flash_protect_ranges[] = {
/* CMP = 0 */
- { 0, X, X, { 0, 0, 0 }, 0, 0 }, /* No protection */
+ { 0, IGN, IGN, { 0, 0, 0 }, 0, 0 }, /* No protection */
{ 0, 0, 1, { 1, 0, 0 }, 0, 0x20000 }, /* Lower 1/8 */
{ 0, 0, 1, { 1, 0, 1 }, 0, 0x40000 }, /* Lower 1/4 */
{ 0, 0, 1, { 1, 1, 0 }, 0, 0x80000 }, /* Lower 1/2 */
diff --git a/include/math_util.h b/include/math_util.h
index 385c044c6f..093c6c099e 100644
--- a/include/math_util.h
+++ b/include/math_util.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_MATH_UTIL_H
#define __CROS_EC_MATH_UTIL_H
+#include <stdint.h>
+
#ifdef CONFIG_FPU
typedef float fp_t;
typedef float fp_inter_t;