]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-bsp/linux/linux-omap/dvfs/0010-OMAP-Voltage-layer-changes-to-support-DVFS.patch
f50aedd9d6138f4e830322716f860cdc840384af
[glsdk/meta-ti-glsdk.git] / recipes-bsp / linux / linux-omap / dvfs / 0010-OMAP-Voltage-layer-changes-to-support-DVFS.patch
1 From 3a9b78f58772645a9e1337454faed4e313e55368 Mon Sep 17 00:00:00 2001
2 From: Thara Gopinath <thara@ti.com>
3 Date: Fri, 29 Oct 2010 20:43:34 +0530
4 Subject: [PATCH 10/19] OMAP: Voltage layer changes to support DVFS.
6 This patch introduces an API to take in the voltage domain and the
7 new voltage as parameter and to scale all the scalable devices
8 associated with the the voltage domain to the rate corresponding to the
9 new voltage and scale the voltage domain to the new voltage.
11 Signed-off-by: Thara Gopinath <thara@ti.com>
12 ---
13  arch/arm/mach-omap2/voltage.c             |   69 +++++++++++++++++++++++++++++
14  arch/arm/plat-omap/include/plat/voltage.h |    7 +++
15  2 files changed, 76 insertions(+), 0 deletions(-)
17 diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
18 index 7381fa6..9adf9d1 100644
19 --- a/arch/arm/mach-omap2/voltage.c
20 +++ b/arch/arm/mach-omap2/voltage.c
21 @@ -27,9 +27,11 @@
22  #include <linux/spinlock.h>
23  #include <linux/plist.h>
24  #include <linux/slab.h>
25 +#include <linux/opp.h>
26  
27  #include <plat/common.h>
28  #include <plat/voltage.h>
29 +#include <plat/omap_device.h>
30  
31  #include "prm-regbits-34xx.h"
32  #include "prm-regbits-44xx.h"
33 @@ -1656,6 +1658,73 @@ struct voltagedomain *omap_voltage_domain_lookup(char *name)
34  }
35  
36  /**
37 + * omap_voltage_scale : API to scale the devices associated with a
38 + *                     voltage domain vdd voltage.
39 + * @volt_domain : the voltage domain to be scaled
40 + * @volt : the new voltage for the voltage domain
41 + *
42 + * This API runs through the list of devices associated with the
43 + * voltage domain and scales the device rates to those corresponding
44 + * to the new voltage of the voltage domain. This API also scales
45 + * the voltage domain voltage to the new value. Returns 0 on success
46 + * else the error value.
47 + */
48 +int omap_voltage_scale(struct voltagedomain *voltdm, unsigned long volt)
49 +{
50 +       unsigned long curr_volt;
51 +       int is_volt_scaled = 0;
52 +       struct omap_vdd_info *vdd;
53 +       struct omap_vdd_dev_list *temp_dev;
54 +
55 +       if (!voltdm || IS_ERR(voltdm)) {
56 +               pr_warning("%s: VDD specified does not exist!\n", __func__);
57 +               return -EINVAL;
58 +       }
59 +
60 +       vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
61 +
62 +       mutex_lock(&vdd->scaling_mutex);
63 +
64 +       curr_volt = omap_voltage_get_nom_volt(voltdm);
65 +
66 +       if (curr_volt == volt) {
67 +               is_volt_scaled = 1;
68 +       } else if (curr_volt < volt) {
69 +               omap_voltage_scale_vdd(voltdm, volt);
70 +               is_volt_scaled = 1;
71 +       }
72 +
73 +       list_for_each_entry(temp_dev, &vdd->dev_list, node) {
74 +               struct device *dev;
75 +               struct opp *opp;
76 +               unsigned long freq;
77 +
78 +               dev = temp_dev->dev;
79 +
80 +               opp = opp_find_voltage(dev, volt);
81 +               if (IS_ERR(opp))
82 +                       continue;
83 +
84 +               freq = opp_get_freq(opp);
85 +
86 +               if (freq == omap_device_get_rate(dev)) {
87 +                       dev_warn(dev, "%s: Already at the requested"
88 +                               "rate %ld\n", __func__, freq);
89 +                       continue;
90 +               }
91 +
92 +               omap_device_set_rate(dev, freq);
93 +       }
94 +
95 +       if (!is_volt_scaled)
96 +               omap_voltage_scale_vdd(voltdm, volt);
97 +
98 +       mutex_unlock(&vdd->scaling_mutex);
99 +
100 +       return 0;
101 +}
103 +/**
104   * omap_voltage_late_init() - Init the various voltage parameters
105   *
106   * This API is to be called in the later stages of the
107 diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h
108 index adbc6af..6782c5e 100644
109 --- a/arch/arm/plat-omap/include/plat/voltage.h
110 +++ b/arch/arm/plat-omap/include/plat/voltage.h
111 @@ -135,6 +135,7 @@ int omap_voltage_late_init(void);
112  int omap_voltage_add_request(struct voltagedomain *voltdm, struct device *dev,
113                 unsigned long *volt);
114  int omap_voltage_add_dev(struct voltagedomain *voltdm, struct device *dev);
115 +int omap_voltage_scale(struct voltagedomain *voltdm, unsigned long volt);
116  #else
117  static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
118                 struct omap_volt_pmic_info *pmic_info) {}
119 @@ -154,6 +155,12 @@ static inline int omap_voltage_add_dev(struct voltagedomain *voltdm,
120  {
121         return -EINVAL;
122  }
124 +static inline int omap_voltage_scale(struct voltagedomain *voltdm,
125 +               unsigned long volt)
126 +{
127 +       return -EINVAL;
128 +}
129  #endif
130  
131  #endif
132 -- 
133 1.6.6.1