14c1184e8SLiam Girdwood /* 24c1184e8SLiam Girdwood * machine.h -- SoC Regulator support, machine/board driver API. 34c1184e8SLiam Girdwood * 44c1184e8SLiam Girdwood * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. 54c1184e8SLiam Girdwood * 61dd68f01SLiam Girdwood * Author: Liam Girdwood <[email protected]> 74c1184e8SLiam Girdwood * 84c1184e8SLiam Girdwood * This program is free software; you can redistribute it and/or modify 94c1184e8SLiam Girdwood * it under the terms of the GNU General Public License version 2 as 104c1184e8SLiam Girdwood * published by the Free Software Foundation. 114c1184e8SLiam Girdwood * 124c1184e8SLiam Girdwood * Regulator Machine/Board Interface. 134c1184e8SLiam Girdwood */ 144c1184e8SLiam Girdwood 154c1184e8SLiam Girdwood #ifndef __LINUX_REGULATOR_MACHINE_H_ 164c1184e8SLiam Girdwood #define __LINUX_REGULATOR_MACHINE_H_ 174c1184e8SLiam Girdwood 184c1184e8SLiam Girdwood #include <linux/regulator/consumer.h> 194c1184e8SLiam Girdwood #include <linux/suspend.h> 204c1184e8SLiam Girdwood 214c1184e8SLiam Girdwood struct regulator; 224c1184e8SLiam Girdwood 234c1184e8SLiam Girdwood /* 244c1184e8SLiam Girdwood * Regulator operation constraint flags. These flags are used to enable 254c1184e8SLiam Girdwood * certain regulator operations and can be OR'ed together. 264c1184e8SLiam Girdwood * 274c1184e8SLiam Girdwood * VOLTAGE: Regulator output voltage can be changed by software on this 284c1184e8SLiam Girdwood * board/machine. 294c1184e8SLiam Girdwood * CURRENT: Regulator output current can be changed by software on this 304c1184e8SLiam Girdwood * board/machine. 314c1184e8SLiam Girdwood * MODE: Regulator operating mode can be changed by software on this 324c1184e8SLiam Girdwood * board/machine. 334c1184e8SLiam Girdwood * STATUS: Regulator can be enabled and disabled. 344c1184e8SLiam Girdwood * DRMS: Dynamic Regulator Mode Switching is enabled for this regulator. 354c1184e8SLiam Girdwood */ 364c1184e8SLiam Girdwood 374c1184e8SLiam Girdwood #define REGULATOR_CHANGE_VOLTAGE 0x1 384c1184e8SLiam Girdwood #define REGULATOR_CHANGE_CURRENT 0x2 394c1184e8SLiam Girdwood #define REGULATOR_CHANGE_MODE 0x4 404c1184e8SLiam Girdwood #define REGULATOR_CHANGE_STATUS 0x8 414c1184e8SLiam Girdwood #define REGULATOR_CHANGE_DRMS 0x10 424c1184e8SLiam Girdwood 434c1184e8SLiam Girdwood /** 444c1184e8SLiam Girdwood * struct regulator_state - regulator state during low power syatem states 454c1184e8SLiam Girdwood * 464c1184e8SLiam Girdwood * This describes a regulators state during a system wide low power state. 47c8e7e464SMark Brown * 48c8e7e464SMark Brown * @uV: Operating voltage during suspend. 49c8e7e464SMark Brown * @mode: Operating mode during suspend. 50c8e7e464SMark Brown * @enabled: Enabled during suspend. 514c1184e8SLiam Girdwood */ 524c1184e8SLiam Girdwood struct regulator_state { 534c1184e8SLiam Girdwood int uV; /* suspend voltage */ 544c1184e8SLiam Girdwood unsigned int mode; /* suspend regulator operating mode */ 554c1184e8SLiam Girdwood int enabled; /* is regulator enabled in this suspend state */ 564c1184e8SLiam Girdwood }; 574c1184e8SLiam Girdwood 584c1184e8SLiam Girdwood /** 594c1184e8SLiam Girdwood * struct regulation_constraints - regulator operating constraints. 604c1184e8SLiam Girdwood * 614c1184e8SLiam Girdwood * This struct describes regulator and board/machine specific constraints. 62c8e7e464SMark Brown * 63c8e7e464SMark Brown * @name: Descriptive name for the constraints, used for display purposes. 64c8e7e464SMark Brown * 65c8e7e464SMark Brown * @min_uV: Smallest voltage consumers may set. 66c8e7e464SMark Brown * @max_uV: Largest voltage consumers may set. 67c8e7e464SMark Brown * 68c8e7e464SMark Brown * @min_uA: Smallest consumers consumers may set. 69c8e7e464SMark Brown * @max_uA: Largest current consumers may set. 70c8e7e464SMark Brown * 71c8e7e464SMark Brown * @valid_modes_mask: Mask of modes which may be configured by consumers. 72c8e7e464SMark Brown * @valid_ops_mask: Operations which may be performed by consumers. 73c8e7e464SMark Brown * 74c8e7e464SMark Brown * @always_on: Set if the regulator should never be disabled. 75c8e7e464SMark Brown * @boot_on: Set if the regulator is enabled when the system is initially 76cacf90f2SMark Brown * started. If the regulator is not enabled by the hardware or 77cacf90f2SMark Brown * bootloader then it will be enabled when the constraints are 78cacf90f2SMark Brown * applied. 79c8e7e464SMark Brown * @apply_uV: Apply the voltage constraint when initialising. 80c8e7e464SMark Brown * 81c8e7e464SMark Brown * @input_uV: Input voltage for regulator when supplied by another regulator. 82c8e7e464SMark Brown * 83c8e7e464SMark Brown * @state_disk: State for regulator when system is suspended in disk mode. 84c8e7e464SMark Brown * @state_mem: State for regulator when system is suspended in mem mode. 85c8e7e464SMark Brown * @state_standby: State for regulator when system is suspended in standby 86c8e7e464SMark Brown * mode. 87c8e7e464SMark Brown * @initial_state: Suspend state to set by default. 88a308466cSMark Brown * @initial_mode: Mode to set at startup. 894c1184e8SLiam Girdwood */ 904c1184e8SLiam Girdwood struct regulation_constraints { 914c1184e8SLiam Girdwood 924c1184e8SLiam Girdwood char *name; 934c1184e8SLiam Girdwood 944c1184e8SLiam Girdwood /* voltage output range (inclusive) - for voltage control */ 954c1184e8SLiam Girdwood int min_uV; 964c1184e8SLiam Girdwood int max_uV; 974c1184e8SLiam Girdwood 984c1184e8SLiam Girdwood /* current output range (inclusive) - for current control */ 994c1184e8SLiam Girdwood int min_uA; 1004c1184e8SLiam Girdwood int max_uA; 1014c1184e8SLiam Girdwood 1024c1184e8SLiam Girdwood /* valid regulator operating modes for this machine */ 1034c1184e8SLiam Girdwood unsigned int valid_modes_mask; 1044c1184e8SLiam Girdwood 1054c1184e8SLiam Girdwood /* valid operations for regulator on this machine */ 1064c1184e8SLiam Girdwood unsigned int valid_ops_mask; 1074c1184e8SLiam Girdwood 1084c1184e8SLiam Girdwood /* regulator input voltage - only if supply is another regulator */ 1094c1184e8SLiam Girdwood int input_uV; 1104c1184e8SLiam Girdwood 1114c1184e8SLiam Girdwood /* regulator suspend states for global PMIC STANDBY/HIBERNATE */ 1124c1184e8SLiam Girdwood struct regulator_state state_disk; 1134c1184e8SLiam Girdwood struct regulator_state state_mem; 1144c1184e8SLiam Girdwood struct regulator_state state_standby; 1154c1184e8SLiam Girdwood suspend_state_t initial_state; /* suspend state to set at init */ 1164c1184e8SLiam Girdwood 117a308466cSMark Brown /* mode to set on startup */ 118a308466cSMark Brown unsigned int initial_mode; 119a308466cSMark Brown 1204c1184e8SLiam Girdwood /* constriant flags */ 1214c1184e8SLiam Girdwood unsigned always_on:1; /* regulator never off when system is on */ 1224c1184e8SLiam Girdwood unsigned boot_on:1; /* bootloader/firmware enabled regulator */ 1234c1184e8SLiam Girdwood unsigned apply_uV:1; /* apply uV constraint iff min == max */ 1244c1184e8SLiam Girdwood }; 1254c1184e8SLiam Girdwood 126a5766f11SLiam Girdwood /** 127a5766f11SLiam Girdwood * struct regulator_consumer_supply - supply -> device mapping 128a5766f11SLiam Girdwood * 12940f9244fSMark Brown * This maps a supply name to a device. Only one of dev or dev_name 13040f9244fSMark Brown * can be specified. Use of dev_name allows support for buses which 13140f9244fSMark Brown * make struct device available late such as I2C and is the preferred 13240f9244fSMark Brown * form. 133c8e7e464SMark Brown * 134c8e7e464SMark Brown * @dev: Device structure for the consumer. 13540f9244fSMark Brown * @dev_name: Result of dev_name() for the consumer. 136c8e7e464SMark Brown * @supply: Name for the supply. 137a5766f11SLiam Girdwood */ 138a5766f11SLiam Girdwood struct regulator_consumer_supply { 139a5766f11SLiam Girdwood struct device *dev; /* consumer */ 14040f9244fSMark Brown const char *dev_name; /* dev_name() for consumer */ 141a5766f11SLiam Girdwood const char *supply; /* consumer supply - e.g. "vcc" */ 142a5766f11SLiam Girdwood }; 1434c1184e8SLiam Girdwood 144a5766f11SLiam Girdwood /** 145a5766f11SLiam Girdwood * struct regulator_init_data - regulator platform initialisation data. 146a5766f11SLiam Girdwood * 147a5766f11SLiam Girdwood * Initialisation constraints, our supply and consumers supplies. 148c8e7e464SMark Brown * 149c8e7e464SMark Brown * @supply_regulator_dev: Parent regulator (if any). 150c8e7e464SMark Brown * 151c8e7e464SMark Brown * @constraints: Constraints. These must be specified for the regulator to 152c8e7e464SMark Brown * be usable. 153c8e7e464SMark Brown * @num_consumer_supplies: Number of consumer device supplies. 154c8e7e464SMark Brown * @consumer_supplies: Consumer device supply configuration. 155c8e7e464SMark Brown * 156c8e7e464SMark Brown * @regulator_init: Callback invoked when the regulator has been registered. 157c8e7e464SMark Brown * @driver_data: Data passed to regulator_init. 158a5766f11SLiam Girdwood */ 159a5766f11SLiam Girdwood struct regulator_init_data { 160a5766f11SLiam Girdwood struct device *supply_regulator_dev; /* or NULL for LINE */ 1614c1184e8SLiam Girdwood 162a5766f11SLiam Girdwood struct regulation_constraints constraints; 1634c1184e8SLiam Girdwood 164a5766f11SLiam Girdwood int num_consumer_supplies; 165a5766f11SLiam Girdwood struct regulator_consumer_supply *consumer_supplies; 166a5766f11SLiam Girdwood 167a5766f11SLiam Girdwood /* optional regulator machine specific init */ 168a5766f11SLiam Girdwood int (*regulator_init)(void *driver_data); 169a5766f11SLiam Girdwood void *driver_data; /* core does not touch this */ 170a5766f11SLiam Girdwood }; 1714c1184e8SLiam Girdwood 1724c1184e8SLiam Girdwood int regulator_suspend_prepare(suspend_state_t state); 1734c1184e8SLiam Girdwood 174*9c19bc04SMark Brown #ifdef CONFIG_REGULATOR 175ca725561SMark Brown void regulator_has_full_constraints(void); 176*9c19bc04SMark Brown #else 177*9c19bc04SMark Brown static inline void regulator_has_full_constraints(void) 178*9c19bc04SMark Brown { 179*9c19bc04SMark Brown } 180*9c19bc04SMark Brown #endif 181ca725561SMark Brown 1824c1184e8SLiam Girdwood #endif 183