Skip to content

Commit 70b3b6d

Browse files
Aidan MacDonaldsre
authored andcommitted
power: supply: axp20x_usb_power: Use regmap fields for USB BC feature
Replace the use of variant IDs with a regmap field, to reduce dependence on variant IDs. Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 05c14ac commit 70b3b6d

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

drivers/power/supply/axp20x_usb_power.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
#define AXP20X_ADC_EN1_VBUS_CURR BIT(2)
4242
#define AXP20X_ADC_EN1_VBUS_VOLT BIT(3)
4343

44-
#define AXP813_BC_EN BIT(0)
45-
4644
/*
4745
* Note do not raise the debounce time, we must report Vusb high within
4846
* 100ms otherwise we get Vbus errors in musb.
@@ -58,13 +56,15 @@ struct axp_data {
5856
struct reg_field curr_lim_fld;
5957
struct reg_field vbus_valid_bit;
6058
struct reg_field vbus_mon_bit;
59+
struct reg_field usb_bc_en_bit;
6160
};
6261

6362
struct axp20x_usb_power {
6463
struct regmap *regmap;
6564
struct regmap_field *curr_lim_fld;
6665
struct regmap_field *vbus_valid_bit;
6766
struct regmap_field *vbus_mon_bit;
67+
struct regmap_field *usb_bc_en_bit;
6868
struct power_supply *supply;
6969
enum axp20x_variants axp20x_id;
7070
const struct axp_data *axp_data;
@@ -433,6 +433,7 @@ static const struct axp_data axp813_data = {
433433
.axp20x_id = AXP813_ID,
434434
.curr_lim_table = axp813_usb_curr_lim_table,
435435
.curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1),
436+
.usb_bc_en_bit = REG_FIELD(AXP288_BC_GLOBAL, 0, 0),
436437
};
437438

438439
#ifdef CONFIG_PM_SLEEP
@@ -572,6 +573,12 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
572573
if (ret)
573574
return ret;
574575

576+
ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap,
577+
axp_data->usb_bc_en_bit,
578+
&power->usb_bc_en_bit);
579+
if (ret)
580+
return ret;
581+
575582
ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect,
576583
axp20x_usb_power_poll_vbus);
577584
if (ret)
@@ -592,10 +599,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
592599
return ret;
593600
}
594601

595-
if (power->axp20x_id == AXP813_ID) {
602+
if (power->usb_bc_en_bit) {
596603
/* Enable USB Battery Charging specification detection */
597-
ret = regmap_update_bits(axp20x->regmap, AXP288_BC_GLOBAL,
598-
AXP813_BC_EN, AXP813_BC_EN);
604+
ret = regmap_field_write(power->usb_bc_en_bit, 1);
599605
if (ret)
600606
return ret;
601607
}

0 commit comments

Comments
 (0)