/**
* struct regulator_desc - Regulator descriptor
*
* Each regulator registered with the core is described with a structure of
* this type.
*
* @name: Identifying name for the regulator.
* @id: Numerical identifier for the regulator.
* @n_voltages: Number of selectors available for ops.list_voltage().
* @ops: Regulator operations table.
* @irq: Interrupt number for the regulator.
* @type: Indicates if the regulator is a voltage or current regulator.
* @owner: Module providing the regulator, used for refcounting.
*/
struct regulator_desc {
const char *name;
int id;
unsigned n_voltages;
struct regulator_ops *ops;
int irq;
enum regulator_type type;
struct module *owner;
};
enum regulator_status {
REGULATOR_STATUS_OFF,
REGULATOR_STATUS_ON,
REGULATOR_STATUS_ERROR,
/* fast/normal/idle/standby are flavors of "on" */
REGULATOR_STATUS_FAST,
REGULATOR_STATUS_NORMAL,
REGULATOR_STATUS_IDLE,
REGULATOR_STATUS_STANDBY,
};
/*
* struct regulator_dev
*
* Voltage / Current regulator class device. On
e for each regulator.
*/
struct regulator_dev {
struct regulator_desc *desc;
int use_count;
/* lists we belong to */
struct list_head list; /* list of all regulators */
struct list_head slist; /* list of supplied regulators */
/* lists we own */
struct list_head consumer_list; /* consumers we supply */
struct list_head supply_list; /* regulators we supply */
struct blocking_notifier_head notifier;
struct mutex mutex; /* consumer lock */
struct module *owner;
struct device dev;
struct regulation_constraints *constraints;
struct regulator_dev *supply;
/* for tree */
void *reg_da
ta;
/* regulator_dev da
ta */
};
/*
* struct regulator
*
* On
e for each consumer device.
*/
struct regulator {
struct device *dev;
struct list_head list;
int uA_load;
int min_uV;
int max_uV;
int enabled; /* count of client enables */
char *supply_name;
struct device_attribute dev_attr;
struct regulator_dev *rdev;
};
/*
* struct regulator_map
*
* Used to provide symbolic supply names to devices.
*/
struct regulator_map {
struct list_head list;
struct device *dev;
const char *supply;
struct regulator_dev *regulator;
};
/**
* struct regulator_state - regulator state during low power syatem states
*
* This describes a regulators state during a system wide low power state.
*
* @uV: Operating voltage during suspend.
* @mode: Operating mode during suspend.
* @enabled: Enabled during suspend.
*/
struct regulator_state {
int uV;
/* suspend voltage */
unsigned int mode; /* suspend regulator operating mode */
int enabled; /* is regulator enabled in this suspend state */
};
/**
* struct regulation_constraints - regulator operating constraints.
*
* This struct describes regulator and board/machine specific constraints.
*
* @name: Descriptive name for the constraints, used for display purposes.
*
* @min_uV: Smallest voltage consumers may set.
* @max_uV: Largest voltage consumers may set.
*
* @min_uA: Smallest consumers consumers may set.
* @max_uA: Largest current consumers may set.
*
* @valid_modes_mask: Mask of modes which may be configured by consumers.
* @valid_ops_mask: Operations which may be performed by consumers.
*
* @always_on: Set if the regulator should never be disabled.
* @boot_on: Set if the regulator is enabled when the system is initially
* started.
* @apply_uV: Apply the voltage constraint when initialising.
*
* @input_uV: Input voltage for regulator when supplied by another regulator.
*
* @state_disk: State for regulator when system is suspended in disk mode.
* @state_mem: State for regulator when system is suspended in mem mode.
* @state_standby: State for regulator when system is suspended in standby
* mode.
* @initial_state: Suspend state to set by default.
*/
struct regulation_constraints {
char *name;
/* voltage output range (inclusive) - for voltage control */
int min_uV;
int max_uV;
/* current output range (inclusive) - for current control */
int min_uA;
int max_uA;
/* valid regulator operating modes for this machine */
unsigned int valid_modes_mask;
/* valid operations for regulator on this machine */
unsigned int valid_ops_mask;
/* regulator input voltage - on
ly if supply is another regulator */
int input_uV;
/* regulator suspend states for global PMIC STANDBY/HIBERNATE */
struct regulator_state state_disk;
struct regulator_state state_mem;
struct regulator_state state_standby;
suspend_state_t initial_state; /* suspend state to set at init */
/* constriant flags */
unsigned always_on:1;
/* regulator never off when system is on */
unsigned boot_on:1;
/* bootloader/firmware enabled regulator */
unsigned apply_uV:1;
/* apply uV constraint iff min == max */
};
/**
* struct regulator_consumer_supply - supply -> device mapping
*
* This maps a supply name to a device.
*
* @dev: Device structure for the consumer.
* @supply: Name for the supply.
*/
struct regulator_consumer_supply {
struct device *dev;
/* consumer */
const char *supply;
/* consumer supply - e.g. "vcc" */
};
/**
* struct regulator_desc - Regulator descriptor
*
* Each regulator registered with the core is described with a structure of
* this type.
*
* @name: Identifying name for the regulator.
* @id: Numerical identifier for the regulator.
* @n_voltages: Number of selectors available for ops.list_voltage().
* @ops: Regulator operations table.
* @irq: Interrupt number for the regulator.
* @type: Indicates if the regulator is a voltage or current regulator.
* @owner: Module providing the regulator, used for refcounting.
*/
struct regulator_desc {
const char *name;
int id;
unsigned n_voltages;
struct regulator_ops *ops;
int irq;
enum regulator_type type;
struct module *owner;
};
/**
* struct regulator_init_da
ta - regulator platform initialisation da
ta.
*
* Initialisation constraints, our supply and consumers supplies.
*
* @supply_regulator_dev: Parent regulator (if any).
*
* @constraints: Constraints. These must be specified for the regulator to
* be usable.
* @num_consumer_supplies: Number of consumer device supplies.
* @consumer_supplies: Consumer device supply configuration.
*
* @regulator_init: Callback invoked when the regulator has been registered.
* @driver_da
ta: Da
ta passed to regulator_init.
*/
struct regulator_init_da
ta {
struct device *supply_regulator_dev; /* or NULL for LINE */
struct regulation_constraints constraints;
int num_consumer_supplies;
struct regulator_consumer_supply *consumer_supplies;
/* optional regulator machine specific init */
int (*regulator_init)(void *driver_da
ta);
void *driver_da
ta;
/* core does not touch this */
};
/*
* Regulator operation constraint flags. These flags are used to enable
* certain regulator operations and can be OR'ed together.
*
* VOLTAGE: Regulator output voltage can be changed by software on this
* board/machine.
* CURRENT: Regulator output current can be changed by software on this
* board/machine.
* MODE: Regulator operating mode can be changed by software on this
* board/machine.
* STATUS: Regulator can be enabled and disabled.
* DRMS: Dynamic Regulator Mode Switching is enabled for this regulator.
*/
#define REGULATOR_CHANGE_VOLTAGE
0x1
#define REGULATOR_CHANGE_CURRENT
0x2
#define REGULATOR_CHANGE_MODE
0x4
#define REGULATOR_CHANGE_STATUS
0x8
#define REGULATOR_CHANGE_DRMS
0x10
/*
* Regulator operating modes.
*
* Regulators can run in a variety of different operating modes depending on
* output load. This allows further system power savings by selecting the
* best (and most efficient) regulator mode for a desired load.
*
* Most drivers will on
ly care about NORMAL. The modes below are generic and
* will probably not match the naming convention of your regulator da
ta sheet
* but should match the use cases in the datasheet.
*
* In order of power efficiency (least efficient at top).
*
* Mode Description
* FAST Regulator can handle fast changes in it's load.
* e.g. useful in CPU voltage & frequency scaling where
* load can quickly increase with CPU frequency increases.
*
* NORMAL Normal regulator power supply mode. Most drivers will
* use this mode.
*
* IDLE Regulator runs in a more efficient mode for light
* loads. Can be used for devices that have a low power
* requirement during periods of inactivity. This mode
* may be more noisy than NORMAL and may not be able
* to handle fast load switching.
*
* STANDBY Regulator runs in the most efficient mode for very
* light loads. Can be used by devices when they are
* in a sleep/standby state. This mode is likely to be
* the most noisy and may not be able to handle fast load
* switching.
*
* NOTE: Most regulators will on
ly support a subset of these modes. Some
* will on
ly just support NORMAL.
*
* These modes can be OR'ed together to make up a mask of valid register modes.
*/
#define REGULATOR_MODE_FAST
0x1
#define REGULATOR_MODE_NORMAL
0x2
#define REGULATOR_MODE_IDLE
0x4
#define REGULATOR_MODE_STANDBY
0x8