codecs: add on-demand supply support
Add new APIs to enable/disable on-demand codec supplies to msm-cdc-supply driver. Change-Id: Iaf33ac40165832595c875e26179dc036b62b36f8 Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
This commit is contained in:
parent
b05cd67f29
commit
cd2fa5348e
2 changed files with 110 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -126,6 +126,106 @@ static int msm_cdc_check_supply_param(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* msm_cdc_disable_ondemand_supply:
|
||||
* Disable codec ondemand supply
|
||||
*
|
||||
* @dev: pointer to codec device
|
||||
* @supplies: pointer to regulator bulk data
|
||||
* @cdc_vreg: pointer to platform regulator data
|
||||
* @num_supplies: number of supplies
|
||||
* @supply_name: Ondemand supply name to be enabled
|
||||
*
|
||||
* Return error code if supply disable is failed
|
||||
*/
|
||||
int msm_cdc_disable_ondemand_supply(struct device *dev,
|
||||
struct regulator_bulk_data *supplies,
|
||||
struct cdc_regulator *cdc_vreg,
|
||||
int num_supplies,
|
||||
char *supply_name)
|
||||
{
|
||||
int rc, i;
|
||||
|
||||
if ((!supply_name) || (!supplies)) {
|
||||
pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* input parameter validation */
|
||||
rc = msm_cdc_check_supply_param(dev, cdc_vreg, num_supplies);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
for (i = 0; i < num_supplies; i++) {
|
||||
if (cdc_vreg[i].ondemand &&
|
||||
!strcmp(cdc_vreg[i].name, supply_name)) {
|
||||
rc = regulator_disable(supplies[i].consumer);
|
||||
if (rc)
|
||||
dev_err(dev, "%s: failed to disable supply %s, err:%d\n",
|
||||
__func__, supplies[i].supply, rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == num_supplies) {
|
||||
dev_err(dev, "%s: not able to find supply %s\n",
|
||||
__func__, supply_name);
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_cdc_disable_ondemand_supply);
|
||||
|
||||
/*
|
||||
* msm_cdc_enable_ondemand_supply:
|
||||
* Enable codec ondemand supply
|
||||
*
|
||||
* @dev: pointer to codec device
|
||||
* @supplies: pointer to regulator bulk data
|
||||
* @cdc_vreg: pointer to platform regulator data
|
||||
* @num_supplies: number of supplies
|
||||
* @supply_name: Ondemand supply name to be enabled
|
||||
*
|
||||
* Return error code if supply enable is failed
|
||||
*/
|
||||
int msm_cdc_enable_ondemand_supply(struct device *dev,
|
||||
struct regulator_bulk_data *supplies,
|
||||
struct cdc_regulator *cdc_vreg,
|
||||
int num_supplies,
|
||||
char *supply_name)
|
||||
{
|
||||
int rc, i;
|
||||
|
||||
if ((!supply_name) || (!supplies)) {
|
||||
pr_err("%s: either dev or supplies or cdc_vreg is NULL\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* input parameter validation */
|
||||
rc = msm_cdc_check_supply_param(dev, cdc_vreg, num_supplies);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
for (i = 0; i < num_supplies; i++) {
|
||||
if (cdc_vreg[i].ondemand &&
|
||||
!strcmp(cdc_vreg[i].name, supply_name)) {
|
||||
rc = regulator_enable(supplies[i].consumer);
|
||||
if (rc)
|
||||
dev_err(dev, "%s: failed to enable supply %s, rc: %d\n",
|
||||
__func__, supplies[i].supply, rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == num_supplies) {
|
||||
dev_err(dev, "%s: not able to find supply %s\n",
|
||||
__func__, supply_name);
|
||||
rc = -EINVAL;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_cdc_enable_ondemand_supply);
|
||||
|
||||
/*
|
||||
* msm_cdc_disable_static_supplies:
|
||||
* Disable codec static supplies
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2016, 2018 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -29,6 +29,14 @@ struct cdc_regulator {
|
|||
extern int msm_cdc_get_power_supplies(struct device *dev,
|
||||
struct cdc_regulator **cdc_vreg,
|
||||
int *total_num_supplies);
|
||||
extern int msm_cdc_disable_ondemand_supply(struct device *dev,
|
||||
struct regulator_bulk_data *supplies,
|
||||
struct cdc_regulator *cdc_vreg,
|
||||
int num_supplies, char *supply_name);
|
||||
extern int msm_cdc_enable_ondemand_supply(struct device *dev,
|
||||
struct regulator_bulk_data *supplies,
|
||||
struct cdc_regulator *cdc_vreg,
|
||||
int num_supplies, char *supply_name);
|
||||
extern int msm_cdc_disable_static_supplies(struct device *dev,
|
||||
struct regulator_bulk_data *supplies,
|
||||
struct cdc_regulator *cdc_vreg,
|
||||
|
|
Loading…
Reference in a new issue