diff options
Diffstat (limited to 'arch/arm/mach-omap2/prm_common.c')
-rw-r--r-- | arch/arm/mach-omap2/prm_common.c | 155 |
1 files changed, 114 insertions, 41 deletions
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c index 6b4d332be2f6..228b850e632f 100644 --- a/arch/arm/mach-omap2/prm_common.c +++ b/arch/arm/mach-omap2/prm_common.c | |||
@@ -24,11 +24,11 @@ | |||
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | 26 | ||
27 | #include <plat/common.h> | ||
28 | #include <plat/prcm.h> | ||
29 | |||
30 | #include "prm2xxx_3xxx.h" | 27 | #include "prm2xxx_3xxx.h" |
28 | #include "prm2xxx.h" | ||
29 | #include "prm3xxx.h" | ||
31 | #include "prm44xx.h" | 30 | #include "prm44xx.h" |
31 | #include "common.h" | ||
32 | 32 | ||
33 | /* | 33 | /* |
34 | * OMAP_PRCM_MAX_NR_PENDING_REG: maximum number of PRM_IRQ*_MPU regs | 34 | * OMAP_PRCM_MAX_NR_PENDING_REG: maximum number of PRM_IRQ*_MPU regs |
@@ -53,6 +53,16 @@ static struct irq_chip_generic **prcm_irq_chips; | |||
53 | */ | 53 | */ |
54 | static struct omap_prcm_irq_setup *prcm_irq_setup; | 54 | static struct omap_prcm_irq_setup *prcm_irq_setup; |
55 | 55 | ||
56 | /* prm_base: base virtual address of the PRM IP block */ | ||
57 | void __iomem *prm_base; | ||
58 | |||
59 | /* | ||
60 | * prm_ll_data: function pointers to SoC-specific implementations of | ||
61 | * common PRM functions | ||
62 | */ | ||
63 | static struct prm_ll_data null_prm_ll_data; | ||
64 | static struct prm_ll_data *prm_ll_data = &null_prm_ll_data; | ||
65 | |||
56 | /* Private functions */ | 66 | /* Private functions */ |
57 | 67 | ||
58 | /* | 68 | /* |
@@ -319,64 +329,127 @@ err: | |||
319 | return -ENOMEM; | 329 | return -ENOMEM; |
320 | } | 330 | } |
321 | 331 | ||
322 | /* | 332 | /** |
323 | * Stubbed functions so that common files continue to build when | 333 | * omap2_set_globals_prm - set the PRM base address (for early use) |
324 | * custom builds are used | 334 | * @prm: PRM base virtual address |
325 | * XXX These are temporary and should be removed at the earliest possible | 335 | * |
326 | * opportunity | 336 | * XXX Will be replaced when the PRM/CM drivers are completed. |
327 | */ | 337 | */ |
328 | u32 __weak omap2_prm_read_mod_reg(s16 module, u16 idx) | 338 | void __init omap2_set_globals_prm(void __iomem *prm) |
329 | { | 339 | { |
330 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 340 | prm_base = prm; |
331 | return 0; | ||
332 | } | 341 | } |
333 | 342 | ||
334 | void __weak omap2_prm_write_mod_reg(u32 val, s16 module, u16 idx) | 343 | /** |
344 | * prm_read_reset_sources - return the sources of the SoC's last reset | ||
345 | * | ||
346 | * Return a u32 bitmask representing the reset sources that caused the | ||
347 | * SoC to reset. The low-level per-SoC functions called by this | ||
348 | * function remap the SoC-specific reset source bits into an | ||
349 | * OMAP-common set of reset source bits, defined in | ||
350 | * arch/arm/mach-omap2/prm.h. Returns the standardized reset source | ||
351 | * u32 bitmask from the hardware upon success, or returns (1 << | ||
352 | * OMAP_UNKNOWN_RST_SRC_ID_SHIFT) if no low-level read_reset_sources() | ||
353 | * function was registered. | ||
354 | */ | ||
355 | u32 prm_read_reset_sources(void) | ||
335 | { | 356 | { |
336 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 357 | u32 ret = 1 << OMAP_UNKNOWN_RST_SRC_ID_SHIFT; |
337 | } | ||
338 | 358 | ||
339 | u32 __weak omap2_prm_rmw_mod_reg_bits(u32 mask, u32 bits, | 359 | if (prm_ll_data->read_reset_sources) |
340 | s16 module, s16 idx) | 360 | ret = prm_ll_data->read_reset_sources(); |
341 | { | 361 | else |
342 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 362 | WARN_ONCE(1, "prm: %s: no mapping function defined for reset sources\n", __func__); |
343 | return 0; | ||
344 | } | ||
345 | 363 | ||
346 | u32 __weak omap2_prm_set_mod_reg_bits(u32 bits, s16 module, s16 idx) | 364 | return ret; |
347 | { | ||
348 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | ||
349 | return 0; | ||
350 | } | 365 | } |
351 | 366 | ||
352 | u32 __weak omap2_prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx) | 367 | /** |
368 | * prm_was_any_context_lost_old - was device context lost? (old API) | ||
369 | * @part: PRM partition ID (e.g., OMAP4430_PRM_PARTITION) | ||
370 | * @inst: PRM instance offset (e.g., OMAP4430_PRM_MPU_INST) | ||
371 | * @idx: CONTEXT register offset | ||
372 | * | ||
373 | * Return 1 if any bits were set in the *_CONTEXT_* register | ||
374 | * identified by (@part, @inst, @idx), which means that some context | ||
375 | * was lost for that module; otherwise, return 0. XXX Deprecated; | ||
376 | * callers need to use a less-SoC-dependent way to identify hardware | ||
377 | * IP blocks. | ||
378 | */ | ||
379 | bool prm_was_any_context_lost_old(u8 part, s16 inst, u16 idx) | ||
353 | { | 380 | { |
354 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 381 | bool ret = true; |
355 | return 0; | ||
356 | } | ||
357 | 382 | ||
358 | u32 __weak omap2_prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask) | 383 | if (prm_ll_data->was_any_context_lost_old) |
359 | { | 384 | ret = prm_ll_data->was_any_context_lost_old(part, inst, idx); |
360 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 385 | else |
361 | return 0; | 386 | WARN_ONCE(1, "prm: %s: no mapping function defined\n", |
387 | __func__); | ||
388 | |||
389 | return ret; | ||
362 | } | 390 | } |
363 | 391 | ||
364 | int __weak omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift) | 392 | /** |
393 | * prm_clear_context_lost_flags_old - clear context loss flags (old API) | ||
394 | * @part: PRM partition ID (e.g., OMAP4430_PRM_PARTITION) | ||
395 | * @inst: PRM instance offset (e.g., OMAP4430_PRM_MPU_INST) | ||
396 | * @idx: CONTEXT register offset | ||
397 | * | ||
398 | * Clear hardware context loss bits for the module identified by | ||
399 | * (@part, @inst, @idx). No return value. XXX Deprecated; callers | ||
400 | * need to use a less-SoC-dependent way to identify hardware IP | ||
401 | * blocks. | ||
402 | */ | ||
403 | void prm_clear_context_loss_flags_old(u8 part, s16 inst, u16 idx) | ||
365 | { | 404 | { |
366 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 405 | if (prm_ll_data->clear_context_loss_flags_old) |
367 | return 0; | 406 | prm_ll_data->clear_context_loss_flags_old(part, inst, idx); |
407 | else | ||
408 | WARN_ONCE(1, "prm: %s: no mapping function defined\n", | ||
409 | __func__); | ||
368 | } | 410 | } |
369 | 411 | ||
370 | int __weak omap2_prm_assert_hardreset(s16 prm_mod, u8 shift) | 412 | /** |
413 | * prm_register - register per-SoC low-level data with the PRM | ||
414 | * @pld: low-level per-SoC OMAP PRM data & function pointers to register | ||
415 | * | ||
416 | * Register per-SoC low-level OMAP PRM data and function pointers with | ||
417 | * the OMAP PRM common interface. The caller must keep the data | ||
418 | * pointed to by @pld valid until it calls prm_unregister() and | ||
419 | * it returns successfully. Returns 0 upon success, -EINVAL if @pld | ||
420 | * is NULL, or -EEXIST if prm_register() has already been called | ||
421 | * without an intervening prm_unregister(). | ||
422 | */ | ||
423 | int prm_register(struct prm_ll_data *pld) | ||
371 | { | 424 | { |
372 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 425 | if (!pld) |
426 | return -EINVAL; | ||
427 | |||
428 | if (prm_ll_data != &null_prm_ll_data) | ||
429 | return -EEXIST; | ||
430 | |||
431 | prm_ll_data = pld; | ||
432 | |||
373 | return 0; | 433 | return 0; |
374 | } | 434 | } |
375 | 435 | ||
376 | int __weak omap2_prm_deassert_hardreset(s16 prm_mod, u8 rst_shift, | 436 | /** |
377 | u8 st_shift) | 437 | * prm_unregister - unregister per-SoC low-level data & function pointers |
438 | * @pld: low-level per-SoC OMAP PRM data & function pointers to unregister | ||
439 | * | ||
440 | * Unregister per-SoC low-level OMAP PRM data and function pointers | ||
441 | * that were previously registered with prm_register(). The | ||
442 | * caller may not destroy any of the data pointed to by @pld until | ||
443 | * this function returns successfully. Returns 0 upon success, or | ||
444 | * -EINVAL if @pld is NULL or if @pld does not match the struct | ||
445 | * prm_ll_data * previously registered by prm_register(). | ||
446 | */ | ||
447 | int prm_unregister(struct prm_ll_data *pld) | ||
378 | { | 448 | { |
379 | WARN(1, "prm: omap2xxx/omap3xxx specific function called on non-omap2xxx/3xxx\n"); | 449 | if (!pld || prm_ll_data != pld) |
450 | return -EINVAL; | ||
451 | |||
452 | prm_ll_data = &null_prm_ll_data; | ||
453 | |||
380 | return 0; | 454 | return 0; |
381 | } | 455 | } |
382 | |||