summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-08-24 13:08:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-08-28 15:24:10 -0700
commit52789bd7fd6307e2d48add81a325c1582303ea1b (patch)
tree419f6251cb2d69e75ec2445f0d9b5e6eafc1dd0e
parente5c69151dfd895162118023b6c591686dd49d4c9 (diff)
downloadchrome-ec-52789bd7fd6307e2d48add81a325c1582303ea1b.tar.gz
usb_port_power_smart: Add CDP/SDP only option.
For some boards, the control lines to the charging port controller are all tied to a power rail. In essence, this leaves the ILIM_SEL as the only signal able to be controlled, which means that we only support CDP/SDP. This commit adds a new CONFIG_* option which describes this. CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY Additionally, some cleanup is made to not always assume the number of smart power ports. BUG=None BRANCH=None TEST=make -j buildall Change-Id: I080ccd67ffc20ccccf1e6b33a3cf9374a6b70ad6 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/634274 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/coral/board.h2
-rw-r--r--board/kahlee/board.h2
-rw-r--r--board/reef/board.h2
-rw-r--r--board/reef_it8320/board.h2
-rw-r--r--board/samus/board.h2
-rw-r--r--board/strago/board.h1
-rw-r--r--common/usb_port_power_smart.c44
-rw-r--r--include/config.h7
8 files changed, 41 insertions, 21 deletions
diff --git a/board/coral/board.h b/board/coral/board.h
index 6523cc2ff1..f0f0f47801 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -67,7 +67,7 @@
#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1
-#define GPIO_USB_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
+#define GPIO_USB1_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
#define GPIO_USB_CTL1 GPIO_EN_PP5000
#define CONFIG_TABLET_MODE
diff --git a/board/kahlee/board.h b/board/kahlee/board.h
index 7fc9c8e33c..240c24569e 100644
--- a/board/kahlee/board.h
+++ b/board/kahlee/board.h
@@ -53,7 +53,7 @@
#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1
-#define GPIO_USB_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
+#define GPIO_USB1_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
#define GPIO_USB_CTL1 GPIO_USB_A_CHARGE_EN_L
/* USB PD config */
diff --git a/board/reef/board.h b/board/reef/board.h
index 5550928089..44b7e66e0c 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -70,7 +70,7 @@
#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1
-#define GPIO_USB_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
+#define GPIO_USB1_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
#define GPIO_USB_CTL1 GPIO_EN_PP5000
#define CONFIG_TABLET_MODE
diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h
index dde27dcfcd..1f444d2c3e 100644
--- a/board/reef_it8320/board.h
+++ b/board/reef_it8320/board.h
@@ -60,7 +60,7 @@
#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1
-#define GPIO_USB_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
+#define GPIO_USB1_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
#define GPIO_USB_CTL1 GPIO_EN_PP5000
/* USB PD config */
diff --git a/board/samus/board.h b/board/samus/board.h
index 59455e7822..82dc062518 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -80,6 +80,8 @@
#define CONFIG_USB_PORT_POWER_SMART
#define CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE USB_CHARGE_MODE_CDP
#define CONFIG_USB_PORT_POWER_SMART_INVERTED
+#define GPIO_USB1_ILIM_SEL GPIO_USB1_ILIM_SEL_L
+#define GPIO_USB2_ILIM_SEL GPIO_USB2_ILIM_SEL_L
#define CONFIG_VBOOT_HASH
#define CONFIG_WIRELESS
#define CONFIG_WIRELESS_SUSPEND \
diff --git a/board/strago/board.h b/board/strago/board.h
index 23100c9a25..f13e650008 100644
--- a/board/strago/board.h
+++ b/board/strago/board.h
@@ -57,6 +57,7 @@
#define CONFIG_USB_PORT_POWER_SMART
#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
+#define GPIO_USB1_ILIM_SEL GPIO_USB_ILIM_SEL
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_TMP432
diff --git a/common/usb_port_power_smart.c b/common/usb_port_power_smart.c
index fb9e1e1230..0d1b18d820 100644
--- a/common/usb_port_power_smart.c
+++ b/common/usb_port_power_smart.c
@@ -30,6 +30,13 @@ static uint8_t charge_mode[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT];
/* GPIOs to enable/disable USB ports. Board specific. */
extern const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT];
+#ifdef CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY
+/*
+ * If we only support CDP and SDP, the control signals are hard-wired so
+ * there's nothing to do. The only to do is set ILIM_SEL.
+ */
+static void usb_charge_set_control_mode(int port_id, int mode) {}
+#else /* !defined(CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY) */
static void usb_charge_set_control_mode(int port_id, int mode)
{
#ifdef CONFIG_USB_PORT_POWER_SMART_SIMPLE
@@ -49,8 +56,9 @@ static void usb_charge_set_control_mode(int port_id, int mode)
gpio_set_level(GPIO_USB2_CTL2, mode & 0x2);
gpio_set_level(GPIO_USB2_CTL3, mode & 0x1);
}
-#endif
+#endif /* defined(CONFIG_USB_PORT_POWER_SMART_SIMPLE) */
}
+#endif /* defined(CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY) */
static void usb_charge_set_enabled(int port_id, int en)
{
@@ -60,22 +68,22 @@ static void usb_charge_set_enabled(int port_id, int en)
static void usb_charge_set_ilim(int port_id, int sel)
{
-#if defined(CONFIG_USB_PORT_POWER_SMART_SIMPLE)
- /* ILIM_SEL signal is shared and inverted */
- gpio_set_level(GPIO_USB_ILIM_SEL, !sel);
-#elif defined(CONFIG_USB_PORT_POWER_SMART_INVERTED)
- /* ILIM_SEL signal is per-port and active low */
- if (port_id == 0)
- gpio_set_level(GPIO_USB1_ILIM_SEL_L, !sel);
- else
- gpio_set_level(GPIO_USB2_ILIM_SEL_L, !sel);
-#else
- /* ILIM_SEL is per-port and active high */
- if (port_id == 0)
- gpio_set_level(GPIO_USB1_ILIM_SEL, sel);
- else
- gpio_set_level(GPIO_USB2_ILIM_SEL, sel);
-#endif /* CONFIG_USB_PORT_POWER_SMART_SIMPLE */
+ enum gpio_signal ilim_sel;
+
+#if defined(CONFIG_USB_PORT_POWER_SMART_SIMPLE) || \
+ defined(CONFIG_USB_PORT_POWER_SMART_INVERTED)
+ /* ILIM_SEL is inverted. */
+ sel = !sel;
+#endif
+
+ ilim_sel = GPIO_USB1_ILIM_SEL;
+#if !defined(CONFIG_USB_PORT_POWER_SMART_SIMPLE) && \
+ CONFIG_USB_PORT_POWER_SMART_PORT_COUNT == 2
+ if (port_id != 0)
+ ilim_sel = GPIO_USB2_ILIM_SEL;
+#endif
+
+ gpio_set_level(ilim_sel, sel);
}
static void usb_charge_all_ports_ctrl(enum usb_charge_mode mode)
@@ -107,10 +115,12 @@ int usb_charge_set_mode(int port_id, enum usb_charge_mode mode)
usb_charge_set_ilim(port_id, 1);
usb_charge_set_enabled(port_id, 1);
break;
+#ifndef CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY
case USB_CHARGE_MODE_DCP_SHORT:
usb_charge_set_control_mode(port_id, 4);
usb_charge_set_enabled(port_id, 1);
break;
+#endif /* !defined(CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY) */
default:
return EC_ERROR_UNKNOWN;
}
diff --git a/include/config.h b/include/config.h
index 73ddc8a033..e4d40ae16f 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2715,6 +2715,13 @@
#undef CONFIG_USB_PORT_POWER_SMART
/*
+ * Support smart power control to the device's USB ports, however only CDP and
+ * SDP are supported. Usually this is the case if all the control lines to the
+ * charging port controller are hard-wired.
+ */
+#undef CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY
+
+/*
* Override the default charging mode for USB smart power control.
* Value is selected from usb_charge_mode in include/usb_charge.h
*/