Skip to content

Commit

Permalink
CHROMIUM: regulator: max8973: Add DT support for ctrl1/2 fields
Browse files Browse the repository at this point in the history
Add DT support for multiple existing fields in control1/control2 so
that they can be configured directly.

BUG=chrome-os-partner:46124
TEST=check out the values of control1 and control2 fields

Change-Id: If0da658c7982b095012388d3ad9945fc0c68cb8d
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/306081
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
  • Loading branch information
Rhyland Klein authored and chrome-bot committed Oct 19, 2015
1 parent a350036 commit 1635ade
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ Optional properties:
-maxim,enable-high-etr-sensitivity: boolean, Enhanced transient response
circuit is enabled and set for high sensitivity. If this
property is available then etr will be enable default.
-maxim,pull-down-enable: boolean, enable pull-down to disable discharge
-maxim,disable-junction-temp: boolean, disable junction temperature interrupt
-maxim,inductor-value: Set inductor value. Values defined in max8973.h.
possible options: nominal, minus_30, plus_30, plus 60
-maxim,watchdog-timer-enable: boolean, I2C watchdog timer enable. default is
disabled

Enhanced transient response (ETR) will affect the configuration of CKADV.

Expand Down
45 changes: 45 additions & 0 deletions drivers/regulator/max8973-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include <linux/interrupt.h>
#include <linux/gpio/consumer.h>

#include "dt-bindings/regulator/max8973.h"

/* Register definitions */
#define MAX8973_VOUT 0x0
#define MAX8973_VOUT_DVS 0x1
Expand Down Expand Up @@ -415,9 +417,21 @@ static int max8973_init_dcdc(struct max8973_chip *max,
if (pdata->control_flags & MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE)
control1 |= MAX8973_FREQSHIFT_9PER;

/*
* Always set BIT(7) of control2 on MAX77621
*/
if (max->id == MAX77621)
control2 |= BIT(7);

if (!(pdata->control_flags & MAX8973_CONTROL_PULL_DOWN_ENABLE))
control2 |= MAX8973_DISCH_ENBABLE;

if (pdata->control_flags & MAX8973_CONTROL_WATCHDOG_TIMER)
control2 |= MAX8973_WDTMR_ENABLE;

if (pdata->control_flags & MAX8973_CONTROL_JUNCTION_TEMP_DISABLE)
control2 |= MAX8973_FT_ENABLE;

/* Clock advance trip configuration */
switch (pdata->control_flags & MAX8973_CONTROL_CLKADV_TRIP_MASK) {
case MAX8973_CONTROL_CLKADV_TRIP_DISABLED:
Expand Down Expand Up @@ -649,6 +663,37 @@ static struct max8973_regulator_platform_data *max8973_parse_dt(
pdata->control_flags |= MAX8973_CONTROL_CLKADV_TRIP_DISABLED;
}

if (of_property_read_bool(np, "maxim,pull-down-enable"))
pdata->control_flags |= MAX8973_CONTROL_PULL_DOWN_ENABLE;

if (of_property_read_bool(np, "maxim,disable-junction-temp"))
pdata->control_flags |= MAX8973_CONTROL_JUNCTION_TEMP_DISABLE;

ret = of_property_read_u32(np, "maxim,inductor-value", &pval);
if (!ret) {
switch (pval) {
case MAX8973_INDUCTOR_VAL_NONIMAL:
pdata->control_flags |=
MAX8973_CONTROL_INDUCTOR_VALUE_NOMINAL;
break;
case MAX8973_INDUCTOR_VAL_MINUS_30_PER:
pdata->control_flags |=
MAX8973_CONTROL_INDUCTOR_VALUE_MINUS_30_PER;
break;
case MAX8973_INDUCTOR_VAL_PLUS_30_PER:
pdata->control_flags |=
MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_30_PER;
break;
case MAX8973_INDUCTOR_VAL_PLUS_60_PER:
pdata->control_flags |=
MAX8973_CONTROL_INDUCTOR_VALUE_PLUS_60_PER;
break;
}
}

if (of_property_read_bool(np, "maxim,watchdog-timer-enable"))
pdata->control_flags |= MAX8973_CONTROL_WATCHDOG_TIMER;

return pdata;
}

Expand Down
14 changes: 14 additions & 0 deletions include/dt-bindings/regulator/max8973.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This header provides constants for binding max8973.
*/

#ifndef _DT_BINDINGS_REGULATOR_MAX8973_H
#define _DT_BINDINGS_REGULATOR_MAX8973_H

/* Inductor Values */
#define MAX8973_INDUCTOR_VAL_NONIMAL 0
#define MAX8973_INDUCTOR_VAL_MINUS_30_PER 1
#define MAX8973_INDUCTOR_VAL_PLUS_30_PER 2
#define MAX8973_INDUCTOR_VAL_PLUS_60_PER 3

#endif
2 changes: 2 additions & 0 deletions include/linux/regulator/max8973-regulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#define MAX8973_CONTROL_BIAS_ENABLE 0x00000008
#define MAX8973_CONTROL_PULL_DOWN_ENABLE 0x00000010
#define MAX8973_CONTROL_FREQ_SHIFT_9PER_ENABLE 0x00000020
#define MAX8973_CONTROL_WATCHDOG_TIMER 0x00000040
#define MAX8973_CONTROL_JUNCTION_TEMP_DISABLE 0x00000080

#define MAX8973_CONTROL_CLKADV_TRIP_DISABLED 0x00000000
#define MAX8973_CONTROL_CLKADV_TRIP_75mV_PER_US 0x00010000
Expand Down

0 comments on commit 1635ade

Please sign in to comment.