mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-31 02:51:26 +00:00
coral: Use SKU ID to initialize motion_sensor_count
This CL adds the config option CONFIG_DYNAMIC_MOTION_SENSOR_COUNT and SKU table which contains the form factor for all known SKUs. Once the SKU ID is known, the variable motion_sensor_count is set based on CLAMSHELL or CONVERTIBLE designation in the SKU table. If there isn't a matching SKU ID in the table then motion_sensor_count will be initialized to the ARRAY_LENGTH of motion_sensors. BUG=b:38271876 BRANCH=None TEST=Manual Tested with Robo360 (SKU ID 71) and verified the motion sensor count and that the motion senors were initialized in the EC console log. [0.088188 Motion Sensor Init: count = 3] [0.346097 Lid Accel: MS Done Init type:0x0 range:2] [0.370386 Base Accel: MS Done Init type:0x0 range:2] [0.386790 Base Gyro: MS Done Init type:0x1 range:1000] Tested with Santa EVT (SKU ID 3) and verified motion_sensor_count is 0 and no EC console messages showing sensor initialization failures. Change-Id: Ia3d60f8c8dd4435dd7cfb80a860f809de2fb931e Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/711195 Commit-Ready: Aaron Durbin <adurbin@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
c478733f19
commit
dfe7473ed8
@@ -38,6 +38,7 @@
|
||||
#include "power_button.h"
|
||||
#include "pwm.h"
|
||||
#include "pwm_chip.h"
|
||||
#include "sku.h"
|
||||
#include "spi.h"
|
||||
#include "switch.h"
|
||||
#include "system.h"
|
||||
@@ -987,7 +988,7 @@ struct motion_sensor_t motion_sensors[] = {
|
||||
},
|
||||
},
|
||||
};
|
||||
const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
|
||||
unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
|
||||
|
||||
/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */
|
||||
const struct motion_sensor_t *motion_als_sensors[] = {
|
||||
@@ -1013,6 +1014,21 @@ void board_hibernate(void)
|
||||
bd9995x_set_power_save_mode(BD9995X_PWR_SAVE_MAX);
|
||||
}
|
||||
|
||||
static void board_set_motion_sensor_count(uint8_t sku_id)
|
||||
{
|
||||
/*
|
||||
* There are two possible sensor configurations. Clamshell device will
|
||||
* not have any of the motion sensors populated, while convertible
|
||||
* devices have the BMI160 Accel/Gryo and Kionx KX022 lid acceleration
|
||||
* sensor. If a new SKU id is used that is not in the table, then the
|
||||
* number of motion sensors will remain as ARRAY_SIZE(motion_sensors).
|
||||
*/
|
||||
motion_sensor_count = SKU_IS_CONVERTIBLE(sku_id) ?
|
||||
ARRAY_SIZE(motion_sensors) : 0;
|
||||
|
||||
CPRINTS("Motion Sensor Count = %d", motion_sensor_count);
|
||||
}
|
||||
|
||||
struct {
|
||||
enum coral_board_version version;
|
||||
int thresh_mv;
|
||||
@@ -1088,39 +1104,75 @@ static void board_get_sku_id(void)
|
||||
(sku_id_higher != BOARD_VERSION_UNKNOWN))
|
||||
sku_id = (sku_id_higher << 4) | sku_id_lower;
|
||||
CPRINTS("SKU ID: %d", sku_id);
|
||||
/* Use sku_id to set motion sensor count */
|
||||
board_set_motion_sensor_count(sku_id);
|
||||
}
|
||||
}
|
||||
/* This can't run until after the ADC module has been initialized */
|
||||
DECLARE_HOOK(HOOK_INIT, board_get_sku_id, HOOK_PRIO_INIT_ADC + 1);
|
||||
|
||||
static int command_board_id(int argc, char **argv)
|
||||
static void print_form_factor_list(int low, int high)
|
||||
{
|
||||
int id;
|
||||
int count = 0;
|
||||
|
||||
if (high > 255)
|
||||
high = 255;
|
||||
for (id = low; id <= high; id++) {
|
||||
ccprintf("SKU ID %03d: %s\n", id, SKU_IS_CONVERTIBLE(id) ?
|
||||
"Convertible" : "Clamshell");
|
||||
/* Don't print too many lines at once */
|
||||
if (!(++count % 5))
|
||||
msleep(20);
|
||||
}
|
||||
}
|
||||
|
||||
static int command_sku(int argc, char **argv)
|
||||
{
|
||||
enum adc_channel chan;
|
||||
|
||||
if (argc < 2)
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
|
||||
if (!strcasecmp(argv[1], "id"))
|
||||
chan = ADC_BOARD_ID;
|
||||
else if (!strcasecmp(argv[1], "sku0"))
|
||||
chan = ADC_BOARD_SKU_0;
|
||||
else if (!strcasecmp(argv[1], "sku1"))
|
||||
chan = ADC_BOARD_SKU_1;
|
||||
else if (!strcasecmp(argv[1], "sku")) {
|
||||
if (argc < 2) {
|
||||
system_get_sku_id();
|
||||
ccprintf("SKU ID: %d\n", sku_id);
|
||||
return EC_SUCCESS;
|
||||
} else
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[1], "form")) {
|
||||
if (argc >= 4) {
|
||||
char *e;
|
||||
int low, high;
|
||||
|
||||
low = strtoi(argv[2], &e, 10);
|
||||
if (*e)
|
||||
return EC_ERROR_PARAM1;
|
||||
|
||||
high = strtoi(argv[3], &e, 10);
|
||||
if (*e)
|
||||
return EC_ERROR_PARAM2;
|
||||
print_form_factor_list(low, high);
|
||||
return EC_SUCCESS;
|
||||
} else {
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcasecmp(argv[1], "board"))
|
||||
chan = ADC_BOARD_ID;
|
||||
else if (!strcasecmp(argv[1], "line0"))
|
||||
chan = ADC_BOARD_SKU_0;
|
||||
else if (!strcasecmp(argv[1], "line1"))
|
||||
chan = ADC_BOARD_SKU_1;
|
||||
else
|
||||
return EC_ERROR_PARAM1;
|
||||
|
||||
ccprintf("Board id|sku: chan %d = %d\n", chan,
|
||||
board_read_version(chan));
|
||||
ccprintf("sku: %s = %d, adc %d\n", argv[1], board_read_version(chan),
|
||||
chan);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(board_id, command_board_id,
|
||||
"<id|sku0|sku1>",
|
||||
"Get board id or sku");
|
||||
DECLARE_CONSOLE_COMMAND(sku, command_sku,
|
||||
"<board|line0|line1|form [low high]>",
|
||||
"Get board id, sku, form factor");
|
||||
|
||||
uint32_t system_get_sku_id(void)
|
||||
{
|
||||
|
||||
@@ -208,6 +208,7 @@
|
||||
#define CONFIG_LID_ANGLE_UPDATE
|
||||
#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL
|
||||
#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL
|
||||
#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
|
||||
|
||||
/* FIFO size is in power of 2. */
|
||||
#define CONFIG_ACCEL_FIFO 1024
|
||||
@@ -278,7 +279,7 @@ enum temp_sensor_id {
|
||||
* For BMI160, accel, gyro and compass sensors must be next to each other.
|
||||
*/
|
||||
enum sensor_id {
|
||||
LID_ACCEL = 0,
|
||||
LID_ACCEL,
|
||||
BASE_ACCEL,
|
||||
BASE_GYRO,
|
||||
LID_ALS,
|
||||
|
||||
90
board/coral/sku.h
Normal file
90
board/coral/sku.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* Copyright 2017 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/* Coral SKU ID Table */
|
||||
|
||||
#ifndef __CROS_EC_SKU_H
|
||||
#define __CROS_EC_SKU_H
|
||||
|
||||
#define SKU_CONVERTIBLE(id) (1 << ((id) & 0x7))
|
||||
|
||||
/*
|
||||
* There are 256 possible SKUs for Coral. This table is used to map a given SKU
|
||||
* ID to its form factor, which is then used to determine number of motion
|
||||
* sensors. A bit value of 0 is for clamshell and a bit value of 1 indicates a
|
||||
* convertible device. The assumption is all devices are defined as clamshells
|
||||
* unless SKU_CONVERTIBLE(id) is spelled out in the initialization.
|
||||
*/
|
||||
static const uint8_t form_factor[32] = {
|
||||
/* SKU 0 - 7 */
|
||||
SKU_CONVERTIBLE(4) | SKU_CONVERTIBLE(5),
|
||||
/* SKU 8 - 15 */
|
||||
SKU_CONVERTIBLE(8) | SKU_CONVERTIBLE(9) | SKU_CONVERTIBLE(10),
|
||||
/* SKU 16 - 23 */
|
||||
0x00,
|
||||
/* SKU 24 - 31 */
|
||||
0x00,
|
||||
/* SKU 32 - 39 */
|
||||
0x00,
|
||||
/* SKU 40 - 47 */
|
||||
0x00,
|
||||
/* SKU 48 - 55 */
|
||||
0x00,
|
||||
/* SKU 56 - 63 */
|
||||
0x00,
|
||||
/* SKU 64 - 71 */
|
||||
SKU_CONVERTIBLE(71),
|
||||
/* SKU 72 - 79 */
|
||||
0x00,
|
||||
/* SKU 80 - 87 */
|
||||
0x00,
|
||||
/* SKU 88 - 95 */
|
||||
0x00,
|
||||
/* SKU 96 - 103 */
|
||||
0x00,
|
||||
/* SKU 104 - 111 */
|
||||
0x00,
|
||||
/* SKU 112 - 119 */
|
||||
0x00,
|
||||
/* SKU 120 - 127 */
|
||||
0x00,
|
||||
/* SKU 128 - 135 */
|
||||
0x00,
|
||||
/* SKU 136 - 143 */
|
||||
0x00,
|
||||
/* SKU 144 - 151 */
|
||||
0x00,
|
||||
/* SKU 152 - 159 */
|
||||
0x00,
|
||||
/* SKU 160 - 167 */
|
||||
SKU_CONVERTIBLE(163) | SKU_CONVERTIBLE(164) | SKU_CONVERTIBLE(165) |
|
||||
SKU_CONVERTIBLE(166),
|
||||
/* SKU 168 - 175 */
|
||||
0x00,
|
||||
/* SKU 176 - 183 */
|
||||
0x00,
|
||||
/* SKU 184 - 191 */
|
||||
0x00,
|
||||
/* SKU 192 - 199 */
|
||||
0x00,
|
||||
/* SKU 200 - 207 */
|
||||
0x00,
|
||||
/* SKU 208 - 215 */
|
||||
0x00,
|
||||
/* SKU 216 - 223 */
|
||||
0x00,
|
||||
/* SKU 224 - 231 */
|
||||
0x00,
|
||||
/* SKU 232 - 239 */
|
||||
0x00,
|
||||
/* SKU 240 - 247 */
|
||||
0x00,
|
||||
/* SKU 248 - 255 */
|
||||
0x00,
|
||||
};
|
||||
|
||||
#define SKU_IS_CONVERTIBLE(id) ((form_factor[(id) >> 3] >> ((id) & 0x7)) & 1)
|
||||
|
||||
#endif /* __CROS_EC_SKU_H */
|
||||
Reference in New Issue
Block a user