Loading Documentation/devicetree/bindings/leds/leds-qpnp-flash-v2.txt +12 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,18 @@ Optional properties: Allowed values are: 0, 15, 30, 45 for pmicobalt. 0, 20, 40, 60 for pm2falcon. - qcom,thermal-thrsh1 : Integer property to specify OTST1 threshold for thermal mitigation. Unit is in Celsius. Accepted values are: 85, 79, 73, 67, 109, 103, 97, 91. - qcom,thermal-thrsh2 : Integer property to specify OTST2 threshold for thermal mitigation. Unit is in Celsius. Accepted values are: 110, 104, 98, 92, 134, 128, 122, 116. - qcom,thermal-thrsh3 : Integer property to specify OTST3 threshold for thermal mitigation. Unit is in Celsius. Accepted values are: 125, 119, 113, 107, 149, 143, 137, 131. - qcom,hw-strobe-option : Integer type to specify hardware strobe option. Based on the specified value, additional GPIO configuration may be required to provide strobing support. Supported values are: Loading drivers/leds/leds-qpnp-flash-v2.c +79 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ #define THERMAL_DEBOUNCE_TIME_MAX 64 #define THERMAL_DERATE_HYSTERESIS_MAX 3 #define FLASH_LED_THERMAL_THRSH_MIN 3 #define FLASH_LED_THERMAL_THRSH_MAX 7 #define FLASH_LED_THERMAL_OTST_LEVELS 3 #define FLASH_LED_VLED_MAX_DEFAULT_UV 3500000 #define FLASH_LED_IBATT_OCP_THRESH_DEFAULT_UA 4500000 Loading Loading @@ -219,6 +220,9 @@ struct flash_led_platform_data { int thermal_derate_fast; int thermal_hysteresis; int thermal_debounce; int thermal_thrsh1; int thermal_thrsh2; int thermal_thrsh3; u32 led1n2_iclamp_low_ma; u32 led1n2_iclamp_mid_ma; u32 led3_iclamp_low_ma; Loading Loading @@ -267,6 +271,18 @@ static int thermal_derate_fast_table[] = { 32, 64, 96, 128, 256, 384, 512, }; static int otst1_threshold_table[] = { 85, 79, 73, 67, 109, 103, 97, 91, }; static int otst2_threshold_table[] = { 110, 104, 98, 92, 134, 128, 122, 116, }; static int otst3_threshold_table[] = { 125, 119, 113, 107, 149, 143, 137, 131, }; static int qpnp_flash_led_read(struct qpnp_flash_led *led, u16 addr, u8 *data) { int rc; Loading Loading @@ -416,6 +432,33 @@ static int qpnp_flash_led_init_settings(struct qpnp_flash_led *led) return rc; } if (led->pdata->thermal_thrsh1 >= 0) { rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_THERMAL_THRSH1(led->base), FLASH_LED_THERMAL_THRSH_MASK, led->pdata->thermal_thrsh1); if (rc < 0) return rc; } if (led->pdata->thermal_thrsh2 >= 0) { rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_THERMAL_THRSH2(led->base), FLASH_LED_THERMAL_THRSH_MASK, led->pdata->thermal_thrsh2); if (rc < 0) return rc; } if (led->pdata->thermal_thrsh3 >= 0) { rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_THERMAL_THRSH3(led->base), FLASH_LED_THERMAL_THRSH_MASK, led->pdata->thermal_thrsh3); if (rc < 0) return rc; } rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_VPH_DROOP_DEBOUNCE(led->base), FLASH_LED_VPH_DROOP_DEBOUNCE_MASK, Loading Loading @@ -1751,6 +1794,42 @@ static int qpnp_flash_led_parse_common_dt(struct qpnp_flash_led *led, return rc; } led->pdata->thermal_thrsh1 = -EINVAL; rc = of_property_read_u32(node, "qcom,thermal-thrsh1", &val); if (!rc) { led->pdata->thermal_thrsh1 = get_code_from_table(otst1_threshold_table, ARRAY_SIZE(otst1_threshold_table), val); } else if (rc != -EINVAL) { dev_err(&led->pdev->dev, "Unable to read thermal thrsh1, rc=%d\n", rc); return rc; } led->pdata->thermal_thrsh2 = -EINVAL; rc = of_property_read_u32(node, "qcom,thermal-thrsh2", &val); if (!rc) { led->pdata->thermal_thrsh2 = get_code_from_table(otst2_threshold_table, ARRAY_SIZE(otst2_threshold_table), val); } else if (rc != -EINVAL) { dev_err(&led->pdev->dev, "Unable to read thermal thrsh2, rc=%d\n", rc); return rc; } led->pdata->thermal_thrsh3 = -EINVAL; rc = of_property_read_u32(node, "qcom,thermal-thrsh3", &val); if (!rc) { led->pdata->thermal_thrsh3 = get_code_from_table(otst3_threshold_table, ARRAY_SIZE(otst3_threshold_table), val); } else if (rc != -EINVAL) { dev_err(&led->pdev->dev, "Unable to read thermal thrsh3, rc=%d\n", rc); return rc; } led->pdata->vph_droop_debounce = FLASH_LED_VPH_DROOP_DEBOUNCE_DEFAULT; rc = of_property_read_u32(node, "qcom,vph-droop-debounce-us", &val); if (!rc) { Loading Loading
Documentation/devicetree/bindings/leds/leds-qpnp-flash-v2.txt +12 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,18 @@ Optional properties: Allowed values are: 0, 15, 30, 45 for pmicobalt. 0, 20, 40, 60 for pm2falcon. - qcom,thermal-thrsh1 : Integer property to specify OTST1 threshold for thermal mitigation. Unit is in Celsius. Accepted values are: 85, 79, 73, 67, 109, 103, 97, 91. - qcom,thermal-thrsh2 : Integer property to specify OTST2 threshold for thermal mitigation. Unit is in Celsius. Accepted values are: 110, 104, 98, 92, 134, 128, 122, 116. - qcom,thermal-thrsh3 : Integer property to specify OTST3 threshold for thermal mitigation. Unit is in Celsius. Accepted values are: 125, 119, 113, 107, 149, 143, 137, 131. - qcom,hw-strobe-option : Integer type to specify hardware strobe option. Based on the specified value, additional GPIO configuration may be required to provide strobing support. Supported values are: Loading
drivers/leds/leds-qpnp-flash-v2.c +79 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ #define THERMAL_DEBOUNCE_TIME_MAX 64 #define THERMAL_DERATE_HYSTERESIS_MAX 3 #define FLASH_LED_THERMAL_THRSH_MIN 3 #define FLASH_LED_THERMAL_THRSH_MAX 7 #define FLASH_LED_THERMAL_OTST_LEVELS 3 #define FLASH_LED_VLED_MAX_DEFAULT_UV 3500000 #define FLASH_LED_IBATT_OCP_THRESH_DEFAULT_UA 4500000 Loading Loading @@ -219,6 +220,9 @@ struct flash_led_platform_data { int thermal_derate_fast; int thermal_hysteresis; int thermal_debounce; int thermal_thrsh1; int thermal_thrsh2; int thermal_thrsh3; u32 led1n2_iclamp_low_ma; u32 led1n2_iclamp_mid_ma; u32 led3_iclamp_low_ma; Loading Loading @@ -267,6 +271,18 @@ static int thermal_derate_fast_table[] = { 32, 64, 96, 128, 256, 384, 512, }; static int otst1_threshold_table[] = { 85, 79, 73, 67, 109, 103, 97, 91, }; static int otst2_threshold_table[] = { 110, 104, 98, 92, 134, 128, 122, 116, }; static int otst3_threshold_table[] = { 125, 119, 113, 107, 149, 143, 137, 131, }; static int qpnp_flash_led_read(struct qpnp_flash_led *led, u16 addr, u8 *data) { int rc; Loading Loading @@ -416,6 +432,33 @@ static int qpnp_flash_led_init_settings(struct qpnp_flash_led *led) return rc; } if (led->pdata->thermal_thrsh1 >= 0) { rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_THERMAL_THRSH1(led->base), FLASH_LED_THERMAL_THRSH_MASK, led->pdata->thermal_thrsh1); if (rc < 0) return rc; } if (led->pdata->thermal_thrsh2 >= 0) { rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_THERMAL_THRSH2(led->base), FLASH_LED_THERMAL_THRSH_MASK, led->pdata->thermal_thrsh2); if (rc < 0) return rc; } if (led->pdata->thermal_thrsh3 >= 0) { rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_THERMAL_THRSH3(led->base), FLASH_LED_THERMAL_THRSH_MASK, led->pdata->thermal_thrsh3); if (rc < 0) return rc; } rc = qpnp_flash_led_masked_write(led, FLASH_LED_REG_VPH_DROOP_DEBOUNCE(led->base), FLASH_LED_VPH_DROOP_DEBOUNCE_MASK, Loading Loading @@ -1751,6 +1794,42 @@ static int qpnp_flash_led_parse_common_dt(struct qpnp_flash_led *led, return rc; } led->pdata->thermal_thrsh1 = -EINVAL; rc = of_property_read_u32(node, "qcom,thermal-thrsh1", &val); if (!rc) { led->pdata->thermal_thrsh1 = get_code_from_table(otst1_threshold_table, ARRAY_SIZE(otst1_threshold_table), val); } else if (rc != -EINVAL) { dev_err(&led->pdev->dev, "Unable to read thermal thrsh1, rc=%d\n", rc); return rc; } led->pdata->thermal_thrsh2 = -EINVAL; rc = of_property_read_u32(node, "qcom,thermal-thrsh2", &val); if (!rc) { led->pdata->thermal_thrsh2 = get_code_from_table(otst2_threshold_table, ARRAY_SIZE(otst2_threshold_table), val); } else if (rc != -EINVAL) { dev_err(&led->pdev->dev, "Unable to read thermal thrsh2, rc=%d\n", rc); return rc; } led->pdata->thermal_thrsh3 = -EINVAL; rc = of_property_read_u32(node, "qcom,thermal-thrsh3", &val); if (!rc) { led->pdata->thermal_thrsh3 = get_code_from_table(otst3_threshold_table, ARRAY_SIZE(otst3_threshold_table), val); } else if (rc != -EINVAL) { dev_err(&led->pdev->dev, "Unable to read thermal thrsh3, rc=%d\n", rc); return rc; } led->pdata->vph_droop_debounce = FLASH_LED_VPH_DROOP_DEBOUNCE_DEFAULT; rc = of_property_read_u32(node, "qcom,vph-droop-debounce-us", &val); if (!rc) { Loading