Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros
omap_hwmod.c File Reference
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/bootmem.h>
#include <plat/clock.h>
#include <plat/omap_hwmod.h>
#include <plat/prcm.h>
#include "soc.h"
#include "common.h"
#include "clockdomain.h"
#include "powerdomain.h"
#include "cm2xxx_3xxx.h"
#include "cminst44xx.h"
#include "cm33xx.h"
#include "prm2xxx_3xxx.h"
#include "prm44xx.h"
#include "prm33xx.h"
#include "prminst44xx.h"
#include "mux.h"
#include "pm.h"

Go to the source code of this file.

Data Structures

struct  omap_hwmod_soc_ops
 

Macros

#define MAX_MODULE_SOFTRESET_WAIT   10000
 
#define MPU_INITIATOR_NAME   "mpu"
 
#define LINKS_PER_OCP_IF   2
 

Functions

whenever possible to avoid

unpredictable effects if hwmod data is later added that causes data ordering to change. Returns 0 upon success or a negative error code upon error.

whenever possible to avoid unpredictable effects if hwmod

data is later added that causes data ordering to change. This function is only intended for use by OMAP core code. Device drivers should not call this function - the appropriate bus-related data accessor functions should be used instead. Returns 0 upon success or a negative error code upon error.

int omap_hwmod_get_resource_byname (struct omap_hwmod *oh, unsigned int type, const char *name, struct resource *rsrc)
 
struct powerdomainomap_hwmod_get_pwrdm (struct omap_hwmod *oh)
 
void __iomemomap_hwmod_get_mpu_rt_va (struct omap_hwmod *oh)
 
int omap_hwmod_add_initiator_dep (struct omap_hwmod *oh, struct omap_hwmod *init_oh)
 
int omap_hwmod_del_initiator_dep (struct omap_hwmod *oh, struct omap_hwmod *init_oh)
 
int omap_hwmod_enable_wakeup (struct omap_hwmod *oh)
 
int omap_hwmod_disable_wakeup (struct omap_hwmod *oh)
 
whenever possible

to avoid unpredictable effects if hwmod data is later added that causes data ordering to change. Returns 0 upon success or a negative error code upon error.

: find an omap_hwmod by name

_lookup - find an omap_hwmod by name

Return a pointer to an omap_hwmod by name, or NULL if not found.

: name of the reset line in the context of this hwmod

_lookup_hardreset - fill register bit info for this hwmod/reset line : struct omap_hwmod *

: struct omap_hwmod_rst_info * that this function will fill in

Return the bit position of the reset line that match the input name. Return -ENOENT if not found.

: name of the reset line to lookup and assert

omap_hwmod_assert_hardreset - assert the HW reset line of submodules contained in the hwmod module. : struct omap_hwmod *

Some IP like dsp, ipu or iva contain processor that require an HW reset line to be assert / deassert in order to enable fully the IP. Returns -EINVAL if is null or if the operation is not yet supported on this OMAP; otherwise, passes along the return value from _assert_hardreset().

int omap_hwmod_assert_hardreset (struct omap_hwmod *oh, const char *name)
 
: name of the reset line to look up and deassert

omap_hwmod_deassert_hardreset - deassert the HW reset line of submodules contained in the hwmod module. : struct omap_hwmod *

Some IP like dsp, ipu or iva contain processor that require an HW reset line to be assert / deassert in order to enable fully the IP. Returns -EINVAL if is null or if the operation is not yet supported on this OMAP; otherwise, passes along the return value from _deassert_hardreset().

int omap_hwmod_deassert_hardreset (struct omap_hwmod *oh, const char *name)
 
: name of the reset line to look up and read

omap_hwmod_read_hardreset - read the HW reset line state of submodules contained in the hwmod module : struct omap_hwmod *

Return the current state of the hwmod 's reset line named

int omap_hwmod_set_ocp_autoidle (struct omap_hwmod *oh, u8 autoidle)
 
u32 omap_hwmod_read (struct omap_hwmod *oh, u16 reg_offs)
 
void omap_hwmod_write (u32 v, struct omap_hwmod *oh, u16 reg_offs)
 
int omap_hwmod_softreset (struct omap_hwmod *oh)
 
int omap_hwmod_set_slave_idlemode (struct omap_hwmod *oh, u8 idlemode)
 
of an omap_hwmod, return a pointer to the registered

struct omap_hwmod *, or NULL upon error.

struct omap_hwmodomap_hwmod_lookup (const char *name)
 
