Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM |
| 3 | * |
| 4 | * Based on alpha version. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Stephen Rothwell | 654810e | 2005-09-19 23:21:15 +1000 | [diff] [blame] | 12 | #ifndef _ASM_POWERPC_OPROFILE_IMPL_H |
| 13 | #define _ASM_POWERPC_OPROFILE_IMPL_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | #define OP_MAX_COUNTER 8 |
| 16 | |
| 17 | /* Per-counter configuration as set via oprofilefs. */ |
| 18 | struct op_counter_config { |
Stephen Rothwell | 654810e | 2005-09-19 23:21:15 +1000 | [diff] [blame] | 19 | #ifdef __powerpc64__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | unsigned long valid; |
Stephen Rothwell | 654810e | 2005-09-19 23:21:15 +1000 | [diff] [blame] | 21 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | unsigned long enabled; |
| 23 | unsigned long event; |
| 24 | unsigned long count; |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 25 | /* Classic doesn't support per-counter user/kernel selection */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | unsigned long kernel; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | unsigned long user; |
| 28 | unsigned long unit_mask; |
| 29 | }; |
| 30 | |
| 31 | /* System-wide configuration as set via oprofilefs. */ |
| 32 | struct op_system_config { |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 33 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | unsigned long mmcr0; |
| 35 | unsigned long mmcr1; |
| 36 | unsigned long mmcra; |
Stephen Rothwell | 654810e | 2005-09-19 23:21:15 +1000 | [diff] [blame] | 37 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | unsigned long enable_kernel; |
| 39 | unsigned long enable_user; |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 40 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | unsigned long backtrace_spinlocks; |
Stephen Rothwell | 654810e | 2005-09-19 23:21:15 +1000 | [diff] [blame] | 42 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | /* Per-arch configuration */ |
Stephen Rothwell | a3e48c1 | 2005-09-19 23:18:31 +1000 | [diff] [blame] | 46 | struct op_powerpc_model { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | void (*reg_setup) (struct op_counter_config *, |
| 48 | struct op_system_config *, |
| 49 | int num_counters); |
| 50 | void (*cpu_setup) (void *); |
| 51 | void (*start) (struct op_counter_config *); |
| 52 | void (*stop) (void); |
| 53 | void (*handle_interrupt) (struct pt_regs *, |
| 54 | struct op_counter_config *); |
| 55 | int num_counters; |
| 56 | }; |
| 57 | |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 58 | #ifdef CONFIG_FSL_BOOKE |
| 59 | extern struct op_powerpc_model op_model_fsl_booke; |
| 60 | #else /* Otherwise, it's classic */ |
| 61 | |
| 62 | #ifdef CONFIG_PPC64 |
Stephen Rothwell | a3e48c1 | 2005-09-19 23:18:31 +1000 | [diff] [blame] | 63 | extern struct op_powerpc_model op_model_rs64; |
| 64 | extern struct op_powerpc_model op_model_power4; |
Anton Blanchard | dca8593 | 2005-09-06 14:55:35 +1000 | [diff] [blame] | 65 | |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 66 | #else /* Otherwise, CONFIG_PPC32 */ |
| 67 | extern struct op_powerpc_model op_model_7450; |
| 68 | #endif |
| 69 | |
| 70 | /* All the classic PPC parts use these */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | static inline unsigned int ctr_read(unsigned int i) |
| 72 | { |
| 73 | switch(i) { |
| 74 | case 0: |
| 75 | return mfspr(SPRN_PMC1); |
| 76 | case 1: |
| 77 | return mfspr(SPRN_PMC2); |
| 78 | case 2: |
| 79 | return mfspr(SPRN_PMC3); |
| 80 | case 3: |
| 81 | return mfspr(SPRN_PMC4); |
| 82 | case 4: |
| 83 | return mfspr(SPRN_PMC5); |
| 84 | case 5: |
| 85 | return mfspr(SPRN_PMC6); |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 86 | |
| 87 | /* No PPC32 chip has more than 6 so far */ |
| 88 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | case 6: |
| 90 | return mfspr(SPRN_PMC7); |
| 91 | case 7: |
| 92 | return mfspr(SPRN_PMC8); |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 93 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | default: |
| 95 | return 0; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | static inline void ctr_write(unsigned int i, unsigned int val) |
| 100 | { |
| 101 | switch(i) { |
| 102 | case 0: |
| 103 | mtspr(SPRN_PMC1, val); |
| 104 | break; |
| 105 | case 1: |
| 106 | mtspr(SPRN_PMC2, val); |
| 107 | break; |
| 108 | case 2: |
| 109 | mtspr(SPRN_PMC3, val); |
| 110 | break; |
| 111 | case 3: |
| 112 | mtspr(SPRN_PMC4, val); |
| 113 | break; |
| 114 | case 4: |
| 115 | mtspr(SPRN_PMC5, val); |
| 116 | break; |
| 117 | case 5: |
| 118 | mtspr(SPRN_PMC6, val); |
| 119 | break; |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 120 | |
| 121 | /* No PPC32 chip has more than 6, yet */ |
| 122 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | case 6: |
| 124 | mtspr(SPRN_PMC7, val); |
| 125 | break; |
| 126 | case 7: |
| 127 | mtspr(SPRN_PMC8, val); |
| 128 | break; |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 129 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | default: |
| 131 | break; |
| 132 | } |
| 133 | } |
Andy Fleming | 555d97a | 2005-12-15 20:02:04 -0600 | [diff] [blame^] | 134 | #endif /* !CONFIG_FSL_BOOKE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
Stephen Rothwell | 654810e | 2005-09-19 23:21:15 +1000 | [diff] [blame] | 136 | #endif /* _ASM_POWERPC_OPROFILE_IMPL_H */ |