Skip to content
Snippets Groups Projects
Commit ad98f882 authored by Wadim Egorov's avatar Wadim Egorov Committed by Philipp Tomsich
Browse files

power: regulator: rk8xx: Allow input current/charger shutdown configuration


The RK818 PMIC contains a charger. Add very basic charger functionality
to be able to regulate the USB input current and charger shutdown limits.

Signed-off-by: default avatarWadim Egorov <w.egorov@phytec.de>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
Acked-by: default avatarPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: default avatarPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
parent 8926c2f5
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#define RK818_LDO_VSEL_MASK 0x1f #define RK818_LDO_VSEL_MASK 0x1f
#define RK818_LDO3_ON_VSEL_MASK 0xf #define RK818_LDO3_ON_VSEL_MASK 0xf
#define RK818_BOOST_ON_VSEL_MASK 0xe0 #define RK818_BOOST_ON_VSEL_MASK 0xe0
#define RK818_USB_ILIM_SEL_MASK 0x0f
#define RK818_USB_CHG_SD_VSEL_MASK 0x70
struct rk8xx_reg_info { struct rk8xx_reg_info {
uint min_uv; uint min_uv;
...@@ -76,6 +79,14 @@ static const struct rk8xx_reg_info rk818_ldo[] = { ...@@ -76,6 +79,14 @@ static const struct rk8xx_reg_info rk818_ldo[] = {
}; };
#endif #endif
static const u16 rk818_chrg_cur_input_array[] = {
450, 800, 850, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000
};
static const uint rk818_chrg_shutdown_vsel_array[] = {
2780000, 2850000, 2920000, 2990000, 3060000, 3130000, 3190000, 3260000
};
static const struct rk8xx_reg_info *get_buck_reg(struct udevice *pmic, static const struct rk8xx_reg_info *get_buck_reg(struct udevice *pmic,
int num) int num)
{ {
...@@ -353,3 +364,26 @@ int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt) ...@@ -353,3 +364,26 @@ int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt)
return _buck_set_enable(pmic, buck, true); return _buck_set_enable(pmic, buck, true);
} }
int rk818_spl_configure_usb_input_current(struct udevice *pmic, int current_ma)
{
uint i;
for (i = 0; i < ARRAY_SIZE(rk818_chrg_cur_input_array); i++)
if (current_ma <= rk818_chrg_cur_input_array[i])
break;
return pmic_clrsetbits(pmic, REG_USB_CTRL, RK818_USB_ILIM_SEL_MASK, i);
}
int rk818_spl_configure_usb_chrg_shutdown(struct udevice *pmic, int uvolt)
{
uint i;
for (i = 0; i < ARRAY_SIZE(rk818_chrg_shutdown_vsel_array); i++)
if (uvolt <= rk818_chrg_shutdown_vsel_array[i])
break;
return pmic_clrsetbits(pmic, REG_USB_CTRL, RK818_USB_CHG_SD_VSEL_MASK,
i);
}
...@@ -189,5 +189,7 @@ struct rk8xx_priv { ...@@ -189,5 +189,7 @@ struct rk8xx_priv {
}; };
int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt); int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt);
int rk818_spl_configure_usb_input_current(struct udevice *pmic, int current_ma);
int rk818_spl_configure_usb_chrg_shutdown(struct udevice *pmic, int uvolt);
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment