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 10:19:48 -0700
commit71612e73d7718338d0479f4e9546467e801b51fc (patch)
tree1b31b9ccc77f18b8218f04c07faede463f94525d
parent6fdd37c71becdad402a2368ec3b22c6dab2e6b35 (diff)
downloadchrome-ec-71612e73d7718338d0479f4e9546467e801b51fc.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 Original-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> (cherry picked from commit d7b9b2a088dcf129739c7a6b8a30bc292ea7234d) Change-Id: I11962991d6d7ba7b9d437fc56eb23974d30930a8 Reviewed-on: https://gerrit.chromium.org/gerrit/58198 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--common/extpower_usb.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/common/extpower_usb.c b/common/extpower_usb.c
index 7fdff81fa2..17ad401001 100644
--- a/common/extpower_usb.c
+++ b/common/extpower_usb.c
@@ -48,12 +48,22 @@ enum ilim_config {
/* 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 */
@@ -76,13 +86,6 @@ enum ilim_config {
#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)
-
/* Current sense resistor values */
#define R_INPUT_MOHM 20 /* mOhm */
#define R_BATTERY_MOHM 33 /* mOhm */