Skip to content

Commit

Permalink
drivers: adp536x: Add buck discharge resistor configuration
Browse files Browse the repository at this point in the history
This patch adds buck discharge resistor configuration
functionality to the ADP536x driver.

Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
  • Loading branch information
jtguggedal committed Apr 8, 2019
1 parent a4200e5 commit 4e9dfc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/adp536x/adp536x.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define ADP536X_CHG_STATUS_2 0x09
#define ADP536X_BAT_PROTECT_CTRL 0x11
#define ADP536X_BAT_OC_CHG 0x15
#define ADP536X_BUCK_CFG 0x29
#define ADP536X_BUCK_OUTPUT 0x2A
#define ADP536X_BUCKBST_CFG 0x2B
#define ADP536X_BUCKBST_OUTPUT 0x2C
Expand Down Expand Up @@ -112,6 +113,10 @@
#define ADP536X_BAT_OC_CHG_DGT_OC_CHG_MSK GENMASK(4, 3)
#define ADP536X_BAT_OC_CHG_DGT_OC_CHG(x) (((x) & 0x03) << 3)

/* Buck configure register. */
#define ADP536X_BUCK_CFG_DISCHG_BUCK_MSK BIT(1)
#define ADP536X_BUCK_CFG_DISCHG_BUCK(x) (((x) & 0x01) << 1)

/* Buck output voltage setting register. */
#define ADP536X_BUCK_OUTPUT_VOUT_BUCK_MSK GENMASK(5, 0)
#define ADP536X_BUCK_OUTPUT_VOUT_BUCK(x) (((x) & 0x3F) << 0)
Expand Down Expand Up @@ -239,6 +244,13 @@ int adp536x_buck_1v8_set(void)
ADP536X_BUCK_OUTPUT_VOUT_BUCK(value));
}

int adp536x_buck_discharge_set(bool enable)
{
return adp536x_reg_write_mask(ADP536X_BUCK_CFG,
ADP536X_BUCK_CFG_DISCHG_BUCK_MSK,
ADP536X_BUCK_CFG_DISCHG_BUCK(enable));
}

int adp536x_buckbst_3v3_set(void)
{
/* 3.3V equals to 0b10011 = 0x13, according to ADP536X datasheet. */
Expand Down
1 change: 1 addition & 0 deletions include/drivers/adp536x.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ int adp536x_buck_1v8_set(void);
int adp536x_buckbst_3v3_set(void);
int adp536x_factory_reset(void);
int adp536x_oc_chg_current_set(u8_t value);
int adp536x_buck_discharge_set(bool enable);

0 comments on commit 4e9dfc5

Please sign in to comment.