Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
clockdomain.c File Reference
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/limits.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/bitops.h>
#include <plat/clock.h>
#include "clockdomain.h"

Go to the source code of this file.

Functions

void _clkdm_add_autodeps (struct clockdomain *clkdm)
 
void _clkdm_del_autodeps (struct clockdomain *clkdm)
 
int clkdm_register_platform_funcs (struct clkdm_ops *co)
 
int clkdm_register_clkdms (struct clockdomain **cs)
 
int clkdm_register_autodeps (struct clkdm_autodep *ia)
 
int clkdm_complete_init (void)
 
. Returns a pointer

to the struct clockdomain if found, or NULL otherwise.

struct clockdomainclkdm_lookup (const char *name)
 
int clkdm_for_each (int(*fn)(struct clockdomain *clkdm, void *user), void *user)
 
struct powerdomainclkdm_get_pwrdm (struct clockdomain *clkdm)
 
int clkdm_add_wkdep (struct clockdomain *clkdm1, struct clockdomain *clkdm2)
 
int clkdm_del_wkdep (struct clockdomain *clkdm1, struct clockdomain *clkdm2)
 
int clkdm_read_wkdep (struct clockdomain *clkdm1, struct clockdomain *clkdm2)
 
int clkdm_clear_all_wkdeps (struct clockdomain *clkdm)
 
int clkdm_add_sleepdep (struct clockdomain *clkdm1, struct clockdomain *clkdm2)
 
int clkdm_del_sleepdep (struct clockdomain *clkdm1, struct clockdomain *clkdm2)
 
int clkdm_read_sleepdep (struct clockdomain *clkdm1, struct clockdomain *clkdm2)
 
int clkdm_clear_all_sleepdeps (struct clockdomain *clkdm)
 
int clkdm_sleep (struct clockdomain *clkdm)
 
int clkdm_wakeup (struct clockdomain *clkdm)
 
void clkdm_allow_idle (struct clockdomain *clkdm)
 
void clkdm_deny_idle (struct clockdomain *clkdm)
 
bool clkdm_in_hwsup (struct clockdomain *clkdm)
 
bool clkdm_missing_idle_reporting (struct clockdomain *clkdm)
 
int clkdm_clk_enable (struct clockdomain *clkdm, struct clk *clk)
 
int clkdm_clk_disable (struct clockdomain *clkdm, struct clk *clk)
 
int clkdm_hwmod_enable (struct clockdomain *clkdm, struct omap_hwmod *oh)
 
int clkdm_hwmod_disable (struct clockdomain *clkdm, struct omap_hwmod *oh)
 

Function Documentation

void _clkdm_add_autodeps ( struct clockdomain clkdm)

Definition at line 166 of file clockdomain.c.

void _clkdm_del_autodeps ( struct clockdomain clkdm)

Definition at line 196 of file clockdomain.c.

int clkdm_add_sleepdep ( struct clockdomain clkdm1,
struct clockdomain clkdm2 
)

clkdm_add_sleepdep - add a sleep dependency from clkdm2 to clkdm1 : prevent this struct clockdomain * from sleeping (dependent) : when this struct clockdomain * is active (source)

Prevent from automatically going inactive (and then to retention or off) if is active. Returns -EINVAL if presented with invalid clockdomain pointers or called on a machine that does not support software-configurable hardware sleep dependencies, -ENOENT if the specified dependency cannot be set in hardware, or 0 upon success.

Definition at line 598 of file clockdomain.c.

int clkdm_add_wkdep ( struct clockdomain clkdm1,
struct clockdomain clkdm2 
)

clkdm_add_wkdep - add a wakeup dependency from clkdm2 to clkdm1 : wake this struct clockdomain * up (dependent) : when this struct clockdomain * wakes up (source)

When the clockdomain represented by wakes up, wake up . Implemented in hardware on the OMAP, this feature is designed to reduce wakeup latency of the dependent clockdomain . Returns -EINVAL if presented with invalid clockdomain pointers, -ENOENT if cannot wake up clkdm1 in hardware, or 0 upon success.

