Clean up patch dir; synchronize patches with kernel-power v48
[kernel-bfs] / kernel-bfs-2.6.28 / debian / patches / extra / voltage_scaling_1.diff
1 From: Leed Aguilar <leed.aguilar@ti.com>
2 Date: Wed, 7 Oct 2009 00:55:09 +0000 (-0500)
3 Subject: OMAP3: PM: Voltage scaling through VP force update
4 X-Git-Tag: android-2.6.29-1.6-13~25
5 X-Git-Url: http://git.omapzoom.org/?p=kernel%2Fomap.git;a=commitdiff_plain;h=337cafa871baae4699dbd9f2cedb7466e5df1f12
6
7 OMAP3: PM: Voltage scaling through VP force update
8
9 This patch implements the VP forcee update method of voltage
10 scaling as per h/w recommendations. Also adds Kconfig option to
11 choose between the existing vc bypass and vp force update methods
12 voltage scaling
13
14 Signed-off-by: Thara Gopinath <thara@ti.com>
15 Signed-off-by: Leed Aguilar <leed.aguilar@ti.com>
16 ---
17
18 Index: kernel-2.6.28/arch/arm/mach-omap2/pm34xx.c
19 ===================================================================
20 --- kernel-2.6.28.orig/arch/arm/mach-omap2/pm34xx.c
21 +++ kernel-2.6.28/arch/arm/mach-omap2/pm34xx.c
22 @@ -113,6 +113,8 @@ static int ssi_pads_saved;
23  /* Interrupt controller control register offset */
24  #define INTC_CONTROL   0x48
25  
26 +#define VP_TRANXDONE_TIMEOUT   62
27 +
28  struct power_state {
29         struct powerdomain *pwrdm;
30         u32 next_state;
31 @@ -1305,6 +1307,123 @@ int omap3_pm_set_suspend_state(struct po
32         return -EINVAL;
33  }
34  
35 +#ifdef CONFIG_VOLTSCALE_VPFORCE
36 +/* Voltage Scale using vp force update */
37 +static int voltagescale_vpforceupdate(u32 target_opp, u32 current_opp,
38 +                                       u8 target_vsel, u8 current_vsel)
39 +{
40 +       u32 vdd, target_opp_no, current_opp_no;
41 +       u32 t2_smps_delay = 0;
42 +       u32 t2_smps_steps = 0;
43 +       u32 vpconfig, vp_config_offs, vp_tranxdone_st;
44 +       int timeout = 0;
45 +
46 +       vdd = get_vdd(target_opp);
47 +       target_opp_no = get_opp_no(target_opp);
48 +       current_opp_no = get_opp_no(current_opp);
49 +       t2_smps_steps = abs(target_vsel - current_vsel);
50 +
51 +       if (vdd == VDD1_OPP) {
52 +               vp_config_offs = OMAP3_PRM_VP1_CONFIG_OFFSET;
53 +               vp_tranxdone_st = OMAP3430_VP1_TRANXDONE_ST;
54 +               vpconfig = target_vsel << OMAP3430_INITVOLTAGE_SHIFT |
55 +                               ((target_opp_no < VDD1_OPP3)
56 +                               ? PRM_VP1_CONFIG_ERRORGAIN_OPPLOW
57 +                               : PRM_VP1_CONFIG_ERRORGAIN_OPPHIGH);
58 +       } else if (vdd == VDD2_OPP) {
59 +               vp_config_offs = OMAP3_PRM_VP2_CONFIG_OFFSET;
60 +               vp_tranxdone_st = OMAP3430_VP2_TRANXDONE_ST;
61 +               vpconfig = target_vsel << OMAP3430_INITVOLTAGE_SHIFT |
62 +                               ((target_opp_no < VDD2_OPP3)
63 +                               ? PRM_VP2_CONFIG_ERRORGAIN_OPPLOW
64 +                               : PRM_VP2_CONFIG_ERRORGAIN_OPPHIGH);
65 +       }
66 +       /* Clear all pending TransactionDone interrupt/status */
67 +       while (timeout < VP_TRANXDONE_TIMEOUT) {
68 +               prm_write_mod_reg(vp_tranxdone_st, OCP_MOD,
69 +                       OMAP2_PRM_IRQSTATUS_MPU_OFFSET);
70 +               if (!(prm_read_mod_reg(OCP_MOD, OMAP2_PRM_IRQSTATUS_MPU_OFFSET)
71 +                                       & vp_tranxdone_st))
72 +                       break;
73 +
74 +               udelay(1);
75 +               timeout++;
76 +       }
77 +       if (timeout == VP_TRANXDONE_TIMEOUT)
78 +               pr_warning("VP1:TRANXDONE timeout exceeded still\
79 +                       going ahead with voltage changed\n");
80 +
81 +       /* Configuring for vpforceupdate */
82 +       prm_rmw_mod_reg_bits(OMAP3430_ERRORGAIN_MASK |
83 +                       OMAP3430_INITVOLTAGE_MASK | OMAP3430_INITVDD |
84 +                       OMAP3430_FORCEUPDATE, vpconfig, OMAP3430_GR_MOD,
85 +                       vp_config_offs);
86 +       /* Initialize VP voltage */
87 +       prm_set_mod_reg_bits(OMAP3430_INITVDD, OMAP3430_GR_MOD,
88 +                       vp_config_offs);
89 +       /* Force update of voltage */
90 +       prm_set_mod_reg_bits(OMAP3430_FORCEUPDATE, OMAP3430_GR_MOD,
91 +                       vp_config_offs);
92 +       timeout = 0;
93 +       /* Wait for TransactionDone */
94 +       while ((timeout < VP_TRANXDONE_TIMEOUT) &&
95 +                       (!(prm_read_mod_reg(OCP_MOD,
96 +                       OMAP2_PRM_IRQSTATUS_MPU_OFFSET) &
97 +                       vp_tranxdone_st))) {
98 +               udelay(1);
99 +               timeout++;
100 +       }
101 +
102 +       if (timeout == VP_TRANXDONE_TIMEOUT)
103 +               pr_warning("VP1:TRANXDONE timeout exceeded going ahead with\
104 +                        the t2 smps wait\n");
105 +
106 +       /* Wait for voltage to settle with SW wait-loop */
107 +       t2_smps_delay = ((t2_smps_steps * 125) / 40) + 2;
108 +       udelay(t2_smps_delay);
109 +
110 +       timeout = 0;
111 +       /* Clear all pending TransactionDone interrupt/status */
112 +        while (timeout < VP_TRANXDONE_TIMEOUT) {
113 +               prm_write_mod_reg(vp_tranxdone_st, OCP_MOD,
114 +                       OMAP2_PRM_IRQSTATUS_MPU_OFFSET);
115 +               if (!(prm_read_mod_reg(OCP_MOD, OMAP2_PRM_IRQSTATUS_MPU_OFFSET)
116 +                                       & vp_tranxdone_st))
117 +                       break;
118 +
119 +               udelay(1);
120 +               timeout++;
121 +       }
122 +       if (timeout == VP_TRANXDONE_TIMEOUT)
123 +               pr_warning("VP1:TRANXDONE timeout exceeded\n");
124 +
125 +       /* Clear INITVDD bit */
126 +       prm_clear_mod_reg_bits(OMAP3430_INITVDD, OMAP3430_GR_MOD,
127 +                       vp_config_offs);
128 +
129 +       /* Clear force bit */
130 +       prm_clear_mod_reg_bits(OMAP3430_FORCEUPDATE, OMAP3430_GR_MOD,
131 +                       vp_config_offs);
132 +       return 0;
133 +}
134 +#endif
135 +
136 +/* Scale voltage using vcbypass or vpforceupdate */
137 +int omap_scale_voltage(u32 target_opp, u32 current_opp,
138 +                               u8 target_vsel, u8 current_vsel)
139 +{
140 +       #if defined(CONFIG_VOLTSCALE_VPFORCE)
141 +               return voltagescale_vpforceupdate(target_opp, current_opp,
142 +                                       target_vsel, current_vsel);
143 +       #elif defined(CONFIG_OMAP_SMARTREFLEX)
144 +               return sr_voltagescale_vcbypass(target_opp, current_opp,
145 +                                       target_vsel, current_vsel);
146 +       #else
147 +               return 0;
148 +       #endif
149 +}
150 +EXPORT_SYMBOL(omap_scale_voltage);
151 +
152  void omap3_set_prm_setup_times(struct prm_setup_times *setup_times)
153  {
154         prm_setup.clksetup = setup_times->clksetup;
155 Index: kernel-2.6.28/arch/arm/mach-omap2/resource34xx.c
156 ===================================================================
157 --- kernel-2.6.28.orig/arch/arm/mach-omap2/resource34xx.c
158 +++ kernel-2.6.28/arch/arm/mach-omap2/resource34xx.c
159 @@ -287,7 +287,7 @@ static int program_opp(int res, struct o
160                                         current_level);
161  #ifdef CONFIG_OMAP_SMARTREFLEX
162                 else
163 -                       sr_voltagescale_vcbypass(t_opp, c_opp,
164 +                       omap_scale_voltage(t_opp, c_opp,
165                                 opp[target_level].vsel,
166                                 opp[current_level].vsel);
167  #endif
168 Index: kernel-2.6.28/arch/arm/mach-omap2/resource34xx.h
169 ===================================================================
170 --- kernel-2.6.28.orig/arch/arm/mach-omap2/resource34xx.h
171 +++ kernel-2.6.28/arch/arm/mach-omap2/resource34xx.h
172 @@ -28,7 +28,7 @@
173  #include <mach/omap-pm.h>
174  #include "resource34xx_mutex.h"
175  
176 -extern int sr_voltagescale_vcbypass(u32 t_opp, u32 c_opp, u8 t_vsel, u8 c_vsel);
177 +extern int omap_scale_voltage(u32 t_opp, u32 c_opp, u8 t_vsel, u8 c_vsel);
178  
179  /*
180   * mpu_latency/core_latency are used to control the cpuidle C state.
181 Index: kernel-2.6.28/arch/arm/plat-omap/Kconfig
182 ===================================================================
183 --- kernel-2.6.28.orig/arch/arm/plat-omap/Kconfig
184 +++ kernel-2.6.28/arch/arm/plat-omap/Kconfig
185 @@ -299,6 +299,16 @@ config OMAP_PM_SRF
186  
187  endchoice
188  
189 +config VOLTSCALE_VPFORCE
190 +       bool "Voltage scaling using VP force update method"
191 +       depends on ARCH_OMAP3 && PM
192 +       help
193 +        Say Y if you want to enable VP force update method
194 +        of voltage scaling. This is the h/w recomended way
195 +        of voltage scaling.
196 +
197 +        If not enabled and if OMAP_SMARTREFLEX is enabled
198 +        vcbypass method will be used for voltage scaling.
199  endmenu
200  
201  endif