summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Hurst <shurst@google.com>2022-10-12 09:01:40 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-14 22:35:37 +0000
commit27f8b4844665d86bffa845f965c5407a553c908f (patch)
tree69bcb2985b945c2e0550b21de674a64be9e20b80
parentc7ce61e16ce0c88fcd4d1621c828f45ec1fdb773 (diff)
downloadchrome-ec-27f8b4844665d86bffa845f965c5407a553c908f.tar.gz
zephyr: emul: ps8xxx: Add REG_ID register
Add REG_ID Register used to distinguish between the PS8745 and PS8815 chips BUG=None TEST=./twister -T zephyr/test/drivers BRANCH=None Signed-off-by: Sam Hurst <shurst@google.com> Change-Id: Ib7ed8f7d5c3dc4d978342fabfb1046b1e531d82e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3950209 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/emul/tcpc/emul_ps8xxx.c20
-rw-r--r--zephyr/include/emul/tcpc/emul_ps8xxx.h19
2 files changed, 39 insertions, 0 deletions
diff --git a/zephyr/emul/tcpc/emul_ps8xxx.c b/zephyr/emul/tcpc/emul_ps8xxx.c
index 467a487802..22972bf084 100644
--- a/zephyr/emul/tcpc/emul_ps8xxx.c
+++ b/zephyr/emul/tcpc/emul_ps8xxx.c
@@ -43,6 +43,12 @@ struct ps8xxx_emul_data {
uint8_t gpio_ctrl;
/** HW revision used by PS8815 */
uint16_t hw_rev;
+ /**
+ * Register ID to distinguish between the PS8815-A2 and PS8745-A2
+ * 0: Indicates this is an 8815-A2 chip
+ * 1: Indicates this is an 8745-A2 chip
+ */
+ uint8_t reg_id;
};
/** Constant configuration of the emulator */
@@ -63,6 +69,15 @@ void ps8xxx_emul_set_chip_rev(const struct emul *emul, uint8_t chip_rev)
}
/** Check description in emul_ps8xxx.h */
+void ps8xxx_emul_set_reg_id(const struct emul *emul, enum ps8xxx_regid reg_id)
+{
+ struct tcpc_emul_data *tcpc_data = emul->data;
+ struct ps8xxx_emul_data *data = tcpc_data->chip_data;
+
+ data->reg_id = reg_id;
+}
+
+/** Check description in emul_ps8xxx.h */
void ps8xxx_emul_set_hw_rev(const struct emul *emul, uint16_t hw_rev)
{
struct tcpc_emul_data *tcpc_data = emul->data;
@@ -371,6 +386,11 @@ static int ps8xxx_emul_read_byte_workhorse(const struct emul *emul, int reg,
*val = data->chip_rev;
return 0;
}
+ if (data->prod_id == PS8815_PRODUCT_ID &&
+ reg == PS8815_P0_REG_ID) {
+ *val = data->chip_rev;
+ return 0;
+ }
break;
case PS8XXX_EMUL_PORT_1:
/* DCI CFG is no available on PS8815 */
diff --git a/zephyr/include/emul/tcpc/emul_ps8xxx.h b/zephyr/include/emul/tcpc/emul_ps8xxx.h
index 6e96af571b..eb49221fd2 100644
--- a/zephyr/include/emul/tcpc/emul_ps8xxx.h
+++ b/zephyr/include/emul/tcpc/emul_ps8xxx.h
@@ -46,6 +46,16 @@ enum ps8xxx_emul_port {
PS8XXX_EMUL_PORT_INVAL,
};
+/**
+ * Register ID to distinguish between the PS8815-A2 and PS8745-A2
+ * 0: Indicates this is an 8815-A2 chip
+ * 1: Indicates this is an 8745-A2 chip
+ */
+enum ps8xxx_regid {
+ PS8815_REG_ID,
+ PS8745_REG_ID,
+};
+
/* For now all devices supported by this emulator has the same FW rev reg */
#define PS8XXX_REG_FW_REV 0x82
@@ -80,6 +90,15 @@ const struct emul *ps8xxx_emul_get_tcpci(const struct emul *emul);
void ps8xxx_emul_set_chip_rev(const struct emul *emul, uint8_t chip_rev);
/**
+ * @brief Set value of REG_ID used to distinguish between the
+ * PS8815-A2 and PS8745-A2
+ *
+ * @param emul Pointer to PS8xxx emulator
+ * @param reg_id Value to be set
+ */
+void ps8xxx_emul_set_reg_id(const struct emul *emul, enum ps8xxx_regid reg_id);
+
+/**
* @brief Set value of HW revision register on PS8815
*
* @param emul Pointer to PS8xxx emulator