Skip to content

Commit 173f81c

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]>
1 parent 9b9ecf0 commit 173f81c

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
@@ -1848,6 +1848,16 @@ static int ln8411_power_supply_init(struct ln8411_device *ln8411,
18481848
}
18491849
}
18501850

1851+
static int ln8411_cfg_sync(struct ln8411_device *ln8411)
1852+
{
1853+
unsigned int reg_code = LN8411_SYNC_FUNCTION_EN;
1854+
1855+
if (ln8411->role == LN8411_MAIN)
1856+
reg_code |= LN8411_SYNC_MASTER_EN;
1857+
1858+
return regmap_update_bits(ln8411->regmap, LN8411_CTRL4, LN8411_SYNC_MASK, reg_code);
1859+
}
1860+
18511861
static int ln8411_apply_conv_dt(struct ln8411_device *ln8411, struct ln8411_init_data *init_data)
18521862
{
18531863
unsigned int reg_code = 0;
@@ -1876,10 +1886,6 @@ static int ln8411_apply_conv_dt(struct ln8411_device *ln8411, struct ln8411_init
18761886
if (ret)
18771887
return ret;
18781888

1879-
if (init_data->sync_func_en)
1880-
reg_code |= LN8411_SYNC_FUNCTION_EN;
1881-
if (init_data->sync_main_en)
1882-
reg_code |= LN8411_SYNC_MASTER_EN;
18831889
if (init_data->vbus_ovp_set)
18841890
reg_code |= LN8411_VBUS_OVP_SET;
18851891
if (init_data->set_ibat_sns_res)
@@ -1982,6 +1988,9 @@ static int ln8411_hw_init(struct ln8411_device *ln8411)
19821988
if (ret)
19831989
return ret;
19841990

1991+
if (ln8411->role > LN8411_DUAL)
1992+
return ln8411_cfg_sync(ln8411);
1993+
19851994
return ret;
19861995
}
19871996

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)