int omap_hwmod_for_each (int(*fn)(struct omap_hwmod *oh, void *data), void *data)
 
int __init omap_hwmod_register_links (struct omap_hwmod_ocp_if **ois)
 
int __init omap_hwmod_setup_one (const char *oh_name)
 
 core_initcall (omap_hwmod_setup_all)
 
int omap_hwmod_enable (struct omap_hwmod *oh)
 
int omap_hwmod_idle (struct omap_hwmod *oh)
 
int omap_hwmod_shutdown (struct omap_hwmod *oh)
 
int omap_hwmod_enable_clocks (struct omap_hwmod *oh)
 
int omap_hwmod_disable_clocks (struct omap_hwmod *oh)
 
void omap_hwmod_ocp_barrier (struct omap_hwmod *oh)
 
int omap_hwmod_reset (struct omap_hwmod *oh)
 
int omap_hwmod_count_resources (struct omap_hwmod *oh)
 
int omap_hwmod_fill_resources (struct omap_hwmod *oh, struct resource *res)
 
int omap_hwmod_fill_dma_resources (struct omap_hwmod *oh, struct resource *res)
 
:

returns -EINVAL upon parameter error or if this operation is unsupported on the current OMAP; otherwise, passes along the return value from _read_hardreset().

int omap_hwmod_read_hardreset (struct omap_hwmod *oh, const char *name)
 
int omap_hwmod_for_each_by_class (const char *classname, int(*fn)(struct omap_hwmod *oh, void *user), void *user)
 
int omap_hwmod_set_postsetup_state (struct omap_hwmod *oh, u8 state)
 
int omap_hwmod_get_context_loss_count (struct omap_hwmod *oh)
 
int omap_hwmod_no_setup_reset (struct omap_hwmod *oh)
 
int omap_hwmod_pad_route_irq (struct omap_hwmod *oh, int pad_idx, int irq_idx)
 
void __init omap_hwmod_init (void)
 
const charomap_hwmod_get_main_clk (struct omap_hwmod *oh)
 

Macro Definition Documentation

#define LINKS_PER_OCP_IF   2

Definition at line 170 of file omap_hwmod.c.

#define MAX_MODULE_SOFTRESET_WAIT   10000

Definition at line 161 of file omap_hwmod.c.

#define MPU_INITIATOR_NAME   "mpu"

Definition at line 164 of file omap_hwmod.c.

Function Documentation

core_initcall ( omap_hwmod_setup_all  )
int omap_hwmod_add_initiator_dep ( struct omap_hwmod oh,
struct omap_hwmod init_oh 
)

omap_hwmod_add_initiator_dep - add sleepdep from to : struct omap_hwmod * : struct omap_hwmod * (initiator)

Add a sleep dependency between the initiator and . Intended to be called by DSP/Bridge code via platform_data for the DSP case; and by the DMA code in the sDMA case. DMA code, *Bridge code needs to add/del initiator dependencies dynamically before/after accessing a device. Returns the return value from _add_initiator_dep().

XXX Keep a usecount in the clockdomain code

Definition at line 3625 of file omap_hwmod.c.

int omap_hwmod_assert_hardreset ( struct omap_hwmod oh,
const char name 
)

Definition at line 3734 of file omap_hwmod.c.

int omap_hwmod_count_resources ( struct omap_hwmod oh)

omap_hwmod_count_resources - count number of struct resources needed by hwmod : struct omap_hwmod * : pointer to the first element of an array of struct resource to fill

Count the number of struct resource array elements necessary to contain omap_hwmod resources. Intended to be called by code that registers omap_devices. Intended to be used to determine the size of a dynamically-allocated struct resource array, before calling omap_hwmod_fill_resources(). Returns the number of struct resource array elements needed.

XXX This code is not optimized. It could attempt to merge adjacent resource IDs.

Definition at line 3388 of file omap_hwmod.c.

int omap_hwmod_deassert_hardreset ( struct omap_hwmod oh,
const char name 
)

Definition at line 3761 of file omap_hwmod.c.

int omap_hwmod_del_initiator_dep ( struct omap_hwmod oh,
struct omap_hwmod init_oh 
)

omap_hwmod_del_initiator_dep - remove sleepdep from to : struct omap_hwmod * : struct omap_hwmod * (initiator)

Remove a sleep dependency between the initiator and . Intended to be called by DSP/Bridge code via platform_data for the DSP case; and by the DMA code in the sDMA case. DMA code, *Bridge code needs to add/del initiator dependencies dynamically before/after accessing a device. Returns the return value from _del_initiator_dep().

