summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-06-10 16:54:02 -0700
committerCommit Bot <commit-bot@chromium.org>2020-06-13 01:34:05 +0000
commite0c11663b9f51ec08d6f709e61409728cfc09422 (patch)
tree17969eefb8b3632d4f2507da1470536f5389ae3b /driver
parent434901c70701b328bce563fe1f63f29308834b81 (diff)
downloadchrome-ec-e0c11663b9f51ec08d6f709e61409728cfc09422.tar.gz
raa489000: Don't write to reserved registers
In the early revision of silicon for the RAA489000, the EC had to make a number of writes to certain registers. However, in the latest datasheets, a lot of the registers are now reserved. Therefore, we shouldn't be writing to them anymore. This commit simply restricts those register writes to the older version of silicon where the registers were still valid. BUG=b:158611239 BRANCH=None TEST=Build and flash on waddledoo with newer silicon, verify that TCPC is still working and were are able to DRP toggle, respond to PD messages, negotiate higher contracts, enter DP alt mode. Verify that both orientations still work. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I33e3fafa50f37bb1de5bc31fb0618867e5e47a53 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2240515 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/tcpm/raa489000.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/driver/tcpm/raa489000.c b/driver/tcpm/raa489000.c
index 29a6af4328..ae6aef2269 100644
--- a/driver/tcpm/raa489000.c
+++ b/driver/tcpm/raa489000.c
@@ -17,6 +17,8 @@
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
+static int dev_id[CONFIG_USB_PD_PORT_MAX_COUNT] = { -1 };
+
static int raa489000_enter_low_power_mode(int port)
{
int rv;
@@ -56,6 +58,7 @@ int raa489000_init(int port)
if (rv)
CPRINTS("C%d: Failed to read DEV_ID", port);
CPRINTS("%s(%d): DEVICE_ID=%d", __func__, port, device_id);
+ dev_id[port] = device_id;
if (device_id > 1) {
/*
@@ -79,18 +82,22 @@ int raa489000_init(int port)
/*
* Set some vendor defined registers to enable the CC comparators and
- * remove the dead battery resistors.
+ * remove the dead battery resistors. This only needs to be done on
+ * early silicon versions.
*/
- rv = tcpc_write16(port, RAA489000_TYPEC_SETTING1,
- RAA489000_SETTING1_RDOE | RAA489000_SETTING1_CC2_CMP3_EN |
- RAA489000_SETTING1_CC2_CMP2_EN |
- RAA489000_SETTING1_CC2_CMP1_EN |
- RAA489000_SETTING1_CC1_CMP3_EN |
- RAA489000_SETTING1_CC1_CMP2_EN |
- RAA489000_SETTING1_CC1_CMP1_EN |
- RAA489000_SETTING1_CC_DB_EN);
- if (rv)
- CPRINTS("c%d: failed to enable CC comparators", port);
+ if (device_id <= 1) {
+ rv = tcpc_write16(port, RAA489000_TYPEC_SETTING1,
+ RAA489000_SETTING1_RDOE |
+ RAA489000_SETTING1_CC2_CMP3_EN |
+ RAA489000_SETTING1_CC2_CMP2_EN |
+ RAA489000_SETTING1_CC2_CMP1_EN |
+ RAA489000_SETTING1_CC1_CMP3_EN |
+ RAA489000_SETTING1_CC1_CMP2_EN |
+ RAA489000_SETTING1_CC1_CMP1_EN |
+ RAA489000_SETTING1_CC_DB_EN);
+ if (rv)
+ CPRINTS("c%d: failed to enable CC comparators", port);
+ }
/* Enable the ADC */
/*
@@ -132,10 +139,13 @@ int raa489000_init(int port)
if (rv)
CPRINTS("c%d: failed to set auto discharge", port);
- /* The vendor says to set this setting. */
- rv = tcpc_write16(port, RAA489000_PD_PHYSICAL_PARAMETER1, 0x6C07);
- if (rv)
- CPRINTS("c%d: failed to set PD PHY PARAM1", port);
+ if (device_id <= 1) {
+ /* The vendor says to set this setting. */
+ rv = tcpc_write16(port, RAA489000_PD_PHYSICAL_PARAMETER1,
+ 0x6C07);
+ if (rv)
+ CPRINTS("c%d: failed to set PD PHY PARAM1", port);
+ }
/* Enable the correct TCPCI interface version */
rv = tcpc_read16(port, RAA489000_TCPC_SETTING1, &regval);
@@ -175,10 +185,10 @@ int raa489000_tcpm_set_cc(int port, int pull)
int rv;
rv = tcpci_tcpm_set_cc(port, pull);
- if (rv)
+ if (dev_id[port] > 1 || rv)
return rv;
- /* TCPM should set RDOE to 1 after setting Rp */
+ /* Older silicon needs the TCPM to set RDOE to 1 after setting Rp */
if (pull == TYPEC_CC_RP)
rv = tcpc_update16(port, RAA489000_TYPEC_SETTING1,
RAA489000_SETTING1_RDOE, MASK_SET);