Definition at line 454 of file clockdomain.c.

void clkdm_allow_idle ( struct clockdomain clkdm)

clkdm_allow_idle - enable hwsup idle transitions for clkdm : struct clockdomain *

Allow the hardware to automatically switch the clockdomain into active or idle states, as needed by downstream clocks. If the clockdomain has any downstream clocks enabled in the clock framework, wkdep/sleepdep autodependencies are added; this is so device drivers can read and write to the device. No return value.

Definition at line 815 of file clockdomain.c.

int clkdm_clear_all_sleepdeps ( struct clockdomain clkdm)

clkdm_clear_all_sleepdeps - remove all sleep dependencies from target clkdm : struct clockdomain * to remove all sleep dependencies from

Remove all inter-clockdomain sleep dependencies that could prevent from idling. Intended to be used during boot to initialize the PRCM to a known state, after all clockdomains are put into swsup idle and woken up. Returns -EINVAL if pointer is invalid, or 0 upon success.

Definition at line 723 of file clockdomain.c.

int clkdm_clear_all_wkdeps ( struct clockdomain clkdm)

clkdm_clear_all_wkdeps - remove all wakeup dependencies from target clkdm : struct clockdomain * to remove all wakeup dependencies from

Remove all inter-clockdomain wakeup dependencies that could cause to wake. Intended to be used during boot to initialize the PRCM to a known state, after all clockdomains are put into swsup idle and woken up. Returns -EINVAL if pointer is invalid, or 0 upon success.

Definition at line 575 of file clockdomain.c.

int clkdm_clk_disable ( struct clockdomain clkdm,
struct clk clk 
)

clkdm_clk_disable - remove an enabled downstream clock from this clkdm : struct clockdomain * : struct clk * of the disabled downstream clock

Decrement the usecount of this clockdomain when is disabled. Intended to be called by clk_disable() code. If the clockdomain usecount goes to 0, put the clockdomain to sleep (software-supervised mode) or remove the clkdm autodependencies (hardware-supervised mode). Returns -EINVAL if passed null pointers; -ERANGE if the usecount underflows; or returns 0 upon success or if the clockdomain is in hwsup idle mode.

Definition at line 1018 of file clockdomain.c.

int clkdm_clk_enable ( struct clockdomain clkdm,
struct clk clk 
)

clkdm_clk_enable - add an enabled downstream clock to this clkdm : struct clockdomain * : struct clk * of the enabled downstream clock

Increment the usecount of the clockdomain and ensure that it is awake before is enabled. Intended to be called by clk_enable() code. If the clockdomain is in software-supervised idle mode, force the clockdomain to wake. If the clockdomain is in hardware-supervised idle mode, add clkdm-pwrdm autodependencies, to ensure that devices in the clockdomain can be read from/written to by on-chip processors. Returns -EINVAL if passed null pointers; returns 0 upon success or if the clockdomain is in hwsup idle mode.

Definition at line 992 of file clockdomain.c.

int clkdm_complete_init ( void  )

clkdm_complete_init - set up the clockdomain layer

Put all clockdomains into software-supervised mode; PM code should later enable hardware-supervised mode as appropriate. Must be called after clkdm_register_clkdms(). Returns -EACCES if called before clkdm_register_clkdms(), or 0 upon success.

Definition at line 342 of file clockdomain.c.

int clkdm_del_sleepdep ( struct clockdomain clkdm1,
struct clockdomain clkdm2 
)

clkdm_del_sleepdep - remove a sleep dependency from clkdm2 to clkdm1 : prevent this struct clockdomain * from sleeping (dependent) : when this struct clockdomain * is active (source)

Allow to automatically go inactive (and then to retention or off), independent of the activity state of . Returns -EINVAL if presented with invalid clockdomain pointers or called on a machine that does not support software-configurable hardware sleep dependencies, -ENOENT if the specified dependency cannot be cleared in hardware, or 0 upon success.

Definition at line 641 of file clockdomain.c.

