regulator: add support for changing control mode of regulator
[linux-2.6.git] / include / linux / regulator / consumer.h
index df6c4bc..109ac78 100644 (file)
@@ -2,6 +2,7 @@
  * consumer.h -- SoC Regulator consumer support.
  *
  * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
+ * Copyright (C) 2012 NVIDIA Corporation
  *
  * Author: Liam Girdwood <lrg@slimlogic.co.uk>
  *
@@ -35,6 +36,9 @@
 #ifndef __LINUX_REGULATOR_CONSUMER_H_
 #define __LINUX_REGULATOR_CONSUMER_H_
 
+struct device;
+struct notifier_block;
+
 /*
  * Regulator operating modes.
  *
 #define REGULATOR_MODE_STANDBY                 0x8
 
 /*
+ * Regulator control modes.
+ *
+ * Regulators can be control through i2c or PWM or any other interface.
+ * The control mode provides the way to control the regulator.
+ *
+ *  Mode       Description
+ *  I2C        Regulator can be control through I2C interface.
+ *  PWM        Regulator can be control through PWM interface.
+ */
+#define REGULATOR_CONTROL_MODE_I2C             0x1
+#define REGULATOR_CONTROL_MODE_PWM             0x2
+
+/*
  * Regulator notifier events.
  *
  * UNDER_VOLTAGE  Regulator output is under voltage.
  * REGULATION_OUT Regulator output is out of regulation.
  * FAIL           Regulator output has failed.
  * OVER_TEMP      Regulator over temp.
- * FORCE_DISABLE  Regulator shut down by software.
+ * FORCE_DISABLE  Regulator forcibly shut down by software.
  * VOLTAGE_CHANGE Regulator voltage changed.
+ * DISABLE        Regulator was disabled.
+ * PRE_ENABLE     Regulator is to be enabled
+ * POST_ENABLE    Regulator was enabled
+ * OUT_PRECHANGE  Regulator is enabled and its voltage is to be changed
+ * OUT_POSTCHANGE Regulator is enabled and its voltage was changed
  *
  * NOTE: These events can be OR'ed together when passed into handler.
  */
 #define REGULATOR_EVENT_OVER_TEMP              0x10
 #define REGULATOR_EVENT_FORCE_DISABLE          0x20
 #define REGULATOR_EVENT_VOLTAGE_CHANGE         0x40
+#define REGULATOR_EVENT_DISABLE                0x80
+#define REGULATOR_EVENT_PRE_ENABLE             0x100
+#define REGULATOR_EVENT_POST_ENABLE            0x200
+#define REGULATOR_EVENT_OUT_PRECHANGE          0x400
+#define REGULATOR_EVENT_OUT_POSTCHANGE         0x800
 
 struct regulator;
 
@@ -118,6 +145,9 @@ struct regulator;
 struct regulator_bulk_data {
        const char *supply;
        struct regulator *consumer;
+
+       /* private: Internal use */
+       int ret;
 };
 
 #if defined(CONFIG_REGULATOR)
@@ -125,25 +155,42 @@ struct regulator_bulk_data {
 /* regulator get and put */
 struct regulator *__must_check regulator_get(struct device *dev,
                                             const char *id);
+struct regulator *__must_check devm_regulator_get(struct device *dev,
+                                            const char *id);
+struct regulator *__must_check regulator_get_exclusive(struct device *dev,
+                                                      const char *id);
 void regulator_put(struct regulator *regulator);
+void devm_regulator_put(struct regulator *regulator);
 
 /* regulator output control and status */
 int regulator_enable(struct regulator *regulator);
 int regulator_disable(struct regulator *regulator);
 int regulator_force_disable(struct regulator *regulator);
 int regulator_is_enabled(struct regulator *regulator);
+int regulator_disable_deferred(struct regulator *regulator, int ms);
 
 int regulator_bulk_get(struct device *dev, int num_consumers,
                       struct regulator_bulk_data *consumers);
+int devm_regulator_bulk_get(struct device *dev, int num_consumers,
+                           struct regulator_bulk_data *consumers);
 int regulator_bulk_enable(int num_consumers,
                          struct regulator_bulk_data *consumers);
 int regulator_bulk_disable(int num_consumers,
                           struct regulator_bulk_data *consumers);
+int regulator_bulk_force_disable(int num_consumers,
+                          struct regulator_bulk_data *consumers);
 void regulator_bulk_free(int num_consumers,
                         struct regulator_bulk_data *consumers);
 
+int regulator_count_voltages(struct regulator *regulator);
+int regulator_list_voltage(struct regulator *regulator, unsigned selector);
+int regulator_is_supported_voltage(struct regulator *regulator,
+                                  int min_uV, int max_uV);
 int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
+int regulator_set_voltage_time(struct regulator *regulator,
+                              int old_uV, int new_uV);
 int regulator_get_voltage(struct regulator *regulator);
+int regulator_sync_voltage(struct regulator *regulator);
 int regulator_set_current_limit(struct regulator *regulator,
                               int min_uA, int max_uA);
 int regulator_get_current_limit(struct regulator *regulator);
@@ -152,6 +199,9 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode);
 unsigned int regulator_get_mode(struct regulator *regulator);
 int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);
 
