summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-02-06 01:44:06 +0800
committerChromeBot <chrome-bot@google.com>2013-02-05 21:20:06 -0800
commite955c627920edc591b2473470fa5de06c3f62e31 (patch)
tree133638116ad5934feb8d43bc6eb871826c44946d
parent57d9c35198edb600cbf4af460b4961122fce943b (diff)
downloadchrome-ec-e955c627920edc591b2473470fa5de06c3f62e31.tar.gz
spring: Limit USB port current
BUG=chrome-os-partner:14319 TEST=Attach different chargers and see corresponding PWM duty cycle set. BRANCH=none Change-Id: I10c6e28ddf5a959849a6f14d9ca3894be4f16e30 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/42691
-rw-r--r--board/spring/usb_charging.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c
index 66b6ad667c..b919ec851b 100644
--- a/board/spring/usb_charging.c
+++ b/board/spring/usb_charging.c
@@ -25,6 +25,13 @@
#define POWERED_DEVICE_TYPE (TSU6721_TYPE_OTG | \
TSU6721_TYPE_JIG_UART_ON)
+/* PWM controlled current limit */
+#define I_LIMIT_500MA 85
+#define I_LIMIT_1000MA 70
+#define I_LIMIT_1500MA 50
+#define I_LIMIT_2000MA 35
+#define I_LIMIT_3000MA 0
+
static enum ilim_config current_ilim_config = ILIM_CONFIG_MANUAL_OFF;
static void board_ilim_use_gpio(void)
@@ -130,10 +137,25 @@ static void usb_device_change(int dev_type)
else
gpio_set_level(GPIO_BOOST_EN, 1);
- if (dev_type & TSU6721_TYPE_VBUS_DEBOUNCED)
+ if (dev_type & TSU6721_TYPE_VBUS_DEBOUNCED) {
+ /* Limit USB port current. 500mA for not listed types. */
+ int current_limit = I_LIMIT_500MA;
+ if (dev_type & TSU6721_TYPE_CHG12)
+ current_limit = I_LIMIT_3000MA;
+ else if (dev_type & TSU6721_TYPE_APPLE_CHG) {
+ /* TODO: Distinguish 1A/2A chargers. */
+ current_limit = I_LIMIT_1000MA;
+ } else if ((dev_type & TSU6721_TYPE_CDP) ||
+ (dev_type & TSU6721_TYPE_DCP))
+ current_limit = I_LIMIT_1500MA;
+
+ board_pwm_duty_cycle(current_limit);
+
+ /* Turns on battery LED */
lp5562_poweron();
- else
+ } else {
lp5562_poweroff();
+ }
/* Log to console */
CPRINTF("[%T USB Attached: ");