leds: qpnp-flash-v2: Add support for programming led clamp currents

Allow the mitigation clamp current values for the leds to be
configured through the device tree.

CRs-Fixed: 1060212
Change-Id: I23bf67fba7cef2735db436899a9d5b3306e5a77f
Signed-off-by: Devesh Jhunjhunwala <deveshj@codeaurora.org>
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
Subbaraman Narayanamurthy 2016-08-26 12:31:56 -07:00
parent 05939b3db2
commit 561bfca197
2 changed files with 96 additions and 0 deletions

View file

@ -32,6 +32,18 @@ Optional properties:
- qcom,vph-droop-debounce-us : Integer property to specify VPH droop debounce time. It is only used - qcom,vph-droop-debounce-us : Integer property to specify VPH droop debounce time. It is only used
if qcom,vph-droop-det is specified. Valid values are 0, 8, 16 and 26. if qcom,vph-droop-det is specified. Valid values are 0, 8, 16 and 26.
Unit is uS. Unit is uS.
- qcom,led1n2-iclamp-low-ma : Integer property to specify current clamp low
level for mitigation. Unit is mA. Allowed
values are same as under qcom,max-current.
- qcom,led1n2-iclamp-mid-ma : Integer property to specify current clamp mid
level for mitigation. Unit is mA. Allowed
values are same as under qcom,max-current.
- qcom,led3-iclamp-low-ma : Integer property to specify current clamp low
level for mitigation. Unit is mA. Allowed
values are same as under qcom,max-current.
- qcom,led3-iclamp-mid-ma : Integer property to specify current clamp mid
level for mitigation. Unit is mA. Allowed
values are same as under qcom,max-current.
- qcom,vled-max-uv : Integer property for flash current predictive mitigation. - qcom,vled-max-uv : Integer property for flash current predictive mitigation.
Default value is 3500000 uV. Default value is 3500000 uV.
- qcom,ibatt-ocp-threshold-ua : Integer property for flash current predictive mitigation. - qcom,ibatt-ocp-threshold-ua : Integer property for flash current predictive mitigation.

View file

