blob: aa257ef7791240a7de646d6f8f12039f5b5f0a8e [file] [log] [blame]
Praveen Chidambaram2a618992012-11-08 17:53:34 -07001/*
2 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <asm/mach-types.h>
17#include <asm/cputype.h>
18#include "avs.h"
19
20u32 avs_get_avscsr(void)
21{
22 u32 val = 0;
23
24 asm volatile ("mrc p15, 7, %[avscsr], c15, c1, 7\n\t"
25 : [avscsr]"=r" (val)
26 );
27
28 return val;
29}
30EXPORT_SYMBOL(avs_get_avscsr);
31
32void avs_set_avscsr(u32 avscsr)
33{
34 asm volatile ("mcr p15, 7, %[avscsr], c15, c1, 7\n\t"
35 "isb\n\t"
36 :
37 : [avscsr]"r" (avscsr)
38 );
39}
40EXPORT_SYMBOL(avs_set_avscsr);
41
42u32 avs_get_avsdscr(void)
43{
44 u32 val = 0;
45
46 asm volatile ("mrc p15, 7, %[avsdscr], c15, c0, 6\n\t"
47 : [avsdscr]"=r" (val)
48 );
49
50 return val;
51}
52EXPORT_SYMBOL(avs_get_avsdscr);
53
54void avs_set_avsdscr(u32 avsdscr)
55{
56 asm volatile("mcr p15, 7, %[avsdscr], c15, c0, 6\n\t"
57 "isb\n\t"
58 :
59 : [avsdscr]"r" (avsdscr)
60 );
61}
62EXPORT_SYMBOL(avs_set_avsdscr);
63
64static void avs_enable_local(void *data)
65{
66 u32 avsdscr = (u32) data;
67 u32 avscsr_enable = 0x61;
68
69 avs_set_avsdscr(avsdscr);
70 avs_set_avscsr(avscsr_enable);
71}
72
73static void avs_disable_local(void *data)
74{
75 avs_set_avscsr(0);
76}
77
78void avs_enable(int cpu, u32 avsdscr)
79{
80 int ret;
81
82 ret = smp_call_function_single(cpu, avs_enable_local,
83 (void *)avsdscr, true);
84 WARN_ON(ret);
85}
86EXPORT_SYMBOL(avs_enable);
87
88void avs_disable(int cpu)
89{
90 int ret;
91
92 ret = smp_call_function_single(cpu, avs_disable_local,
93 (void *) 0, true);
94 WARN_ON(ret);
95}
96EXPORT_SYMBOL(avs_disable);