[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-3.0 / pm-wip / voltdm / 0130-OMAP3-VP-struct-omap_vp_common-replace-shift-with-__.patch
1 From 19b2a24927050ee82e6f587ac47f484f1b114a57 Mon Sep 17 00:00:00 2001
2 From: Kevin Hilman <khilman@ti.com>
3 Date: Mon, 4 Apr 2011 16:02:28 -0700
4 Subject: [PATCH 130/149] OMAP3+: VP: struct omap_vp_common: replace shift with __ffs(mask)
6 In struct omap_vp_common, the shift value can be derived from the mask
7 value by using __ffs(), so remove the shift value for the various
8 VPCONFIG bitfields, and use __ffs() in the code for the shift value.
10 While here, rename field names in kerneldoc comment to match actual
11 field names in structure. Also, cleanup indendentaion for other VP
12 register accesses in omap_vp_init().
14 No functional changes.
16 Signed-off-by: Kevin Hilman <khilman@ti.com>
17 ---
18 arch/arm/mach-omap2/vc.c | 2 +-
19 arch/arm/mach-omap2/voltage.c | 2 +-
20 arch/arm/mach-omap2/vp.c | 29 ++++++++++++++---------------
21 arch/arm/mach-omap2/vp.h | 34 ++++++++++++++--------------------
22 arch/arm/mach-omap2/vp3xxx_data.c | 4 +---
23 arch/arm/mach-omap2/vp44xx_data.c | 4 +---
24 6 files changed, 32 insertions(+), 43 deletions(-)
26 diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
27 index 7058585..f64c826 100644
28 --- a/arch/arm/mach-omap2/vc.c
29 +++ b/arch/arm/mach-omap2/vc.c
30 @@ -140,7 +140,7 @@ int omap_vc_pre_scale(struct voltagedomain *voltdm,
31 vdd->vp_rt_data.vpconfig_errorgain = volt_data->vp_errgain;
32 vp_errgain_val &= voltdm->vp->common->vpconfig_errorgain_mask;
33 vp_errgain_val |= vdd->vp_rt_data.vpconfig_errorgain <<
34 - voltdm->vp->common->vpconfig_errorgain_shift;
35 + __ffs(voltdm->vp->common->vpconfig_errorgain_mask);
36 voltdm->write(vp_errgain_val, voltdm->vp->vpconfig);
37 }
39 diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
40 index eaa5f93..5b16fd1 100644
41 --- a/arch/arm/mach-omap2/voltage.c
42 +++ b/arch/arm/mach-omap2/voltage.c
43 @@ -82,7 +82,7 @@ static int __init _config_common_vdd_data(struct voltagedomain *voltdm)
45 vdd->vp_rt_data.vpconfig_erroroffset =
46 (voltdm->pmic->vp_erroroffset <<
47 - voltdm->vp->common->vpconfig_erroroffset_shift);
48 + __ffs(voltdm->vp->common->vpconfig_erroroffset_mask));
50 timeout_val = (sys_clk_speed * voltdm->pmic->vp_timeout_us) / 1000;
51 vdd->vp_rt_data.vlimitto_timeout = timeout_val;
52 diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
53 index c9a315f..297d094 100644
54 --- a/arch/arm/mach-omap2/vp.c
55 +++ b/arch/arm/mach-omap2/vp.c
56 @@ -34,8 +34,7 @@ static void vp_latch_vsel(struct voltagedomain *voltdm)
57 vpconfig = voltdm->read(vp->vpconfig);
58 vpconfig &= ~(vp->common->vpconfig_initvoltage_mask |
59 vp->common->vpconfig_initvdd);
60 - vpconfig |= vsel << vp->common->vpconfig_initvoltage_shift;
61 -
62 + vpconfig |= vsel << __ffs(vp->common->vpconfig_initvoltage_mask);
63 voltdm->write(vpconfig, vp->vpconfig);
65 /* Trigger initVDD value copy to voltage processor */
66 @@ -61,28 +60,28 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
68 vp_val = vdd->vp_rt_data.vpconfig_erroroffset |
69 (vdd->vp_rt_data.vpconfig_errorgain <<
70 - vp->common->vpconfig_errorgain_shift) |
71 + __ffs(vp->common->vpconfig_errorgain_mask)) |
72 vp->common->vpconfig_timeouten;
73 voltdm->write(vp_val, vp->vpconfig);
75 vp_val = ((vdd->vp_rt_data.vstepmin_smpswaittimemin <<
76 - vp->common->vstepmin_smpswaittimemin_shift) |
77 - (vdd->vp_rt_data.vstepmin_stepmin <<
78 - vp->common->vstepmin_stepmin_shift));
79 + vp->common->vstepmin_smpswaittimemin_shift) |
80 + (vdd->vp_rt_data.vstepmin_stepmin <<
81 + vp->common->vstepmin_stepmin_shift));
82 voltdm->write(vp_val, vp->vstepmin);
84 vp_val = ((vdd->vp_rt_data.vstepmax_smpswaittimemax <<
85 - vp->common->vstepmax_smpswaittimemax_shift) |
86 - (vdd->vp_rt_data.vstepmax_stepmax <<
87 - vp->common->vstepmax_stepmax_shift));
88 + vp->common->vstepmax_smpswaittimemax_shift) |
89 + (vdd->vp_rt_data.vstepmax_stepmax <<
90 + vp->common->vstepmax_stepmax_shift));
91 voltdm->write(vp_val, vp->vstepmax);
93 vp_val = ((vdd->vp_rt_data.vlimitto_vddmax <<
94 - vp->common->vlimitto_vddmax_shift) |
95 - (vdd->vp_rt_data.vlimitto_vddmin <<
96 - vp->common->vlimitto_vddmin_shift) |
97 - (vdd->vp_rt_data.vlimitto_timeout <<
98 - vp->common->vlimitto_timeout_shift));
99 + vp->common->vlimitto_vddmax_shift) |
100 + (vdd->vp_rt_data.vlimitto_vddmin <<
101 + vp->common->vlimitto_vddmin_shift) |
102 + (vdd->vp_rt_data.vlimitto_timeout <<
103 + vp->common->vlimitto_timeout_shift));
104 voltdm->write(vp_val, vp->vlimitto);
105 }
107 @@ -121,7 +120,7 @@ int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
108 vp->common->vpconfig_forceupdate |
109 vp->common->vpconfig_initvoltage_mask);
110 vpconfig |= ((target_vsel <<
111 - vp->common->vpconfig_initvoltage_shift));
112 + __ffs(vp->common->vpconfig_initvoltage_mask)));
113 voltdm->write(vpconfig, vp->vpconfig);
115 /* Trigger initVDD value copy to voltage processor */
116 diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
117 index 1d63960..2afe11d 100644
118 --- a/arch/arm/mach-omap2/vp.h
119 +++ b/arch/arm/mach-omap2/vp.h
120 @@ -46,37 +46,32 @@ struct omap_vp_ops {
122 /**
123 * struct omap_vp_common - register data common to all VDDs
124 + * @vpconfig_erroroffset_mask: ERROROFFSET bitmask in the PRM_VP*_CONFIG reg
125 * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg
126 * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg
127 - * @vpconfig_timeouten_mask: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
128 + * @vpconfig_timeouten: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
129 * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg
130 * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg
131 * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg
132 * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg
133 * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg
134 * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg
135 - * @vpconfig_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
136 - * @vpconfig_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
137 - * @vpconfig_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
138 - * @vpconfig_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
139 - * @vpconfig_vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
140 - * @vpconfig_vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
141 - * @vpconfig_vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
142 - *
143 - * XXX It it not necessary to have both a mask and a shift for the same
144 - * bitfield - remove one
145 - * XXX Many of these fields are wrongly named -- e.g., vpconfig_smps* -- fix!
146 + * @vstepmin_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
147 + * @vstepmin_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
148 + * @vstepmax_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
149 + * @vstepmax_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
150 + * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
151 + * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
152 + * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
153 */
154 struct omap_vp_common {
155 + u32 vpconfig_erroroffset_mask;
156 u32 vpconfig_errorgain_mask;
157 u32 vpconfig_initvoltage_mask;
158 - u32 vpconfig_timeouten;
159 - u32 vpconfig_initvdd;
160 - u32 vpconfig_forceupdate;
161 - u32 vpconfig_vpenable;
162 - u8 vpconfig_erroroffset_shift;
163 - u8 vpconfig_errorgain_shift;
164 - u8 vpconfig_initvoltage_shift;
165 + u8 vpconfig_timeouten;
166 + u8 vpconfig_initvdd;
167 + u8 vpconfig_forceupdate;
168 + u8 vpconfig_vpenable;
169 u8 vstepmin_stepmin_shift;
170 u8 vstepmin_smpswaittimemin_shift;
171 u8 vstepmax_stepmax_shift;
172 @@ -127,7 +122,6 @@ struct omap_vp_instance {
173 * XXX Is this structure really needed? Why not just program the
174 * device directly? They are in PRM space, therefore in the WKUP
175 * powerdomain, so register contents should not be lost in off-mode.
176 - * XXX Some of these fields are incorrectly named, e.g., vstep*
177 */
178 struct omap_vp_runtime_data {
179 u32 vpconfig_erroroffset;
180 diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c
181 index 79c3df9..d429c44 100644
182 --- a/arch/arm/mach-omap2/vp3xxx_data.c
183 +++ b/arch/arm/mach-omap2/vp3xxx_data.c
184 @@ -37,10 +37,8 @@ static const struct omap_vp_ops omap3_vp_ops = {
185 * XXX This stuff presumably belongs in the vp3xxx.c or vp.c file.
186 */
187 static const struct omap_vp_common omap3_vp_common = {
188 - .vpconfig_erroroffset_shift = OMAP3430_ERROROFFSET_SHIFT,
189 + .vpconfig_erroroffset_mask = OMAP3430_ERROROFFSET_MASK,
190 .vpconfig_errorgain_mask = OMAP3430_ERRORGAIN_MASK,
191 - .vpconfig_errorgain_shift = OMAP3430_ERRORGAIN_SHIFT,
192 - .vpconfig_initvoltage_shift = OMAP3430_INITVOLTAGE_SHIFT,
193 .vpconfig_initvoltage_mask = OMAP3430_INITVOLTAGE_MASK,
194 .vpconfig_timeouten = OMAP3430_TIMEOUTEN_MASK,
195 .vpconfig_initvdd = OMAP3430_INITVDD_MASK,
196 diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c
197 index 8f75cd9..0daf2a4 100644
198 --- a/arch/arm/mach-omap2/vp44xx_data.c
199 +++ b/arch/arm/mach-omap2/vp44xx_data.c
200 @@ -37,10 +37,8 @@ static const struct omap_vp_ops omap4_vp_ops = {
201 * XXX This stuff presumably belongs in the vp44xx.c or vp.c file.
202 */
203 static const struct omap_vp_common omap4_vp_common = {
204 - .vpconfig_erroroffset_shift = OMAP4430_ERROROFFSET_SHIFT,
205 + .vpconfig_erroroffset_mask = OMAP4430_ERROROFFSET_MASK,
206 .vpconfig_errorgain_mask = OMAP4430_ERRORGAIN_MASK,
207 - .vpconfig_errorgain_shift = OMAP4430_ERRORGAIN_SHIFT,
208 - .vpconfig_initvoltage_shift = OMAP4430_INITVOLTAGE_SHIFT,
209 .vpconfig_initvoltage_mask = OMAP4430_INITVOLTAGE_MASK,
210 .vpconfig_timeouten = OMAP4430_TIMEOUTEN_MASK,
211 .vpconfig_initvdd = OMAP4430_INITVDD_MASK,
212 --
213 1.7.2.5