/*
* linux/arch/arm/mach-omap2/clock.c
*
* Copyright (C) 2005-2008 Texas Instruments, Inc.
* Copyright (C) 2004-2010 Nokia Corporation
*
* Contacts:
* Richard Woodruff <r-woodruff2@ti.com>
* Paul Walmsley
*
* 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.
*/
#undef DEBUG
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/delay.h>
#ifdef CONFIG_COMMON_CLK
#include <linux/clk-provider.h>
#else
#include <linux/clk.h>
#endif
#include <linux/io.h>
#include <linux/bitops.h>
#include <asm/cpu.h>
#include <trace/events/power.h>
#include "soc.h"
#include "clockdomain.h"
#include "clock.h"
#include "cm.h"
#include "cm2xxx.h"
#include "cm3xxx.h"
#include "cm-regbits-24xx.h"
#include "cm-regbits-34xx.h"
#include "common.h"
/*
* MAX_MODULE_ENABLE_WAIT: maximum of number of microseconds to wait
* for a module to indicate that it is no longer in idle
*/
#define MAX_MODULE_ENABLE_WAIT 100000
u16 cpu_mask;
/*
* clkdm_control: if true, then when a clock is enabled in the
* hardware, its clockdomain will first be enabled; and when a clock
* is disabled in the hardware, its clockdomain will be disabled
* afterwards.
*/
static bool clkdm_control = true;
static LIST_HEAD(clocks);
static DEFINE_MUTEX(clocks_mutex);
#ifndef CONFIG_COMMON_CLK
static DEFINE_SPINLOCK(clockfw_lock);
#endif
#ifdef CONFIG_COMMON_CLK
static LIST_HEAD(clk_hw_omap_clocks);
/*
* Used for clocks that have the same value as the parent clock,
* divided by some factor
*/
unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_hw_omap *oclk;
if (!hw) {
pr_warn("%s: hw is NULL\n", __func__);
return -EINVAL;
}
oclk = to_clk_hw_omap(hw);
WARN_ON(!oclk->fixed_div);
return parent_rate / oclk->fixed_div;
}
#endif
/*
* OMAP2+ specific clock functions
*/
/* Private functions */
/**
* _wait_idlest_generic - wait for a module to leave the idle state
* @reg: virtual address of module IDLEST register
* @mask: value to mask against to determine if the module is active
* @idlest: idle state indicator (0 or 1) for the clock
* @name: name of the clock (for printk)
*<