summaryrefslogtreecommitdiff
path: root/board/samus_pd
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-05-11 17:31:16 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-27 02:39:41 +0000
commit5b5f737d8f6f1be15d4ab5f42f290d20576307c4 (patch)
treebe384973f533436d9a53c46b742be35f5b377a4f /board/samus_pd
parent25ce43fc3d35669500d74e44f3b7c96302ee2ade (diff)
downloadchrome-ec-5b5f737d8f6f1be15d4ab5f42f290d20576307c4.tar.gz
pd: move non-phy layer config out of usb_pd_config.h
Move parts of usb_pd_config.h that are not part of the phy layer out of usb_pd_config.h and into board.h. This cleans up the division between the TCPC and TCPM as only the TCPC needs to use usb_pd_config.h. Also cleans up the use of the CC detection voltage thresholds by creating standard macros to use based on Rp strength for the board. BUG=none BRANCH=none TEST=make -j buildall Change-Id: I946cceb38bea8233095b8a4b287102bb8a3a296d Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/270337 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/samus_pd')
-rw-r--r--board/samus_pd/board.c12
-rw-r--r--board/samus_pd/board.h24
-rw-r--r--board/samus_pd/usb_pd_config.h36
-rw-r--r--board/samus_pd/usb_pd_policy.c11
4 files changed, 38 insertions, 45 deletions
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c
index 165c8ebe4f..59b562f888 100644
--- a/board/samus_pd/board.c
+++ b/board/samus_pd/board.c
@@ -25,7 +25,6 @@
#include "task.h"
#include "usb.h"
#include "usb_pd.h"
-#include "usb_pd_config.h"
#include "util.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
@@ -69,8 +68,8 @@ static int desired_charge_rate_ma = -1;
* Store the state of our USB data switches so that they can be restored
* after pericom reset.
*/
-static int usb_switch_state[PD_PORT_COUNT];
-static struct mutex usb_switch_lock[PD_PORT_COUNT];
+static int usb_switch_state[CONFIG_USB_PD_PORT_COUNT];
+static struct mutex usb_switch_lock[CONFIG_USB_PD_PORT_COUNT];
/* PWM channels. Must be in the exact same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
@@ -403,7 +402,7 @@ static void board_init(void)
/* Initialize all pericom charge suppliers to 0 */
charge_none.voltage = USB_BC12_CHARGE_VOLTAGE;
charge_none.current = 0;
- for (i = 0; i < PD_PORT_COUNT; i++) {
+ for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
charge_manager_update_charge(CHARGE_SUPPLIER_PROPRIETARY,
i,
&charge_none);
@@ -548,7 +547,7 @@ const struct usb_port_mux usb_muxes[] = {
.ss2_dp_mode = GPIO_USB_C1_SS2_DP_MODE,
},
};
-BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == PD_PORT_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_COUNT);
static void board_set_usb_switches(int port, int open)
@@ -684,7 +683,8 @@ static void pd_send_ec_int(void)
int board_set_active_charge_port(int charge_port)
{
/* charge port is a realy physical port */
- int is_real_port = (charge_port >= 0 && charge_port < PD_PORT_COUNT);
+ int is_real_port = (charge_port >= 0 &&
+ charge_port < CONFIG_USB_PD_PORT_COUNT);
/* check if we are source vbus on that port */
int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN :
GPIO_USB_C1_5V_EN);
diff --git a/board/samus_pd/board.h b/board/samus_pd/board.h
index 5585055f35..dbcd97fec5 100644
--- a/board/samus_pd/board.h
+++ b/board/samus_pd/board.h
@@ -57,6 +57,7 @@
#define CONFIG_USB_PD_INTERNAL_COMP
#define CONFIG_USB_PD_LOGGING
#define CONFIG_USB_PD_LOG_SIZE 512
+#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_TCPC
#define CONFIG_USB_PD_TCPM_STUB
#define CONFIG_USB_SWITCH_PI3USB9281
@@ -129,6 +130,29 @@ enum charge_supplier {
/* supplier_priority table defined in board.c */
extern const int supplier_priority[];
+/* Standard-current Rp */
+#define PD_SRC_VNC PD_SRC_DEF_VNC_MV
+#define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV
+
+/* start as a sink in case we have no other power supply/battery */
+#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
+
+/*
+ * delay to turn on the power supply max is ~16ms.
+ * delay to turn off the power supply max is about ~180ms.
+ */
+#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
+#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */
+
+/* delay to turn on/off vconn */
+#define PD_VCONN_SWAP_DELAY 5000 /* 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
+
/* Charge current limit min / max, based on PWM duty cycle */
#define PWM_0_MA 500
#define PWM_100_MA 4000
diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h
index b655c8e914..5ec5af9416 100644
--- a/board/samus_pd/usb_pd_config.h
+++ b/board/samus_pd/usb_pd_config.h
@@ -12,11 +12,6 @@
#ifndef __USB_PD_CONFIG_H
#define __USB_PD_CONFIG_H
-/* Port and task configuration */
-#define PD_PORT_COUNT 2
-#define PORT_TO_TASK_ID(port) ((port) ? TASK_ID_PD_C1 : TASK_ID_PD_C0)
-#define TASK_ID_TO_PORT(id) ((id) == TASK_ID_PD_C0 ? 0 : 1)
-
/* Timer selection for baseband PD communication */
#define TIM_CLOCK_PD_TX_C0 17
#define TIM_CLOCK_PD_RX_C0 1
@@ -279,35 +274,4 @@ static inline void pd_set_vconn(int port, int polarity, int enable)
GPIO_USB_C1_CC2_VCONN1_EN_L, !enable);
}
-static inline int pd_snk_is_vbus_provided(int port)
-{
- return gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE :
- GPIO_USB_C0_VBUS_WAKE);
-}
-
-/* Standard-current DFP : no-connect voltage is 1.55V */
-#define PD_SRC_VNC 1550 /* mV */
-
-/* UFP-side : threshold for DFP connection detection */
-#define PD_SNK_VA 200 /* mV */
-
-/* start as a sink in case we have no other power supply/battery */
-#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED
-
-/*
- * delay to turn on the power supply max is ~16ms.
- * delay to turn off the power supply max is about ~180ms.
- */
-#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
-#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */
-
-/* delay to turn on/off vconn */
-#define PD_VCONN_SWAP_DELAY 5000 /* 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
-
#endif /* __USB_PD_CONFIG_H */
diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c
index 05df870be9..154a1303e7 100644
--- a/board/samus_pd/usb_pd_policy.c
+++ b/board/samus_pd/usb_pd_policy.c
@@ -16,7 +16,6 @@
#include "timer.h"
#include "util.h"
#include "usb_pd.h"
-#include "usb_pd_config.h"
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
@@ -129,6 +128,12 @@ void typec_set_input_current_limit(int port, uint32_t max_ma,
pd_send_host_event(PD_EVENT_POWER_CHANGE);
}
+int pd_snk_is_vbus_provided(int port)
+{
+ return gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE :
+ GPIO_USB_C0_VBUS_WAKE);
+}
+
int pd_board_checks(void)
{
return EC_SUCCESS;
@@ -257,9 +262,9 @@ int pd_custom_vdm(int port, int cnt, uint32_t *payload,
return 0;
}
-static int dp_flags[PD_PORT_COUNT];
+static int dp_flags[CONFIG_USB_PD_PORT_COUNT];
/* DP Status VDM as returned by UFP */
-static uint32_t dp_status[PD_PORT_COUNT];
+static uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT];
static void svdm_safe_dp_mode(int port)
{