Merge remote-tracking branch cros/main into firmware-brya-14505.B-main

Generated by: util/update_release_branch.py --baseboard brya --relevant_paths_file
baseboard/brya/relevant-paths.txt firmware-brya-14505.B-main

Relevant changes:

git log --oneline 734d1beb4f..1199515e8c -- baseboard/brya board/anahera
board/banshee board/brya board/crota board/dochi board/felwinter
board/gimble board/kano board/marasov board/mithrax board/omnigul
board/osiris board/primus board/redrix board/taeko board/taniks
board/vell board/volmar board/xol driver/bc12/pi3usb9201_public.*
driver/charger/bq25710.* driver/ppc/nx20p348x.*
driver/ppc/syv682x_public.* driver/retimer/bb_retimer_public.*
driver/tcpm/nct38xx.* driver/tcpm/ps8xxx_public.* driver/tcpm/tcpci.*
include/power/alderlake* include/intel_x86.h power/alderlake*
power/intel_x86.c util/getversion.sh

1199515e8c xol: make use of i2c bitbang mode

BUG=b:327656989
TEST=`emerge-[brya,brask] chromeos-ec`

Force-Relevant-Builds: all
Change-Id: Ic7d773b06402baa642a394545260d9913b0b92f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/5464049
Commit-Queue: YH Lin <yueherngl@chromium.org>
Commit-Queue: Forest Mittelberg <bmbm@google.com>
Tested-by: YH Lin <yueherngl@chromium.org>
Auto-Submit: YH Lin <yueherngl@chromium.org>
Reviewed-by: Forest Mittelberg <bmbm@google.com>
This commit is contained in:
YH Lin 2024-04-18 00:38:29 +00:00 committed by Chromeos LUCI
commit 18c42484ff
43 changed files with 1203 additions and 375 deletions

View File

@ -468,11 +468,11 @@ bldversion=$(shell (./util/getversion.sh ; echo VERSION) | $(CPP) -P -)
cmd_lcov=lcov --rc branch_coverage=1 --gcov-tool \
$(HOSTGCOV) -q -o $@ -c -d build/coverage/$* -t $* \
--exclude '*/ec/test/*' --exclude '*/ec/include/tests/*' \
--ignore-errors unused,unused,inconsistent,inconsistent
--ignore-errors unused,unused,inconsistent,inconsistent,negative,negative
cmd_lcov-initial=lcov --rc branch_coverage=1 --gcov-tool \
$(GCOV) -q -o $@ -c -d build/coverage/initial-$* \
-i -t $* --exclude '*/ec/test/*' --exclude '*/ec/include/tests/*' \
--ignore-errors unused,unused,inconsistent,inconsistent
--ignore-errors unused,unused,inconsistent,inconsistent,negative,negative
cmd_merge_cov=lcov --rc branch_coverage=1 -o build/coverage/lcov.info \
$(foreach info,$^,-a ${info})
cmd_report_cov=genhtml --branch-coverage -q -o build/coverage/coverage_rpt -t \

View File

