aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-10-21 03:01:11 -0400
committerPaul Walmsley <paul@pwsan.com>2012-10-21 03:01:11 -0400
commite24c35737413c8626f9c4e8f47e33926b7ab7f23 (patch)
treea49061ee1ae5a4492767fe9e7fbfa82440004714
parent4bd5259e53accda0fe295d3b25da348f4d5f4b09 (diff)
ARM: OMAP2+: PRM: prepare for use of prm_ll_data function pointers
There are several PRM operations which behave similarly across OMAP2+ SoCs, but which have slight differences in their underlying implementations. For example, to fetch the SoC's last reset sources, different registers are read across OMAP2xxx, 3xxx, and 44xx, and different bits are used on each SoC. But the information returned is so similar that a single, common interface for drivers is useful. This patch creates the support code for this function pointer registration process. No function pointers are included yet, but a subsequent patch will create one for the reset source API. To illustrate the end goal with the above reset source example, each per-SoC driver will use its own low-level implementation function -- e.g., prm2xxx.c would contain omap2xxx_prm_read_reset_sources(). This function would read the appropriate register and remap the register bits to a standard set of reset source bits. When the prm2xxx.c driver is loaded, it would register this function with the common PRM driver, prm.c. prm.c would then export a common function, omap_prm_read_reset_sources(). Calling it would call through to the function pointer for the currently-registered SoC PRM driver. This will allow other drivers to use PRM-provided data and operations without needing to know which SoC is currently in use. Signed-off-by: Paul Walmsley <paul@pwsan.com>
-rw-r--r--arch/arm/mach-omap2/prm.h11
-rw-r--r--arch/arm/mach-omap2/prm_common.c52
2 files changed, 63 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/prm.h b/arch/arm/mach-omap2/prm.h
index 39d562169d18..3e51c1d15757 100644
--- a/arch/arm/mach-omap2/prm.h
+++ b/arch/arm/mach-omap2/prm.h
@@ -52,5 +52,16 @@
52#define OMAP_POWERSTATE_SHIFT 0 52#define OMAP_POWERSTATE_SHIFT 0
53#define OMAP_POWERSTATE_MASK (0x3 << 0) 53#define OMAP_POWERSTATE_MASK (0x3 << 0)
54 54
55#ifndef __ASSEMBLER__
56
57/**
58 * struct prm_ll_data - fn ptrs to per-SoC PRM function implementations
59 */
60struct prm_ll_data {};
61
62extern int prm_register(struct prm_ll_data *pld);
63extern int prm_unregister(struct prm_ll_data *pld);
64
65#endif
55 66
56#endif 67#endif
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 0a100d9465b4..8670a3c4bc5e 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -53,6 +53,13 @@ static struct irq_chip_generic **prcm_irq_chips;
53 */ 53 */
54static struct omap_prcm_irq_setup *prcm_irq_setup; 54static struct omap_prcm_irq_setup *prcm_irq_setup;
55 55
56/*
57 * prm_ll_data: function pointers to SoC-specific implementations of
58 * common PRM functions
59 */
60static struct prm_ll_data null_prm_ll_data;
61static struct prm_ll_data *prm_ll_data = &null_prm_ll_data;
62
56/* Private functions */ 63/* Private functions */
57 64
58/* 65/*
@@ -318,3 +325,48 @@ err:
318 omap_prcm_irq_cleanup(); 325 omap_prcm_irq_cleanup();
319 return -ENOMEM; 326 return -ENOMEM;
320} 327}
328
329/**
330 * prm_register - register per-SoC low-level data with the PRM
331 * @pld: low-level per-SoC OMAP PRM data & function pointers to register
332 *
333 * Register per-SoC low-level OMAP PRM data and function pointers with
334 * the OMAP PRM common interface. The caller must keep the data
335 * pointed to by @pld valid until it calls prm_unregister() and
336 * it returns successfully. Returns 0 upon success, -EINVAL if @pld
337 * is NULL, or -EEXIST if prm_register() has already been called
338 * without an intervening prm_unregister().
339 */
340int prm_register(struct prm_ll_data *pld)
341{
342 if (!pld)
343 return -EINVAL;
344
345 if (prm_ll_data != &null_prm_ll_data)
346 return -EEXIST;
347
348 prm_ll_data = pld;
349
350 return 0;
351}
352
353/**
354 * prm_unregister - unregister per-SoC low-level data & function pointers
355 * @pld: low-level per-SoC OMAP PRM data & function pointers to unregister
356 *
357 * Unregister per-SoC low-level OMAP PRM data and function pointers
358 * that were previously registered with prm_register(). The
359 * caller may not destroy any of the data pointed to by @pld until
360 * this function returns successfully. Returns 0 upon success, or
361 * -EINVAL if @pld is NULL or if @pld does not match the struct
362 * prm_ll_data * previously registered by prm_register().
363 */
364int prm_unregister(struct prm_ll_data *pld)
365{
366 if (!pld || prm_ll_data != pld)
367 return -EINVAL;
368
369 prm_ll_data = &null_prm_ll_data;
370
371 return 0;
372}