summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2022-09-07 13:44:29 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-20 17:20:53 +0000
commit3f70c7a15f3d5fc8c0ce71969cd9fa62153f37c8 (patch)
treed91f14a3830d189ce5f4616a2ea30f08c6710079
parent80f0002742f45cb83cd7d60a24d024d717100e35 (diff)
downloadchrome-ec-3f70c7a15f3d5fc8c0ce71969cd9fa62153f37c8.tar.gz
Skyrim: Fold SBU protection into mux board_set
Since the SBU protection chip isn't a true mux, fold it into the board_set for the actual muxes. LOW_COVERAGE_REASON=Skyrim board tests not created yet: b/247151116 BRANCH=None BUG=b:244457125 TEST=zmake build skyrim; verify SBU polarity is set correctly on both ports Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I96744fef11c9fc0044b97b2fe39f588b89e80e43 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3880672 Commit-Queue: Robert Zieba <robertzieba@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Robert Zieba <robertzieba@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/projects/skyrim/gpio.dts4
-rw-r--r--zephyr/projects/skyrim/src/usbc_config.c85
-rw-r--r--zephyr/projects/skyrim/src/winterhold/usbc_config.c85
3 files changed, 64 insertions, 110 deletions
diff --git a/zephyr/projects/skyrim/gpio.dts b/zephyr/projects/skyrim/gpio.dts
index 3251104cc5..c3b911ba4d 100644
--- a/zephyr/projects/skyrim/gpio.dts
+++ b/zephyr/projects/skyrim/gpio.dts
@@ -287,7 +287,7 @@
ioex_usb_a0_fault_odl: usb_a0_fault_odl {
gpios = <&ioex_c0_port1 6 GPIO_INPUT>;
};
- usb_c0_sbu_flip {
+ ioex_usb_c0_sbu_flip: usb_c0_sbu_flip {
gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>;
enum-name = "IOEX_USB_C0_SBU_FLIP";
};
@@ -324,7 +324,7 @@
ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl {
gpios = <&ioex_c1_port1 6 GPIO_INPUT>;
};
- usb_c1_sbu_flip {
+ ioex_usb_c1_sbu_flip: usb_c1_sbu_flip {
gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>;
enum-name = "IOEX_USB_C1_SBU_FLIP";
};
diff --git a/zephyr/projects/skyrim/src/usbc_config.c b/zephyr/projects/skyrim/src/usbc_config.c
index 7f969ecb17..291637128d 100644
--- a/zephyr/projects/skyrim/src/usbc_config.c
+++ b/zephyr/projects/skyrim/src/usbc_config.c
@@ -84,39 +84,40 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_fault_interrupt_disable,
HOOK_PRIO_DEFAULT);
/*
- * .init is not necessary here because it has nothing
- * to do. Primary mux will handle mux state so .get is
- * not needed as well. usb_mux.c can handle the situation
- * properly.
- */
-static int ioex_set_flip(const struct usb_mux *, mux_state_t, bool *);
-struct usb_mux_driver ioex_sbu_mux_driver = {
- .set = ioex_set_flip,
-};
-
-/*
- * Since NX3DV221GM is not a i2c device, .i2c_port and
- * .i2c_addr_flags are not required here.
+ * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
+ * indicate flipped polarity to a protection switch.
*/
-struct usb_mux_chain usbc0_sbu_mux = {
- .mux =
- &(const struct usb_mux){
- .usb_port = USBC_PORT_C0,
- .driver = &ioex_sbu_mux_driver,
- },
-};
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == USBC_PORT_C0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
-struct usb_mux_chain usbc1_sbu_mux = {
- .mux =
- &(const struct usb_mux){
- .usb_port = USBC_PORT_C1,
- .driver = &ioex_sbu_mux_driver,
- },
-};
+ return EC_SUCCESS;
+}
int baseboard_anx7483_c0_mux_set(const struct usb_mux *me,
mux_state_t mux_state)
{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
return anx7483_set_default_tuning(me, mux_state);
}
@@ -125,6 +126,9 @@ int baseboard_anx7483_c1_mux_set(const struct usb_mux *me,
{
bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
/* Remove flipped from the state for easier compraisons */
mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
@@ -180,7 +184,6 @@ struct usb_mux_chain usbc0_anx7483 = {
.driver = &anx7483_usb_retimer_driver,
.board_set = &baseboard_anx7483_c0_mux_set,
},
- .next = &usbc0_sbu_mux,
};
__overridable int board_c1_ps8818_mux_set(const struct usb_mux *me,
@@ -218,7 +221,6 @@ struct usb_mux_chain usbc1_anx7483 = {
.driver = &anx7483_usb_retimer_driver,
.board_set = &baseboard_anx7483_c1_mux_set,
},
- .next = &usbc1_sbu_mux,
};
struct usb_mux_chain usb_muxes[] = {
@@ -243,31 +245,6 @@ struct usb_mux_chain usb_muxes[] = {
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT);
-/*
- * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
- * indicate flipped polarity to a protection switch.
- */
-static int ioex_set_flip(const struct usb_mux *me, mux_state_t mux_state,
- bool *ack_required)
-{
- /* This driver does not use host command ACKs */
- *ack_required = false;
-
- if (me->usb_port == USBC_PORT_C0) {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- ioex_set_level(IOEX_USB_C0_SBU_FLIP, 1);
- else
- ioex_set_level(IOEX_USB_C0_SBU_FLIP, 0);
- } else {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- ioex_set_level(IOEX_USB_C1_SBU_FLIP, 1);
- else
- ioex_set_level(IOEX_USB_C1_SBU_FLIP, 0);
- }
-
- return EC_SUCCESS;
-}
-
static void setup_mux(void)
{
uint32_t val;
diff --git a/zephyr/projects/skyrim/src/winterhold/usbc_config.c b/zephyr/projects/skyrim/src/winterhold/usbc_config.c
index 0623079191..9e8dc1a9ed 100644
--- a/zephyr/projects/skyrim/src/winterhold/usbc_config.c
+++ b/zephyr/projects/skyrim/src/winterhold/usbc_config.c
@@ -83,39 +83,40 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_fault_interrupt_disable,
HOOK_PRIO_DEFAULT);
/*
- * .init is not necessary here because it has nothing
- * to do. Primary mux will handle mux state so .get is
- * not needed as well. usb_mux.c can handle the situation
- * properly.
+ * USB C0 and C1 use IOEX pins to indicate flipped polarity to a
+ * protection switch.
*/
-static int ioex_set_flip(const struct usb_mux *, mux_state_t, bool *);
-struct usb_mux_driver ioex_sbu_mux_driver = {
- .set = ioex_set_flip,
-};
-
-/*
- * Since NX3DV221GM is not a i2c device, .i2c_port and
- * .i2c_addr_flags are not required here.
- */
-struct usb_mux_chain usbc0_sbu_mux = {
- .mux =
- &(const struct usb_mux){
- .usb_port = USBC_PORT_C0,
- .driver = &ioex_sbu_mux_driver,
- },
-};
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == USBC_PORT_C0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
-struct usb_mux_chain usbc1_sbu_mux = {
- .mux =
- &(const struct usb_mux){
- .usb_port = USBC_PORT_C1,
- .driver = &ioex_sbu_mux_driver,
- },
-};
+ return EC_SUCCESS;
+}
int baseboard_anx7483_c0_mux_set(const struct usb_mux *me,
mux_state_t mux_state)
{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
return anx7483_set_default_tuning(me, mux_state);
}
@@ -124,6 +125,9 @@ int baseboard_anx7483_c1_mux_set(const struct usb_mux *me,
{
bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
/* Remove flipped from the state for easier compraisons */
mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
@@ -179,7 +183,6 @@ struct usb_mux_chain usbc0_anx7483 = {
.driver = &anx7483_usb_retimer_driver,
.board_set = &baseboard_anx7483_c0_mux_set,
},
- .next = &usbc0_sbu_mux,
};
__overridable int board_c1_ps8818_mux_set(const struct usb_mux *me,
@@ -217,7 +220,6 @@ struct usb_mux_chain usbc1_anx7483 = {
.driver = &anx7483_usb_retimer_driver,
.board_set = &baseboard_anx7483_c1_mux_set,
},
- .next = &usbc1_sbu_mux,
};
struct usb_mux_chain usb_muxes[] = {
@@ -242,31 +244,6 @@ struct usb_mux_chain usb_muxes[] = {
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT);
-/*
- * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
- * indicate flipped polarity to a protection switch.
- */
-static int ioex_set_flip(const struct usb_mux *me, mux_state_t mux_state,
- bool *ack_required)
-{
- /* This driver does not use host command ACKs */
- *ack_required = false;
-
- if (me->usb_port == USBC_PORT_C0) {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- ioex_set_level(IOEX_USB_C0_SBU_FLIP, 1);
- else
- ioex_set_level(IOEX_USB_C0_SBU_FLIP, 0);
- } else {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- ioex_set_level(IOEX_USB_C1_SBU_FLIP, 1);
- else
- ioex_set_level(IOEX_USB_C1_SBU_FLIP, 0);
- }
-
- return EC_SUCCESS;
-}
-
static void setup_mux(void)
{
uint32_t val;