b7ea04a3c17babb427aa91d7032cfa6a113c6e96
[openembedded.git] /
1 From 717bd73868e57fde49a25104af9bb8b9c6400b67 Mon Sep 17 00:00:00 2001
2 From: Thara Gopinath <thara@ti.com>
3 Date: Fri, 29 Oct 2010 20:43:10 +0530
4 Subject: [PATCH 07/19] OMAP: Introduce API in the OPP layer to find the opp entry corresponding to a voltage.
5
6 This patch adds an API in the opp layer to get the opp table entry
7 corresponding to the voltage passed as the parameter.
8
9 Signed-off-by: Thara Gopinath <thara@ti.com>
10 ---
11  drivers/base/power/opp.c |   28 ++++++++++++++++++++++++++++
12  include/linux/opp.h      |    8 ++++++++
13  2 files changed, 36 insertions(+), 0 deletions(-)
14
15 diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
16 index 2bb9b4c..60b4478 100644
17 --- a/drivers/base/power/opp.c
18 +++ b/drivers/base/power/opp.c
19 @@ -354,6 +354,34 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq)
20  }
21  
22  /**
23 + * opp_find_voltage() - search for an exact voltage
24 + * @dev:       device pointer associated with the opp type
25 + * @volt:      voltage to search for
26 + *
27 + * Searches for exact match in the opp list and returns handle to the matching
28 + * opp if found, else returns ERR_PTR in case of error and should be handled
29 + * using IS_ERR.
30 + */
31 +struct opp *opp_find_voltage(struct device *dev, unsigned long volt)
32 +{
33 +       struct device_opp *dev_opp;
34 +       struct opp *temp_opp, *opp = ERR_PTR(-ENODEV);
35 +
36 +       dev_opp = find_device_opp(dev);
37 +       if (IS_ERR(dev_opp))
38 +               return opp;
39 +
40 +       list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) {
41 +               if (temp_opp->available && temp_opp->u_volt == volt) {
42 +                       opp = temp_opp;
43 +                       break;
44 +               }
45 +       }
46 +
47 +       return opp;
48 +}
49 +
50 +/**
51   * opp_add()  - Add an OPP table from a table definitions
52   * @dev:       device for which we do this operation
53   * @freq:      Frequency in Hz for this OPP
54 diff --git a/include/linux/opp.h b/include/linux/opp.h
55 index 5449945..4977d5c 100644
56 --- a/include/linux/opp.h
57 +++ b/include/linux/opp.h
58 @@ -34,6 +34,8 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
59  
60  struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
61  
62 +struct opp *opp_find_voltage(struct device *dev, unsigned long volt);
63 +
64  int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
65  
66  int opp_enable(struct device *dev, unsigned long freq);
67 @@ -74,6 +76,12 @@ static inline struct opp *opp_find_freq_ceil(struct device *dev,
68         return ERR_PTR(-EINVAL);
69  }
70  
71 +static inline struct opp *opp_find_voltage(struct device *dev,
72 +                                               unsigned long volt)
73 +{
74 +       return ERR_PTR(-EINVAL);
75 +}
76 +
77  static inline int opp_add(struct device *dev, unsigned long freq,
78                                         unsigned long u_volt)
79  {
80 -- 
81 1.6.6.1
82