diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2020-08-20 20:28:52 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-25 18:54:34 +0000 |
commit | e8873c81d0ea3ee44a649ec8cbc362a44459d373 (patch) | |
tree | bb827fa67b32fa81d837f7b7c8c48ad07aefe25a /board | |
parent | 81f396b4576d0ab6535dcbb0d06d76caa12d34ea (diff) | |
download | chrome-ec-e8873c81d0ea3ee44a649ec8cbc362a44459d373.tar.gz |
bb retimer: Use mutex to lock the access to shared NVM
If the BB retimer has a shared NVM we need 40ms delay after releasing
the RESET line to synchronize, load and initialize both the retimers.
On a non-shared NVM we need 20ms delay to load and initialize. In order
to synchronize, instead of 40ms delay this CL uses a MUTEX to lock
the access of another retimer by not releasing the RESET line until the
first retimer completes initialization.
BUG=b:165895649
BRANCH=none
TEST=Tested on volteer(non shared NVM), tglrvpu_ite (shared NVM)
Retimer is able to initialize (DP, USB, TBT, USB4 are detected)
Change-Id: I709377c2e6401faa26871289143d71665ee516d1
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2368223
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/delbin/board.c | 1 | ||||
-rw-r--r-- | board/terrador/board.c | 1 | ||||
-rw-r--r-- | board/tglrvpu_ite/board.c | 23 | ||||
-rw-r--r-- | board/tglrvpu_ite/board.h | 8 | ||||
-rw-r--r-- | board/todor/board.c | 1 | ||||
-rw-r--r-- | board/voxel/board.c | 1 |
6 files changed, 14 insertions, 21 deletions
diff --git a/board/delbin/board.c b/board/delbin/board.c index 5d52800439..e72d4487e4 100644 --- a/board/delbin/board.c +++ b/board/delbin/board.c @@ -255,7 +255,6 @@ static const struct usb_mux mux_config_p1_usb3 = { }; static const struct bb_usb_control bb_p0_control = { - .shared_nvm = false, .usb_ls_en_gpio = GPIO_USB_C0_LS_EN, .retimer_rst_gpio = GPIO_USB_C0_RT_RST_ODL, }; diff --git a/board/terrador/board.c b/board/terrador/board.c index 8f9e973e06..3781dfc356 100644 --- a/board/terrador/board.c +++ b/board/terrador/board.c @@ -180,7 +180,6 @@ __override void board_cbi_init(void) */ setup_mux(); /* Reassign USB_C0_RT_RST_ODL */ - bb_controls[USBC_PORT_C0].shared_nvm = false; bb_controls[USBC_PORT_C0].usb_ls_en_gpio = GPIO_USB_C0_LS_EN; bb_controls[USBC_PORT_C0].retimer_rst_gpio = GPIO_USB_C0_RT_RST_ODL; diff --git a/board/tglrvpu_ite/board.c b/board/tglrvpu_ite/board.c index aa4ff77e96..5698761c6a 100644 --- a/board/tglrvpu_ite/board.c +++ b/board/tglrvpu_ite/board.c @@ -26,6 +26,9 @@ #define CPRINTS(format, args...) cprints(CC_COMMAND, format, ## args) #define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ## args) +/* Mutex for shared NVM access */ +static struct mutex bb_nvm_mutex; + /* TCPC gpios */ const struct tcpc_gpio_config_t tcpc_gpios[] = { [TYPE_C_PORT_0] = { @@ -170,6 +173,13 @@ __override void bb_retimer_power_handle(const struct usb_mux *me, int on_off) /* handle retimer's power domain */ if (on_off) { + /* + * BB retimer NVM can be shared between multiple ports, hence + * lock enabling the retimer until the current retimer request + * is complete. + */ + mutex_lock(&bb_nvm_mutex); + gpio_set_level(control->usb_ls_en_gpio, 1); /* * Tpw, minimum time from VCC to RESET_N de-assertion is 100us. @@ -182,15 +192,10 @@ __override void bb_retimer_power_handle(const struct usb_mux *me, int on_off) msleep(10); gpio_set_level(force_power_gpio, 1); - /* - * If BB retimer NVM is shared between multiple ports, allow - * 40ms time for all the retimers to be initialized. - * Else allow 20ms to initialize. - */ - if (control->shared_nvm) - msleep(40); - else - msleep(20); + /* Allow 20ms time for the retimer to be initialized. */ + msleep(20); + + mutex_unlock(&bb_nvm_mutex); } else { gpio_set_level(force_power_gpio, 0); msleep(1); diff --git a/board/tglrvpu_ite/board.h b/board/tglrvpu_ite/board.h index d6d238fdb9..9559d5526d 100644 --- a/board/tglrvpu_ite/board.h +++ b/board/tglrvpu_ite/board.h @@ -79,18 +79,10 @@ #ifdef BOARD_TGLRVPU_ITE #define I2C_PORT0_BB_RETIMER_ADDR 0x42 #define I2C_PORT1_BB_RETIMER_ADDR 0x43 - - /* BB retimer nvm is shared between port 0 & 1 */ - #define BB_RETIMER_SHARED_NVM true #else /* BOARD_TGLRVPY_ITE */ #define I2C_PORT0_BB_RETIMER_ADDR 0x42 #define I2C_PORT1_BB_RETIMER_ADDR 0x41 - - /* BB retimers have respective nvm for port 0 & 1 */ - #define BB_RETIMER_SHARED_NVM false #endif /* BOARD_TGLRVPU_ITE */ -#define USB_PORT0_BB_RETIMER_SHARED_NVM BB_RETIMER_SHARED_NVM -#define USB_PORT1_BB_RETIMER_SHARED_NVM BB_RETIMER_SHARED_NVM /* Enabling SOP* communication */ #define CONFIG_USB_PD_DECODE_SOP diff --git a/board/todor/board.c b/board/todor/board.c index ce036ffab2..215725129e 100644 --- a/board/todor/board.c +++ b/board/todor/board.c @@ -206,7 +206,6 @@ __override void board_cbi_init(void) */ setup_mux(); /* Reassign USB_C0_RT_RST_ODL */ - bb_controls[USBC_PORT_C0].shared_nvm = false; bb_controls[USBC_PORT_C0].usb_ls_en_gpio = GPIO_USB_C0_LS_EN; bb_controls[USBC_PORT_C0].retimer_rst_gpio = GPIO_USB_C0_RT_RST_ODL; diff --git a/board/voxel/board.c b/board/voxel/board.c index 66015c522d..a46bf3ee83 100644 --- a/board/voxel/board.c +++ b/board/voxel/board.c @@ -236,7 +236,6 @@ __override void board_cbi_init(void) setup_mux(); /* Reassign USB_C0_RT_RST_ODL */ - bb_controls[USBC_PORT_C0].shared_nvm = false; bb_controls[USBC_PORT_C0].usb_ls_en_gpio = GPIO_USB_C0_LS_EN; bb_controls[USBC_PORT_C0].retimer_rst_gpio = GPIO_USB_C0_RT_RST_ODL; } |