1
0
Fork 0

regulator: stpmic1: Add active discharge support

Add support for active discharge for USB power switches.

Signed-off-by: pascal paillet <p.paillet@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
hifive-unleashed-5.1
Pascal PAILLET-LME 2019-02-19 10:04:35 +00:00 committed by Mark Brown
parent 714a74f13e
commit e6fff62ab8
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 55 additions and 13 deletions

View File

@ -176,11 +176,19 @@ static const struct regulator_ops stpmic1_vref_ddr_ops = {
.disable = regulator_disable_regmap,
};
static const struct regulator_ops stpmic1_boost_regul_ops = {
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.set_over_current_protection = stpmic1_set_icc,
};
static const struct regulator_ops stpmic1_switch_regul_ops = {
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.set_over_current_protection = stpmic1_set_icc,
.set_active_discharge = regulator_set_active_discharge_regmap,
};
#define REG_LDO(ids, base) { \
@ -281,7 +289,24 @@ static const struct regulator_ops stpmic1_switch_regul_ops = {
.supply_name = #base, \
}
#define REG_SWITCH(ids, base, reg, mask, val) { \
#define REG_BOOST(ids, base) { \
.name = #ids, \
.id = STPMIC1_##ids, \
.n_voltages = 1, \
.ops = &stpmic1_boost_regul_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = 0, \
.fixed_uV = 5000000, \
.enable_reg = BST_SW_CR, \
.enable_mask = BOOST_ENABLED, \
.enable_val = BOOST_ENABLED, \
.disable_val = 0, \
.enable_time = PMIC_ENABLE_TIME_US, \
.supply_name = #base, \
}
#define REG_VBUS_OTG(ids, base) { \
.name = #ids, \
.id = STPMIC1_##ids, \
.n_voltages = 1, \
@ -290,12 +315,35 @@ static const struct regulator_ops stpmic1_switch_regul_ops = {
.owner = THIS_MODULE, \
.min_uV = 0, \
.fixed_uV = 5000000, \
.enable_reg = (reg), \
.enable_mask = (mask), \
.enable_val = (val), \
.enable_reg = BST_SW_CR, \
.enable_mask = USBSW_OTG_SWITCH_ENABLED, \
.enable_val = USBSW_OTG_SWITCH_ENABLED, \
.disable_val = 0, \
.enable_time = PMIC_ENABLE_TIME_US, \
.supply_name = #base, \
.active_discharge_reg = BST_SW_CR, \
.active_discharge_mask = VBUS_OTG_DISCHARGE, \
.active_discharge_on = VBUS_OTG_DISCHARGE, \
}
#define REG_SW_OUT(ids, base) { \
.name = #ids, \
.id = STPMIC1_##ids, \
.n_voltages = 1, \
.ops = &stpmic1_switch_regul_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = 0, \
.fixed_uV = 5000000, \
.enable_reg = BST_SW_CR, \
.enable_mask = SWIN_SWOUT_ENABLED, \
.enable_val = SWIN_SWOUT_ENABLED, \
.disable_val = 0, \
.enable_time = PMIC_ENABLE_TIME_US, \
.supply_name = #base, \
.active_discharge_reg = BST_SW_CR, \
.active_discharge_mask = SW_OUT_DISCHARGE, \
.active_discharge_on = SW_OUT_DISCHARGE, \
}
static const struct stpmic1_regulator_cfg stpmic1_regulator_cfgs[] = {
@ -375,23 +423,17 @@ static const struct stpmic1_regulator_cfg stpmic1_regulator_cfgs[] = {
.mask_reset_mask = BIT(6),
},
[STPMIC1_BOOST] = {
.desc = REG_SWITCH(BOOST, boost, BST_SW_CR,
BOOST_ENABLED,
BOOST_ENABLED),
.desc = REG_BOOST(BOOST, boost),
.icc_reg = BUCKS_ICCTO_CR,
.icc_mask = BIT(6),
},
[STPMIC1_VBUS_OTG] = {
.desc = REG_SWITCH(VBUS_OTG, pwr_sw1, BST_SW_CR,
USBSW_OTG_SWITCH_ENABLED,
USBSW_OTG_SWITCH_ENABLED),
.desc = REG_VBUS_OTG(VBUS_OTG, pwr_sw1),
.icc_reg = BUCKS_ICCTO_CR,
.icc_mask = BIT(4),
},
[STPMIC1_SW_OUT] = {
.desc = REG_SWITCH(SW_OUT, pwr_sw2, BST_SW_CR,
SWIN_SWOUT_ENABLED,
SWIN_SWOUT_ENABLED),
.desc = REG_SW_OUT(SW_OUT, pwr_sw2),
.icc_reg = BUCKS_ICCTO_CR,
.icc_mask = BIT(5),
},