1/* 2 * arch/metag/include/asm/clock.h 3 * 4 * Copyright (C) 2012 Imagination Technologies Ltd. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. 9 */ 10 11#ifndef _METAG_CLOCK_H_ 12#define _METAG_CLOCK_H_ 13 14#include <asm/mach/arch.h> 15 16/** 17 * struct meta_clock_desc - Meta Core clock callbacks. 18 * @get_core_freq: Get the frequency of the Meta core. If this is NULL, the 19 * core frequency will be determined like this: 20 * Meta 1: based on loops_per_jiffy. 21 * Meta 2: (EXPAND_TIMER_DIV + 1) MHz. 22 * If a "core" clock is provided by the device tree, it 23 * will override this function. 24 */ 25struct meta_clock_desc { 26 unsigned long (*get_core_freq)(void); 27}; 28 29extern struct meta_clock_desc _meta_clock; 30 31/* 32 * Perform platform clock initialisation, reading clocks from device tree etc. 33 * Only accessible during boot. 34 */ 35void init_metag_clocks(void); 36 37/* 38 * Set up the default clock, ensuring all callbacks are valid - only accessible 39 * during boot. 40 */ 41void setup_meta_clocks(struct meta_clock_desc *desc); 42 43/** 44 * get_coreclock() - Get the frequency of the Meta core clock. 45 * 46 * Returns: The Meta core clock frequency in Hz. 47 */ 48static inline unsigned long get_coreclock(void) 49{ 50 /* 51 * Use the current clock callback. If set correctly this will provide 52 * the most accurate frequency as it can be calculated directly from the 53 * PLL configuration. otherwise a default callback will have been set 54 * instead. 55 */ 56 return _meta_clock.get_core_freq(); 57} 58 59#endif /* _METAG_CLOCK_H_ */ 60