diff --git a/drivers/power/supply/qcom/qpnp-smb2.c b/drivers/power/supply/qcom/qpnp-smb2.c index 4f0d85b8e1e6..a1afd1e236b8 100644 --- a/drivers/power/supply/qcom/qpnp-smb2.c +++ b/drivers/power/supply/qcom/qpnp-smb2.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -1660,180 +1659,172 @@ static int smb2_determine_initial_status(struct smb2 *chip) * INTERRUPT REGISTRATION * **************************/ -struct smb2_irq_info { - const char *name; - const irq_handler_t handler; - const bool wake; - const struct storm_watch storm_data; - int irq; -}; - -static struct smb2_irq_info smb2_irqs[] = { +static struct smb_irq_info smb2_irqs[] = { /* CHARGER IRQs */ - { + [CHG_ERROR_IRQ] = { .name = "chg-error", .handler = smblib_handle_debug, }, - { + [CHG_STATE_CHANGE_IRQ] = { .name = "chg-state-change", .handler = smblib_handle_chg_state_change, .wake = true, }, - { + [STEP_CHG_STATE_CHANGE_IRQ] = { .name = "step-chg-state-change", .handler = smblib_handle_step_chg_state_change, .wake = true, }, - { + [STEP_CHG_SOC_UPDATE_FAIL_IRQ] = { .name = "step-chg-soc-update-fail", .handler = smblib_handle_step_chg_soc_update_fail, .wake = true, }, - { + [STEP_CHG_SOC_UPDATE_REQ_IRQ] = { .name = "step-chg-soc-update-request", .handler = smblib_handle_step_chg_soc_update_request, .wake = true, }, /* OTG IRQs */ - { + [OTG_FAIL_IRQ] = { .name = "otg-fail", .handler = smblib_handle_debug, }, - { + [OTG_OVERCURRENT_IRQ] = { .name = "otg-overcurrent", .handler = smblib_handle_otg_overcurrent, }, - { + [OTG_OC_DIS_SW_STS_IRQ] = { .name = "otg-oc-dis-sw-sts", .handler = smblib_handle_debug, }, - { + [TESTMODE_CHANGE_DET_IRQ] = { .name = "testmode-change-detect", .handler = smblib_handle_debug, }, /* BATTERY IRQs */ - { + [BATT_TEMP_IRQ] = { .name = "bat-temp", .handler = smblib_handle_batt_temp_changed, }, - { + [BATT_OCP_IRQ] = { .name = "bat-ocp", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_OV_IRQ] = { .name = "bat-ov", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_LOW_IRQ] = { .name = "bat-low", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_THERM_ID_MISS_IRQ] = { .name = "bat-therm-or-id-missing", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_TERM_MISS_IRQ] = { .name = "bat-terminal-missing", .handler = smblib_handle_batt_psy_changed, }, /* USB INPUT IRQs */ - { + [USBIN_COLLAPSE_IRQ] = { .name = "usbin-collapse", .handler = smblib_handle_debug, }, - { + [USBIN_LT_3P6V_IRQ] = { .name = "usbin-lt-3p6v", .handler = smblib_handle_debug, }, - { + [USBIN_UV_IRQ] = { .name = "usbin-uv", .handler = smblib_handle_debug, }, - { + [USBIN_OV_IRQ] = { .name = "usbin-ov", .handler = smblib_handle_debug, }, - { + [USBIN_PLUGIN_IRQ] = { .name = "usbin-plugin", .handler = smblib_handle_usb_plugin, .wake = true, }, - { + [USBIN_SRC_CHANGE_IRQ] = { .name = "usbin-src-change", .handler = smblib_handle_usb_source_change, .wake = true, }, - { + [USBIN_ICL_CHANGE_IRQ] = { .name = "usbin-icl-change", .handler = smblib_handle_icl_change, .wake = true, }, - { + [TYPE_C_CHANGE_IRQ] = { .name = "type-c-change", .handler = smblib_handle_usb_typec_change, .wake = true, }, /* DC INPUT IRQs */ - { + [DCIN_COLLAPSE_IRQ] = { .name = "dcin-collapse", .handler = smblib_handle_debug, }, - { + [DCIN_LT_3P6V_IRQ] = { .name = "dcin-lt-3p6v", .handler = smblib_handle_debug, }, - { + [DCIN_UV_IRQ] = { .name = "dcin-uv", .handler = smblib_handle_debug, }, - { + [DCIN_OV_IRQ] = { .name = "dcin-ov", .handler = smblib_handle_debug, }, - { + [DCIN_PLUGIN_IRQ] = { .name = "dcin-plugin", .handler = smblib_handle_dc_plugin, .wake = true, }, - { + [DIV2_EN_DG_IRQ] = { .name = "div2-en-dg", .handler = smblib_handle_debug, }, - { + [DCIN_ICL_CHANGE_IRQ] = { .name = "dcin-icl-change", .handler = smblib_handle_debug, }, /* MISCELLANEOUS IRQs */ - { + [WDOG_SNARL_IRQ] = { .name = "wdog-snarl", .handler = NULL, }, - { + [WDOG_BARK_IRQ] = { .name = "wdog-bark", .handler = NULL, }, - { + [AICL_FAIL_IRQ] = { .name = "aicl-fail", .handler = smblib_handle_debug, }, - { + [AICL_DONE_IRQ] = { .name = "aicl-done", .handler = smblib_handle_debug, }, - { + [HIGH_DUTY_CYCLE_IRQ] = { .name = "high-duty-cycle", .handler = smblib_handle_high_duty_cycle, .wake = true, }, - { + [INPUT_CURRENT_LIMIT_IRQ] = { .name = "input-current-limiting", .handler = smblib_handle_debug, }, - { + [TEMPERATURE_CHANGE_IRQ] = { .name = "temperature-change", .handler = smblib_handle_debug, }, - { + [SWITCH_POWER_OK_IRQ] = { .name = "switcher-power-ok", .handler = smblib_handle_switcher_power_ok, .storm_data = {true, 1000, 3}, @@ -1892,6 +1883,7 @@ static int smb2_request_interrupt(struct smb2 *chip, } smb2_irqs[irq_index].irq = irq; + smb2_irqs[irq_index].irq_data = irq_data; if (smb2_irqs[irq_index].wake) enable_irq_wake(irq); @@ -2005,6 +1997,7 @@ static int smb2_probe(struct platform_device *pdev) chg->param = v1_params; chg->debug_mask = &__debug_mask; chg->mode = PARALLEL_MASTER; + chg->irq_info = smb2_irqs; chg->name = "PMI"; chg->regmap = dev_get_regmap(chg->dev->parent, NULL); diff --git a/drivers/power/supply/qcom/smb-lib.h b/drivers/power/supply/qcom/smb-lib.h index 5516f339026f..d7dea7172464 100644 --- a/drivers/power/supply/qcom/smb-lib.h +++ b/drivers/power/supply/qcom/smb-lib.h @@ -13,6 +13,7 @@ #ifndef __SMB2_CHARGER_H #define __SMB2_CHARGER_H #include +#include #include #include #include @@ -79,6 +80,57 @@ enum { TYPEC_CC2_REMOVAL_WA_BIT = BIT(2), }; +enum smb_irq_index { + CHG_ERROR_IRQ = 0, + CHG_STATE_CHANGE_IRQ, + STEP_CHG_STATE_CHANGE_IRQ, + STEP_CHG_SOC_UPDATE_FAIL_IRQ, + STEP_CHG_SOC_UPDATE_REQ_IRQ, + OTG_FAIL_IRQ, + OTG_OVERCURRENT_IRQ, + OTG_OC_DIS_SW_STS_IRQ, + TESTMODE_CHANGE_DET_IRQ, + BATT_TEMP_IRQ, + BATT_OCP_IRQ, + BATT_OV_IRQ, + BATT_LOW_IRQ, + BATT_THERM_ID_MISS_IRQ, + BATT_TERM_MISS_IRQ, + USBIN_COLLAPSE_IRQ, + USBIN_LT_3P6V_IRQ, + USBIN_UV_IRQ, + USBIN_OV_IRQ, + USBIN_PLUGIN_IRQ, + USBIN_SRC_CHANGE_IRQ, + USBIN_ICL_CHANGE_IRQ, + TYPE_C_CHANGE_IRQ, + DCIN_COLLAPSE_IRQ, + DCIN_LT_3P6V_IRQ, + DCIN_UV_IRQ, + DCIN_OV_IRQ, + DCIN_PLUGIN_IRQ, + DIV2_EN_DG_IRQ, + DCIN_ICL_CHANGE_IRQ, + WDOG_SNARL_IRQ, + WDOG_BARK_IRQ, + AICL_FAIL_IRQ, + AICL_DONE_IRQ, + HIGH_DUTY_CYCLE_IRQ, + INPUT_CURRENT_LIMIT_IRQ, + TEMPERATURE_CHANGE_IRQ, + SWITCH_POWER_OK_IRQ, + SMB_IRQ_MAX, +}; + +struct smb_irq_info { + const char *name; + const irq_handler_t handler; + const bool wake; + const struct storm_watch storm_data; + struct smb_irq_data *irq_data; + int irq; +}; + static const unsigned int smblib_extcon_cable[] = { EXTCON_USB, EXTCON_USB_HOST, @@ -167,6 +219,7 @@ struct smb_charger { struct device *dev; char *name; struct regmap *regmap; + struct smb_irq_info *irq_info; struct smb_params param; struct smb_iio iio; int *debug_mask; diff --git a/drivers/power/supply/qcom/smb138x-charger.c b/drivers/power/supply/qcom/smb138x-charger.c index 8f91642db214..554625adda7d 100644 --- a/drivers/power/supply/qcom/smb138x-charger.c +++ b/drivers/power/supply/qcom/smb138x-charger.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -985,171 +984,164 @@ static int smb138x_determine_initial_status(struct smb138x *chip) * INTERRUPT REGISTRATION * **************************/ -struct smb138x_irq_info { - const char *name; - const irq_handler_t handler; - const bool wake; - const struct storm_watch storm_data; -}; - -static const struct smb138x_irq_info smb138x_irqs[] = { +static struct smb_irq_info smb138x_irqs[] = { /* CHARGER IRQs */ - { + [CHG_ERROR_IRQ] = { .name = "chg-error", .handler = smblib_handle_debug, }, - { + [CHG_STATE_CHANGE_IRQ] = { .name = "chg-state-change", .handler = smb138x_handle_slave_chg_state_change, .wake = true, }, - { + [STEP_CHG_STATE_CHANGE_IRQ] = { .name = "step-chg-state-change", .handler = smblib_handle_debug, }, - { + [STEP_CHG_SOC_UPDATE_FAIL_IRQ] = { .name = "step-chg-soc-update-fail", .handler = smblib_handle_debug, }, - { + [STEP_CHG_SOC_UPDATE_REQ_IRQ] = { .name = "step-chg-soc-update-request", .handler = smblib_handle_debug, }, /* OTG IRQs */ - { + [OTG_FAIL_IRQ] = { .name = "otg-fail", .handler = smblib_handle_debug, }, - { + [OTG_OVERCURRENT_IRQ] = { .name = "otg-overcurrent", .handler = smblib_handle_debug, }, - { + [OTG_OC_DIS_SW_STS_IRQ] = { .name = "otg-oc-dis-sw-sts", .handler = smblib_handle_debug, }, - { + [TESTMODE_CHANGE_DET_IRQ] = { .name = "testmode-change-detect", .handler = smblib_handle_debug, }, /* BATTERY IRQs */ - { + [BATT_TEMP_IRQ] = { .name = "bat-temp", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_OCP_IRQ] = { .name = "bat-ocp", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_OV_IRQ] = { .name = "bat-ov", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_LOW_IRQ] = { .name = "bat-low", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_THERM_ID_MISS_IRQ] = { .name = "bat-therm-or-id-missing", .handler = smblib_handle_batt_psy_changed, }, - { + [BATT_TERM_MISS_IRQ] = { .name = "bat-terminal-missing", .handler = smblib_handle_batt_psy_changed, }, /* USB INPUT IRQs */ - { + [USBIN_COLLAPSE_IRQ] = { .name = "usbin-collapse", .handler = smblib_handle_debug, }, - { + [USBIN_LT_3P6V_IRQ] = { .name = "usbin-lt-3p6v", .handler = smblib_handle_debug, }, - { + [USBIN_UV_IRQ] = { .name = "usbin-uv", .handler = smblib_handle_debug, }, - { + [USBIN_OV_IRQ] = { .name = "usbin-ov", .handler = smblib_handle_debug, }, - { + [USBIN_PLUGIN_IRQ] = { .name = "usbin-plugin", .handler = smblib_handle_usb_plugin, }, - { + [USBIN_SRC_CHANGE_IRQ] = { .name = "usbin-src-change", .handler = smblib_handle_usb_source_change, }, - { + [USBIN_ICL_CHANGE_IRQ] = { .name = "usbin-icl-change", .handler = smblib_handle_debug, }, - { + [TYPE_C_CHANGE_IRQ] = { .name = "type-c-change", .handler = smblib_handle_usb_typec_change, }, /* DC INPUT IRQs */ - { + [DCIN_COLLAPSE_IRQ] = { .name = "dcin-collapse", .handler = smblib_handle_debug, }, - { + [DCIN_LT_3P6V_IRQ] = { .name = "dcin-lt-3p6v", .handler = smblib_handle_debug, }, - { + [DCIN_UV_IRQ] = { .name = "dcin-uv", .handler = smblib_handle_debug, }, - { + [DCIN_OV_IRQ] = { .name = "dcin-ov", .handler = smblib_handle_debug, }, - { + [DCIN_PLUGIN_IRQ] = { .name = "dcin-plugin", .handler = smblib_handle_debug, }, - { + [DIV2_EN_DG_IRQ] = { .name = "div2-en-dg", .handler = smblib_handle_debug, }, - { + [DCIN_ICL_CHANGE_IRQ] = { .name = "dcin-icl-change", .handler = smblib_handle_debug, }, /* MISCELLANEOUS IRQs */ - { + [WDOG_SNARL_IRQ] = { .name = "wdog-snarl", .handler = smblib_handle_debug, }, - { + [WDOG_BARK_IRQ] = { .name = "wdog-bark", .handler = smblib_handle_wdog_bark, .wake = true, }, - { + [AICL_FAIL_IRQ] = { .name = "aicl-fail", .handler = smblib_handle_debug, }, - { + [AICL_DONE_IRQ] = { .name = "aicl-done", .handler = smblib_handle_debug, }, - { + [HIGH_DUTY_CYCLE_IRQ] = { .name = "high-duty-cycle", .handler = smblib_handle_debug, }, - { + [INPUT_CURRENT_LIMIT_IRQ] = { .name = "input-current-limiting", .handler = smblib_handle_debug, }, - { + [TEMPERATURE_CHANGE_IRQ] = { .name = "temperature-change", .handler = smb138x_handle_temperature_change, }, - { + [SWITCH_POWER_OK_IRQ] = { .name = "switcher-power-ok", .handler = smblib_handle_debug, }, @@ -1411,6 +1403,7 @@ static int smb138x_probe(struct platform_device *pdev) chip->chg.dev = &pdev->dev; chip->chg.debug_mask = &__debug_mask; + chip->chg.irq_info = smb138x_irqs; chip->chg.name = "SMB"; chip->chg.regmap = dev_get_regmap(chip->chg.dev->parent, NULL);