XXX Keep a usecount in the clockdomain code

Definition at line 3650 of file omap_hwmod.c.

int omap_hwmod_disable_clocks ( struct omap_hwmod oh)

omap_hwmod_disable_clocks - disable main_clk, all interface clocks : struct omap_hwmod *oh

Intended to be called by the omap_device code.

Definition at line 3306 of file omap_hwmod.c.

int omap_hwmod_disable_wakeup ( struct omap_hwmod oh)

omap_hwmod_disable_wakeup - prevent device from waking the system : struct omap_hwmod *

Clears the module OCP socket ENAWAKEUP bit to prevent the module from sending wakeups to the PRCM, and disable I/O ring wakeup events for this IP block if it has dynamic mux entries. Eventually this should clear PRCM wakeup registers to cause the PRCM to ignore wakeup events from the module. Does not set any wakeup routing registers beyond this point - if the module is to wake up any other module or subsystem, that must be set separately. Called by omap_device code. Returns -EINVAL on error or 0 upon success.

Definition at line 3702 of file omap_hwmod.c.

int omap_hwmod_enable ( struct omap_hwmod oh)

omap_hwmod_enable - enable an omap_hwmod : struct omap_hwmod *

Enable an omap_hwmod . Intended to be called by omap_device_enable(). Returns -EINVAL on error or passes along the return value from _enable().

Definition at line 3225 of file omap_hwmod.c.

int omap_hwmod_enable_clocks ( struct omap_hwmod oh)

omap_hwmod_enable_clocks - enable main_clk, all interface clocks : struct omap_hwmod *oh

Intended to be called by the omap_device code.

Definition at line 3289 of file omap_hwmod.c.

int omap_hwmod_enable_wakeup ( struct omap_hwmod oh)

omap_hwmod_enable_wakeup - allow device to wake up the system : struct omap_hwmod *

Sets the module OCP socket ENAWAKEUP bit to allow the module to send wakeups to the PRCM, and enable I/O ring wakeup events for this IP block if it has dynamic mux entries. Eventually this should set PRCM wakeup registers to cause the PRCM to receive wakeup events from the module. Does not set any wakeup routing registers beyond this point - if the module is to wake up any other module or subsystem, that must be set separately. Called by omap_device code. Returns -EINVAL on error or 0 upon success.

Definition at line 3669 of file omap_hwmod.c.

int omap_hwmod_fill_dma_resources ( struct omap_hwmod oh,
struct resource res 
)

omap_hwmod_fill_dma_resources - fill struct resource array with dma data : struct omap_hwmod * : pointer to the array of struct resource to fill

Fill the struct resource array with dma resource data from the omap_hwmod . Intended to be called by code that registers omap_devices. See also omap_hwmod_count_resources(). Returns the number of array elements filled.

Definition at line 3473 of file omap_hwmod.c.

int omap_hwmod_fill_resources ( struct omap_hwmod oh,
struct resource res 
)

omap_hwmod_fill_resources - fill struct resource array with hwmod data : struct omap_hwmod * : pointer to the first element of an array of struct resource to fill

Fill the struct resource array with resource data from the omap_hwmod . Intended to be called by code that registers omap_devices. See also omap_hwmod_count_resources(). Returns the number of array elements filled.

Definition at line 3417 of file omap_hwmod.c.

