| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 | /* * omap_hwmod implementation for OMAP2/3/4 * * Copyright (C) 2009-2011 Nokia Corporation * Copyright (C) 2011-2012 Texas Instruments, Inc. * * Paul Walmsley, Benoît Cousson, Kevin Hilman * * Created in collaboration with (alphabetical order): Thara Gopinath, * Tony Lindgren, Rajendra Nayak, Vikram Pandita, Sakari Poussa, Anand * Sawant, Santosh Shilimkar, Richard Woodruff * * 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. * * Introduction * ------------ * One way to view an OMAP SoC is as a collection of largely unrelated * IP blocks connected by interconnects.  The IP blocks include * devices such as ARM processors, audio serial interfaces, UARTs, * etc.  Some of these devices, like the DSP, are created by TI; * others, like the SGX, largely originate from external vendors.  In * TI's documentation, on-chip devices are referred to as "OMAP * modules."  Some of these IP blocks are identical across several * OMAP versions.  Others are revised frequently. * * These OMAP modules are tied together by various interconnects. * Most of the address and data flow between modules is via OCP-based * interconnects such as the L3 and L4 buses; but there are other * interconnects that distribute the hardware clock tree, handle idle * and reset signaling, supply power, and connect the modules to * various pads or balls on the OMAP package. * * OMAP hwmod provides a consistent way to describe the on-chip * hardware blocks and their integration into the rest of the chip. * This description can be automatically generated from the TI * hardware database.  OMAP hwmod provides a standard, consistent API * to reset, enable, idle, and disable these hardware blocks.  And * hwmod provides a way for other core code, such as the Linux device * code or the OMAP power management and address space mapping code, * to query the hardware database. * * Using hwmod * ----------- * Drivers won't call hwmod functions directly.  That is done by the * omap_device code, and in rare occasions, by custom integration code * in arch/arm/ *omap*.  The omap_device code includes functions to * build a struct platform_device using omap_hwmod data, and that is * currently how hwmod data is communicated to drivers and to the * Linux driver model.  Most drivers will call omap_hwmod functions only * indirectly, via pm_runtime*() functions. * * From a layering perspective, here is where the OMAP hwmod code * fits into the kernel software stack: * *            +-------------------------------+ *            |      Device driver code       | *            |      (e.g., drivers/)         | *            +-------------------------------+ *            |      Linux driver model       | *            |     (platform_device /        | *            |  platform_driver data/code)   | *            +-------------------------------+ *            | OMAP core-driver integration  | *            |(arch/arm/mach-omap2/devices.c)| *            +-------------------------------+ *            |      omap_device code         | *            | (../plat-omap/omap_device.c)  | *            +-------------------------------+ *   ---->    |    omap_hwmod code/data       |    <----- *            | (../mach-omap2/omap_hwmod*)   | *            +-------------------------------+ *            | OMAP clock/PRCM/register fns  | *            | (__raw_{read,write}l, clk*)   | *            +-------------------------------+ * * Device drivers should not contain any OMAP-specific code or data in * them.  They should only contain code to operate the IP block that * the driver is responsible for.  This is because these IP blocks can * also appear in other SoCs, either from TI (such as DaVinci) or from * other manufacturers; and drivers should be reusable across other * platforms. * * The OMAP hwmod code also will attempt to reset and idle all on-chip * devices upon boot.  The goal here is for the kernel to be * completely self-reliant and independent from bootloaders.  This is * to ensure a repeatable configuration, both to ensure consistent * runtime behavior, and to make it easier for others to reproduce * bugs. * * OMAP module activity states * --------------------------- * The hwmod code considers modules to be in one of several activity * states.  IP blocks start out in an UNKNOWN state, then once they * are registered via the hwmod code, proceed to the REGISTERED state. * Once their clock names are resolved to clock pointers, the module * enters the CLKS_INITED state; and finally, once the module has been * reset and the integration registers programmed, the INITIALIZED state * is entered.  The hwmod code will then place the module into either * the IDLE state to save power, or in the case of a critical system * module, the ENABLED state. * * OMAP core integration code can then call omap_hwmod*() functions * directly to move the module between the IDLE, ENABLED, and DISABLED * states, as needed.  This is done during both the PM idle loop, and * in the OMAP core integration code's implementation of the PM runtime * functions. * * References * ---------- * This is a partial list. * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064) * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090) * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108) * - OMAP4430 Multimedia Device Silicon Revision 1.0 (SWPU140) * - Open Core Protocol Specification 2.2 * * To do: * - handle IO mapping * - bus throughput & module latency measurement code * * XXX add tests at the beginning of each function to ensure the hwmod is * in the appropriate state * XXX error return values should be checked to ensure that they are * appropriate */#undef DEBUG#include <linux/kernel.h>#include <linux/errno.h>#include <linux/io.h>#include <linux/clk-provider.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 "clock.h"#include "omap_hwmod.h"#include "soc.h"#include "common.h"#include "clockdomain.h"#include "powerdomain.h"#include "cm2xxx.h"#include "cm3xxx.h"#include "cminst44xx.h"#include "cm33xx.h"#include "prm.h"#include "prm3xxx.h"#include "prm44xx.h"#include "prm33xx.h"#include "prminst44xx.h"#include "mux.h"#include "pm.h"/* Name of the OMAP hwmod for the MPU */#define MPU_INITIATOR_NAME		"mpu"/* * Number of struct omap_hwmod_link records per struct * omap_hwmod_ocp_if record (master->slave and slave->master) */#define LINKS_PER_OCP_IF		2/** * struct omap_hwmod_soc_ops - fn ptrs for some SoC-specific operations * @enable_module: function to enable a module (via MODULEMODE) * @disable_module: function to disable a module (via MODULEMODE) * * XXX Eventually this functionality will be hidden inside the PRM/CM * device drivers.  Until then, this should avoid huge blocks of cpu_is_*() * conditionals in this code. */struct omap_hwmod_soc_ops {	void (*enable_module)(struct omap_hwmod *oh);	int (*disable_module)(struct omap_hwmod *oh);	int (*wait_target_ready)(struct omap_hwmod *oh);	int (*assert_hardreset)(struct omap_hwmod *oh,				struct omap_hwmod_rst_info *ohri);	int (*deassert_hardreset)(struct omap_hwmod *oh,				  struct omap_hwmod_rst_info *ohri);	int (*is_hardreset_asserted)(struct omap_hwmod *oh,				     struct omap_hwmod_rst_info *ohri);	int (*init_clkdm)(struct omap_hwmod *oh);	void (*update_context_lost)(struct omap_hwmod *oh);	int (*get_context_lost)(struct omap_hwmod *oh);};/* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */static struct omap_hwmod_soc_ops soc_ops;/* omap_hwmod_list contains all registered struct omap_hwmods */static LIST_HEAD(omap_hwmod_list);/* mpu_oh: used to add/remove MPU initiator from sleepdep list */static struct omap_hwmod *mpu_oh;/* io_chain_lock: used to serialize reconfigurations of the I/O chain */static DEFINE_SPINLOCK(io_chain_lock);/* * linkspace: ptr to a buffer that struct omap_hwmod_link records are * allocated from - used to reduce the number of small memory * allocations, which has a significant impact on performance */static struct omap_hwmod_link *linkspace;/* * free_ls, max_ls: array indexes into linkspace; representing the * next free struct omap_hwmod_link index, and the maximum number of * struct omap_hwmod_link records allocated (respectively) */static unsigned short free_ls, max_ls, ls_supp;/* inited: set to true once the hwmod code is initialized */static bool inited;/* Private functions *//** * _fetch_next_ocp_if - return the next OCP interface in a list * @p: ptr to a ptr to the list_head inside the ocp_if to return * @i: pointer to the index of the element pointed to by @p in the list * * Return a pointer to the struct omap_hwmod_ocp_if record * containing the struct list_head pointed to by @p, and increment * @p such that a future call to this routine will return the next * record. */static struct omap_hwmod_ocp_if *_fetch_next_ocp_if(struct list_head **p,						    int *i){	struct omap_hwmod_ocp_if *oi;	oi = list_entry(*p, struct omap_hwmod_link, node)->ocp_if;	*p = (*p)->next;	*i = *i + 1;	return oi;}/** * _update_sysc_cache - return the module OCP_SYSCONFIG register, keep copy * @oh: struct omap_hwmod * * * Load the current value of the hwmod OCP_SYSCONFIG register into the * struct omap_hwmod for later use.  Returns -EINVAL if the hwmod has no * OCP_SYSCONFIG register or 0 upon success. */static int _update_sysc_cache(struct omap_hwmod *oh){	if (!oh->class->sysc) {		WARN(1, "omap_hwmod: %s: cannot read OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name);		return -EINVAL;	}	/* XXX ensure module interface clock is up */	oh->_sysc_cache = omap_hwmod_read(oh, oh->class->sysc->sysc_offs);	if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE))		oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED;	return 0;}/** * _write_sysconfig - write a value to the module's OCP_SYSCONFIG register * @v: OCP_SYSCONFIG value to write * @oh: struct omap_hwmod * * * Write @v into the module class' OCP_SYSCONFIG register, if it has * one.  No return value. */static void _write_sysconfig(u32 v, struct omap_hwmod *oh){	if (!oh->class->sysc) {		WARN(1, "omap_hwmod: %s: cannot write OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name);		return;	}	/* XXX ensure module interface clock is up */	/* Module might have lost context, always update cache and register */	oh->_sysc_cache = v;	omap_hwmod_write(v, oh, oh->class->sysc->sysc_offs);}/** * _set_master_standbymode: set the OCP_SYSCONFIG MIDLEMODE field in @v * @oh: struct omap_hwmod * * @standbymode: MIDLEMODE field bits * @v: pointer to register contents to modify * * Update the master standby mode bits in @v to be @standbymode for * the @oh hwmod.  Does not write to the hardware.  Returns -EINVAL * upon error or 0 upon success. */static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,				   u32 *v){	u32 mstandby_mask;	u8 mstandby_shift;	if (!oh->class->sysc ||	    !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	mstandby_shift = oh->class->sysc->sysc_fields->midle_shift;	mstandby_mask = (0x3 << mstandby_shift);	*v &= ~mstandby_mask;	*v |= __ffs(standbymode) << mstandby_shift;	return 0;}/** * _set_slave_idlemode: set the OCP_SYSCONFIG SIDLEMODE field in @v * @oh: struct omap_hwmod * * @idlemode: SIDLEMODE field bits * @v: pointer to register contents to modify * * Update the slave idle mode bits in @v to be @idlemode for the @oh * hwmod.  Does not write to the hardware.  Returns -EINVAL upon error * or 0 upon success. */static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v){	u32 sidle_mask;	u8 sidle_shift;	if (!oh->class->sysc ||	    !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	sidle_shift = oh->class->sysc->sysc_fields->sidle_shift;	sidle_mask = (0x3 << sidle_shift);	*v &= ~sidle_mask;	*v |= __ffs(idlemode) << sidle_shift;	return 0;}/** * _set_clockactivity: set OCP_SYSCONFIG.CLOCKACTIVITY bits in @v * @oh: struct omap_hwmod * * @clockact: CLOCKACTIVITY field bits * @v: pointer to register contents to modify * * Update the clockactivity mode bits in @v to be @clockact for the * @oh hwmod.  Used for additional powersaving on some modules.  Does * not write to the hardware.  Returns -EINVAL upon error or 0 upon * success. */static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v){	u32 clkact_mask;	u8  clkact_shift;	if (!oh->class->sysc ||	    !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	clkact_shift = oh->class->sysc->sysc_fields->clkact_shift;	clkact_mask = (0x3 << clkact_shift);	*v &= ~clkact_mask;	*v |= clockact << clkact_shift;	return 0;}/** * _set_softreset: set OCP_SYSCONFIG.CLOCKACTIVITY bits in @v * @oh: struct omap_hwmod * * @v: pointer to register contents to modify * * Set the SOFTRESET bit in @v for hwmod @oh.  Returns -EINVAL upon * error or 0 upon success. */static int _set_softreset(struct omap_hwmod *oh, u32 *v){	u32 softrst_mask;	if (!oh->class->sysc ||	    !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);	*v |= softrst_mask;	return 0;}/** * _wait_softreset_complete - wait for an OCP softreset to complete * @oh: struct omap_hwmod * to wait on * * Wait until the IP block represented by @oh reports that its OCP * softreset is complete.  This can be triggered by software (see * _ocp_softreset()) or by hardware upon returning from off-mode (one * example is HSMMC).  Waits for up to MAX_MODULE_SOFTRESET_WAIT * microseconds.  Returns the number of microseconds waited. */static int _wait_softreset_complete(struct omap_hwmod *oh){	struct omap_hwmod_class_sysconfig *sysc;	u32 softrst_mask;	int c = 0;	sysc = oh->class->sysc;	if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS)		omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs)				   & SYSS_RESETDONE_MASK),				  MAX_MODULE_SOFTRESET_WAIT, c);	else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {		softrst_mask = (0x1 << sysc->sysc_fields->srst_shift);		omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs)				    & softrst_mask),				  MAX_MODULE_SOFTRESET_WAIT, c);	}	return c;}/** * _set_dmadisable: set OCP_SYSCONFIG.DMADISABLE bit in @v * @oh: struct omap_hwmod * * * The DMADISABLE bit is a semi-automatic bit present in sysconfig register * of some modules. When the DMA must perform read/write accesses, the * DMADISABLE bit is cleared by the hardware. But when the DMA must stop * for power management, software must set the DMADISABLE bit back to 1. * * Set the DMADISABLE bit in @v for hwmod @oh.  Returns -EINVAL upon * error or 0 upon success. */static int _set_dmadisable(struct omap_hwmod *oh){	u32 v;	u32 dmadisable_mask;	if (!oh->class->sysc ||	    !(oh->class->sysc->sysc_flags & SYSC_HAS_DMADISABLE))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	/* clocks must be on for this operation */	if (oh->_state != _HWMOD_STATE_ENABLED) {		pr_warn("omap_hwmod: %s: dma can be disabled only from enabled state\n", oh->name);		return -EINVAL;	}	pr_debug("omap_hwmod: %s: setting DMADISABLE\n", oh->name);	v = oh->_sysc_cache;	dmadisable_mask =		(0x1 << oh->class->sysc->sysc_fields->dmadisable_shift);	v |= dmadisable_mask;	_write_sysconfig(v, oh);	return 0;}/** * _set_module_autoidle: set the OCP_SYSCONFIG AUTOIDLE field in @v * @oh: struct omap_hwmod * * @autoidle: desired AUTOIDLE bitfield value (0 or 1) * @v: pointer to register contents to modify * * Update the module autoidle bit in @v to be @autoidle for the @oh * hwmod.  The autoidle bit controls whether the module can gate * internal clocks automatically when it isn't doing anything; the * exact function of this bit varies on a per-module basis.  This * function does not write to the hardware.  Returns -EINVAL upon * error or 0 upon success. */static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,				u32 *v){	u32 autoidle_mask;	u8 autoidle_shift;	if (!oh->class->sysc ||	    !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift;	autoidle_mask = (0x1 << autoidle_shift);	*v &= ~autoidle_mask;	*v |= autoidle << autoidle_shift;	return 0;}/** * _set_idle_ioring_wakeup - enable/disable IO pad wakeup on hwmod idle for mux * @oh: struct omap_hwmod * * @set_wake: bool value indicating to set (true) or clear (false) wakeup enable * * Set or clear the I/O pad wakeup flag in the mux entries for the * hwmod @oh.  This function changes the @oh->mux->pads_dynamic array * in memory.  If the hwmod is currently idled, and the new idle * values don't match the previous ones, this function will also * update the SCM PADCTRL registers.  Otherwise, if the hwmod is not * currently idled, this function won't touch the hardware: the new * mux settings are written to the SCM PADCTRL registers when the * hwmod is idled.  No return value. */static void _set_idle_ioring_wakeup(struct omap_hwmod *oh, bool set_wake){	struct omap_device_pad *pad;	bool change = false;	u16 prev_idle;	int j;	if (!oh->mux || !oh->mux->enabled)		return;	for (j = 0; j < oh->mux->nr_pads_dynamic; j++) {		pad = oh->mux->pads_dynamic[j];		if (!(pad->flags & OMAP_DEVICE_PAD_WAKEUP))			continue;		prev_idle = pad->idle;		if (set_wake)			pad->idle |= OMAP_WAKEUP_EN;		else			pad->idle &= ~OMAP_WAKEUP_EN;		if (prev_idle != pad->idle)			change = true;	}	if (change && oh->_state == _HWMOD_STATE_IDLE)		omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE);}/** * _enable_wakeup: set OCP_SYSCONFIG.ENAWAKEUP bit in the hardware * @oh: struct omap_hwmod * * * Allow the hardware module @oh to send wakeups.  Returns -EINVAL * upon error or 0 upon success. */static int _enable_wakeup(struct omap_hwmod *oh, u32 *v){	if (!oh->class->sysc ||	    !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) ||	      (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) ||	      (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)		*v |= 0x1 << oh->class->sysc->sysc_fields->enwkup_shift;	if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP)		_set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART_WKUP, v);	if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)		_set_master_standbymode(oh, HWMOD_IDLEMODE_SMART_WKUP, v);	/* XXX test pwrdm_get_wken for this hwmod's subsystem */	oh->_int_flags |= _HWMOD_WAKEUP_ENABLED;	return 0;}/** * _disable_wakeup: clear OCP_SYSCONFIG.ENAWAKEUP bit in the hardware * @oh: struct omap_hwmod * * * Prevent the hardware module @oh to send wakeups.  Returns -EINVAL * upon error or 0 upon success. */static int _disable_wakeup(struct omap_hwmod *oh, u32 *v){	if (!oh->class->sysc ||	    !((oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP) ||	      (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP) ||	      (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)))		return -EINVAL;	if (!oh->class->sysc->sysc_fields) {		WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name);		return -EINVAL;	}	if (oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)		*v &= ~(0x1 << oh->class->sysc->sysc_fields->enwkup_shift);	if (oh->class->sysc->idlemodes & SIDLE_SMART_WKUP)		_set_slave_idlemode(oh, HWMOD_IDLEMODE_SMART, v);	if (oh->class->sysc->idlemodes & MSTANDBY_SMART_WKUP)		_set_master_standbymode(oh, HWMOD_IDLEMODE_SMART, v);	/* XXX test pwrdm_get_wken for this hwmod's subsystem */	oh->_int_flags &= ~_HWMOD_WAKEUP_ENABLED;	return 0;}static struct clockdomain *_get_clkdm(struct omap_hwmod *oh){	struct clk_hw_omap *clk;	if (oh->clkdm) {		return oh->clkdm;	} else if (oh->_clk) {		clk = to_clk_hw_omap(__clk_get_hw(oh->_clk));		return  clk->clkdm;	}	return NULL;}/** * _add_initiator_dep: prevent @oh from smart-idling while @init_oh is active * @oh: struct omap_hwmod * * * Prevent the hardware module @oh from entering idle while the * hardare module initiator @init_oh is active.  Useful when a module * will be accessed by a particular initiator (e.g., if a module will * be accessed by the IVA, there should be a sleepdep between the IVA * initiator and the module).  Only applies to modules in smart-idle * mode.  If the clockdomain is marked as not needing autodeps, return * 0 without doing anything.  Otherwise, returns -EINVAL upon error or * passes along clkdm_add_sleepdep() value upon success. */static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh){	struct clockdomain *clkdm, *init_clkdm;	clkdm = _get_clkdm(oh);	init_clkdm = _get_clkdm(init_oh);	if (!clkdm || !init_clkdm)		return -EINVAL;	if (clkdm && clkdm->flags & CLKDM_NO_AUTODEPS)		return 0;	return clkdm_add_sleepdep(clkdm, init_clkdm);}/** * _del_initiator_dep: allow @oh to smart-idle even if @init_oh is active * @oh: struct omap_hwmod * * * Allow the hardware module @oh to enter idle while the hardare * module initiator @init_oh is active.  Useful when a module will not * be accessed by a particular initiator (e.g., if a module will not * be accessed by the IVA, there should be no sleepdep between the IVA * initiator and the module).  Only applies to modules in smart-idle * mode.  If the clockdomain is marked as not needing autodeps, return * 0 without doing anything.  Returns -EINVAL upon error or passes * along clkdm_del_sleepdep() value upon success. */static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh){	struct clockdomain *clkdm, *init_clkdm;	clkdm = _get_clkdm(oh);	init_clkdm = _get_clkdm(init_oh);	if (!clkdm || !init_clkdm)		return -EINVAL;	if (clkdm && clkdm->flags & CLKDM_NO_AUTODEPS)		return 0;	return clkdm_del_sleepdep(clkdm, init_clkdm);}/** * _init_main_clk - get a struct clk * for the the hwmod's main functional clk * @oh: struct omap_hwmod * * * Called from _init_clocks().  Populates the @oh _clk (main * functional clock pointer) if a main_clk is present.  Returns 0 on * success or -EINVAL on error. */static int _init_main_clk(struct omap_hwmod *oh){	int ret = 0;	if (!oh->main_clk)		return 0;	oh->_clk = clk_get(NULL, oh->main_clk);	if (IS_ERR(oh->_clk)) {		pr_warning("omap_hwmod: %s: cannot clk_get main_clk %s\n",			   oh->name, oh->main_clk);		return -EINVAL;	}	/*	 * HACK: This needs a re-visit once clk_prepare() is implemented	 * to do something meaningful. Today its just a no-op.	 * If clk_prepare() is used at some point to do things like	 * voltage scaling etc, then this would have to be moved to	 * some point where subsystems like i2c and pmic become	 * available.	 */	clk_prepare(oh->_clk);	if (!_get_clkdm(oh))		pr_debug("omap_hwmod: %s: missing clockdomain for %s.\n",			   oh->name, oh->main_clk);	return ret;}/** * _init_interface_clks - get a struct clk * for the the hwmod's interface clks * @oh: struct omap_hwmod * * * Called from _init_clocks().  Populates the @oh OCP slave interface * clock pointers.  Returns 0 on success or -EINVAL on error. */static int _init_interface_clks(struct omap_hwmod *oh){	struct omap_hwmod_ocp_if *os;	struct list_head *p;	struct clk *c;	int i = 0;	int ret = 0;	p = oh->slave_ports.next;	while (i < oh->slaves_cnt) {		os = _fetch_next_ocp_if(&p, &i);		if (!os->clk)			continue;		c = clk_get(NULL, os->clk);		if (IS_ERR(c)) {			pr_warning("omap_hwmod: %s: cannot clk_get interface_clk %s\n",				   oh->name, os->clk);			ret = -EINVAL;		}		os->_clk = c;		/*		 * HACK: This needs a re-visit once clk_prepare() is implemented		 * to do something meaningful. Today its just a no-op.		 * If clk_prepare() is used at some point to do things like		 * voltage scaling etc, then this would have to be moved to		 * some point where subsystems like i2c and pmic become		 * available.		 */		clk_prepare(os->_clk);	}	return ret;}/** * _init_opt_clk - get a struct clk * for the the hwmod's optional clocks * @oh: struct omap_hwmod * * * Called from _init_clocks().  Populates the @oh omap_hwmod_opt_clk * clock pointers.  Returns 0 on success or -EINVAL on error. */static int _init_opt_clks(struct omap_hwmod *oh){	struct omap_hwmod_opt_clk *oc;	struct clk *c;	int i;	int ret = 0;	for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) {		c = clk_get(NULL, oc->clk);		if (IS_ERR(c)) {			pr_warning("omap_hwmod: %s: cannot clk_get opt_clk %s\n",				   oh->name, oc->clk);			ret = -EINVAL;		}		oc->_clk = c;		/*		 * HACK: This needs a re-visit once clk_prepare() is implemented
 |