drivers: regulator: Import Xiaomi changes

* From dagu-s-oss

Change-Id: I9e27aed218eb449ee481cece50eb1cea474fd298
This commit is contained in:
Sebastiano Barezzi
2022-11-15 16:58:05 +01:00
committed by Sebastiano Barezzi
parent be43d29ce7
commit a2f88b40c6
2 changed files with 46 additions and 0 deletions

View File

@@ -1177,5 +1177,10 @@ config REGULATOR_PM8008
This driver controls PM8008 PMIC chip and the voltage
regulators found in Qualcomm Technologies Inc. PM8008
PMIC.
config I2C_RETRY
bool "Stub Regulator"
help
This help control I2C retry functions
endif

View File

@@ -70,6 +70,10 @@
#define MAX_REG_NAME 20
#define PM8008_MAX_LDO 7
#ifdef CONFIG_I2C_RETRY
#define MAX_RETRY_TIME 5
#endif
enum pmic_subtype {
PM8008_SUBTYPE,
PM8010_SUBTYPE,
@@ -167,10 +171,21 @@ static int pm8008_read(struct regmap *regmap, u16 reg, u8 *val, int count)
{
int rc;
#ifdef CONFIG_I2C_RETRY
int retry = 0;
do {
rc = regmap_bulk_read(regmap, reg, val, count);
} while (rc < 0 && retry++ < MAX_RETRY_TIME);
if (retry > 0)
pr_err("failed to read 0x%04x retry time %d success\n", reg, retry);
if (rc < 0)
pr_err("failed to read 0x%04x\n", reg);
#else
rc = regmap_bulk_read(regmap, reg, val, count);
if (rc < 0)
pr_err("failed to read 0x%04x\n", reg);
#endif
return rc;
}
@@ -179,11 +194,23 @@ static int pm8008_write(struct regmap *regmap, u16 reg, const u8 *val,
{
int rc;
#ifdef CONFIG_I2C_RETRY
int retry = 0;
pr_debug("Writing 0x%02x to 0x%04x\n", val, reg);
do {
rc = regmap_bulk_write(regmap, reg, val, count);
} while (rc < 0 && retry++ < MAX_RETRY_TIME);
if (retry > 0)
pr_err("failed to write 0x%04x retry time %d success\n", reg, retry);
if (rc < 0)
pr_err("failed to write 0x%04x\n", reg);
#else
pr_debug("Writing 0x%02x to 0x%04x\n", val, reg);
rc = regmap_bulk_write(regmap, reg, val, count);
if (rc < 0)
pr_err("failed to write 0x%04x\n", reg);
#endif
return rc;
}
@@ -192,12 +219,26 @@ static int pm8008_masked_write(struct regmap *regmap, u16 reg, u8 mask,
{
int rc;
#ifdef CONFIG_I2C_RETRY
int retry = 0;
pr_debug("Writing 0x%02x to 0x%04x with mask 0x%02x\n", val, reg, mask);
do {
rc = regmap_update_bits(regmap, reg, mask, val);
} while (rc < 0 && retry++ < MAX_RETRY_TIME);
if (retry > 0)
pr_err("failed to write 0x%02x to 0x%04x with mask 0x%02x retry time %d success\n",
val, reg, retry);
if (rc < 0)
pr_err("failed to write 0x%02x to 0x%04x with mask 0x%02x\n",
val, reg, mask);
#else
pr_debug("Writing 0x%02x to 0x%04x with mask 0x%02x\n", val, reg, mask);
rc = regmap_update_bits(regmap, reg, mask, val);
if (rc < 0)
pr_err("failed to write 0x%02x to 0x%04x with mask 0x%02x\n",
val, reg, mask);
#endif
return rc;
}