Skip to content

Commit 67b04e4

Browse files
committed
power: supply: ln8411: Configures sync function autonomously
Automatically configures the sync function based on the driver instance. This eliminates the need to properly configure the sync function in the devicetree. Change-Id: I17f0d8900e7e4d1cf1ed3c55c6323df730a45e5a Signed-off-by: Ricardo Rivera-Matos <[email protected]> (cherry picked from commit 173f81c)
1 parent a054e38 commit 67b04e4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

drivers/power/supply/ln8411_charger.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,16 @@ static int ln8411_power_supply_init(struct ln8411_device *ln8411,
18601860
}
18611861
}
18621862

1863+
static int ln8411_cfg_sync(struct ln8411_device *ln8411)
1864+
{
1865+
unsigned int reg_code = LN8411_SYNC_FUNCTION_EN;
1866+
1867+
if (ln8411->role == LN8411_MAIN)
1868+
reg_code |= LN8411_SYNC_MASTER_EN;
1869+
1870+
return regmap_update_bits(ln8411->regmap, LN8411_CTRL4, LN8411_SYNC_MASK, reg_code);
1871+
}
1872+
18631873
static int ln8411_apply_conv_dt(struct ln8411_device *ln8411, struct ln8411_init_data *init_data)
18641874
{
18651875
unsigned int reg_code = 0;
@@ -1888,10 +1898,6 @@ static int ln8411_apply_conv_dt(struct ln8411_device *ln8411, struct ln8411_init
18881898
if (ret)
18891899
return ret;
18901900

1891-
if (init_data->sync_func_en)
1892-
reg_code |= LN8411_SYNC_FUNCTION_EN;
1893-
if (init_data->sync_main_en)
1894-
reg_code |= LN8411_SYNC_MASTER_EN;
18951901
if (init_data->vbus_ovp_set)
18961902
reg_code |= LN8411_VBUS_OVP_SET;
18971903
if (init_data->set_ibat_sns_res)
@@ -1994,6 +2000,9 @@ static int ln8411_hw_init(struct ln8411_device *ln8411)
19942000
if (ret)
19952001
return ret;
19962002

2003+
if (ln8411->role > LN8411_DUAL)
2004+
return ln8411_cfg_sync(ln8411);
2005+
19972006
return ret;
19982007
}
19992008

drivers/power/supply/ln8411_charger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
#define LN8411_CTRL4 0xd
154154
#define LN8411_SYNC_FUNCTION_EN BIT(7)
155155
#define LN8411_SYNC_MASTER_EN BIT(6)
156+
#define LN8411_SYNC_MASK (LN8411_SYNC_FUNCTION_EN | LN8411_SYNC_MASTER_EN)
156157
#define LN8411_VBUS_OVP_SET BIT(5)
157158
#define LN8411_SET_IBAT_SNS_RES BIT(4)
158159
#define LN8411_MODE_MASK GENMASK(2, 0)

0 commit comments

Comments
 (0)