@ -2242,6 +2242,10 @@ def all_targets():
core = "cortex-m",
zephyr = False,
)
ec_target(
name = "veluza",
board = "veluza",
)
ec_target(
name = "vilboz",
baseboard = "zork",

View File

@ -170,6 +170,15 @@
#include "registers.h"
#include "usbc_config.h"
/* I2C access in polling mode before task is initialized */
#define CONFIG_I2C_BITBANG
enum banshee_bitbang_i2c_channel {
I2C_BITBANG_CHAN_BRD_ID,
I2C_BITBANG_CHAN_COUNT
};
#define I2C_BITBANG_PORT_COUNT I2C_BITBANG_CHAN_COUNT
enum adc_channel {
ADC_TEMP_SENSOR_1,
ADC_TEMP_SENSOR_2,

View File

@ -8,6 +8,7 @@
#include "console.h"
#include "hooks.h"
#include "i2c.h"
#include "i2c_bitbang.h"
/* I2C port map configuration */
const struct i2c_port_t i2c_ports[] = {
@ -53,3 +54,16 @@ const struct i2c_port_t i2c_ports[] = {
},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct i2c_port_t i2c_bitbang_ports[] = {
[I2C_BITBANG_CHAN_BRD_ID] = {
.name = "bitbang_brd_id",
.port = I2C_PORT_EEPROM,
.kbps = 100,
.scl = GPIO_EC_I2C_MISC_SCL_R,
.sda = GPIO_EC_I2C_MISC_SDA_R,
.drv = &bitbang_drv,
},
};
BUILD_ASSERT(ARRAY_SIZE(i2c_bitbang_ports) == I2C_BITBANG_CHAN_COUNT);
const unsigned int i2c_bitbang_ports_used = ARRAY_SIZE(i2c_bitbang_ports);

View File

@ -192,6 +192,9 @@ uint32_t get_feature_flags1(void)
#endif
#ifdef CONFIG_USB_PD_DP21_MODE
| EC_FEATURE_MASK_1(EC_FEATURE_TYPEC_DP2_1)
#endif
#ifdef CONFIG_UCSI_PPM
| EC_FEATURE_MASK_1(EC_FEATURE_UCSI_PPM)
#endif
;
return board_override_feature_flags1(result);

View File

@ -75,7 +75,12 @@ static void print_reg(int regnum, const uint32_t *regs, int index)
*/
static int32_t is_frame_in_handler_stack(const uint32_t exc_return)
{
return (exc_return & 0xf) == 1 || (exc_return & 0xf) == 9;
#ifdef CONFIG_FPU
return exc_return == 0xfffffff1 || exc_return == 0xfffffff9 ||
exc_return == 0xffffffe1 || exc_return == 0xffffffe9;
#else
return exc_return == 0xfffffff1 || exc_return == 0xfffffff9;
#endif /* CONFIG_FPU */
}
/*
@ -372,8 +377,10 @@ void __keep report_panic(void)
/* Start safe mode if possible */
if (IS_ENABLED(CONFIG_SYSTEM_SAFE_MODE)) {
/* TODO: check for nested exceptions */
if (start_system_safe_mode() == EC_SUCCESS) {
/* Only start safe mode if panic occurred in thread context */
if (!is_frame_in_handler_stack(
pdata->cm.regs[CORTEX_PANIC_REGISTER_LR]) &&
start_system_safe_mode() == EC_SUCCESS) {
pdata->flags |= PANIC_DATA_FLAG_SAFE_MODE_STARTED;
/* If not in an interrupt context (e.g. software_panic),
* the next highest priority task will immediately

View File

@ -67,7 +67,7 @@ static void print_reg(int regnum, const uint32_t *regs, int index)
*/
static int32_t is_frame_in_handler_stack(const uint32_t exc_return)
{
return (exc_return & 0xf) == 1 || (exc_return & 0xf) == 9;
return exc_return == 0xfffffff1 || exc_return == 0xfffffff9;
}
/*

View File

@ -518,12 +518,12 @@ class OpmUnitTest : public TestFixture {
void TearDown()
{
/* Clean up ppm */
ppm_drv_->cleanup(ppm_drv_);
/* Clean up main loop (cdev) */
pthread_kill(thread_, SIGTERM);
pthread_join(thread_, NULL);
/* Clean up ppm */
ppm_drv_->cleanup(ppm_drv_);
}
static void *MainLoop(void *ptr)

View File

@ -1697,6 +1697,10 @@ enum ec_feature_code {
* The MCU is System Companion Processor Core 1
*/
EC_FEATURE_SCP_C1 = 53,
/*
* The EC supports UCSI PPM.
*/
EC_FEATURE_UCSI_PPM = 54,
};
#define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32)
@ -6355,7 +6359,7 @@ enum cbi_data_tag {
union ec_common_control {
struct {
uint32_t bcic_enabled : 1; /* Unused. Take it over as yours. */
uint32_t ucsi_disabled : 1;
};
uint32_t raw_value;
};

View File

@ -38,6 +38,80 @@ extern "C" {
/* Temporary buffer, to avoid using too much stack space. */
static uint8_t tmp[512];
struct AesTestVector {
std::vector<uint8_t> key;
std::vector<uint8_t> plaintext;
std::vector<uint8_t> nonce;
std::vector<uint8_t> ciphertext;
std::vector<uint8_t> tag;
/* clang-format off */
auto operator<=> (const AesTestVector &) const = default;
/* clang-format on */
};
struct TestVectorHex {
std::string key;
std::string plaintext;
std::string nonce;
std::string ciphertext;
std::string tag;
};
test_static std::optional<uint8_t> HexCharToDigit(const char c)
{
if (c >= '0' && c <= '9')
return static_cast<uint8_t>(c - '0');
if (c >= 'a' && c <= 'f')
return static_cast<uint8_t>(c - 'a' + 10);
if (c >= 'A' && c <= 'F')
return static_cast<uint8_t>(c - 'A' + 10);
return std::nullopt;
}
test_static bool HexStringToBytes(std::string input,
std::vector<uint8_t> *output)
{
size_t count = input.size();
if ((count % 2) != 0) {
return false;
}
if (output == nullptr) {
return false;
}
output->clear();
output->reserve(count / 2);
for (size_t i = 0; i < count; i += 2) {
// most significant 4 bits
std::optional<uint8_t> msb = HexCharToDigit(input[i]);
if (!msb) {
return false;
}
// least significant 4 bits
std::optional<uint8_t> lsb = HexCharToDigit(input[i + 1]);
if (!lsb) {
return false;
}
output->emplace_back((*msb << 4) | *lsb);
}
return true;
}
test_static ec_error_list TestVectorHexToBytes(const TestVectorHex &input,
AesTestVector *output)
{
TEST_ASSERT(HexStringToBytes(input.key, &output->key));
TEST_ASSERT(HexStringToBytes(input.plaintext, &output->plaintext));
TEST_ASSERT(HexStringToBytes(input.nonce, &output->nonce));
TEST_ASSERT(HexStringToBytes(input.ciphertext, &output->ciphertext));
TEST_ASSERT(HexStringToBytes(input.tag, &output->tag));
return EC_SUCCESS;
}
/*
* Do encryption, put result in |result|, and compare with |ciphertext|.
*/
@ -158,276 +232,111 @@ static int test_aes_gcm_raw(const uint8_t *key, int key_size,
return EC_SUCCESS;
}
static int test_aes_gcm(void)
test_static int test_aes_gcm(void)
{
/*
* Test vectors from BoringSSL crypto/fipsmodule/modes/gcm_tests.txt
* Test vectors from BoringSSL
* https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt
* (only the ones with actual data, and no additional data).
*/
static const uint8_t key1[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t plain1[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t nonce1[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t cipher1[] = {
0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78,
};
static const uint8_t tag1[] = {
0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf,
// https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt#8
TestVectorHex test_vector_hex1 = {
.key = "00000000000000000000000000000000",
.plaintext = "00000000000000000000000000000000",
.nonce = "000000000000000000000000",
.ciphertext = "0388dace60b6a392f328c2b971b2fe78",
.tag = "ab6e47d42cec13bdf53a67b21257bddf",
};
static const uint8_t key2[] = {
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
};
static const uint8_t plain2[] = {
0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
0x1a, 0xaf, 0xd2, 0x55,
};
static const uint8_t nonce2[] = {
0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
};
static const uint8_t cipher2[] = {
0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72,
0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f,
0x2c, 0x02, 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac,
0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3,
0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91,
0x47, 0x3f, 0x59, 0x85,
};
static const uint8_t tag2[] = {
0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4,
// https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt#15
TestVectorHex test_vector_hex2 = {
.key = "feffe9928665731c6d6a8f9467308308",
.plaintext =
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255",
.nonce = "cafebabefacedbaddecaf888",
.ciphertext =
"42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985",
.tag = "4d5c2af327cd64a62cf35abd2ba6fab4",
};
static const uint8_t key3[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t plain3[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t nonce3[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t cipher3[] = {
0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41,
0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00,
};
static const uint8_t tag3[] = {
0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab,
0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb,
// https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt#50
TestVectorHex test_vector_hex3 = {
.key = "000000000000000000000000000000000000000000000000",
.plaintext = "00000000000000000000000000000000",
.nonce = "000000000000000000000000",
.ciphertext = "98e7247c07f0fe411c267e4384b0f600",
.tag = "2ff58d80033927ab8ef4d4587514f0fb",
};
static const uint8_t key4[] = {
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
};
static const uint8_t plain4[] = {
0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
0x1a, 0xaf, 0xd2, 0x55,
};
static const uint8_t nonce4[] = {
0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
};
static const uint8_t cipher4[] = {
0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 0xeb, 0x06,
0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 0x85, 0x9e, 0x1c, 0xea,
0xa6, 0xef, 0xd9, 0x84, 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1,
0xe1, 0x9c, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 0x18, 0xe2,
0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 0xcc, 0xda, 0x27, 0x10,
0xac, 0xad, 0xe2, 0x56,
};
static const uint8_t tag4[] = {
0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf,
0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14,
// https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt#57
TestVectorHex test_vector_hex4 = {
.key = "feffe9928665731c6d6a8f9467308308feffe9928665731c",
.plaintext =
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255",
.nonce = "cafebabefacedbaddecaf888",
.ciphertext =
"3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256",
.tag = "9924a7c8587336bfb118024db8674a14",
};
static const uint8_t key5[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t plain5[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t nonce5[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t cipher5[] = {
0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18,
};
static const uint8_t tag5[] = {
0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19,
// https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt#99
TestVectorHex test_vector_hex5 = {
.key = "0000000000000000000000000000000000000000000000000000000000000000",
.plaintext = "00000000000000000000000000000000",
.nonce = "000000000000000000000000",
.ciphertext = "cea7403d4d606b6e074ec5d3baf39d18",
.tag = "d0d1c8a799996bf0265b98b5d48ab919",
};
static const uint8_t key6[] = {
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
};
static const uint8_t plain6[] = {
0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
0x1a, 0xaf, 0xd2, 0x55,
};
static const uint8_t nonce6[] = {
0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
};
static const uint8_t cipher6[] = {
0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f,
0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc,
0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55,
0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6,
0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62,
0x89, 0x80, 0x15, 0xad,
};
static const uint8_t tag6[] = {
0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd,
0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c,
// https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt#106
TestVectorHex test_vector_hex6 = {
.key = "feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308",
.plaintext =
"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255",
.nonce = "cafebabefacedbaddecaf888",
.ciphertext =
"522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad",
.tag = "b094dac5d93471bdec1a502270e3cc6c",
};
static const uint8_t key7[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint8_t plain7[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
/* This nonce results in 0xfff in counter LSB. */
static const uint8_t nonce7[] = {
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
static const uint8_t cipher7[] = {
0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 0x2b, 0x64,
0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 0x25, 0xf1, 0x0d, 0x47,
0xa7, 0x5a, 0x5f, 0xce, 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a,
0xf2, 0x4f, 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70,
0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 0xa9, 0xae,
0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 0xc6, 0xa7, 0x83, 0x97,
0xb9, 0xa8, 0x5b, 0x49, 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67,
0xca, 0xab, 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c,
0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 0xb4, 0xf3,
0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 0xc9, 0xe8, 0xc4, 0xdc,
0x0a, 0x2a, 0x5f, 0xf1, 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22,
0x13, 0x76, 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2,
0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 0xb0, 0xab,
0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 0x8c, 0x90, 0xbe, 0x40,
0x2d, 0xdf, 0x6d, 0x86, 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1,
0x5b, 0xfb, 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18,
0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 0x3c, 0x71,
0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 0x11, 0xf4, 0x2b, 0xae,
0x12, 0xaf, 0x46, 0x2b, 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e,
0x36, 0x06, 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24,
0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 0x4b, 0xcc,
0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 0x20, 0xa2, 0xf8, 0xeb,
0x66, 0xdc, 0xf3, 0x64, 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69,
0x90, 0x03, 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6,
0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 0x27, 0x83,
0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 0x18, 0x8a, 0x43, 0x9c,
0x7e, 0xbc, 0xc0, 0x67, 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2,
0x79, 0x46, 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78,
0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c,
};
static const uint8_t tag7[] = {
0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a,
0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f,
// https://boringssl.googlesource.com/boringssl/+/f94f3ed3965ea033001fb9ae006084eee408b861/crypto/fipsmodule/modes/gcm_tests.txt#141
TestVectorHex test_vector_hex7 = {
.key = "00000000000000000000000000000000",
.plaintext =
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
.nonce =
"ffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
.ciphertext =
"56b3373ca9ef6e4a2b64fe1e9a17b61425f10d47a75a5fce13efc6bc784af24f4141bdd48cf7c770887afd573cca5418a9aeffcd7c5ceddfc6a78397b9a85b499da558257267caab2ad0b23ca476a53cb17fb41c4b8b475cb4f3f7165094c229c9e8c4dc0a2a5ff1903e501511221376a1cdb8364c5061a20cae74bc4acd76ceb0abc9fd3217ef9f8c90be402ddf6d8697f4f880dff15bfb7a6b28241ec8fe183c2d59e3f9dfff653c7126f0acb9e64211f42bae12af462b1070bef1ab5e3606872ca10dee15b3249b1a1b958f23134c4bccb7d03200bce420a2f8eb66dcf3644d1423c1b5699003c13ecef4bf38a3b60eedc34033bac1902783dc6d89e2e774188a439c7ebcc0672dbda4ddcfb2794613b0be41315ef778708a70ee7d75165c",
.tag = "8b307f6b33286d0ab026a9ed3fe1e85f",
};
TEST_ASSERT(!test_aes_gcm_raw(key1, sizeof(key1), plain1, cipher1,
sizeof(plain1), nonce1, sizeof(nonce1),
tag1, sizeof(tag1)));
TEST_ASSERT(!test_aes_gcm_raw(key2, sizeof(key2), plain2, cipher2,
sizeof(plain2), nonce2, sizeof(nonce2),
tag2, sizeof(tag2)));
TEST_ASSERT(!test_aes_gcm_raw(key3, sizeof(key3), plain3, cipher3,
sizeof(plain3), nonce3, sizeof(nonce3),
tag3, sizeof(tag3)));
TEST_ASSERT(!test_aes_gcm_raw(key4, sizeof(key4), plain4, cipher4,
sizeof(plain4), nonce4, sizeof(nonce4),
tag4, sizeof(tag4)));
TEST_ASSERT(!test_aes_gcm_raw(key5, sizeof(key5), plain5, cipher5,
sizeof(plain5), nonce5, sizeof(nonce5),
tag5, sizeof(tag5)));
TEST_ASSERT(!test_aes_gcm_raw(key6, sizeof(key6), plain6, cipher6,
sizeof(plain6), nonce6, sizeof(nonce6),
tag6, sizeof(tag6)));
TEST_ASSERT(!test_aes_gcm_raw(key7, sizeof(key7), plain7, cipher7,
sizeof(plain7), nonce7, sizeof(nonce7),
tag7, sizeof(tag7)));
const std::array hex_test_vectors = {
test_vector_hex1, test_vector_hex2, test_vector_hex3,
test_vector_hex4, test_vector_hex5, test_vector_hex6,
test_vector_hex7
};
std::vector<AesTestVector> test_vectors;
for (const auto &hex_test_vector : hex_test_vectors) {
AesTestVector test_vector;
TEST_ASSERT(TestVectorHexToBytes(hex_test_vector,
&test_vector) == EC_SUCCESS);
test_vectors.emplace_back(test_vector);
}
constexpr size_t kExpectedNumTestVectors = 7;
TEST_EQ(test_vectors.size(), kExpectedNumTestVectors, "%zu");
for (const auto &test_vector : test_vectors) {
TEST_ASSERT(!test_aes_gcm_raw(
test_vector.key.data(), test_vector.key.size(),
test_vector.plaintext.data(),
test_vector.ciphertext.data(),
test_vector.plaintext.size(), test_vector.nonce.data(),
test_vector.nonce.size(), test_vector.tag.data(),
test_vector.tag.size()));
}
return EC_SUCCESS;
}

View File

@ -692,7 +692,7 @@ def power_cycle(board_config: BoardConfig) -> None:
def fp_sensor_sel(
board_config: BoardConfig, sensor_type: FPSensorType = FPSensorType.FPC
) -> None:
) -> bool:
"""
Explicitly select the appropriate fingerprint sensor.
This function assumes that the fp_sensor_sel servo control is connected to
@ -707,10 +707,14 @@ def fp_sensor_sel(
]
logging.debug('Running command: "%s"', " ".join(cmd))
subprocess.run(cmd, check=False).check_returncode()
proc = subprocess.run(cmd, check=False)
# power cycle after setting sensor type to ensure detection
power_cycle(board_config)
if proc.returncode == 0:
# power cycle after setting sensor type to ensure detection
power_cycle(board_config)
return True
return False
def hw_write_protect(enable: bool) -> None:

View File

@ -672,6 +672,7 @@ static const char *const ec_feature_names[] = {
[EC_FEATURE_TOKENIZED_LOGGING] = "Tokenized Logging",
[EC_FEATURE_AMD_STB_DUMP] = "AMD STB dump",
[EC_FEATURE_MEMORY_DUMP] = "Memory Dump",
[EC_FEATURE_UCSI_PPM] = "UCSI PPM",
};
int cmd_inventory(int argc, char *argv[])

View File

@ -200,7 +200,7 @@ DEFINE_string dut_ip "" \
"DUT IP address"
DEFINE_string token_db "${EC_DIR}/build/tokens.bin" \
"Full pathname of the EC tokenized database to copy to DUT."
DEFINE_boolean use_i2c_pseudo "${FLAGS_TRUE}" \
DEFINE_boolean use_i2c_pseudo "${FLAGS_FALSE}" \
"Use the linux i2c_pseudo driver instead of accessing the servo " \
"i2c endpoint directly."

View File

@ -130,8 +130,7 @@ static int ccg_get_connector_capability(const struct device *dev,
return 0;
}
static int ccg_set_ccom(const struct device *dev, enum ccom_t ccom,
enum drp_mode_t dm)
static int ccg_set_ccom(const struct device *dev, enum ccom_t ccom)
{
return 0;
}

View File

@ -134,7 +134,6 @@ const struct smbus_cmd_t SET_NOTIFICATION_ENABLE = { 0x08, 0x06, 0x01 };
const struct smbus_cmd_t SET_PDOS = { 0x08, 0x03, 0x03 };
const struct smbus_cmd_t SET_RDO = { 0x08, 0x06, 0x04 };
const struct smbus_cmd_t SET_TPC_RP = { 0x08, 0x03, 0x05 };
const struct smbus_cmd_t SET_TPC_CSD_OPERATION_MODE = { 0x08, 0x03, 0x1D };
const struct smbus_cmd_t SET_TPC_RECONNECT = { 0x08, 0x03, 0x1F };
const struct smbus_cmd_t FORCE_SET_POWER_SWITCH = { 0x08, 0x03, 0x21 };
const struct smbus_cmd_t GET_PDOS = { 0x08, 0x03, 0x83 };
@ -152,6 +151,7 @@ const struct smbus_cmd_t SET_PDR = { 0x0E, 0x04, 0x0B };
const struct smbus_cmd_t UCSI_GET_CONNECTOR_STATUS = { 0x0E, 0x3, 0x12 };
const struct smbus_cmd_t UCSI_GET_ERROR_STATUS = { 0x0E, 0x03, 0x13 };
const struct smbus_cmd_t UCSI_READ_POWER_LEVEL = { 0x0E, 0x05, 0x1E };
const struct smbus_cmd_t UCSI_SET_CCOM = { 0x0E, 0x04, 0x08 };
const struct smbus_cmd_t GET_IC_STATUS = { 0x3A, 0x03, 0x00 };
const struct smbus_cmd_t SET_RETIMER_FW_UPDATE_MODE = { 0x20, 0x03, 0x00 };
const struct smbus_cmd_t GET_CABLE_PROPERTY = { 0x0E, 0x02, 0x11 };
@ -1938,11 +1938,15 @@ static int rts54_get_vbus_voltage(const struct device *dev, uint16_t *voltage)
(uint8_t *)voltage);
}
static int rts54_set_ccom(const struct device *dev, enum ccom_t ccom,
enum drp_mode_t dm)
static int rts54_set_ccom(const struct device *dev, enum ccom_t ccom)
{
struct pdc_data_t *data = dev->data;
uint8_t byte = 0;
uint16_t conn_opmode = 0;
/*
* From bit 32, the first 7 bits are connector. The next 4 bits are for
* the CC operation mode.
*/
const uint8_t opmode_offset = 7;
if (get_state(data) != ST_IDLE) {
return -EBUSY;
@ -1950,36 +1954,20 @@ static int rts54_set_ccom(const struct device *dev, enum ccom_t ccom,
switch (ccom) {
case CCOM_RP:
byte = 0x02;
break;
case CCOM_DRP:
byte = 0x01;
switch (dm) {
case DRP_NORMAL:
/* No Try.Src or Try.Snk */
break;
case DRP_TRY_SRC:
byte |= (1 << 3);
break;
case DRP_TRY_SNK:
byte |= (2 << 3);
break;
}
conn_opmode = 1 << (opmode_offset + 0);
break;
case CCOM_RD:
byte = 0;
conn_opmode = 1 << (opmode_offset + 1);
break;
case CCOM_DRP:
conn_opmode = 1 << (opmode_offset + 2);
break;
}
/* We always want Accessory Support */
byte |= (1 << 2);
uint8_t payload[] = {
SET_TPC_CSD_OPERATION_MODE.cmd,
SET_TPC_CSD_OPERATION_MODE.len,
SET_TPC_CSD_OPERATION_MODE.sub,
0x00,
byte,
UCSI_SET_CCOM.cmd, UCSI_SET_CCOM.len,
UCSI_SET_CCOM.sub, 0x00 /* data length */,
conn_opmode & 0xff, (conn_opmode >> 8) & 0xff,
};
return rts54_post_command(dev, CMD_SET_CCOM, payload,

View File

@ -398,13 +398,12 @@ static int set_tpc_rp(struct rts5453p_emul_pdc_data *data,
return 0;
}
static int set_tpc_csd_operation_mode(struct rts5453p_emul_pdc_data *data,
const union rts54_request *req)
static int set_ccom(struct rts5453p_emul_pdc_data *data,
const union rts54_request *req)
{
LOG_INF("SET_TPC_CSD_OPERATION_MODE port=%d",
req->set_tpc_csd_operation_mode.port_num);
LOG_INF("SET_CCOM port=%d", req->set_ccom.port_and_ccom.port_num);
data->csd_op_mode = req->set_tpc_csd_operation_mode.op_mode;
data->set_ccom_mode = req->set_ccom.port_and_ccom;
memset(&data->response, 0, sizeof(data->response));
send_response(data);
@ -639,7 +638,7 @@ const struct commands sub_cmd_x08[] = {
{ .code = 0x05, HANDLER_DEF(set_tpc_rp) },
{ .code = 0x19, HANDLER_DEF(unsupported) },
{ .code = 0x1A, HANDLER_DEF(unsupported) },
{ .code = 0x1D, HANDLER_DEF(set_tpc_csd_operation_mode) },
{ .code = 0x1D, HANDLER_DEF(unsupported) },
{ .code = 0x1F, HANDLER_DEF(set_tpc_reconnect) },
{ .code = 0x20, HANDLER_DEF(unsupported) },
{ .code = 0x21, HANDLER_DEF(force_set_power_switch) },
@ -669,6 +668,7 @@ const struct commands sub_cmd_x0E[] = {
{ .code = 0x03, HANDLER_DEF(connector_reset) },
{ .code = 0x06, HANDLER_DEF(get_capability) },
{ .code = 0x07, HANDLER_DEF(get_connector_capability) },
{ .code = 0x08, HANDLER_DEF(set_ccom) },
{ .code = 0x09, HANDLER_DEF(set_uor) },
{ .code = 0x0B, HANDLER_DEF(set_pdr) },
{ .code = 0x0C, HANDLER_DEF(unsupported) },
@ -1088,37 +1088,23 @@ emul_realtek_rts54xx_get_requested_power_level(const struct emul *target,
}
static int emul_realtek_rts54xx_get_ccom(const struct emul *target,
enum ccom_t *ccom, enum drp_mode_t *dm)
enum ccom_t *ccom)
{
struct rts5453p_emul_pdc_data *data =
rts5453p_emul_get_pdc_data(target);
switch (data->csd_op_mode.csd_mode) {
case 0:
*ccom = CCOM_RD;
break;
case 1:
*ccom = CCOM_DRP;
switch (data->csd_op_mode.drp_mode) {
case 0:
*dm = DRP_NORMAL;
break;
case 1:
*dm = DRP_TRY_SRC;
break;
case 2:
*dm = DRP_TRY_SNK;
break;
default:
LOG_ERR("Invalid drp 0x%X", data->csd_op_mode.drp_mode);
return -EINVAL;
}
break;
case 2:
switch (data->set_ccom_mode.ccom) {
case 0x1:
*ccom = CCOM_RP;
break;
case 0x2:
*ccom = CCOM_RD;
break;
case 0x4:
*ccom = CCOM_DRP;
break;
default:
LOG_ERR("Invalid csd_mode 0x%X", data->csd_op_mode.csd_mode);
LOG_ERR("Invalid ccom mode 0x%X", data->set_ccom_mode.ccom);
return -EINVAL;
}

View File

@ -175,19 +175,17 @@ union rts54_request {
} tpc_rp;
} set_tpc_rp;
struct set_tpc_csd_operation_mode_req {
struct set_ccom_req {
struct rts54_subcommand_header header;
uint8_t port_num;
union csd_op_mode_t {
uint8_t raw_value;
union port_and_ccom_t {
uint16_t raw_value;
struct {
uint8_t csd_mode : 2;
uint8_t accessory_support : 1;
uint8_t drp_mode : 2;
uint8_t reserved : 3;
uint16_t port_num : 7;
uint16_t ccom : 4;
uint16_t reserved : 5;
};
} op_mode;
} set_tpc_csd_operation_mode;
} port_and_ccom;
} set_ccom;
struct force_set_power_switch_req {
struct rts54_subcommand_header header;
@ -409,7 +407,7 @@ struct rts5453p_emul_pdc_data {
union error_status_t error;
uint32_t rdo;
union tpc_rp_t tpc_rp;
union csd_op_mode_t csd_op_mode;
union port_and_ccom_t set_ccom_mode;
struct force_set_power_switch_t set_power_switch_data;
uint8_t set_tpc_reconnect_param;
struct pdc_info_t info;

View File

@ -92,8 +92,7 @@ typedef int (*pdc_get_capability_t)(const struct device *dev,
struct capability_t *caps);
typedef int (*pdc_get_connector_capability_t)(
const struct device *dev, union connector_capability_t *caps);
typedef int (*pdc_set_ccom_t)(const struct device *dev, enum ccom_t ccom,
enum drp_mode_t dm);
typedef int (*pdc_set_ccom_t)(const struct device *dev, enum ccom_t ccom);
typedef int (*pdc_set_uor_t)(const struct device *dev, union uor_t uor);
typedef int (*pdc_set_pdr_t)(const struct device *dev, union pdr_t pdr);
typedef int (*pdc_set_sink_path_t)(const struct device *dev, bool en);
@ -434,8 +433,7 @@ pdc_get_connector_capability(const struct device *dev,
* @retval -EBUSY if not ready to execute the command
* @retval -ENOSYS if not implemented
*/
static inline int pdc_set_ccom(const struct device *dev, enum ccom_t ccom,
enum drp_mode_t dm)
static inline int pdc_set_ccom(const struct device *dev, enum ccom_t ccom)
{
const struct pdc_driver_api_t *api =
(const struct pdc_driver_api_t *)dev->api;
@ -445,7 +443,7 @@ static inline int pdc_set_ccom(const struct device *dev, enum ccom_t ccom,
return -ENOSYS;
}
return api->set_ccom(dev, ccom, dm);
return api->set_ccom(dev, ccom);
}
/**

View File

@ -23,8 +23,8 @@ typedef int (*emul_pdc_set_capability_t)(const struct emul *target,
const struct capability_t *caps);
typedef int (*emul_pdc_set_connector_capability_t)(
const struct emul *target, const union connector_capability_t *caps);
typedef int (*emul_pdc_get_ccom_t)(const struct emul *target, enum ccom_t *ccom,
enum drp_mode_t *dm);
typedef int (*emul_pdc_get_ccom_t)(const struct emul *target,
enum ccom_t *ccom);
typedef int (*emul_pdc_get_uor_t)(const struct emul *target, union uor_t *uor);
typedef int (*emul_pdc_get_pdr_t)(const struct emul *target, union pdr_t *pdr);
typedef int (*emul_pdc_get_sink_path_t)(const struct emul *target, bool *en);
@ -172,7 +172,7 @@ emul_pdc_set_connector_capability(const struct emul *target,
}
static inline int emul_pdc_get_ccom(const struct emul *target,
enum ccom_t *ccom, enum drp_mode_t *dm)
enum ccom_t *ccom)
{
if (!target || !target->backend_api) {
return -ENOTSUP;
@ -181,7 +181,7 @@ static inline int emul_pdc_get_ccom(const struct emul *target,
const struct emul_pdc_api_t *api = target->backend_api;
if (api->get_ccom) {
return api->get_ccom(target, ccom, dm);
return api->get_ccom(target, ccom);
}
return -ENOSYS;
}

View File

@ -83,6 +83,7 @@ register_corsola_project("chinchou")
register_corsola_project("woobat")
register_corsola_project("wugtrio")
register_corsola_project("skitty")
register_corsola_project("veluza")
register_corsola_project(
project_name="kyogre",
@ -104,3 +105,4 @@ assert_rw_fwid_DO_NOT_EDIT(project_name="voltorb", addr=0x7FFE0)
assert_rw_fwid_DO_NOT_EDIT(project_name="woobat", addr=0xBFFE0)
assert_rw_fwid_DO_NOT_EDIT(project_name="wugtrio", addr=0xBFFE0)
assert_rw_fwid_DO_NOT_EDIT(project_name="skitty", addr=0xBFFE0)
assert_rw_fwid_DO_NOT_EDIT(project_name="veluza", addr=0xBFFE0)

View File

@ -59,4 +59,7 @@ elseif(DEFINED CONFIG_BOARD_WUGTRIO)
elseif(DEFINED CONFIG_BOARD_SKITTY)
project(skitty)
add_subdirectory(skitty)
elseif(DEFINED CONFIG_BOARD_VELUZA)
project(veluza)
add_subdirectory(veluza)
endif()

View File

@ -80,6 +80,12 @@ config BOARD_SKITTY
Build Google Skitty variant board. Skitty is a variant of Krabby
and has MediaTek MT8186 SoC with ITE it81202-bx EC
config BOARD_VELUZA
bool "Google Veluza Board"
help
Build Google Veluza variant board. Veluza is a variant of Krabby
and has MediaTek MT8186 SoC with ITE it81202-bx EC
config VARIANT_CORSOLA_DB_DETECTION
bool "Corsola Platform Runtime Daughter Board Detection"
depends on PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG

View File

@ -0,0 +1,10 @@
# Copyright 2024 The ChromiumOS Authors
# Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Chinchou Makeifile
zephyr_include_directories("include")
zephyr_library_sources("../src/ite_hooks.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "../src/ite_i2c.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
"../src/ite_usb_pd_policy.c" "../src/ite_usbc.c")
zephyr_library_sources("src/temp.c" "src/ppc.c")

View File

@ -0,0 +1,29 @@
# Copyright 2024 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Variant config
CONFIG_BOARD_VELUZA=y
# Variant config
CONFIG_VARIANT_CORSOLA_DB_DETECTION=n
# Motion sensor
CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=n
CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=n
CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y
# BC1.2
CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=n
# USB-C
CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n
CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=n
# battery
CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
CONFIG_PLATFORM_EC_I2C_NACK_RETRY_COUNT=10
CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY_ADDR=0x0f
CONFIG_PLATFORM_EC_SMBUS_PEC=y
CONFIG_PLATFORM_EC_SMART_BATTERY_OPTIONAL_MFG_FUNC=y
# Button
CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n
# Keyboard
CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
# Remove debug options and features for FW QUAL
CONFIG_PLATFORM_EC_BRINGUP=n
CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n

View File

@ -0,0 +1,242 @@
/* Copyright 2024 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Corsola program common DTS includes */
#include <cros/thermistor/thermistor.dtsi>
#include "../common.dtsi"
#include "../power_signal.dtsi"
#include "../usba.dtsi"
#include "../ite_adc.dtsi"
#include "../ite_gpio.dtsi"
#include "../ite_keyboard.dtsi"
#include "../ite_i2c.dtsi"
#include "../ite_interrupts.dtsi"
#include "../ite_led.dtsi"
#include "../ite_usbc.dtsi"
#include "../ite_shi.dtsi"
#include "./thermistor.dtsi"
/ {
named-gpios {
/delete-node/ usb_c0_ppc_bc12_int_odl;
usb_c0_ppc_int_odl: usb_c0_ppc_int_odl {
gpios = <&gpiod 1 GPIO_INPUT>;
enum-name = "GPIO_USB_C0_PPC_INT_ODL";
};
/delete-node/ usb_c0_ppc_frsinfo;
usb_c0_frs_en: usb_c0_frs_en {
gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
enum-name = "GPIO_USB_C0_FRS_EN";
};
};
unused-pins {
unused-gpios =
/* pg_pp5000_z2_od */
<&gpiod 2 GPIO_INPUT>,
/* GPIO_VOLUME_DOWN_L */
<&gpiod 5 GPIO_INPUT>,
/* GPIO_VOLUME_UP_L */
<&gpiod 6 GPIO_INPUT>,
/* pg_mt6315_proc_b_odl */
<&gpioe 1 GPIO_INPUT>,
/* ec_pen_chg_dis_odl */
<&gpioh 3 GPIO_ODR_HIGH>,
/* unnamed nc pins */
<&gpioa 3 GPIO_INPUT_PULL_DOWN>,
<&gpioa 6 GPIO_INPUT_PULL_DOWN>,
<&gpioa 7 GPIO_INPUT_PULL_DOWN>,
<&gpiod 7 GPIO_INPUT_PULL_DOWN>,
<&gpioh 0 GPIO_INPUT_PULL_DOWN>,
<&gpioh 6 GPIO_INPUT_PULL_DOWN>,
<&gpioi 3 GPIO_INPUT_PULL_DOWN>,
<&gpioi 6 GPIO_INPUT_PULL_DOWN>,
<&gpioi 7 GPIO_INPUT_PULL_DOWN>,
<&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>,
/* spi_clk_gpg6 */
<&gpiog 6 GPIO_INPUT_PULL_UP>,
/* spi_mosi_gpg4 */
<&gpiog 4 GPIO_OUTPUT_LOW>,
/* spi_miso_gpg5 */
<&gpiog 5 GPIO_OUTPUT_LOW>,
/* spi_cs_gpg7 */
<&gpiog 7 GPIO_OUTPUT_LOW>;
};
gpio-interrupts {
/delete-node/ volume_up;
/delete-node/ volume_down;
/delete-node/ usb_c0_ppc_bc12;
/delete-node/ base_imu;
/delete-node/ lid_imu;
int_usb_c0_ppc: usb_c0_ppc {
irq-pin = <&usb_c0_ppc_int_odl>;
flags = <GPIO_INT_EDGE_FALLING>;
handler = "ppc_interrupt";
};
};
usbc {
port0@0 {
ppc_alt = <&ppc_port0>;
};
/delete-node/ port1@1;
};
named-adc-channels {
adc_ambient: ambient {
enum-name = "ADC_TEMP_SENSOR_2_AMBIENT";
io-channels = <&adc0 5>;
};
};
temp_ambient: ambient {
compatible = "cros-ec,temp-sensor-thermistor";
thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>;
adc = <&adc_ambient>;
};
named-temp-sensors {
compatible = "cros-ec,temp-sensors";
ambient {
temp_host_high = <56>;
temp_host_halt = <80>;
temp_host_release_high = <42>;
sensor = <&temp_ambient>;
};
temp_charger: charger {
temp_host_high = <68>;
temp_host_halt = <90>;
temp_host_release_high = <59>;
sensor = <&charger_bc12_port1>;
};
};
led-colors {
compatible = "cros-ec,led-policy";
/* Veluza LED bat charge */
bat-power-state-charge {
charge-state = "LED_PWRS_CHARGE";
/* Battery percent range (>= Empty, <= 94%) */
batt-lvl = <BATTERY_LEVEL_EMPTY 94>;
battery-led {
led-id = "EC_LED_ID_BATTERY_LED";
color-0 {
led-color = "LED_AMBER";
};
};
};
bat-power-state-charge-near-full {
charge-state = "LED_PWRS_CHARGE";
/* Battery percent range (>= 95%, <= Full) */
batt-lvl = <95 BATTERY_LEVEL_FULL>;
battery-led {
led-id = "EC_LED_ID_BATTERY_LED";
color-0 {
led-color = "LED_WHITE";
};
};
};
/* Veluza LED bat discharge */
bat-power-state-discharge-s0 {
charge-state = "LED_PWRS_DISCHARGE";
chipset-state = "POWER_S0";
/* Battery percent range (>= 11%, <= Full) */
batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>;
battery-led {
led-id = "EC_LED_ID_BATTERY_LED";
color-0 {
led-color = "LED_WHITE";
};
};
};
bat-power-state-discharge-s5 {
charge-state = "LED_PWRS_DISCHARGE";
chipset-state = "POWER_S5";
battery-led {
led-id = "EC_LED_ID_BATTERY_LED";
color-0 {
led-color = "LED_OFF";
};
};
};
/* Veluza LED bat error */
bat-power-state-error {
charge-state = "LED_PWRS_ERROR";
chipset-state = "POWER_S0";
battery-led {
led-id = "EC_LED_ID_BATTERY_LED";
color-0 {
led-color = "LED_AMBER";
period-ms = <1000>;
};
color-1 {
led-color = "LED_OFF";
period-ms = <1000>;
};
};
};
bat-power-state-error-s3 {
charge-state = "LED_PWRS_ERROR";
chipset-state = "POWER_S3";
battery-led {
led-id = "EC_LED_ID_BATTERY_LED";
color-0 {
led-color = "LED_WHITE";
period-ms = <1000>;
};
color-1 {
led-color = "LED_OFF";
period-ms = <3000>;
};
};
};
bat-power-state-error-s5 {
charge-state = "LED_PWRS_ERROR";
chipset-state = "POWER_S5";
battery-led {
led-id = "EC_LED_ID_BATTERY_LED";
color-0 {
led-color = "LED_OFF";
};
};
};
};
pwm-led-pins {
compatible = "cros-ec,pwm-led-pins";
power_led: power-led {
led-id = "EC_LED_ID_POWER_LED";
led-pwms = <&led_power_white>;
/* Overwrite Power LED white to off */
color-power-white {
led-color = "LED_WHITE";
led-values = <0>;
};
};
};
batteries {
default_battery: c235 {
compatible = "celxpert,c235-41", "battery-smart";
};
};
};
&adc0 {
pinctrl-0 = <&adc0_ch0_gpi0_default
&adc0_ch1_gpi1_default
&adc0_ch2_gpi2_default
&adc0_ch5_gpi5_default>;
};
&thermistor_3V3_30K9_47K_NCP15WB {
status = "okay";
};
&i2c0 {
charger_bc12_port1: rt9490@53 {
thermistor = <&thermistor_rt9490>;
};
};
&i2c2 {
ppc_port0: syv682x@40 {
compatible = "silergy,syv682x";
status = "okay";
reg = <0x40>;
frs_en_gpio = <&usb_c0_frs_en>;
};
};
&i2c4 {
/delete-node/ tusb1064-mux-1@44;
/delete-node/ ps8743_mux_1;
};

View File

@ -0,0 +1,27 @@
/* Copyright 2024 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Veluza configuration */
#include "baseboard_usbc_config.h"
#include "cros_board_info.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "usb_mux.h"
#include "usbc/ppc.h"
#include <zephyr/logging/log.h>
#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
static void board_usbc_init(void)
{
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
}
DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT);
void ppc_interrupt(enum gpio_signal signal)
{
if (signal == GPIO_SIGNAL(DT_NODELABEL(usb_c0_ppc_int_odl))) {
ppc_chips[0].drv->interrupt(0);
}
}

View File

@ -0,0 +1,115 @@
/* Copyright 2024 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "charge_state.h"
#include "common.h"
#include "driver/charger/rt9490.h"
#include "hooks.h"
#include "temp_sensor/temp_sensor.h"
#define NUM_CURRENT_LEVELS ARRAY_SIZE(current_table)
#define TEMP_THRESHOLD 50
#define TEMP_BUFF_SIZE 60
#define KEEP_TIME 5
BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_VELUZA) || IS_ENABLED(CONFIG_TEST));
/* calculate current average temperature */
static int average_tempature(void)
{
static int temp_history_buffer[TEMP_BUFF_SIZE];
static int buff_ptr;
static int temp_sum;
static int past_temp;
static int avg_temp;
int cur_temp, t;
temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)), &t);
cur_temp = K_TO_C(t);
past_temp = temp_history_buffer[buff_ptr];
temp_history_buffer[buff_ptr] = cur_temp;
temp_sum = temp_sum + temp_history_buffer[buff_ptr] - past_temp;
buff_ptr++;
if (buff_ptr >= TEMP_BUFF_SIZE) {
buff_ptr = 0;
}
/* Calculate per minute temperature.
* It's expected low temperature when the first 60 seconds.
*/
avg_temp = temp_sum / TEMP_BUFF_SIZE;
return avg_temp;
}
static int current_level;
/* Limit charging current table : 3600/3000/2400/1800
* note this should be in descending order.
*/
static uint16_t current_table[] = {
3600,
3000,
2400,
1600,
};
/* Called by hook task every hook second (1 sec) */
static void current_update(void)
{
int temp;
static uint8_t uptime;
static uint8_t dntime;
temp = average_tempature();
#ifndef CONFIG_TEST
if (led_pwr_get_state() == LED_PWRS_DISCHARGE) {
current_level = 0;
uptime = 0;
dntime = 0;
return;
}
#endif
if (temp >= TEMP_THRESHOLD) {
dntime = 0;
if (uptime < KEEP_TIME) {
uptime++;
} else {
uptime = 0;
current_level++;
}
} else if (current_level != 0 && temp < TEMP_THRESHOLD) {
uptime = 0;
if (dntime < KEEP_TIME) {
dntime++;
} else {
dntime = 0;
current_level--;
}
} else {
uptime = 0;
dntime = 0;
}
if (current_level > NUM_CURRENT_LEVELS) {
current_level = NUM_CURRENT_LEVELS;
}
}
DECLARE_HOOK(HOOK_SECOND, current_update, HOOK_PRIO_DEFAULT);
int charger_profile_override(struct charge_state_data *curr)
{
/*
* Precharge must be executed when communication is failed on
* dead battery.
*/
if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE))
return 0;
if (current_level != 0) {
if (curr->requested_current > current_table[current_level - 1])
curr->requested_current =
current_table[current_level - 1];
}
return 0;
}
enum ec_status charger_profile_override_get_param(uint32_t param,
uint32_t *value)
{
return EC_RES_INVALID_PARAM;
}
enum ec_status charger_profile_override_set_param(uint32_t param,
uint32_t value)
{
return EC_RES_INVALID_PARAM;
}

View File

@ -0,0 +1,120 @@
/* Copyright 2024 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/ {
thermistor_rt9490: thermistor-rt9490 {
status = "okay";
compatible = "cros-ec,thermistor";
scaling-factor = <3>;
num-pairs = <21>;
steinhart-reference-mv = <4900>;
steinhart-reference-res = <10000>;
sample-datum-0 {
milivolt = <(731 / 3)>;
temp = <0>;
sample-index = <0>;
};
sample-datum-1 {
milivolt = <(708 / 3)>;
temp = <5>;
sample-index = <1>;
};
sample-datum-2 {
milivolt = <(682 / 3)>;
temp = <10>;
sample-index = <2>;
};
sample-datum-3 {
milivolt = <(653 / 3)>;
temp = <15>;
sample-index = <3>;
};
sample-datum-4 {
milivolt = <(622 / 3)>;
temp = <20>;
sample-index = <4>;
};
sample-datum-5 {
milivolt = <(589 / 3)>;
temp = <25>;
sample-index = <5>;
};
sample-datum-6 {
milivolt = <(554 / 3)>;
temp = <30>;
sample-index = <6>;
};
sample-datum-7 {
milivolt = <(519 / 3)>;
temp = <35>;
sample-index = <7>;
};
sample-datum-8 {
milivolt = <(483 / 3)>;
temp = <40>;
sample-index = <8>;
};
sample-datum-9 {
milivolt = <(446 / 3)>;
temp = <45>;
sample-index = <9>;
};
sample-datum-10 {
milivolt = <(411 / 3)>;
temp = <50>;
sample-index = <10>;
};
sample-datum-11 {
milivolt = <(376 / 3)>;
temp = <55>;
sample-index = <11>;
};
sample-datum-12 {
milivolt = <(343 / 3)>;
temp = <60>;
sample-index = <12>;
};
sample-datum-13 {
milivolt = <(312 / 3)>;
temp = <65>;
sample-index = <13>;
};
sample-datum-14 {
milivolt = <(284 / 3)>;
temp = <70>;
sample-index = <14>;
};
sample-datum-15 {
milivolt = <(257 / 3)>;
temp = <75>;
sample-index = <15>;
};
sample-datum-16 {
milivolt = <(232 / 3)>;
temp = <80>;
sample-index = <16>;
};
sample-datum-17 {
milivolt = <(209 / 3)>;
temp = <85>;
sample-index = <17>;
};
sample-datum-18 {
milivolt = <(188 / 3)>;
temp = <90>;
sample-index = <18>;
};
sample-datum-19 {
milivolt = <(169 / 3)>;
temp = <95>;
sample-index = <19>;
};
sample-datum-20 {
milivolt = <(152 / 3)>;
temp = <100>;
sample-index = <20>;
};
};
};

View File

@ -130,7 +130,7 @@ CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
CONFIG_PLATFORM_EC_TABLET_MODE=y
CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=110000
# Sensor Drivers
CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y

View File

@ -122,6 +122,7 @@
};
gpio_en_kb_bl: en_kb_bl {
gpios = <&gpiog 2 (GPIO_OUTPUT | GPIO_ACTIVE_HIGH)>;
enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
};
gpio_en_pp3700_s5: en_pp3700_s5 {
gpios = <&gpioh 5 (GPIO_OUTPUT | GPIO_ACTIVE_HIGH)>;

View File

@ -90,6 +90,7 @@
};
/* a label to prevent build break in power sequencing */
en_pp4200_s5: en_pp3700_s5 {
gpios = <&gpioh 5 (GPIO_OUTPUT_LOW)>;
};
/* Arbitrage doesn't support INPUT | ACTIVE_LOW gpios */
als_int_ec_odl {

View File

@ -52,7 +52,8 @@ CONFIG_ADC=y
# b:188434233: Use EC adc command
CONFIG_ADC_SHELL=n
CONFIG_PWM=n
CONFIG_PWM=y
CONFIG_PWM_SHELL=y
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
CONFIG_PLATFORM_EC_VBOOT_EFS2=y

View File

@ -8,3 +8,4 @@ CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
CONFIG_PLATFORM_EC_PP3700_DISCHARGE_TIME_MS=3500
CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y

View File

@ -242,6 +242,12 @@
compatible = "cosmx,ap20cbl-3", "battery-smart";
};
};
kb_bl_pwm {
compatible = "cros-ec,kblight-pwm";
pwms = <&pwm3 0 PWM_HZ(324) PWM_POLARITY_NORMAL>;
status = "okay";
};
};
/*

View File

@ -361,8 +361,6 @@ struct pdc_unattached_policy_t {
enum usb_typec_current_t tcc;
/** CC Operation Mode */
enum ccom_t cc_mode;
/** DRP Operation Mode */
enum drp_mode_t drp_mode;
};
/**
@ -433,6 +431,8 @@ struct pdc_snk_attached_policy_t {
enum policy_src_attached_t {
/** Enables swap to Sink */
SRC_POLICY_SWAP_TO_SNK,
/** Forces sink-only operation, even if it requires a disconnect */
SRC_POLICY_FORCE_SNK,
/** SRC_POLICY_COUNT */
SRC_POLICY_COUNT
@ -702,8 +702,6 @@ static ALWAYS_INLINE void pdc_thread(void *pdc_dev, void *unused1,
DT_INST_PROP(inst, policy), unattached_rp_value), \
.port.una_policy.cc_mode = DT_STRING_TOKEN( \
DT_INST_PROP(inst, policy), unattached_cc_mode), \
.port.una_policy.drp_mode = DT_STRING_TOKEN( \
DT_INST_PROP(inst, policy), unattached_try), \
.port.suspend = ATOMIC_INIT(0), \
}; \
\
@ -1029,6 +1027,10 @@ static void run_src_policies(struct pdc_port_t *port)
SRC_POLICY_SWAP_TO_SNK)) {
queue_internal_cmd(port, CMD_PDC_SET_PDR);
return;
} else if (atomic_test_and_clear_bit(port->src_policy.flags,
SRC_POLICY_FORCE_SNK)) {
queue_internal_cmd(port, CMD_PDC_SET_CCOM);
return;
}
send_pending_public_commands(port);
@ -1383,8 +1385,7 @@ static int send_pdc_cmd(struct pdc_port_t *port)
rv = pdc_set_power_level(port->pdc, port->una_policy.tcc);
break;
case CMD_PDC_SET_CCOM:
rv = pdc_set_ccom(port->pdc, port->una_policy.cc_mode,
port->una_policy.drp_mode);
rv = pdc_set_ccom(port->pdc, port->una_policy.cc_mode);
break;
case CMD_PDC_GET_PDOS:
rv = pdc_get_pdos(port->pdc, port->pdo_type, PDO_OFFSET_0,
@ -2468,6 +2469,14 @@ void pdc_power_mgmt_set_dual_role(int port, enum pd_dual_role_states state)
port_data->pdr.swap_to_snk = 1;
atomic_set_bit(port_data->src_policy.flags,
SRC_POLICY_SWAP_TO_SNK);
/*
* If PRS to Sink fails, disconnect and reconnect as
* Sink.
*/
port_data->una_policy.cc_mode = CCOM_RD;
atomic_set_bit(port_data->src_policy.flags,
SRC_POLICY_FORCE_SNK);
}
break;
/* Switch to source */

View File

@ -80,3 +80,11 @@ target_sources_ifdef(CONFIG_TEST_SKITTY
src/temp_skitty.c
${PLATFORM_EC_PROGRAM_DIR}/corsola/skitty/src/ppc.c
${PLATFORM_EC_PROGRAM_DIR}/corsola/skitty/src/temp.c)
target_sources_ifdef(CONFIG_TEST_VELUZA
app PRIVATE
src/fake.c
src/ppc_veluza.c
src/temp_veluza.c
${PLATFORM_EC_PROGRAM_DIR}/corsola/veluza/src/ppc.c
${PLATFORM_EC_PROGRAM_DIR}/corsola/veluza/src/temp.c)

View File

@ -58,6 +58,12 @@ config TEST_SKITTY
Include skitty test into the binary to test temperature
threshold trigger current control.
config TEST_VELUZA
bool "Run the tests intended for veluza"
help
Include veluza test into the binary to test temperature
threshold trigger current control.
endchoice
source "Kconfig.zephyr"

View File

@ -0,0 +1,160 @@
/* Copyright 2024 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "common.dtsi"
#include "../program/corsola/ite_gpio.dtsi"
#include "../program/corsola/ite_interrupts.dtsi"
#include "../program/corsola/veluza/thermistor.dtsi"
/* remove pinctrl to avoid pull in too many unwanted dependency */
/delete-node/ &pinctrl;
/delete-node/ &int_usb_c0_ppc_bc12;
/delete-node/ &int_volume_up;
/delete-node/ &int_volume_down;
/delete-node/ &int_tablet_mode;
/delete-node/ &{/hibernate-wake-pins};
/*
* The unused-pins functionality is not currently tested. Remove
* to avoid mismatches in the GPIO flags configuration.
*/
/delete-node/ &{/unused-pins};
/ {
name_temp_charger: charger {
compatible = "cros-ec,temp-sensor-thermistor";
thermistor = <&thermistor_rt9490>;
adc = <&adc_charger>;
};
named-temp-sensors {
compatible = "cros-ec,temp-sensors";
temp_charger: charger {
status = "okay";
sensor = <&name_temp_charger>;
};
};
named-gpios {
/delete-node/ usb_c0_ppc_bc12_int_odl;
usb_c0_ppc_int_odl: usb_c0_ppc_int_odl {
gpios = <&gpiod 1 GPIO_INPUT>;
enum-name = "GPIO_USB_C0_PPC_INT_ODL";
};
/delete-node/ usb_c0_ppc_frsinfo;
usb_c0_frs_en: usb_c0_frs_en {
gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
enum-name = "GPIO_USB_C0_FRS_EN";
};
};
gpio-interrupts {
/delete-node/ usb_c0_ppc_bc12;
};
named-i2c-ports {
compatible = "named-i2c-ports";
i2c_sensor: i2c-sensor {
i2c-port = <&i2c0>;
enum-names = "I2C_PORT_SENSOR";
};
i2c_eeprom: i2c-eeprom {
i2c-port = <&i2c0>;
enum-names = "I2C_PORT_EEPROM";
};
};
gpio-interrupts {
/delete-node/ base_imu;
/delete-node/ lid_imu;
int_usb_c0_ppc: usb_c0_ppc {
irq-pin = <&usb_c0_ppc_int_odl>;
flags = <GPIO_INT_EDGE_FALLING>;
handler = "ppc_interrupt";
};
int_x_ec_gpio2: x_ec_gpio2 {
/* We have bypassed the db detection, so link
* int_x_ec_gpio2 to ppc_interrupt directly.
*/
handler = "ppc_interrupt";
};
};
usbc {
port0@0 {
ppc_alt = <&ppc_port0>;
};
/delete-node/ port1@1;
};
};
/* open-drain is not supported in gpio emul, re-config to push-pull */
&ec_pmic_en_odl {
gpios = <&gpiod 0 (GPIO_OUTPUT_HIGH | GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
};
&sys_rst_odl {
gpios = <&gpiog 1 GPIO_OUTPUT_LOW>;
};
&gpio_ec_bl_en_od {
gpios = <&gpiob 5 (GPIO_OUTPUT_LOW | GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
};
&ec_int_l {
gpios = <&gpioe 6 (GPIO_OUTPUT_HIGH | GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
};
&ec_ap_dp_hpd_odl {
gpios = <&gpioj 0 (GPIO_OUTPUT_HIGH | GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
};
&en_ec_id_odl {
gpios = <&gpioh 5 (GPIO_OUTPUT_HIGH | GPIO_INPUT)>;
};
/* set default gpio-emul state */
&power_button_l {
gpios = <&gpioe 4 (GPIO_INPUT | GPIO_PULL_UP)>;
};
&i2c0 {
status="okay";
/delete-node/ pi3usb9201_emul0;
/delete-node/ ppc0_emul;
/delete-node/ ppc1_emul;
/delete-node/ rt1718s_emul;
/delete-node/ ppc_port1;
/delete-node/ bc12_ppc_port0;
};
&i2c2 {
status="okay";
ppc_port0: syv682x@44 {
compatible = "silergy,syv682x", "cros,i2c-mock";
status = "okay";
reg = <0x44>;
};
};
&i2c4 {
/delete-node/ tusb1064-mux-1@44;
/delete-node/ ps8743_mux_1;
};

View File

@ -0,0 +1,53 @@
/* Copyright 2024 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gpio.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "usbc/ppc.h"
#include <zephyr/devicetree.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/fff.h>
#include <zephyr/ztest.h>
FAKE_VOID_FUNC(ppc_chip_0_interrupt, int);
ZTEST(ppc_veluza, test_ppc_init)
{
const struct device *ppc_int_gpio = DEVICE_DT_GET(
DT_GPIO_CTLR(DT_NODELABEL(usb_c0_ppc_int_odl), gpios));
const gpio_port_pins_t ppc_int_pin =
DT_GPIO_PIN(DT_NODELABEL(usb_c0_ppc_int_odl), gpios);
hook_notify(HOOK_INIT);
zassert_ok(gpio_emul_input_set(ppc_int_gpio, ppc_int_pin, 1), NULL);
k_sleep(K_MSEC(100));
zassert_ok(gpio_emul_input_set(ppc_int_gpio, ppc_int_pin, 0), NULL);
k_sleep(K_MSEC(100));
zassert_equal(ppc_chip_0_interrupt_fake.call_count, 1);
}
static void *ppc_veluza_init(void)
{
static struct ppc_drv fake_ppc_drv_0;
zassert_equal(ppc_cnt, 1);
/* inject mocked interrupt handlers into ppc_drv */
fake_ppc_drv_0 = *ppc_chips[0].drv;
fake_ppc_drv_0.interrupt = ppc_chip_0_interrupt;
ppc_chips[0].drv = &fake_ppc_drv_0;
return NULL;
}
static void ppc_veluza_before(void *fixture)
{
RESET_FAKE(ppc_chip_0_interrupt);
}
ZTEST_SUITE(ppc_veluza, NULL, ppc_veluza_init, ppc_veluza_before, NULL, NULL);

View File

@ -0,0 +1,106 @@
/* Copyright 2024 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "charge_state.h"
#include "charger.h"
#include "charger_profile_override.h"
#include "common.h"
#include "config.h"
#include "hooks.h"
#include "temp_sensor.h"
#include "temp_sensor/temp_sensor.h"
#include "util.h"
#include <zephyr/drivers/adc.h>
#include <zephyr/drivers/adc/adc_emul.h>
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
#define ADC_DEVICE_NODE DT_NODELABEL(adc0)
#define CHARGER_TEMP TEMP_SENSOR_ID(DT_NODELABEL(temp_charger))
#define ORIGINAL_CURRENT 5000
struct charge_state_data curr;
static int fake_voltage;
int count;
/* Limit charging current table : 3600/3000/2400/1800
* note this should be in descending order.
*/
static uint16_t current_table[] = {
3600,
3000,
2400,
1600,
};
int setup_faketemp(int fake_voltage)
{
const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
const uint8_t channel_id =
DT_IO_CHANNELS_INPUT(DT_NODELABEL(adc_charger));
int emul_temp;
emul_temp = adc_emul_const_value_set(adc_dev, channel_id, fake_voltage);
return emul_temp;
}
static void ignore_first_minute(void)
{
for (int i = 0; i < 60; i++) {
hook_notify(HOOK_SECOND);
}
}
ZTEST(temp_veluza, test_decrease_current)
{
fake_voltage = 411;
curr.batt.flags |= BATT_FLAG_RESPONSIVE;
count = 0;
setup_faketemp(fake_voltage);
/* Calculate per minute temperature.
* It's expected low temperature when the first 60 seconds.
*/
ignore_first_minute();
for (int i = 1; i < 26; i++) {
hook_notify(HOOK_SECOND);
curr.requested_current = ORIGINAL_CURRENT;
charger_profile_override(&curr);
if (i % 6 == 0) {
zassert_equal(current_table[count],
curr.requested_current, NULL);
count++;
}
}
zassert_equal(count, 4, NULL);
}
ZTEST(temp_veluza, test_increase_current)
{
fake_voltage = 446;
curr.batt.flags |= BATT_FLAG_RESPONSIVE;
count = 3;
setup_faketemp(fake_voltage);
for (int i = 1; i < 26; i++) {
hook_notify(HOOK_SECOND);
curr.requested_current = ORIGINAL_CURRENT;
charger_profile_override(&curr);
if (i % 5 == 0) {
if (curr.requested_current == ORIGINAL_CURRENT) {
zassert_equal(ORIGINAL_CURRENT,
curr.requested_current, NULL);
} else {
zassert_equal(current_table[count],
curr.requested_current, NULL);
count--;
}
}
}
zassert_equal(count, -1, NULL);
}
ZTEST_SUITE(temp_veluza, NULL, NULL, NULL, NULL, NULL);

View File

@ -128,3 +128,12 @@ tests:
- CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n
extra_dtc_overlay_files:
- krabby.skitty.overlay
krabby.veluza:
extra_configs:
- CONFIG_TEST_VELUZA=y
- CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
- CONFIG_EEPROM=y
- CONFIG_EEPROM_SIMULATOR=n
- CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n
extra_dtc_overlay_files:
- krabby.veluza.overlay

View File

@ -272,25 +272,18 @@ ZTEST_USER(pdc_api, test_get_bus_voltage)
ZTEST_USER(pdc_api, test_set_ccom)
{
int i, j;
int i;
enum ccom_t ccom_in[] = { CCOM_RP, CCOM_RD, CCOM_DRP };
enum ccom_t ccom_out;
enum drp_mode_t dm_in[] = { DRP_NORMAL, DRP_TRY_SRC, DRP_TRY_SNK };
enum drp_mode_t dm_out;
k_sleep(K_MSEC(SLEEP_MS));
for (i = 0; i < ARRAY_SIZE(ccom_in); i++) {
for (j = 0; j < ARRAY_SIZE(dm_in); j++) {
zassert_ok(pdc_set_ccom(dev, ccom_in[i], dm_in[j]));
zassert_ok(pdc_set_ccom(dev, ccom_in[i]));
k_sleep(K_MSEC(SLEEP_MS));
zassert_ok(emul_pdc_get_ccom(emul, &ccom_out, &dm_out));
zassert_equal(ccom_in[i], ccom_out);
if (ccom_in[i] == CCOM_DRP) {
zassert_equal(dm_in[j], dm_out);
}
}
k_sleep(K_MSEC(SLEEP_MS));
zassert_ok(emul_pdc_get_ccom(emul, &ccom_out));
zassert_equal(ccom_in[i], ccom_out);
}
}

View File

@ -585,7 +585,6 @@ ZTEST_USER(pdc_power_mgmt_api, test_set_dual_role)
union connector_status_t connector_status;
enum ccom_t ccom;
enum drp_mode_t dm;
union pdr_t pdr;
uint32_t timeout = k_ms_to_cyc_ceil32(4000);
uint32_t start;
@ -606,7 +605,7 @@ ZTEST_USER(pdc_power_mgmt_api, test_set_dual_role)
k_msleep(TEST_WAIT_FOR_INTERVAL_MS);
if (test[i].e.check_cc_mode) {
emul_pdc_get_ccom(emul, &ccom, &dm);
emul_pdc_get_ccom(emul, &ccom);
if (test[i].e.cc_mode != ccom)
continue;
@ -644,7 +643,6 @@ ZTEST_USER(pdc_power_mgmt_api, test_chipset_suspend)
{
union connector_status_t connector_status;
enum ccom_t ccom;
enum drp_mode_t dm;
uint32_t timeout = k_ms_to_cyc_ceil32(PDC_TEST_TIMEOUT);
uint32_t start;
@ -661,7 +659,7 @@ ZTEST_USER(pdc_power_mgmt_api, test_chipset_suspend)
start = k_cycle_get_32();
while (k_cycle_get_32() - start < timeout) {
k_msleep(TEST_WAIT_FOR_INTERVAL_MS);
emul_pdc_get_ccom(emul, &ccom, &dm);
emul_pdc_get_ccom(emul, &ccom);
if (ccom != CCOM_RD)
continue;
@ -676,7 +674,6 @@ ZTEST_USER(pdc_power_mgmt_api, test_chipset_resume)
{
union connector_status_t connector_status;
enum ccom_t ccom;
enum drp_mode_t dm;
emul_pdc_configure_snk(emul, &connector_status);
emul_pdc_connect_partner(emul, &connector_status);
@ -686,7 +683,7 @@ ZTEST_USER(pdc_power_mgmt_api, test_chipset_resume)
hook_notify(HOOK_CHIPSET_RESUME);
TEST_WORKING_DELAY(PDC_TEST_TIMEOUT);
emul_pdc_get_ccom(emul, &ccom, &dm);
emul_pdc_get_ccom(emul, &ccom);
zassert_equal(CCOM_DRP, ccom);
}
@ -694,7 +691,6 @@ ZTEST_USER(pdc_power_mgmt_api, test_chipset_startup)
{
union connector_status_t connector_status;
enum ccom_t ccom;
enum drp_mode_t dm;
uint32_t timeout = k_ms_to_cyc_ceil32(PDC_TEST_TIMEOUT);
uint32_t start;
@ -711,7 +707,7 @@ ZTEST_USER(pdc_power_mgmt_api, test_chipset_startup)
start = k_cycle_get_32();
while (k_cycle_get_32() - start < timeout) {
k_msleep(TEST_WAIT_FOR_INTERVAL_MS);
emul_pdc_get_ccom(emul, &ccom, &dm);
emul_pdc_get_ccom(emul, &ccom);
if (ccom != CCOM_RD)
continue;