aboutsummaryrefslogtreecommitdiff
path: root/arch/blackfin/oprofile/op_blackfin.h
blob: f88f446c814fd8137b84fd93861766d480300977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * File:         arch/blackfin/oprofile/op_blackfin.h
 * Based on:
 * Author:       Anton Blanchard <anton@au.ibm.com>
 *
 * Created:
 * Description:
 *
 * Modified:
 *               Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
 *               Copyright 2004-2006 Analog Devices Inc.
 *
 * Bugs:         Enter bugs at http://blackfin.uclinux.org/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see the file COPYING, or write
 * to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef OP_BLACKFIN_H
#define OP_BLACKFIN_H 1

#define OP_MAX_COUNTER 2

#include <asm/blackfin.h>

/* Per-counter configuration as set via oprofilefs.  */
struct op_counter_config {
	unsigned long valid;
	unsigned long enabled;
	unsigned long event;
	unsigned long count;
	unsigned long kernel;
	unsigned long user;
	unsigned long unit_mask;
};

/* System-wide configuration as set via oprofilefs.  */
struct op_system_config {
	unsigned long enable_kernel;
	unsigned long enable_user;
};

/* Per-arch configuration */
struct op_bfin533_model {
	int (*reg_setup) (struct op_counter_config *);
	int (*start) (struct op_counter_config *);
	void (*stop) (void);
	int num_counters;
	char *name;
};

extern struct op_bfin533_model op_model_bfin533;

static inline unsigned int ctr_read(void)
{
	unsigned int tmp;

	tmp = bfin_read_PFCTL();
	__builtin_bfin_csync();

	return tmp;
}

static inline void ctr_write(unsigned int val)
{
	bfin_write_PFCTL(val);
	__builtin_bfin_csync();
}

static inline void count_read(unsigned int *count)
{
	count[0] = bfin_read_PFCNTR0();
	count[1] = bfin_read_PFCNTR1();
	__builtin_bfin_csync();
}

static inline void count_write(unsigned int *count)
{
	bfin_write_PFCNTR0(count[0]);
	bfin_write_PFCNTR1(count[1]);
	__builtin_bfin_csync();
}

extern int pm_overflow_handler(int irq, struct pt_regs *regs);

#endif