@ -49,6 +49,10 @@
#define FLASH_LED_REG_VPH_DROOP_THRESHOLD(base) (base + 0x61) #define FLASH_LED_REG_VPH_DROOP_THRESHOLD(base) (base + 0x61)
#define FLASH_LED_REG_VPH_DROOP_DEBOUNCE(base) (base + 0x62) #define FLASH_LED_REG_VPH_DROOP_DEBOUNCE(base) (base + 0x62)
#define FLASH_LED_REG_ILED_GRT_THRSH(base) (base + 0x67) #define FLASH_LED_REG_ILED_GRT_THRSH(base) (base + 0x67)
#define FLASH_LED_REG_LED1N2_ICLAMP_LOW(base) (base + 0x68)
#define FLASH_LED_REG_LED1N2_ICLAMP_MID(base) (base + 0x69)
#define FLASH_LED_REG_LED3_ICLAMP_LOW(base) (base + 0x6A)
#define FLASH_LED_REG_LED3_ICLAMP_MID(base) (base + 0x6B)
#define FLASH_LED_REG_MITIGATION_SEL(base) (base + 0x6E) #define FLASH_LED_REG_MITIGATION_SEL(base) (base + 0x6E)
#define FLASH_LED_REG_MITIGATION_SW(base) (base + 0x6F) #define FLASH_LED_REG_MITIGATION_SW(base) (base + 0x6F)
#define FLASH_LED_REG_LMH_LEVEL(base) (base + 0x70) #define FLASH_LED_REG_LMH_LEVEL(base) (base + 0x70)
@ -196,6 +200,10 @@ struct flash_led_platform_data {
int rpara_uohm; int rpara_uohm;
int lmh_rbatt_threshold_uohm; int lmh_rbatt_threshold_uohm;
int lmh_ocv_threshold_uv; int lmh_ocv_threshold_uv;
u32 led1n2_iclamp_low_ma;
u32 led1n2_iclamp_mid_ma;
u32 led3_iclamp_low_ma;
u32 led3_iclamp_mid_ma;
u8 isc_delay; u8 isc_delay;
u8 warmup_delay; u8 warmup_delay;
u8 current_derate_en_cfg; u8 current_derate_en_cfg;
@ -379,6 +387,46 @@ static int qpnp_flash_led_init_settings(struct qpnp_flash_led *led)
if (rc < 0) if (rc < 0)
return rc; return rc;
if (led->pdata->led1n2_iclamp_low_ma) {
val = CURRENT_MA_TO_REG_VAL(led->pdata->led1n2_iclamp_low_ma,
led->fnode[0].ires_ua);
rc = qpnp_flash_led_masked_write(led,
FLASH_LED_REG_LED1N2_ICLAMP_LOW(led->base),
FLASH_LED_CURRENT_MASK, val);
if (rc < 0)
return rc;
}
if (led->pdata->led1n2_iclamp_mid_ma) {
val = CURRENT_MA_TO_REG_VAL(led->pdata->led1n2_iclamp_mid_ma,
led->fnode[0].ires_ua);
rc = qpnp_flash_led_masked_write(led,
FLASH_LED_REG_LED1N2_ICLAMP_MID(led->base),
FLASH_LED_CURRENT_MASK, val);
if (rc < 0)
return rc;
}
if (led->pdata->led3_iclamp_low_ma) {
val = CURRENT_MA_TO_REG_VAL(led->pdata->led3_iclamp_low_ma,
led->fnode[3].ires_ua);
rc = qpnp_flash_led_masked_write(led,
FLASH_LED_REG_LED3_ICLAMP_LOW(led->base),
FLASH_LED_CURRENT_MASK, val);
if (rc < 0)
return rc;
}
if (led->pdata->led3_iclamp_mid_ma) {
val = CURRENT_MA_TO_REG_VAL(led->pdata->led3_iclamp_mid_ma,
led->fnode[3].ires_ua);
rc = qpnp_flash_led_masked_write(led,
FLASH_LED_REG_LED3_ICLAMP_MID(led->base),
FLASH_LED_CURRENT_MASK, val);
if (rc < 0)
return rc;
}
return 0; return 0;
} }
@ -1571,6 +1619,42 @@ static int qpnp_flash_led_parse_common_dt(struct qpnp_flash_led *led,
return rc; return rc;
} }
rc = of_property_read_u32(node, "qcom,led1n2-iclamp-low-ma", &val);
if (!rc) {
led->pdata->led1n2_iclamp_low_ma = val;
} else if (rc != -EINVAL) {
dev_err(&led->pdev->dev, "Unable to read led1n2_iclamp_low current, rc=%d\n",
rc);
return rc;
}
rc = of_property_read_u32(node, "qcom,led1n2-iclamp-mid-ma", &val);
if (!rc) {
led->pdata->led1n2_iclamp_mid_ma = val;
} else if (rc != -EINVAL) {
dev_err(&led->pdev->dev, "Unable to read led1n2_iclamp_mid current, rc=%d\n",
rc);
return rc;
}
rc = of_property_read_u32(node, "qcom,led3-iclamp-low-ma", &val);
if (!rc) {
led->pdata->led3_iclamp_low_ma = val;
} else if (rc != -EINVAL) {
dev_err(&led->pdev->dev, "Unable to read led3_iclamp_low current, rc=%d\n",
rc);
return rc;
}
rc = of_property_read_u32(node, "qcom,led3-iclamp-mid-ma", &val);
if (!rc) {
led->pdata->led3_iclamp_mid_ma = val;
} else if (rc != -EINVAL) {
dev_err(&led->pdev->dev, "Unable to read led3_iclamp_mid current, rc=%d\n",
rc);
return rc;
}
led->pdata->vled_max_uv = FLASH_LED_VLED_MAX_DEFAULT_UV; led->pdata->vled_max_uv = FLASH_LED_VLED_MAX_DEFAULT_UV;
rc = of_property_read_u32(node, "qcom,vled-max-uv", &val); rc = of_property_read_u32(node, "qcom,vled-max-uv", &val);
if (!rc) { if (!rc) {