Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/oprofile/op_blackfin.h |
| 3 | * Based on: |
| 4 | * Author: Anton Blanchard <anton@au.ibm.com> |
| 5 | * |
| 6 | * Created: |
| 7 | * Description: |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM |
| 11 | * Copyright 2004-2006 Analog Devices Inc. |
| 12 | * |
| 13 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or modify |
| 16 | * it under the terms of the GNU General Public License as published by |
| 17 | * the Free Software Foundation; either version 2 of the License, or |
| 18 | * (at your option) any later version. |
| 19 | * |
| 20 | * This program is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with this program; if not, see the file COPYING, or write |
| 27 | * to the Free Software Foundation, Inc., |
| 28 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 29 | */ |
| 30 | |
| 31 | #ifndef OP_BLACKFIN_H |
| 32 | #define OP_BLACKFIN_H 1 |
| 33 | |
| 34 | #define OP_MAX_COUNTER 2 |
| 35 | |
| 36 | #include <asm/blackfin.h> |
| 37 | |
| 38 | /* Per-counter configuration as set via oprofilefs. */ |
| 39 | struct op_counter_config { |
| 40 | unsigned long valid; |
| 41 | unsigned long enabled; |
| 42 | unsigned long event; |
| 43 | unsigned long count; |
| 44 | unsigned long kernel; |
| 45 | unsigned long user; |
| 46 | unsigned long unit_mask; |
| 47 | }; |
| 48 | |
| 49 | /* System-wide configuration as set via oprofilefs. */ |
| 50 | struct op_system_config { |
| 51 | unsigned long enable_kernel; |
| 52 | unsigned long enable_user; |
| 53 | }; |
| 54 | |
| 55 | /* Per-arch configuration */ |
| 56 | struct op_bfin533_model { |
| 57 | int (*reg_setup) (struct op_counter_config *); |
| 58 | int (*start) (struct op_counter_config *); |
| 59 | void (*stop) (void); |
| 60 | int num_counters; |
| 61 | char *name; |
| 62 | }; |
| 63 | |
| 64 | extern struct op_bfin533_model op_model_bfin533; |
| 65 | |
| 66 | static inline unsigned int ctr_read(void) |
| 67 | { |
| 68 | unsigned int tmp; |
| 69 | |
| 70 | tmp = bfin_read_PFCTL(); |
| 71 | __builtin_bfin_csync(); |
| 72 | |
| 73 | return tmp; |
| 74 | } |
| 75 | |
| 76 | static inline void ctr_write(unsigned int val) |
| 77 | { |
| 78 | bfin_write_PFCTL(val); |
| 79 | __builtin_bfin_csync(); |
| 80 | } |
| 81 | |
| 82 | static inline void count_read(unsigned int *count) |
| 83 | { |
| 84 | count[0] = bfin_read_PFCNTR0(); |
| 85 | count[1] = bfin_read_PFCNTR1(); |
| 86 | __builtin_bfin_csync(); |
| 87 | } |
| 88 | |
| 89 | static inline void count_write(unsigned int *count) |
| 90 | { |
| 91 | bfin_write_PFCNTR0(count[0]); |
| 92 | bfin_write_PFCNTR1(count[1]); |
| 93 | __builtin_bfin_csync(); |
| 94 | } |
| 95 | |
| 96 | extern int pm_overflow_handler(int irq, struct pt_regs *regs); |
| 97 | |
| 98 | #endif |