int omap_hwmod_for_each ( int(*)(struct omap_hwmod *oh, void *data fn,
void data 
)

Definition at line 3092 of file omap_hwmod.c.

int omap_hwmod_for_each_by_class ( const char classname,
int(*)(struct omap_hwmod *oh, void *user fn,
void user 
)

Definition at line 3815 of file omap_hwmod.c.

int omap_hwmod_get_context_loss_count ( struct omap_hwmod oh)

omap_hwmod_get_context_loss_count - get lost context count : struct omap_hwmod *

Query the powerdomain of of to get the context loss count for this device.

Returns the context loss count of the powerdomain assocated with upon success, or zero if no powerdomain exists for .

Definition at line 3896 of file omap_hwmod.c.

const char* omap_hwmod_get_main_clk ( struct omap_hwmod oh)

omap_hwmod_get_main_clk - get pointer to main clock name : struct omap_hwmod *

Returns the main clock name assocated with upon success, or NULL if is NULL.

Definition at line 4032 of file omap_hwmod.c.

void __iomem* omap_hwmod_get_mpu_rt_va ( struct omap_hwmod oh)

omap_hwmod_get_mpu_rt_va - return the module's base address (for the MPU) : struct omap_hwmod *

Returns the virtual address corresponding to the beginning of the module's register target, in the address range that is intended to be used by the MPU. Returns the virtual address upon success or NULL upon error.

Definition at line 3597 of file omap_hwmod.c.

struct powerdomain* omap_hwmod_get_pwrdm ( struct omap_hwmod oh)
read

omap_hwmod_get_pwrdm - return pointer to this module's main powerdomain : struct omap_hwmod *

Return the powerdomain pointer associated with the OMAP module 's main clock. If does not have a main clk, return the powerdomain associated with the interface clock associated with the module's MPU port. (XXX Perhaps this should use the SDMA port instead?) Returns NULL on error, or a struct powerdomain * on success.

Definition at line 3564 of file omap_hwmod.c.

int omap_hwmod_get_resource_byname ( struct omap_hwmod oh,
unsigned int  type,
const char name,
struct resource rsrc 
)

Definition at line 3512 of file omap_hwmod.c.

int omap_hwmod_idle ( struct omap_hwmod oh)

omap_hwmod_idle - idle an omap_hwmod : struct omap_hwmod *

Idle an omap_hwmod . Intended to be called by omap_device_idle(). Returns -EINVAL on error or passes along the return value from _idle().

Definition at line 3247 of file omap_hwmod.c.

void __init omap_hwmod_init ( void  )

omap_hwmod_init - initialize the hwmod code

Sets up some function pointers needed by the hwmod code to operate on the currently-booted SoC. Intended to be called once during kernel init before any hwmods are registered. No return value.

Definition at line 3995 of file omap_hwmod.c.

struct omap_hwmod* omap_hwmod_lookup ( const char name)
read

Definition at line 3068 of file omap_hwmod.c.

int omap_hwmod_no_setup_reset ( struct omap_hwmod oh)

omap_hwmod_no_setup_reset - prevent a hwmod from being reset upon setup : struct omap_hwmod *

Prevent the hwmod from being reset during the setup process. Intended for use by board-*.c files on boards with devices that cannot tolerate being reset. Must be called before the hwmod has been set up. Returns 0 upon success or negative error code upon failure.

Definition at line 3918 of file omap_hwmod.c.

void omap_hwmod_ocp_barrier ( struct omap_hwmod oh)

omap_hwmod_ocp_barrier - wait for posted writes against the hwmod to complete : struct omap_hwmod *oh

Intended to be called by drivers and core code when all posted writes to a device must complete before continuing further execution (for example, after clearing some device IRQSTATUS register bits)

XXX what about targets with multiple OCP threads?

Definition at line 3328 of file omap_hwmod.c.

int omap_hwmod_pad_route_irq ( struct omap_hwmod oh,
int  pad_idx,
int  irq_idx 
)

omap_hwmod_pad_route_irq - route an I/O pad wakeup to a particular MPU IRQ : struct omap_hwmod * containing hwmod mux entries : array index in oh->mux of the hwmod mux entry to route wakeup : the hwmod mpu_irqs array index of the IRQ to trigger on wakeup

When an I/O pad wakeup arrives for the dynamic or wakeup hwmod mux entry number for the hwmod , trigger the interrupt service routine for the hwmod's mpu_irqs array index . If this function is not called for a given pad_idx, then the ISR associated with 's first MPU IRQ will be triggered when an I/O pad wakeup occurs on that pad. Note that is the index of the dynamic or wakeup entry: if there are other entries not marked with OMAP_DEVICE_PAD_WAKEUP or OMAP_DEVICE_PAD_REMUX, these entries are NOT COUNTED in the dynamic pad index. This function must be called separately for each pad that requires its interrupt to be re-routed this way. Returns -EINVAL if there is an argument problem or if does not have hwmod mux entries or MPU IRQs; returns -ENOMEM if memory cannot be allocated; or 0 upon success.

XXX This function interface is fragile. Rather than using array indexes, which are subject to unpredictable change, it should be using hwmod IRQ names, and some other stable key for the hwmod mux pad records.

Definition at line 3959 of file omap_hwmod.c.

u32 omap_hwmod_read ( struct omap_hwmod oh,
u16  reg_offs 
)

Definition at line 2986 of file omap_hwmod.c.

int omap_hwmod_read_hardreset ( struct omap_hwmod oh,
const char name 
)

Definition at line 3787 of file omap_hwmod.c.

int __init omap_hwmod_register_links ( struct omap_hwmod_ocp_if **  ois)

omap_hwmod_register_links - register an array of hwmod links : pointer to an array of omap_hwmod_ocp_if to register

Intended to be called early in boot before the clock framework is initialized. If is not null, will register all omap_hwmods listed in that are valid for this chip. Returns -EINVAL if omap_hwmod_init() hasn't been called before calling this function, -ENOMEM if the link memory area can't be allocated, or 0 upon success.

Definition at line 3121 of file omap_hwmod.c.

int omap_hwmod_reset ( struct omap_hwmod oh)

omap_hwmod_reset - reset the hwmod : struct omap_hwmod *

Under some conditions, a driver may wish to reset the entire device. Called from omap_device code. Returns -EINVAL on error or passes along the return value from _reset().

Definition at line 3353 of file omap_hwmod.c.

int omap_hwmod_set_ocp_autoidle ( struct omap_hwmod oh,
u8  autoidle 
)

omap_hwmod_set_ocp_autoidle - set the hwmod's OCP autoidle bit : struct omap_hwmod * : desired AUTOIDLE bitfield value (0 or 1)

Sets the IP block's OCP autoidle bit in hardware, and updates our local copy. Intended to be used by drivers that require direct manipulation of the AUTOIDLE bits. Returns -EINVAL if is null or is not in the ENABLED state, or passes along the return value from _set_module_autoidle().

Any users of this function should be scrutinized carefully.

Definition at line 2172 of file omap_hwmod.c.

int omap_hwmod_set_postsetup_state ( struct omap_hwmod oh,
u8  state 
)

omap_hwmod_set_postsetup_state - set the post-_setup() state for this hwmod : struct omap_hwmod * : state that _setup() should leave the hwmod in

Sets the hwmod state that will enter at the end of setup() (called by omap_hwmod_setup*()). See also the documentation for _setup_postsetup(), above. Returns 0 upon success or -EINVAL if there is a problem with the arguments or if the hwmod is in the wrong state.

Definition at line 3857 of file omap_hwmod.c.

int omap_hwmod_set_slave_idlemode ( struct omap_hwmod oh,
u8  idlemode 
)

omap_hwmod_set_slave_idlemode - set the hwmod's OCP slave idlemode : struct omap_hwmod * : SIDLEMODE field bits (shifted to bit 0)

Sets the IP block's OCP slave idlemode in hardware, and updates our local copy. Intended to be used by drivers that have some erratum that requires direct manipulation of the SIDLEMODE bits. Returns -EINVAL if is null, or passes along the return value from _set_slave_idlemode().

XXX Does this function have any current users? If not, we should remove it; it is better to let the rest of the hwmod code handle this. Any users of this function should be scrutinized carefully.

Definition at line 3044 of file omap_hwmod.c.

int __init omap_hwmod_setup_one ( const char oh_name)

omap_hwmod_setup_one - set up a single hwmod : const char * name of the already-registered hwmod to set up

Initialize and set up a single hwmod. Intended to be used for a small number of early devices, such as the timer IP blocks used for the scheduler clock. Must be called after omap2_clk_init(). Resolves the struct clk names to struct clk pointers for each registered omap_hwmod. Also calls _setup() on each hwmod. Returns -EINVAL upon error or 0 upon success.

Definition at line 3179 of file omap_hwmod.c.

int omap_hwmod_shutdown ( struct omap_hwmod oh)

omap_hwmod_shutdown - shutdown an omap_hwmod : struct omap_hwmod *

Shutdown an omap_hwmod . Intended to be called by omap_device_shutdown(). Returns -EINVAL on error or passes along the return value from _shutdown().

Definition at line 3269 of file omap_hwmod.c.

int omap_hwmod_softreset ( struct omap_hwmod oh)

omap_hwmod_softreset - reset a module via SYSCONFIG.SOFTRESET bit : struct omap_hwmod *

This is a public function exposed to drivers. Some drivers may need to do some settings before and after resetting the device. Those drivers after doing the necessary settings could use this function to start a reset by setting the SYSCONFIG.SOFTRESET bit.

Definition at line 3011 of file omap_hwmod.c.

void omap_hwmod_write ( u32  v,
struct omap_hwmod oh,
u16  reg_offs 
)

Definition at line 2994 of file omap_hwmod.c.