int clkdm_del_wkdep ( struct clockdomain clkdm1,
struct clockdomain clkdm2 
)

clkdm_del_wkdep - remove a wakeup dependency from clkdm2 to clkdm1 : wake this struct clockdomain * up (dependent) : when this struct clockdomain * wakes up (source)

Remove a wakeup dependency causing to wake up when wakes up. Returns -EINVAL if presented with invalid clockdomain pointers, -ENOENT if cannot wake up clkdm1 in hardware, or 0 upon success.

Definition at line 495 of file clockdomain.c.

void clkdm_deny_idle ( struct clockdomain clkdm)

clkdm_deny_idle - disable hwsup idle transitions for clkdm : struct clockdomain *

Prevent the hardware from automatically switching the clockdomain into inactive or idle states. If the clockdomain has downstream clocks enabled in the clock framework, wkdep/sleepdep autodependencies are removed. No return value.

Definition at line 850 of file clockdomain.c.

int clkdm_for_each ( int(*)(struct clockdomain *clkdm, void *user fn,
void user 
)

Definition at line 405 of file clockdomain.c.

struct powerdomain* clkdm_get_pwrdm ( struct clockdomain clkdm)
read

clkdm_get_pwrdm - return a ptr to the pwrdm that this clkdm resides in : struct clockdomain *

Return a pointer to the struct powerdomain that the specified clockdomain exists in, or returns NULL if is NULL.

Definition at line 431 of file clockdomain.c.

int clkdm_hwmod_disable ( struct clockdomain clkdm,
struct omap_hwmod oh 
)

clkdm_hwmod_disable - remove an enabled downstream hwmod from this clkdm : struct clockdomain * : struct omap_hwmod * of the disabled downstream hwmod

Decrement the usecount of this clockdomain when is disabled. Intended to be called by module_disable() code. If the clockdomain usecount goes to 0, put the clockdomain to sleep (software-supervised mode) or remove the clkdm autodependencies (hardware-supervised mode). Returns -EINVAL if passed null pointers; -ERANGE if the usecount underflows; or returns 0 upon success or if the clockdomain is in hwsup idle mode.

Definition at line 1077 of file clockdomain.c.

int clkdm_hwmod_enable ( struct clockdomain clkdm,
struct omap_hwmod oh 
)

clkdm_hwmod_enable - add an enabled downstream hwmod to this clkdm : struct clockdomain * : struct omap_hwmod * of the enabled downstream hwmod

Increment the usecount of the clockdomain and ensure that it is awake before is enabled. Intended to be called by module_enable() code. If the clockdomain is in software-supervised idle mode, force the clockdomain to wake. If the clockdomain is in hardware-supervised idle mode, add clkdm-pwrdm autodependencies, to ensure that devices in the clockdomain can be read from/written to by on-chip processors. Returns -EINVAL if passed null pointers; returns 0 upon success or if the clockdomain is in hwsup idle mode.

Definition at line 1046 of file clockdomain.c.

bool clkdm_in_hwsup ( struct clockdomain clkdm)

clkdm_in_hwsup - is clockdomain have hardware-supervised idle enabled? : struct clockdomain *

Returns true if clockdomain currently has hardware-supervised idle enabled, or false if it does not or if is NULL. It is only valid to call this function after clkdm_init() has been called. This function does not actually read bits from the hardware; it instead tests an in-memory flag that is changed whenever the clockdomain code changes the auto-idle mode.

Definition at line 887 of file clockdomain.c.

struct clockdomain* clkdm_lookup ( const char name)
read

Definition at line 372 of file clockdomain.c.

bool clkdm_missing_idle_reporting ( struct clockdomain clkdm)

clkdm_missing_idle_reporting - can enter autoidle even if in use? : struct clockdomain *

Returns true if clockdomain has the CLKDM_MISSING_IDLE_REPORTING flag set, or false if not or is null. More information is available in the documentation for the CLKDM_MISSING_IDLE_REPORTING macro.

Definition at line 911 of file clockdomain.c.

int clkdm_read_sleepdep ( struct clockdomain clkdm1,
struct clockdomain clkdm2 
)

clkdm_read_sleepdep - read sleep dependency state from clkdm2 to clkdm1 : prevent this struct clockdomain * from sleeping (dependent) : when this struct clockdomain * is active (source)

Return 1 if a hardware sleep dependency exists wherein will not be allowed to automatically go inactive if is active; 0 if 's automatic power state inactivity transition is independent of 's; -EINVAL if either clockdomain pointer is invalid or called on a machine that does not support software-configurable hardware sleep dependencies; or -ENOENT if the hardware is incapable.

REVISIT: Currently this function only represents software-controllable sleep dependencies. Sleep dependencies fixed in hardware are not yet handled here.

Definition at line 688 of file clockdomain.c.

int clkdm_read_wkdep ( struct clockdomain clkdm1,
struct clockdomain clkdm2 
)

clkdm_read_wkdep - read wakeup dependency state from clkdm2 to clkdm1 : wake this struct clockdomain * up (dependent) : when this struct clockdomain * wakes up (source)

Return 1 if a hardware wakeup dependency exists wherein will be awoken when wakes up; 0 if dependency is not set; -EINVAL if either clockdomain pointer is invalid; or -ENOENT if the hardware is incapable.

REVISIT: Currently this function only represents software-controllable wakeup dependencies. Wakeup dependencies fixed in hardware are not yet handled here.

Definition at line 540 of file clockdomain.c.

int clkdm_register_autodeps ( struct clkdm_autodep ia)

clkdm_register_autodeps - register autodeps (if required) : pointer to a static array of struct clkdm_autodep to register

Register clockdomain "automatic dependencies." These are clockdomain wakeup and sleep dependencies that are automatically added whenever the first clock inside a clockdomain is enabled, and removed whenever the last clock inside a clockdomain is disabled. These are currently only used on OMAP3 devices, and are deprecated, since they waste energy. However, until the OMAP2/3 IP block enable/disable sequence can be converted to match the OMAP4 sequence, they are needed.

Must be called only after all of the SoC clockdomains are registered, since the function will resolve autodep clockdomain names into clockdomain pointers.

The struct clkdm_autodep array must be static, as this function does not copy the array elements.

Returns -EACCES if called before any clockdomains have been registered, -EINVAL if called with a null argument, -EEXIST if autodeps have already been registered, or 0 upon success.

Definition at line 314 of file clockdomain.c.

int clkdm_register_clkdms ( struct clockdomain **  cs)

clkdm_register_clkdms - register SoC clockdomains : pointer to an array of struct clockdomain to register

Register the clockdomains available on a particular OMAP SoC. Must be called after clkdm_register_platform_funcs(). May be called multiple times. Returns -EACCES if called before clkdm_register_platform_funcs(); -EINVAL if the argument is null; or 0 upon success.

Definition at line 274 of file clockdomain.c.

int clkdm_register_platform_funcs ( struct clkdm_ops co)

clkdm_register_platform_funcs - register clockdomain implementation fns : func pointers for arch specific implementations

Register the list of function pointers used to implement the clockdomain functions on different OMAP SoCs. Should be called before any other clkdm_register*() function. Returns -EINVAL if is null, -EEXIST if platform functions have already been registered, or 0 upon success.

Definition at line 251 of file clockdomain.c.

int clkdm_sleep ( struct clockdomain clkdm)

clkdm_sleep - force clockdomain sleep transition : struct clockdomain *

Instruct the CM to force a sleep transition on the specified clockdomain . Returns -EINVAL if is NULL or if clockdomain does not support software-initiated sleep; 0 upon success.

Definition at line 743 of file clockdomain.c.

int clkdm_wakeup ( struct clockdomain clkdm)

clkdm_wakeup - force clockdomain wakeup transition : struct clockdomain *

Instruct the CM to force a wakeup transition on the specified clockdomain . Returns -EINVAL if is NULL or if the clockdomain does not support software-controlled wakeup; 0 upon success.

Definition at line 778 of file clockdomain.c.