diff options
author | Edward Hill <ecgh@chromium.org> | 2020-02-25 14:53:22 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-27 00:56:12 +0000 |
commit | 4baea4e432c476e66d1defb81391ce982e3cdfd8 (patch) | |
tree | 06da51510acdea97552250a2f70ac75d0f715b7d /baseboard/zork/variant_trembyle.c | |
parent | 3e8d6447b38d8083ef6e6c6321e0e5b8b9f9c38f (diff) | |
download | chrome-ec-4baea4e432c476e66d1defb81391ce982e3cdfd8.tar.gz |
zork: Create baseboard variants for trembyle/dalboz
BUG=b:150110428
BRANCH=none
TEST=none
Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: I30503a0416325fc8573a4a62b3bc3ff943b5008e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2071390
Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'baseboard/zork/variant_trembyle.c')
-rw-r--r-- | baseboard/zork/variant_trembyle.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c new file mode 100644 index 0000000000..b8f70c6295 --- /dev/null +++ b/baseboard/zork/variant_trembyle.c @@ -0,0 +1,70 @@ +/* Copyright 2020 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. + */ + +#include "common.h" +#include "console.h" +#include "driver/retimer/ps8811.h" +#include "gpio.h" +#include "hooks.h" +#include "i2c.h" +#include "ioexpander.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args) + +/***************************************************************************** + * USB-A Retimer tuning + */ +#define PS8811_ACCESS_RETRIES 2 + +/* PS8811 gain tuning */ +static void ps8811_tuning_init(void) +{ + int rv; + int retry; + + /* Turn on the retimers */ + ioex_set_level(IOEX_USB_A0_RETIMER_EN, 1); + ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1); + + /* USB-A0 can run with default settings */ + for (retry = 0; retry < PS8811_ACCESS_RETRIES; ++retry) { + int val; + + rv = i2c_read8(I2C_PORT_USBA0, + PS8811_I2C_ADDR_FLAGS + PS8811_REG_PAGE1, + PS8811_REG1_USB_BEQ_LEVEL, &val); + if (!rv) + break; + } + if (rv) { + ioex_set_level(IOEX_USB_A0_RETIMER_EN, 0); + CPRINTSUSB("C0: PS8811 not detected"); + } + + /* USB-A1 needs to increase gain to get over MB/DB connector */ + for (retry = 0; retry < PS8811_ACCESS_RETRIES; ++retry) { + rv = i2c_write8(I2C_PORT_USBA1, + PS8811_I2C_ADDR_FLAGS + PS8811_REG_PAGE1, + PS8811_REG1_USB_BEQ_LEVEL, + PS8811_BEQ_I2C_LEVEL_UP_13DB | + PS8811_BEQ_PIN_LEVEL_UP_18DB); + if (!rv) + break; + } + if (rv) { + ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); + CPRINTSUSB("C1: PS8811 not detected"); + } +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, ps8811_tuning_init, HOOK_PRIO_DEFAULT); + +static void ps8811_retimer_off(void) +{ + /* Turn on the retimers */ + ioex_set_level(IOEX_USB_A0_RETIMER_EN, 0); + ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); +} +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, ps8811_retimer_off, HOOK_PRIO_DEFAULT); |