summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-04-04 11:51:41 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-05-02 01:16:56 +0000
commit07728886bf499941b58331fff815869e0d7380ae (patch)
treeabd7505dd9d838a92c7575c47dfc563062fd1f82
parent34c9267440ee9b5c3cae19d0ced85d28350d3ea9 (diff)
downloadchrome-ec-07728886bf499941b58331fff815869e0d7380ae.tar.gz
rt946x: Allow board customize initialization parameters
Currently, initialization parameters are fixed. This patch allows a board to customize how the chip is initialized. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/80482240 BRANCH=none TEST=buildall Change-Id: I0be0547d73de4d3f37e80e763efaf7840fd678c2 Reviewed-on: https://chromium-review.googlesource.com/1553564 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> (cherry picked from commit 0f15b8e5a3583cac214ea93b97918e25d5ff88bc) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1591482 Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: YH Lin <yueherngl@chromium.org> Tested-by: YH Lin <yueherngl@chromium.org>
-rw-r--r--driver/charger/rt946x.c32
-rw-r--r--driver/charger/rt946x.h9
2 files changed, 24 insertions, 17 deletions
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c
index 57dc8707a8..984c1d1d4f 100644
--- a/driver/charger/rt946x.c
+++ b/driver/charger/rt946x.c
@@ -42,16 +42,7 @@ static const struct charger_info rt946x_charger_info = {
.input_current_step = INPUT_I_STEP,
};
-struct charger_init_setting {
- uint16_t eoc_current;
- uint16_t mivr;
- uint16_t ircmp_vclamp;
- uint16_t ircmp_res;
- uint16_t boost_voltage;
- uint16_t boost_current;
-};
-
-static const struct charger_init_setting rt946x_charger_init_setting = {
+static const struct rt946x_init_setting default_init_setting = {
.eoc_current = 400,
.mivr = 4000,
.ircmp_vclamp = 32,
@@ -60,6 +51,12 @@ static const struct charger_init_setting rt946x_charger_init_setting = {
.boost_current = 1500,
};
+__attribute__((weak))
+const struct rt946x_init_setting *board_rt946x_init_setting(void)
+{
+ return &default_init_setting;
+}
+
enum rt946x_ilmtsel {
RT946X_ILMTSEL_PSEL_OTG,
RT946X_ILMTSEL_AICR = 2,
@@ -406,6 +403,7 @@ static int rt946x_init_setting(void)
{
int rv = 0;
const struct battery_info *batt_info = battery_get_info();
+ const struct rt946x_init_setting *setting = board_rt946x_init_setting();
#ifdef CONFIG_CHARGER_OTG
/* Disable boost-mode output voltage */
@@ -433,24 +431,24 @@ static int rt946x_init_setting(void)
rv = rt946x_clr_bit(RT946X_REG_CHGCTRL12, RT946X_MASK_TMR_EN);
if (rv)
return rv;
- rv = rt946x_set_mivr(rt946x_charger_init_setting.mivr);
+ rv = rt946x_set_mivr(setting->mivr);
if (rv)
return rv;
- rv = rt946x_set_ieoc(rt946x_charger_init_setting.eoc_current);
+ rv = rt946x_set_ieoc(setting->eoc_current);
if (rv)
return rv;
rv = rt946x_set_boost_voltage(
- rt946x_charger_init_setting.boost_voltage);
+ setting->boost_voltage);
if (rv)
return rv;
rv = rt946x_set_boost_current(
- rt946x_charger_init_setting.boost_current);
+ setting->boost_current);
if (rv)
return rv;
- rv = rt946x_set_ircmp_vclamp(rt946x_charger_init_setting.ircmp_vclamp);
+ rv = rt946x_set_ircmp_vclamp(setting->ircmp_vclamp);
if (rv)
return rv;
- rv = rt946x_set_ircmp_res(rt946x_charger_init_setting.ircmp_res);
+ rv = rt946x_set_ircmp_res(setting->ircmp_res);
if (rv)
return rv;
rv = rt946x_set_vprec(batt_info->voltage_min);
@@ -1102,4 +1100,4 @@ int mt6370_led_set_pwm_frequency(enum mt6370_led_index index,
freq << MT6370_SHIFT_RGBISNK_DIMFSEL);
return EC_SUCCESS;
}
-#endif
+#endif /* CONFIG_CHARGER_MT6370 */
diff --git a/driver/charger/rt946x.h b/driver/charger/rt946x.h
index 0f7bcb2426..f4f37975ad 100644
--- a/driver/charger/rt946x.h
+++ b/driver/charger/rt946x.h
@@ -550,6 +550,15 @@ int rt946x_cutoff_battery(void);
/* Enable/Disable charge temination */
int rt946x_enable_charge_termination(int en);
+struct rt946x_init_setting {
+ uint16_t eoc_current;
+ uint16_t mivr;
+ uint16_t ircmp_vclamp;
+ uint16_t ircmp_res;
+ uint16_t boost_voltage;
+ uint16_t boost_current;
+};
+
#ifdef CONFIG_CHARGER_MT6370
/*