summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2013-06-10 17:43:42 -0700
committerChromeBot <chrome-bot@google.com>2013-06-11 08:42:11 -0700
commitd7b9b2a088dcf129739c7a6b8a30bc292ea7234d (patch)
treed8fbfca1b874c0ac69e5768bdfb324d47787d923
parentefc560f04f292cb42bdaf81c0d4fa3b1f5a1482a (diff)
downloadchrome-ec-d7b9b2a088dcf129739c7a6b8a30bc292ea7234d.tar.gz
spring: update PWM characterization for DVT1
The new constants used to convert PWM duty cycle to input current, based on a linear regression done on Aaron's characterization data measured on DVT1 PCB. The data points are linear enough to use the linear relationship to set the current limitation. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=spring BUG=chrome-os-partner:19281 TEST=none Change-Id: I8378aaea21d5b3229d505caf4849257ded77e1ad Reviewed-on: https://gerrit.chromium.org/gerrit/58143 Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/spring/usb_charging.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c
index 277720c886..a6a73fdf36 100644
--- a/board/spring/usb_charging.c
+++ b/board/spring/usb_charging.c
@@ -41,12 +41,22 @@
/* Voltage threshold of D+ for video */
#define VIDEO_ID_THRESHOLD 1335
+/*
+ * Mapping from PWM duty to current:
+ * Current = A + B * PWM_Duty
+ */
+#define PWM_MAPPING_A 2958
+#define PWM_MAPPING_B (-29)
+
+/* Map current in milli-amps to PWM duty cycle percentage */
+#define MA_TO_PWM(curr) (((curr) - PWM_MAPPING_A) / PWM_MAPPING_B)
+
/* PWM controlled current limit */
-#define I_LIMIT_500MA 90
-#define I_LIMIT_1000MA 75
-#define I_LIMIT_1500MA 60
-#define I_LIMIT_2000MA 50
-#define I_LIMIT_2400MA 35
+#define I_LIMIT_500MA MA_TO_PWM(500)
+#define I_LIMIT_1000MA MA_TO_PWM(1000)
+#define I_LIMIT_1500MA MA_TO_PWM(1500)
+#define I_LIMIT_2000MA MA_TO_PWM(2000)
+#define I_LIMIT_2400MA MA_TO_PWM(2400)
#define I_LIMIT_3000MA 0
/* PWM control loop parameters */
@@ -69,13 +79,6 @@
#define DELAY_USB_DP_DN_MS 20
#define DELAY_ID_MUX_MS 30
-/*
- * Mapping from PWM duty to current:
- * Current = A + B * PWM_Duty
- */
-#define PWM_MAPPING_A 3012
-#define PWM_MAPPING_B (-29)
-
static int current_dev_type = TSU6721_TYPE_NONE;
static int nominal_pwm_duty;
static int current_pwm_duty;