+int regulator_set_control_mode(struct regulator *regulator, unsigned int mode);
+unsigned int regulator_get_control_mode(struct regulator *regulator);
+
 /* regulator notifier block */
 int regulator_register_notifier(struct regulator *regulator,
                              struct notifier_block *nb);
@@ -173,14 +223,36 @@ static inline struct regulator *__must_check regulator_get(struct device *dev,
 {
        /* Nothing except the stubbed out regulator API should be
         * looking at the value except to check if it is an error
-        * value so the actual return value doesn't matter.
+        * value. Drivers are free to handle NULL specifically by
+        * skipping all regulator API calls, but they don't have to.
+        * Drivers which don't, should make sure they properly handle
+        * corner cases of the API, such as regulator_get_voltage()
+        * returning 0.
         */
-       return (struct regulator *)id;
+       return NULL;
+}
+
+static inline struct regulator *__must_check regulator_get_exclusive(
+               struct device *dev, const char *id)
+{
+       /* See comment for regulator_get() stub, above */
+       return NULL;
+}
+
+static inline struct regulator *__must_check
+devm_regulator_get(struct device *dev, const char *id)
+{
+       return NULL;
 }
+
 static inline void regulator_put(struct regulator *regulator)
 {
 }
 
+static inline void devm_regulator_put(struct regulator *regulator)
+{
+}
+
 static inline int regulator_enable(struct regulator *regulator)
 {
        return 0;
@@ -191,6 +263,22 @@ static inline int regulator_disable(struct regulator *regulator)
        return 0;
 }
 
+static inline int regulator_force_disable(struct regulator *regulator)
+{
+       return 0;
+}
+
+static inline int regulator_disable_deferred(struct regulator *regulator,
+                                            int ms)
+{
+       return 0;
+}
+
+static inline int regulator_force_disable(struct regulator *regulator)
+{
+       return 0;
+}
+
 static inline int regulator_is_enabled(struct regulator *regulator)
 {
        return 1;
@@ -203,6 +291,12 @@ static inline int regulator_bulk_get(struct device *dev,
        return 0;
 }
 
+static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
+                                         struct regulator_bulk_data *consumers)
+{
+       return 0;
+}
+
 static inline int regulator_bulk_enable(int num_consumers,
                                        struct regulator_bulk_data *consumers)
 {
@@ -215,22 +309,56 @@ static inline int regulator_bulk_disable(int num_consumers,
        return 0;
 }
 
+static inline int regulator_bulk_force_disable(int num_consumers,
+                                       struct regulator_bulk_data *consumers)
+{
+       return 0;
+}
+
 static inline void regulator_bulk_free(int num_consumers,
                                       struct regulator_bulk_data *consumers)
 {
 }
 
+static inline int regulator_count_voltages(struct regulator *regulator)
+{
+       return 0;
+}
+
+static inline int regulator_list_voltage(struct regulator *regulator,
+                                        unsigned selector)
+{
+       return 0;
+}
+
+static inline int regulator_is_supported_voltage(struct regulator *regulator,
+                                                int min_uV, int max_uV)
+{
+       return 0;
+}
+
 static inline int regulator_set_voltage(struct regulator *regulator,
                                        int min_uV, int max_uV)
 {
        return 0;
 }
 
+static inline int regulator_set_voltage_time(struct regulator *regulator,
+                                            int old_uV, int new_uV)
+{
+       return 0;
+}
+
 static inline int regulator_get_voltage(struct regulator *regulator)
 {
        return 0;
 }
 
+static inline int regulator_sync_voltage(struct regulator *regulator)
+{
+       return 0;
+}
+
 static inline int regulator_set_current_limit(struct regulator *regulator,
                                             int min_uA, int max_uA)
 {
@@ -259,6 +387,18 @@ static inline int regulator_set_optimum_mode(struct regulator *regulator,
        return REGULATOR_MODE_NORMAL;
 }
 
+static inline int regulator_set_control_mode(struct regulator *regulator,
+               unsigned int mode)
+{
+       return 0;
+}
+
+static inline unsigned int regulator_get_control_mode(
+               struct regulator *regulator)
+{
+       return REGULATOR_CONTROL_MODE_I2C;
+}
+
 static inline int regulator_register_notifier(struct regulator *regulator,
                              struct notifier_block *nb)
 {