drivers/regulator: Import Sony Changes

*52.1.A.3.74

Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
exer 2023-01-15 11:05:54 +00:00 • committed by Sorayukii
commit 400b5ba8dd
4 changed files with 1123 additions and 3 deletions

View file

@ -1088,5 +1088,9 @@ config REGULATOR_STUB
Clients can use the real regulator device names with proper
constraint checking while the real driver is being developed.
config SOMC_LCD_OCP_ENABLED
bool "enable SoMC LCD OCP function"
help
Select this to enable SoMC LCD Over current protection function.
endif

View file

@ -3532,6 +3532,33 @@ int regulator_allow_bypass(struct regulator *regulator, bool enable)
}
EXPORT_SYMBOL_GPL(regulator_allow_bypass);
/*
* regulator_register_ocp_notification - register ocp notification
* @regulator: regulator source
* @notification: pointer of client ocp_notification
*
*/
int regulator_register_ocp_notification(struct regulator *regulator,
struct regulator_ocp_notification *notification)
{
struct regulator_dev *rdev = regulator->rdev;
int ret;
mutex_lock(&rdev->mutex);
/* sanity check */
if (!rdev->desc->ops->register_ocp_notification) {
ret = -EINVAL;
goto out;
}
ret = rdev->desc->ops->register_ocp_notification(rdev, notification);
out:
mutex_unlock(&rdev->mutex);
return ret;
}
EXPORT_SYMBOL_GPL(regulator_register_ocp_notification);
/**
* regulator_register_notifier - register regulator event notifier
* @regulator: regulator source

File diff suppressed because it is too large Load diff

View file

@ -341,6 +341,8 @@ struct qpnp_regulator {
int ocp_count;
int ocp_max_retries;
int ocp_retry_delay_ms;
struct regulator_ocp_notification ocp_notification;
spinlock_t ocp_lock;
int system_load;
int hpm_min_load;
int slew_rate;
@ -1246,6 +1248,34 @@ static int qpnp_regulator_common_enable_time(struct regulator_dev *rdev)
return vreg->enable_time;
}
static int qpnp_regulator_vs_register_ocp_notification(
struct regulator_dev *rdev,
struct regulator_ocp_notification *notification)
{
unsigned long flags;
struct qpnp_regulator *vreg = rdev_get_drvdata(rdev);
spin_lock_irqsave(&vreg->ocp_lock, flags);
if (notification) {
/* register ocp notification */
vreg->ocp_notification = *notification;
} else {
/* unregister ocp notification */
memset(&vreg->ocp_notification, 0,
sizeof(vreg->ocp_notification));
}
spin_unlock_irqrestore(&vreg->ocp_lock, flags);
if (qpnp_vreg_debug_mask & QPNP_VREG_DEBUG_OCP) {
pr_info("%s: registered ocp notification(notify=%p, ctxt=%p)\n",
vreg->rdesc.name,
vreg->ocp_notification.notify,
vreg->ocp_notification.ctxt);
}
return 0;
}
static int qpnp_regulator_vs_clear_ocp(struct qpnp_regulator *vreg)
{
int rc;
@ -1319,8 +1349,14 @@ static irqreturn_t qpnp_regulator_vs_ocp_isr(int irq, void *data)
schedule_delayed_work(&vreg->ocp_work,
msecs_to_jiffies(vreg->ocp_retry_delay_ms) + 1);
} else {
unsigned long flags;
vreg_err(vreg, "OCP triggered %d times; no further retries\n",
vreg->ocp_count);
spin_lock_irqsave(&vreg->ocp_lock, flags);
if (vreg->ocp_notification.notify)
vreg->ocp_notification.notify(
vreg->ocp_notification.ctxt);
spin_unlock_irqrestore(&vreg->ocp_lock, flags);
}
return IRQ_HANDLED;
@ -1551,6 +1587,8 @@ static struct regulator_ops qpnp_vs_ops = {
.disable = qpnp_regulator_common_disable,
.is_enabled = qpnp_regulator_common_is_enabled,
.enable_time = qpnp_regulator_common_enable_time,
.register_ocp_notification
= qpnp_regulator_vs_register_ocp_notification,
};
static struct regulator_ops qpnp_boost_ops = {
@ -2245,6 +2283,10 @@ static int qpnp_regulator_probe(struct platform_device *pdev)
if (vreg->ocp_retry_delay_ms == 0)
vreg->ocp_retry_delay_ms = QPNP_VS_OCP_DEFAULT_RETRY_DELAY_MS;
memset(&vreg->ocp_notification, 0,
sizeof(vreg->ocp_notification));
spin_lock_init(&vreg->ocp_lock);
rdesc = &vreg->rdesc;
rdesc->id = to_spmi_device(pdev->dev.parent)->ctrl->nr;
rdesc->owner = THIS_MODULE;