diff options
author | Paul Walmsley <paul@pwsan.com> | 2012-10-21 01:01:12 -0600 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-10-21 01:01:12 -0600 |
commit | 21325b25f4d81c5fcffd55afb6c81cc873ee8b0a (patch) | |
tree | 313ae5c07d618b5cafcf1ec66fbed2228bb1e44b /arch/arm/mach-omap2/cm_common.c | |
parent | e24c35737413c8626f9c4e8f47e33926b7ab7f23 (diff) |
ARM: OMAP2+: CM: prepare for use of cm_ll_data function pointers
There are several CM operations which behave similarly across OMAP2+
SoCs, but which have slight differences in their underlying
implementations.
This patch creates the support code for this function pointer
registration process. No function pointers are included yet, but a
subsequent patch will create these for the module IDLEST registers.
This patch allows other code to use CM-provided data and operations
without needing to know which SoC is currently in use. A further
description of the concept is provided in the patch entitled
"ARM: OMAP2+: PRM: prepare for use of prm_ll_data function pointers".
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/cm_common.c')
-rw-r--r-- | arch/arm/mach-omap2/cm_common.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/cm_common.c b/arch/arm/mach-omap2/cm_common.c new file mode 100644 index 00000000000..3246cef151d --- /dev/null +++ b/arch/arm/mach-omap2/cm_common.c @@ -0,0 +1,71 @@ +/* + * OMAP2+ common Clock Management (CM) IP block functions + * + * Copyright (C) 2012 Texas Instruments, Inc. + * Paul Walmsley <paul@pwsan.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * XXX This code should eventually be moved to a CM driver. + */ + +#include <linux/kernel.h> +#include <linux/init.h> + +#include "cm2xxx.h" +#include "cm3xxx.h" +#include "cm44xx.h" + +/* + * cm_ll_data: function pointers to SoC-specific implementations of + * common CM functions + */ +static struct cm_ll_data null_cm_ll_data; +static struct cm_ll_data *cm_ll_data = &null_cm_ll_data; + +/** + * cm_register - register per-SoC low-level data with the CM + * @cld: low-level per-SoC OMAP CM data & function pointers to register + * + * Register per-SoC low-level OMAP CM data and function pointers with + * the OMAP CM common interface. The caller must keep the data + * pointed to by @cld valid until it calls cm_unregister() and + * it returns successfully. Returns 0 upon success, -EINVAL if @cld + * is NULL, or -EEXIST if cm_register() has already been called + * without an intervening cm_unregister(). + */ +int cm_register(struct cm_ll_data *cld) +{ + if (!cld) + return -EINVAL; + + if (cm_ll_data != &null_cm_ll_data) + return -EEXIST; + + cm_ll_data = cld; + + return 0; +} + +/** + * cm_unregister - unregister per-SoC low-level data & function pointers + * @cld: low-level per-SoC OMAP CM data & function pointers to unregister + * + * Unregister per-SoC low-level OMAP CM data and function pointers + * that were previously registered with cm_register(). The + * caller may not destroy any of the data pointed to by @cld until + * this function returns successfully. Returns 0 upon success, or + * -EINVAL if @cld is NULL or if @cld does not match the struct + * cm_ll_data * previously registered by cm_register(). + */ +int cm_unregister(struct cm_ll_data *cld) +{ + if (!cld || cm_ll_data != cld) + return -EINVAL; + + cm_ll_data = &null_cm_ll_data; + + return 0; +} |