Re: [RFC PATCH 06/11] DT: regulator: Helper routine to extract fixed_voltage_config

2011-09-16 Thread Rajendra Nayak

On Thursday 15 September 2011 07:20 PM, Mark Brown wrote:

On Thu, Sep 15, 2011 at 04:52:02PM +0530, Rajendra Nayak wrote:


  .../devicetree/bindings/regulator/regulator.txt|   19 
  drivers/of/of_regulator.c  |   31 
  include/linux/of_regulator.h   |7 
  3 files changed, 57 insertions(+), 0 deletions(-)


Again, this should be part of the regulator API code not hidden away
where it will only get reviewed by device tree people.


Ok, will do.




  Required properties:
  - compatible: Must be regulator;
+or
+- compatible: Must be regulator-fixed; /* For Fixed volatge regulator */


This seems at best confusing - the fixed voltage regulator is a
particular regulator driver, and the general concept of a fixed voltage
regulator is still a subset of regulators.


Yeah, I will be defining the compatible based on the different regulator
types, fixed being one of them.
so they would be something like
- compatible: Must be regulator-twl for twl regulators
- compatible: Must be regulator-fixed for fixed regulators




+# For fixed voltage regulators
+- supply-name: Name of the regulator supply
+- microvolts: Output voltage of regulator
+- gpio: gpio to use for enable control
+- startup-delay: startup time in microseconds
+- enable-high: Polarity of enable GPIO, 1 = Active High, 0 = Active low
+- enabled-at-boot: 1 = yes, 0 = no


Much of this is specific to the Linux fixed voltage regulator driver
rather than a generic regulator with a fixed voltage.


So how should these non-generic things be handled through device
tree? Should they never be part of dt or should the bindings just be
defined such that its clear they are linux specific?

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 06/11] DT: regulator: Helper routine to extract fixed_voltage_config

2011-09-16 Thread Mark Brown
On Fri, Sep 16, 2011 at 12:49:17PM +0530, Rajendra Nayak wrote:
 On Thursday 15 September 2011 07:20 PM, Mark Brown wrote:
 On Thu, Sep 15, 2011 at 04:52:02PM +0530, Rajendra Nayak wrote:

 +# For fixed voltage regulators
 +- supply-name: Name of the regulator supply
 +- microvolts: Output voltage of regulator
 +- gpio: gpio to use for enable control
 +- startup-delay: startup time in microseconds
 +- enable-high: Polarity of enable GPIO, 1 = Active High, 0 = Active low
 +- enabled-at-boot: 1 = yes, 0 = no

 Much of this is specific to the Linux fixed voltage regulator driver
 rather than a generic regulator with a fixed voltage.

 So how should these non-generic things be handled through device
 tree? Should they never be part of dt or should the bindings just be
 defined such that its clear they are linux specific?

Having them be part of the fixed voltage regulator bindings would be
fine, the problem is that you're adding this in framework code not in a
driver.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 06/11] DT: regulator: Helper routine to extract fixed_voltage_config

2011-09-16 Thread Rajendra Nayak

On Friday 16 September 2011 02:31 PM, Mark Brown wrote:

On Fri, Sep 16, 2011 at 12:49:17PM +0530, Rajendra Nayak wrote:

On Thursday 15 September 2011 07:20 PM, Mark Brown wrote:

On Thu, Sep 15, 2011 at 04:52:02PM +0530, Rajendra Nayak wrote:



+# For fixed voltage regulators
+- supply-name: Name of the regulator supply
+- microvolts: Output voltage of regulator
+- gpio: gpio to use for enable control
+- startup-delay: startup time in microseconds
+- enable-high: Polarity of enable GPIO, 1 = Active High, 0 = Active low
+- enabled-at-boot: 1 = yes, 0 = no



Much of this is specific to the Linux fixed voltage regulator driver
rather than a generic regulator with a fixed voltage.



So how should these non-generic things be handled through device
tree? Should they never be part of dt or should the bindings just be
defined such that its clear they are linux specific?


Having them be part of the fixed voltage regulator bindings would be
fine, the problem is that you're adding this in framework code not in a
driver.


agree, will make the bindings fixed voltage regulator specific.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 06/11] DT: regulator: Helper routine to extract fixed_voltage_config

2011-09-15 Thread Rajendra Nayak
The helper routine defined here (of_get_fixed_voltage_config) can
be used to extract information about fixed regulators (which are not
software controlable) from device tree.

Add documenation about additional bindings for fixed
regulators that can be passed through DT.

Signed-off-by: Rajendra Nayak rna...@ti.com
---
 .../devicetree/bindings/regulator/regulator.txt|   19 
 drivers/of/of_regulator.c  |   31 
 include/linux/of_regulator.h   |7 
 3 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt 
b/Documentation/devicetree/bindings/regulator/regulator.txt
index 001e5ce..f8c51d8 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -2,6 +2,8 @@ Voltage/Current Regulators
 
 Required properties:
 - compatible: Must be regulator;
+or
+- compatible: Must be regulator-fixed; /* For Fixed volatge regulator */
 
 Optional properties:
 - supply-regulator: Name of the parent regulator
@@ -24,6 +26,13 @@ Optional properties:
 - always-on: boolean, regulator should never be disabled
 - boot-on: bootloader/firmware enabled regulator
 - apply-uV: apply uV constraint if min == max
+# For fixed voltage regulators
+- supply-name: Name of the regulator supply
+- microvolts: Output voltage of regulator
+- gpio: gpio to use for enable control
+- startup-delay: startup time in microseconds
+- enable-high: Polarity of enable GPIO, 1 = Active High, 0 = Active low
+- enabled-at-boot: 1 = yes, 0 = no
 
 Example:
 
@@ -35,3 +44,13 @@ Example:
change-voltage;
always-on;
};
+
+   abc-fixedregulator {
+   compatible = regulator-fixed;
+   supply-name = fixed-supply;
+   microvolts = 180;
+   gpio = 43;
+   startup-delay = 7;
+   enable-high;
+   enabled-at-boot;
+   };
diff --git a/drivers/of/of_regulator.c b/drivers/of/of_regulator.c
index f01d275..4d7a49d 100644
--- a/drivers/of/of_regulator.c
+++ b/drivers/of/of_regulator.c
@@ -13,6 +13,7 @@
 #include linux/slab.h
 #include linux/of.h
 #include linux/regulator/machine.h
+#include linux/regulator/fixed.h
 
 static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data)
@@ -83,3 +84,33 @@ struct regulator_init_data 
*of_get_regulator_init_data(struct device_node *np)
return init_data;
 }
 EXPORT_SYMBOL(of_get_regulator_init_data);
+
+/**
+ * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
+ * @np: Pointer to fixed-regulator device tree node
+ *
+ * Populates fixed_voltage_config structure by extracting data from device
+ * tree node, returns a pointer to the populated structure of NULL if memory
+ * alloc fails.
+ */
+struct fixed_voltage_config *of_get_fixed_voltage_config(struct device_node 
*np)
+{
+   struct fixed_voltage_config *config;
+
+   config = kzalloc(sizeof(struct fixed_voltage_config), GFP_KERNEL);
+   if (!config)
+   return NULL;
+
+   config-supply_name = (char *)of_get_property(np, supply-name, NULL);
+   of_property_read_u32(np, microvolts, config-microvolts);
+   of_property_read_u32(np, gpio, config-gpio);
+   of_property_read_u32(np, startup-delay, config-startup_delay);
+   if (of_find_property(np, enable-high, NULL))
+   config-enable_high = true;
+   if (of_find_property(np, enabled-at-boot, NULL))
+   config-enabled_at_boot = true;
+   config-init_data = of_get_regulator_init_data(np);
+
+   return config;
+}
+EXPORT_SYMBOL(of_get_fixed_voltage_config);
diff --git a/include/linux/of_regulator.h b/include/linux/of_regulator.h
index 5eb048c..39860c5 100644
--- a/include/linux/of_regulator.h
+++ b/include/linux/of_regulator.h
@@ -11,12 +11,19 @@
 #if defined(CONFIG_OF_REGULATOR)
 extern struct regulator_init_data
*of_get_regulator_init_data(struct device_node *np);
+extern struct fixed_voltage_config
+   *of_get_fixed_voltage_config(struct device_node *np);
 #else
 static inline struct regulator_init_data
*of_get_regulator_init_data(struct device_node *np)
 {
return NULL;
 }
+static inline struct fixed_voltage_config
+   *of_get_fixed_voltage_config(struct device_node *np)
+{
+   return NULL;
+}
 #endif /* CONFIG_OF_REGULATOR */
 
 #endif /* __LINUX_OF_REG_H */
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 06/11] DT: regulator: Helper routine to extract fixed_voltage_config

2011-09-15 Thread Mark Brown
On Thu, Sep 15, 2011 at 04:52:02PM +0530, Rajendra Nayak wrote:

  .../devicetree/bindings/regulator/regulator.txt|   19 
  drivers/of/of_regulator.c  |   31 
 
  include/linux/of_regulator.h   |7 
  3 files changed, 57 insertions(+), 0 deletions(-)

Again, this should be part of the regulator API code not hidden away
where it will only get reviewed by device tree people.

  Required properties:
  - compatible: Must be regulator;
 +or
 +- compatible: Must be regulator-fixed; /* For Fixed volatge regulator */

This seems at best confusing - the fixed voltage regulator is a
particular regulator driver, and the general concept of a fixed voltage
regulator is still a subset of regulators.

 +# For fixed voltage regulators
 +- supply-name: Name of the regulator supply
 +- microvolts: Output voltage of regulator
 +- gpio: gpio to use for enable control
 +- startup-delay: startup time in microseconds
 +- enable-high: Polarity of enable GPIO, 1 = Active High, 0 = Active low
 +- enabled-at-boot: 1 = yes, 0 = no

Much of this is specific to the Linux fixed voltage regulator driver
rather than a generic regulator with a fixed voltage.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 06/11] DT: regulator: Helper routine to extract fixed_voltage_config

2011-09-15 Thread Grant Likely
On Thu, Sep 15, 2011 at 04:52:02PM +0530, Rajendra Nayak wrote:
 The helper routine defined here (of_get_fixed_voltage_config) can
 be used to extract information about fixed regulators (which are not
 software controlable) from device tree.
 
 Add documenation about additional bindings for fixed
 regulators that can be passed through DT.
 
 Signed-off-by: Rajendra Nayak rna...@ti.com
 ---
  .../devicetree/bindings/regulator/regulator.txt|   19 
  drivers/of/of_regulator.c  |   31 
 
  include/linux/of_regulator.h   |7 
  3 files changed, 57 insertions(+), 0 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt 
 b/Documentation/devicetree/bindings/regulator/regulator.txt
 index 001e5ce..f8c51d8 100644
 --- a/Documentation/devicetree/bindings/regulator/regulator.txt
 +++ b/Documentation/devicetree/bindings/regulator/regulator.txt
 @@ -2,6 +2,8 @@ Voltage/Current Regulators
  
  Required properties:
  - compatible: Must be regulator;
 +or
 +- compatible: Must be regulator-fixed; /* For Fixed volatge regulator */

regulator-fixed should actually just be another driver binding that
uses the regulator binding.

  
  Optional properties:
  - supply-regulator: Name of the parent regulator
 @@ -24,6 +26,13 @@ Optional properties:
  - always-on: boolean, regulator should never be disabled
  - boot-on: bootloader/firmware enabled regulator
  - apply-uV: apply uV constraint if min == max
 +# For fixed voltage regulators
 +- supply-name: Name of the regulator supply
 +- microvolts: Output voltage of regulator
 +- gpio: gpio to use for enable control
 +- startup-delay: startup time in microseconds
 +- enable-high: Polarity of enable GPIO, 1 = Active High, 0 = Active low
 +- enabled-at-boot: 1 = yes, 0 = no
  
  Example:
  
 @@ -35,3 +44,13 @@ Example:
   change-voltage;
   always-on;
   };
 +
 + abc-fixedregulator {
 + compatible = regulator-fixed;
 + supply-name = fixed-supply;
 + microvolts = 180;
 + gpio = 43;
 + startup-delay = 7;
 + enable-high;
 + enabled-at-boot;
 + };
 diff --git a/drivers/of/of_regulator.c b/drivers/of/of_regulator.c
 index f01d275..4d7a49d 100644
 --- a/drivers/of/of_regulator.c
 +++ b/drivers/of/of_regulator.c
 @@ -13,6 +13,7 @@
  #include linux/slab.h
  #include linux/of.h
  #include linux/regulator/machine.h
 +#include linux/regulator/fixed.h
  
  static void of_get_regulation_constraints(struct device_node *np,
   struct regulator_init_data **init_data)
 @@ -83,3 +84,33 @@ struct regulator_init_data 
 *of_get_regulator_init_data(struct device_node *np)
   return init_data;
  }
  EXPORT_SYMBOL(of_get_regulator_init_data);
 +
 +/**
 + * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
 + * @np: Pointer to fixed-regulator device tree node
 + *
 + * Populates fixed_voltage_config structure by extracting data from device
 + * tree node, returns a pointer to the populated structure of NULL if memory
 + * alloc fails.
 + */
 +struct fixed_voltage_config *of_get_fixed_voltage_config(struct device_node 
 *np)
 +{
 + struct fixed_voltage_config *config;
 +
 + config = kzalloc(sizeof(struct fixed_voltage_config), GFP_KERNEL);
 + if (!config)
 + return NULL;
 +
 + config-supply_name = (char *)of_get_property(np, supply-name, NULL);
 + of_property_read_u32(np, microvolts, config-microvolts);
 + of_property_read_u32(np, gpio, config-gpio);
 + of_property_read_u32(np, startup-delay, config-startup_delay);
 + if (of_find_property(np, enable-high, NULL))
 + config-enable_high = true;
 + if (of_find_property(np, enabled-at-boot, NULL))
 + config-enabled_at_boot = true;
 + config-init_data = of_get_regulator_init_data(np);
 +
 + return config;
 +}
 +EXPORT_SYMBOL(of_get_fixed_voltage_config);
 diff --git a/include/linux/of_regulator.h b/include/linux/of_regulator.h
 index 5eb048c..39860c5 100644
 --- a/include/linux/of_regulator.h
 +++ b/include/linux/of_regulator.h
 @@ -11,12 +11,19 @@
  #if defined(CONFIG_OF_REGULATOR)
  extern struct regulator_init_data
   *of_get_regulator_init_data(struct device_node *np);
 +extern struct fixed_voltage_config
 + *of_get_fixed_voltage_config(struct device_node *np);
  #else
  static inline struct regulator_init_data
   *of_get_regulator_init_data(struct device_node *np)
  {
   return NULL;
  }
 +static inline struct fixed_voltage_config
 + *of_get_fixed_voltage_config(struct device_node *np)
 +{
 + return NULL;
 +}
  #endif /* CONFIG_OF_REGULATOR */
  
  #endif /* __LINUX_OF_REG_H */
 -- 
 1.7.1
 
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at