Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/extres/regulator/regulator.c
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
/* Default regulator methods. */ | /* Default regulator methods. */ | ||||
static int regnode_method_enable(struct regnode *regnode, bool enable, | static int regnode_method_enable(struct regnode *regnode, bool enable, | ||||
int *udelay); | int *udelay); | ||||
static int regnode_method_status(struct regnode *regnode, int *status); | static int regnode_method_status(struct regnode *regnode, int *status); | ||||
static int regnode_method_set_voltage(struct regnode *regnode, int min_uvolt, | static int regnode_method_set_voltage(struct regnode *regnode, int min_uvolt, | ||||
int max_uvolt, int *udelay); | int max_uvolt, int *udelay); | ||||
static int regnode_method_get_voltage(struct regnode *regnode, int *uvolt); | static int regnode_method_get_voltage(struct regnode *regnode, int *uvolt); | ||||
static void regulator_shutdown(void *dummy); | |||||
/* | /* | ||||
* Regulator controller methods. | * Regulator controller methods. | ||||
*/ | */ | ||||
static regnode_method_t regnode_methods[] = { | static regnode_method_t regnode_methods[] = { | ||||
REGNODEMETHOD(regnode_enable, regnode_method_enable), | REGNODEMETHOD(regnode_enable, regnode_method_enable), | ||||
REGNODEMETHOD(regnode_status, regnode_method_status), | REGNODEMETHOD(regnode_status, regnode_method_status), | ||||
REGNODEMETHOD(regnode_set_voltage, regnode_method_set_voltage), | REGNODEMETHOD(regnode_set_voltage, regnode_method_set_voltage), | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
#define REG_TOPO_XLOCK() sx_xlock(®node_topo_lock) | #define REG_TOPO_XLOCK() sx_xlock(®node_topo_lock) | ||||
#define REG_TOPO_UNLOCK() sx_unlock(®node_topo_lock) | #define REG_TOPO_UNLOCK() sx_unlock(®node_topo_lock) | ||||
#define REG_TOPO_ASSERT() sx_assert(®node_topo_lock, SA_LOCKED) | #define REG_TOPO_ASSERT() sx_assert(®node_topo_lock, SA_LOCKED) | ||||
#define REG_TOPO_XASSERT() sx_assert(®node_topo_lock, SA_XLOCKED) | #define REG_TOPO_XASSERT() sx_assert(®node_topo_lock, SA_XLOCKED) | ||||
#define REGNODE_SLOCK(_sc) sx_slock(&((_sc)->lock)) | #define REGNODE_SLOCK(_sc) sx_slock(&((_sc)->lock)) | ||||
#define REGNODE_XLOCK(_sc) sx_xlock(&((_sc)->lock)) | #define REGNODE_XLOCK(_sc) sx_xlock(&((_sc)->lock)) | ||||
#define REGNODE_UNLOCK(_sc) sx_unlock(&((_sc)->lock)) | #define REGNODE_UNLOCK(_sc) sx_unlock(&((_sc)->lock)) | ||||
SYSINIT(regulator_shutdown, SI_SUB_LAST, SI_ORDER_ANY, regulator_shutdown, | |||||
NULL); | |||||
/* | |||||
* Disable unused regulator | |||||
* We run this function at SI_SUB_LAST which mean that every driver that needs | |||||
* regulator should have already enable them. | |||||
* All the remaining regulators should be those left enabled by the bootloader | |||||
* or enable by default by the PMIC. | |||||
*/ | |||||
static void | |||||
regulator_shutdown(void *dummy) | |||||
{ | |||||
struct regnode *entry; | |||||
int disable = 1; | |||||
REG_TOPO_SLOCK(); | |||||
TUNABLE_INT_FETCH("hw.regulator.disable_unused", &disable); | |||||
TAILQ_FOREACH(entry, ®node_list, reglist_link) { | |||||
if (entry->enable_cnt == 0 && | |||||
entry->std_param.always_on == 0 && disable) { | |||||
if (bootverbose) | |||||
printf("regulator: shuting down %s\n", | |||||
entry->name); | |||||
regnode_stop(entry, 0); | |||||
} | |||||
} | |||||
REG_TOPO_UNLOCK(); | |||||
} | |||||
/* | /* | ||||
* sysctl handler | * sysctl handler | ||||
*/ | */ | ||||
static int | static int | ||||
regnode_uvolt_sysctl(SYSCTL_HANDLER_ARGS) | regnode_uvolt_sysctl(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
struct regnode *regnode = arg1; | struct regnode *regnode = arg1; | ||||
▲ Show 20 Lines • Show All 1,000 Lines • Show Last 20 Lines |