@@ -76,6 +76,8 @@ struct omap_opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
struct omap_opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
+struct omap_opp *opp_find_voltage(struct device *dev, unsigned long volt);
+
int opp_add(const struct omap_opp_def *opp_def);
int opp_enable(struct omap_opp *opp);
@@ -119,6 +121,12 @@ static inline struct omap_opp *opp_find_freq_ceil(struct omap_opp *oppl,
return ERR_PTR(-EINVAL);
}
+static inline struct omap_opp *opp_find_voltage(struct device *dev,
+ unsigned long volt)
+{
+ return ERR_PTR(-EINVAL);
+}
+
static inline struct omap_opp *opp_add(struct omap_opp *oppl,
const struct omap_opp_def *opp_def)
{
@@ -290,6 +290,34 @@ struct omap_opp *opp_find_freq_floor(struct device *dev, unsigned long *freq)
return opp;
}
+/**
+ * opp_find_voltage() - search for an exact voltage
+ * @dev: device pointer associated with the opp type
+ * @volt: voltage to search for
+ *
+ * Searches for exact match in the opp list and returns handle to the matching
+ * opp if found, else returns ERR_PTR in case of error and should be handled
+ * using IS_ERR.
+ */
+struct omap_opp *opp_find_voltage(struct device *dev, unsigned long volt)
+{
+ struct device_opp *dev_opp;
+ struct omap_opp *temp_opp, *opp = ERR_PTR(-ENODEV);
+
+ dev_opp = find_device_opp(dev);
+ if (IS_ERR(dev_opp))
+ return opp;
+
+ list_for_each_entry(temp_opp, &dev_opp->opp_list, node) {
+ if (temp_opp->enabled && temp_opp->u_volt == volt) {
+ opp = temp_opp;
+ break;
+ }
+ }
+
+ return opp;
+}
+
/* wrapper to reuse converting opp_def to opp struct */
static void omap_opp_populate(struct omap_opp *opp,
const struct omap_opp_def *opp_def)