summaryrefslogtreecommitdiff
path: root/board/pdeval-stm32f072
diff options
context:
space:
mode:
Diffstat (limited to 'board/pdeval-stm32f072')
-rw-r--r--board/pdeval-stm32f072/PD_evaluation.md4
-rw-r--r--board/pdeval-stm32f072/board.c24
-rw-r--r--board/pdeval-stm32f072/board.h17
-rw-r--r--board/pdeval-stm32f072/build.mk2
-rw-r--r--board/pdeval-stm32f072/ec.tasklist2
-rw-r--r--board/pdeval-stm32f072/gpio.inc2
-rw-r--r--board/pdeval-stm32f072/openocd-flash.cfg2
-rw-r--r--board/pdeval-stm32f072/usb_pd_pdo.c2
-rw-r--r--board/pdeval-stm32f072/usb_pd_pdo.h2
-rw-r--r--board/pdeval-stm32f072/usb_pd_policy.c100
10 files changed, 63 insertions, 94 deletions
diff --git a/board/pdeval-stm32f072/PD_evaluation.md b/board/pdeval-stm32f072/PD_evaluation.md
index 4f1c8636c6..fd4763a849 100644
--- a/board/pdeval-stm32f072/PD_evaluation.md
+++ b/board/pdeval-stm32f072/PD_evaluation.md
@@ -43,12 +43,12 @@ also need to create/delete the corresponding `PD_Cx` tasks in
[board/pdeval-stm32f072/ec.tasklist](ec.tasklist).
By default, the firmware is using I2C1 with SCL/SDA on pins PB6 and PB7, running
-with a 100kHz clock, and tries to talk to TCPCs at i2c slave addresses 0x9c and
+with a 100kHz clock, and tries to talk to TCPCs at i2c target addresses 0x9c and
0x9e. To change the pins or speed, you need to edit `i2c_ports` in
[board/pdeval-stm32f072/board.c](board.c), update `I2C_PORT_TCPC` in
[board/pdeval-stm32f072/board.h](board.h) with the right controller number, and
change the pin mux in [board/pdeval-stm32f072/gpio.inc](gpio.inc). To change
-TCPC i2c slave addresses, update `TCPC1_I2C_ADDR` and `TCPC2_I2C_ADDR` in
+TCPC i2c target addresses, update `TCPC1_I2C_ADDR` and `TCPC2_I2C_ADDR` in
[board/pdeval-stm32f072/board.h](board.h).
The I2C bus needs pull-up resistors on SCL/SDA. If your setup doesn't have
diff --git a/board/pdeval-stm32f072/board.c b/board/pdeval-stm32f072/board.c
index 525f14a4af..e1e75bcea7 100644
--- a/board/pdeval-stm32f072/board.c
+++ b/board/pdeval-stm32f072/board.c
@@ -1,4 +1,4 @@
-/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+/* Copyright 2015 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -30,10 +30,10 @@ void alert_event(enum gpio_signal signal)
#include "gpio_list.h"
const void *const usb_strings[] = {
- [USB_STR_DESC] = usb_string_desc,
- [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."),
- [USB_STR_PRODUCT] = USB_STRING_DESC("PDeval-stm32f072"),
- [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
+ [USB_STR_DESC] = usb_string_desc,
+ [USB_STR_VENDOR] = USB_STRING_DESC("Google LLC"),
+ [USB_STR_PRODUCT] = USB_STRING_DESC("PDeval-stm32f072"),
+ [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
[USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Shell"),
};
@@ -52,15 +52,11 @@ void board_reset_pd_mcu(void)
}
/* I2C ports */
-const struct i2c_port_t i2c_ports[] = {
- {
- .name = "tcpc",
- .port = I2C_PORT_TCPC,
- .kbps = 400 /* kHz */,
- .scl = GPIO_I2C0_SCL,
- .sda = GPIO_I2C0_SDA
- }
-};
+const struct i2c_port_t i2c_ports[] = { { .name = "tcpc",
+ .port = I2C_PORT_TCPC,
+ .kbps = 400 /* kHz */,
+ .scl = GPIO_I2C0_SCL,
+ .sda = GPIO_I2C0_SDA } };
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/board/pdeval-stm32f072/board.h b/board/pdeval-stm32f072/board.h
index c075772e9f..4cb55573f4 100644
--- a/board/pdeval-stm32f072/board.h
+++ b/board/pdeval-stm32f072/board.h
@@ -1,4 +1,4 @@
-/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+/* Copyright 2015 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -15,6 +15,8 @@
#undef CONFIG_UART_CONSOLE
#define CONFIG_UART_CONSOLE 2
+#define CONFIG_LTO
+
/* Optional features */
#define CONFIG_HW_CRC
#define CONFIG_I2C
@@ -32,6 +34,7 @@
#define CONFIG_USB_PD_VBUS_DETECT_TCPC
#define CONFIG_USB_PD_TCPM_ANX7447
#define CONFIG_USB_PD_TCPM_MUX
+#define CONFIG_USBC_SS_MUX
#undef CONFIG_USB_PD_INITIAL_DRP_STATE
#define CONFIG_USB_PD_INITIAL_DRP_STATE PD_DRP_TOGGLE_ON
@@ -40,14 +43,14 @@
#define CONFIG_USB_PD_PULLUP TYPEC_RP_USB
/* fake board specific type-C power constants */
-#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
+#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
#define PD_POWER_SUPPLY_TURN_OFF_DELAY 650000 /* us */
/* Define typical operating power and max power */
#define PD_OPERATING_POWER_MW 15000
-#define PD_MAX_POWER_MW 60000
-#define PD_MAX_CURRENT_MA 3000
-#define PD_MAX_VOLTAGE_MV 20000
+#define PD_MAX_POWER_MW 60000
+#define PD_MAX_CURRENT_MA 3000
+#define PD_MAX_VOLTAGE_MV 20000
/* I2C master port connected to the TCPC */
#define I2C_PORT_TCPC 0
@@ -66,12 +69,12 @@
/* USB interface indexes (use define rather than enum to expand them) */
#define USB_IFACE_CONSOLE 0
-#define USB_IFACE_COUNT 1
+#define USB_IFACE_COUNT 1
/* USB endpoint indexes (use define rather than enum to expand them) */
#define USB_EP_CONTROL 0
#define USB_EP_CONSOLE 1
-#define USB_EP_COUNT 2
+#define USB_EP_COUNT 2
/* Remove console commands / features for flash / RAM savings */
#undef CONFIG_WATCHDOG_HELP
diff --git a/board/pdeval-stm32f072/build.mk b/board/pdeval-stm32f072/build.mk
index 30d5bf8ac8..2238f8f59a 100644
--- a/board/pdeval-stm32f072/build.mk
+++ b/board/pdeval-stm32f072/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Copyright 2015 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
diff --git a/board/pdeval-stm32f072/ec.tasklist b/board/pdeval-stm32f072/ec.tasklist
index 5003fc7ba1..e897969a55 100644
--- a/board/pdeval-stm32f072/ec.tasklist
+++ b/board/pdeval-stm32f072/ec.tasklist
@@ -1,4 +1,4 @@
-/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+/* Copyright 2015 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/board/pdeval-stm32f072/gpio.inc b/board/pdeval-stm32f072/gpio.inc
index 5409077c34..fb8537ffbe 100644
--- a/board/pdeval-stm32f072/gpio.inc
+++ b/board/pdeval-stm32f072/gpio.inc
@@ -1,6 +1,6 @@
/* -*- mode:c -*-
*
- * Copyright 2015 The Chromium OS Authors. All rights reserved.
+ * Copyright 2015 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/board/pdeval-stm32f072/openocd-flash.cfg b/board/pdeval-stm32f072/openocd-flash.cfg
index ec32416934..05a697acf8 100644
--- a/board/pdeval-stm32f072/openocd-flash.cfg
+++ b/board/pdeval-stm32f072/openocd-flash.cfg
@@ -1,4 +1,4 @@
-# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Copyright 2014 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/board/pdeval-stm32f072/usb_pd_pdo.c b/board/pdeval-stm32f072/usb_pd_pdo.c
index 442e708923..31d84f9785 100644
--- a/board/pdeval-stm32f072/usb_pd_pdo.c
+++ b/board/pdeval-stm32f072/usb_pd_pdo.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/board/pdeval-stm32f072/usb_pd_pdo.h b/board/pdeval-stm32f072/usb_pd_pdo.h
index 58fd1f153c..13640a7471 100644
--- a/board/pdeval-stm32f072/usb_pd_pdo.h
+++ b/board/pdeval-stm32f072/usb_pd_pdo.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/board/pdeval-stm32f072/usb_pd_policy.c b/board/pdeval-stm32f072/usb_pd_policy.c
index b7425ce66c..9ea36a1b0d 100644
--- a/board/pdeval-stm32f072/usb_pd_policy.c
+++ b/board/pdeval-stm32f072/usb_pd_policy.c
@@ -1,4 +1,4 @@
-/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+/* Copyright 2015 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -17,18 +17,21 @@
#include "usb_pd.h"
#include "usb_pd_pdo.h"
-#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
/* Used to fake VBUS presence since no GPIO is available to read VBUS */
static int vbus_present;
-
#if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447)
-const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
- .usb_port = 0,
- .driver = &anx7447_usb_mux_driver,
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = 0,
+ .driver = &anx7447_usb_mux_driver,
+ .hpd_update = &anx7447_tcpc_update_hpd_status,
+ },
},
};
#endif
@@ -81,8 +84,8 @@ void pd_power_supply_reset(int port)
void pd_set_input_current_limit(int port, uint32_t max_ma,
uint32_t supply_voltage)
{
- CPRINTS("USBPD current limit port %d max %d mA %d mV",
- port, max_ma, supply_voltage);
+ CPRINTS("USBPD current limit port %d max %d mA %d mV", port, max_ma,
+ supply_voltage);
/* do some LED coding of the power we can sink */
if (max_ma) {
if (supply_voltage > 6500)
@@ -98,8 +101,8 @@ void pd_set_input_current_limit(int port, uint32_t max_ma,
__override void typec_set_input_current_limit(int port, uint32_t max_ma,
uint32_t supply_voltage)
{
- CPRINTS("TYPEC current limit port %d max %d mA %d mV",
- port, max_ma, supply_voltage);
+ CPRINTS("TYPEC current limit port %d max %d mA %d mV", port, max_ma,
+ supply_voltage);
gpio_set_level(GPIO_LED_R, !!max_ma);
}
@@ -109,24 +112,21 @@ void button_event(enum gpio_signal signal)
CPRINTS("VBUS %d", vbus_present);
}
-static int command_vbus_toggle(int argc, char **argv)
+static int command_vbus_toggle(int argc, const char **argv)
{
vbus_present = !vbus_present;
CPRINTS("VBUS %d", vbus_present);
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(vbus, command_vbus_toggle,
- "",
- "Toggle VBUS detected");
+DECLARE_CONSOLE_COMMAND(vbus, command_vbus_toggle, "", "Toggle VBUS detected");
int pd_snk_is_vbus_provided(int port)
{
return vbus_present;
}
-__override int pd_check_data_swap(int port,
- enum pd_data_role data_role)
+__override int pd_check_data_swap(int port, enum pd_data_role data_role)
{
/* Always allow data swap */
return 1;
@@ -144,22 +144,18 @@ int pd_check_vconn_swap(int port)
}
#endif
-__override void pd_check_pr_role(int port,
- enum pd_power_role pr_role,
+__override void pd_check_pr_role(int port, enum pd_power_role pr_role,
int flags)
{
}
-__override void pd_check_dr_role(int port,
- enum pd_data_role dr_role,
- int flags)
+__override void pd_check_dr_role(int port, enum pd_data_role dr_role, int flags)
{
}
/* ----------------- Vendor Defined Messages ------------------ */
const uint32_t vdo_idh = VDO_IDH(1, /* data caps as USB host */
0, /* data caps as USB device */
- IDH_PTYPE_PERIPH,
- 0, /* supports alt modes */
+ IDH_PTYPE_PERIPH, 0, /* supports alt modes */
0x0000);
const uint32_t vdo_product = VDO_PRODUCT(0x0000, 0x0000);
@@ -193,87 +189,62 @@ __override int svdm_dp_config(int port, uint32_t *payload)
{
int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
int pin_mode = pd_dfp_dp_get_pin_mode(port, dp_status[port]);
- bool unused;
-#if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447)
- const struct usb_mux *mux = &usb_muxes[port];
-#endif
-
-#ifdef CONFIG_USB_PD_TCPM_ANX7447
mux_state_t mux_state = USB_PD_MUX_NONE;
- if (polarity_rm_dts(pd_get_polarity(port)))
- mux_state |= USB_PD_MUX_POLARITY_INVERTED;
-#endif
CPRINTS("pin_mode = %d", pin_mode);
if (!pin_mode)
return 0;
-#if defined(CONFIG_USB_PD_TCPM_MUX) && defined(CONFIG_USB_PD_TCPM_ANX7447)
switch (pin_mode) {
case MODE_DP_PIN_A:
case MODE_DP_PIN_C:
case MODE_DP_PIN_E:
mux_state |= USB_PD_MUX_DP_ENABLED;
- /*
- * Note: Direct mux driver calls are deprecated. Calls
- * should go through the usb_mux APIs instead.
- */
- mux->driver->set(mux, mux_state, &unused);
break;
case MODE_DP_PIN_B:
case MODE_DP_PIN_D:
case MODE_DP_PIN_F:
mux_state |= USB_PD_MUX_DOCK;
- mux->driver->set(mux, mux_state, &unused);
break;
}
-#endif
+ usb_mux_set(port, mux_state, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
/*
* board_set_usb_mux(port, USB_PD_MUX_DP_ENABLED,
* polarity_rm_dts(pd_get_polarity(port)));
*/
- payload[0] = VDO(USB_SID_DISPLAYPORT, 1,
- CMD_DP_CONFIG | VDO_OPOS(opos));
+ payload[0] =
+ VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos));
payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
- 1, /* DPv1.3 signaling */
- 2); /* UFP connected */
+ 1, /* DPv1.3 signaling */
+ 2); /* UFP connected */
return 2;
}
__override void svdm_dp_post_config(int port)
{
- bool unused;
- const struct usb_mux *mux = &usb_muxes[port];
-
dp_flags[port] |= DP_FLAGS_DP_ON;
if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING))
return;
- /* Note: Usage is deprecated, use usb_mux_hpd_update instead */
- if (IS_ENABLED(CONFIG_USB_PD_TCPM_ANX7447))
- anx7447_tcpc_update_hpd_status(mux, USB_PD_MUX_HPD_LVL |
- USB_PD_MUX_HPD_IRQ_DEASSERTED,
- &unused);
+ usb_mux_hpd_update(port,
+ USB_PD_MUX_HPD_LVL | USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
__override int svdm_dp_attention(int port, uint32_t *payload)
{
-#ifdef CONFIG_USB_PD_TCPM_ANX7447
int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
- const struct usb_mux *mux = &usb_muxes[port];
- bool unused;
- mux_state_t mux_state = (lvl ? USB_PD_MUX_HPD_LVL :
- USB_PD_MUX_HPD_LVL_DEASSERTED) |
- (irq ? USB_PD_MUX_HPD_IRQ :
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ mux_state_t mux_state =
+ (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
/* Note: Usage is deprecated, use usb_mux_hpd_update instead */
CPRINTS("Attention: 0x%x", payload[1]);
- anx7447_tcpc_update_hpd_status(mux, mux_state, &unused);
-#endif
+ usb_mux_hpd_update(port, mux_state);
+
dp_status[port] = payload[1];
/* ack */
@@ -282,8 +253,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload)
__override void svdm_exit_dp_mode(int port)
{
-#ifdef CONFIG_USB_PD_TCPM_ANX7447
- anx7447_tcpc_clear_hpd_status(port);
-#endif
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */