diff options
author | Kevin Hilman <khilman@ti.com> | 2011-03-30 19:36:30 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2011-09-15 15:08:58 -0400 |
commit | f5395480f5088a86cc8594d29b5c2f07f6995c3d (patch) | |
tree | 85b13fd9a57214de3d59f6dbf4a3702f7873cc6e /arch/arm/mach-omap2/vc.c | |
parent | ce8ebe0dfb1f8713337cebf82499d3dced288328 (diff) |
OMAP3+: VC: make I2C config programmable with PMIC-specific settings
Remove hard-coded I2C configuration in favor of settings that can be
configured from PMIC-specific values. Currently only high-speed mode
and the master-code value are supported, since they were the only
fields currently used, but extending this is now trivial.
Thanks to Nishanth Menon <nm@ti.com> for reporting/fixing a sparse
problem and making omap_vc_i2c_init() static, as well as finding and
fixing a problem with the shift/mask of mcode.
Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/vc.c')
-rw-r--r-- | arch/arm/mach-omap2/vc.c | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 4ac761440d62..5d545632388d 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c | |||
@@ -208,13 +208,6 @@ static void __init omap3_vc_init_channel(struct voltagedomain *voltdm) | |||
208 | if (is_initialized) | 208 | if (is_initialized) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | /* | ||
212 | * Generic VC parameters init | ||
213 | * XXX This data should be abstracted out | ||
214 | */ | ||
215 | voltdm->write(OMAP3430_MCODE_SHIFT | OMAP3430_HSEN_MASK, | ||
216 | OMAP3_PRM_VC_I2C_CFG_OFFSET); | ||
217 | |||
218 | omap3_vfsm_init(voltdm); | 211 | omap3_vfsm_init(voltdm); |
219 | 212 | ||
220 | is_initialized = true; | 213 | is_initialized = true; |
@@ -237,6 +230,48 @@ static void __init omap4_vc_init_channel(struct voltagedomain *voltdm) | |||
237 | is_initialized = true; | 230 | is_initialized = true; |
238 | } | 231 | } |
239 | 232 | ||
233 | /** | ||
234 | * omap_vc_i2c_init - initialize I2C interface to PMIC | ||
235 | * @voltdm: voltage domain containing VC data | ||
236 | * | ||
237 | * Use PMIC supplied seetings for I2C high-speed mode and | ||
238 | * master code (if set) and program the VC I2C configuration | ||
239 | * register. | ||
240 | * | ||
241 | * The VC I2C configuration is common to all VC channels, | ||
242 | * so this function only configures I2C for the first VC | ||
243 | * channel registers. All other VC channels will use the | ||
244 | * same configuration. | ||
245 | */ | ||
246 | static void __init omap_vc_i2c_init(struct voltagedomain *voltdm) | ||
247 | { | ||
248 | struct omap_vc_channel *vc = voltdm->vc; | ||
249 | static bool initialized; | ||
250 | static bool i2c_high_speed; | ||
251 | u8 mcode; | ||
252 | |||
253 | if (initialized) { | ||
254 | if (voltdm->pmic->i2c_high_speed != i2c_high_speed) | ||
255 | pr_warn("%s: I2C config for all channels must match.", | ||
256 | __func__); | ||
257 | return; | ||
258 | } | ||
259 | |||
260 | i2c_high_speed = voltdm->pmic->i2c_high_speed; | ||
261 | if (i2c_high_speed) | ||
262 | voltdm->rmw(vc->common->i2c_cfg_hsen_mask, | ||
263 | vc->common->i2c_cfg_hsen_mask, | ||
264 | vc->common->i2c_cfg_reg); | ||
265 | |||
266 | mcode = voltdm->pmic->i2c_mcode; | ||
267 | if (mcode) | ||
268 | voltdm->rmw(vc->common->i2c_mcode_mask, | ||
269 | mcode << __ffs(vc->common->i2c_mcode_mask), | ||
270 | vc->common->i2c_cfg_reg); | ||
271 | |||
272 | initialized = true; | ||
273 | } | ||
274 | |||
240 | void __init omap_vc_init_channel(struct voltagedomain *voltdm) | 275 | void __init omap_vc_init_channel(struct voltagedomain *voltdm) |
241 | { | 276 | { |
242 | struct omap_vc_channel *vc = voltdm->vc; | 277 | struct omap_vc_channel *vc = voltdm->vc; |
@@ -305,6 +340,8 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) | |||
305 | vc->setup_time << __ffs(voltdm->vfsm->voltsetup_mask), | 340 | vc->setup_time << __ffs(voltdm->vfsm->voltsetup_mask), |
306 | voltdm->vfsm->voltsetup_reg); | 341 | voltdm->vfsm->voltsetup_reg); |
307 | 342 | ||
343 | omap_vc_i2c_init(voltdm); | ||
344 | |||
308 | if (cpu_is_omap34xx()) | 345 | if (cpu_is_omap34xx()) |
309 | omap3_vc_init_channel(voltdm); | 346 | omap3_vc_init_channel(voltdm); |
310 | else if (cpu_is_omap44xx()) | 347 | else if (cpu_is_omap44xx()) |