1 /*
2 *
3 * (C) COPYRIGHT 2011-2013 ARM Limited. All rights reserved.
4 *
5 * This program is free software and is provided to you under the terms of the
6 * GNU General Public License version 2 as published by the Free Software
7 * Foundation, and any use by you of this program is subject to the terms
8 * of such GNU licence.
9 *
10 * A copy of the licence is included with the program, and can also be obtained
11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12 * Boston, MA 02110-1301, USA.
13 *
14 */
15
16
17
18
19
20 #include <linux/io.h>
21 #include <mali_kbase.h>
22 #include "mali_kbase_cpu_vexpress.h"
23
24 #define HZ_IN_MHZ (1000000)
25
26 #define CORETILE_EXPRESS_A9X4_SCC_START (0x100E2000)
27 #define MOTHERBOARD_SYS_CFG_START (0x10000000)
28 #define SYS_CFGDATA_OFFSET (0x000000A0)
29 #define SYS_CFGCTRL_OFFSET (0x000000A4)
30 #define SYS_CFGSTAT_OFFSET (0x000000A8)
31
32 #define SYS_CFGCTRL_START_BIT_VALUE (1 << 31)
33 #define READ_REG_BIT_VALUE (0 << 30)
34 #define DCC_DEFAULT_BIT_VALUE (0 << 26)
35 #define SYS_CFG_OSC_FUNC_BIT_VALUE (1 << 20)
36 #define SITE_DEFAULT_BIT_VALUE (1 << 16)
37 #define BOARD_STACK_POS_DEFAULT_BIT_VALUE (0 << 12)
38 #define DEVICE_DEFAULT_BIT_VALUE (2 << 0)
39 #define SYS_CFG_COMPLETE_BIT_VALUE (1 << 0)
40 #define SYS_CFG_ERROR_BIT_VALUE (1 << 1)
41
42 #define FEED_REG_BIT_MASK (0x0F)
43 #define FCLK_PA_DIVIDE_BIT_SHIFT (0x03)
44 #define FCLK_PB_DIVIDE_BIT_SHIFT (0x07)
45 #define FCLK_PC_DIVIDE_BIT_SHIFT (0x0B)
46 #define AXICLK_PA_DIVIDE_BIT_SHIFT (0x0F)
47 #define AXICLK_PB_DIVIDE_BIT_SHIFT (0x13)
48
49 #define IS_SINGLE_BIT_SET(val, pos) (val&(1<<pos))
50
51 #define CPU_CLOCK_SPEED_UNDEFINED 0
52
53 #define CPU_CLOCK_SPEED_6XV7 50
54
55 static u32 cpu_clock_speed = CPU_CLOCK_SPEED_UNDEFINED;
56
57 static DEFINE_RAW_SPINLOCK(syscfg_lock);
58 /**
59 * kbase_get_vendor_specific_cpu_clock_speed
60 * @brief Retrieves the CPU clock speed.
61 * The implementation is platform specific.
62 * @param[out] cpu_clock - the value of CPU clock speed in MHz
63 * @return 0 on success, 1 otherwise
64 */
kbase_get_vexpress_cpu_clock_speed(u32 * cpu_clock)65 int kbase_get_vexpress_cpu_clock_speed(u32 *cpu_clock)
66 {
67 /* TODO: MIDBASE-2873 - Provide runtime detection of CPU clock freq for 6XV7 board */
68 *cpu_clock = CPU_CLOCK_SPEED_6XV7;
69
70 return 0;
71 }
72