Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
Pratik Patel | cf41862 | 2011-09-22 11:15:11 -0700 | [diff] [blame] | 15 | #include <linux/init.h> |
| 16 | #include <linux/types.h> |
| 17 | #include <linux/device.h> |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/io.h> |
| 20 | #include <linux/err.h> |
| 21 | #include <linux/fs.h> |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 22 | #include <linux/slab.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/smp.h> |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 25 | #include <linux/wakelock.h> |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 26 | #include <linux/sysfs.h> |
| 27 | #include <linux/stat.h> |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 28 | #include <linux/mutex.h> |
Pratik Patel | f17b147 | 2012-05-25 22:23:52 -0700 | [diff] [blame] | 29 | #include <linux/clk.h> |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 30 | #include <linux/cpu.h> |
Pratik Patel | 5f6d1af | 2012-06-13 15:48:13 -0700 | [diff] [blame] | 31 | #include <linux/of_coresight.h> |
Pratik Patel | 1746b8f | 2012-06-02 21:11:41 -0700 | [diff] [blame] | 32 | #include <linux/coresight.h> |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 33 | #include <asm/sections.h> |
Pratik Patel | 2d0c7b6 | 2012-02-24 19:04:37 -0800 | [diff] [blame] | 34 | #include <mach/socinfo.h> |
Pratik Patel | 2647779 | 2012-09-07 01:35:36 -0700 | [diff] [blame] | 35 | #include <mach/msm_memory_dump.h> |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 36 | |
Pratik Patel | 1746b8f | 2012-06-02 21:11:41 -0700 | [diff] [blame] | 37 | #include "coresight-priv.h" |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 38 | |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 39 | #define etm_writel_mm(drvdata, val, off) \ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 40 | __raw_writel((val), drvdata->base + off) |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 41 | #define etm_readl_mm(drvdata, off) \ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 42 | __raw_readl(drvdata->base + off) |
| 43 | |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 44 | #define etm_writel(drvdata, val, off) \ |
| 45 | ({ \ |
| 46 | if (cpu_is_krait_v3()) \ |
| 47 | etm_writel_cp14(val, off); \ |
| 48 | else \ |
| 49 | etm_writel_mm(drvdata, val, off); \ |
| 50 | }) |
| 51 | #define etm_readl(drvdata, off) \ |
| 52 | ({ \ |
| 53 | uint32_t val; \ |
| 54 | if (cpu_is_krait_v3()) \ |
| 55 | val = etm_readl_cp14(off); \ |
| 56 | else \ |
| 57 | val = etm_readl_mm(drvdata, off); \ |
| 58 | val; \ |
| 59 | }) |
| 60 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 61 | #define ETM_LOCK(drvdata) \ |
| 62 | do { \ |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 63 | /* recommended by spec to ensure ETM writes are committed prior |
| 64 | * to resuming execution |
| 65 | */ \ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 66 | mb(); \ |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 67 | isb(); \ |
| 68 | etm_writel_mm(drvdata, 0x0, CORESIGHT_LAR); \ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 69 | } while (0) |
| 70 | #define ETM_UNLOCK(drvdata) \ |
| 71 | do { \ |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 72 | etm_writel_mm(drvdata, CORESIGHT_UNLOCK, CORESIGHT_LAR); \ |
| 73 | /* ensure unlock and any pending writes are committed prior to |
| 74 | * programming ETM registers |
| 75 | */ \ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 76 | mb(); \ |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 77 | isb(); \ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 78 | } while (0) |
| 79 | |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 80 | /* |
| 81 | * Device registers: |
| 82 | * 0x000 - 0x2FC: Trace registers |
| 83 | * 0x300 - 0x314: Management registers |
| 84 | * 0x318 - 0xEFC: Trace registers |
| 85 | * |
| 86 | * Coresight registers |
| 87 | * 0xF00 - 0xF9C: Management registers |
| 88 | * 0xFA0 - 0xFA4: Management registers in PFTv1.0 |
| 89 | * Trace registers in PFTv1.1 |
| 90 | * 0xFA8 - 0xFFC: Management registers |
| 91 | */ |
| 92 | |
| 93 | /* Trace registers (0x000-0x2FC) */ |
| 94 | #define ETMCR (0x000) |
| 95 | #define ETMCCR (0x004) |
| 96 | #define ETMTRIGGER (0x008) |
| 97 | #define ETMSR (0x010) |
| 98 | #define ETMSCR (0x014) |
| 99 | #define ETMTSSCR (0x018) |
| 100 | #define ETMTEEVR (0x020) |
| 101 | #define ETMTECR1 (0x024) |
| 102 | #define ETMFFLR (0x02C) |
| 103 | #define ETMACVRn(n) (0x040 + (n * 4)) |
| 104 | #define ETMACTRn(n) (0x080 + (n * 4)) |
| 105 | #define ETMCNTRLDVRn(n) (0x140 + (n * 4)) |
| 106 | #define ETMCNTENRn(n) (0x150 + (n * 4)) |
| 107 | #define ETMCNTRLDEVRn(n) (0x160 + (n * 4)) |
| 108 | #define ETMCNTVRn(n) (0x170 + (n * 4)) |
| 109 | #define ETMSQ12EVR (0x180) |
| 110 | #define ETMSQ21EVR (0x184) |
| 111 | #define ETMSQ23EVR (0x188) |
Pratik Patel | d5bbc76 | 2012-01-29 14:13:21 -0800 | [diff] [blame] | 112 | #define ETMSQ31EVR (0x18C) |
| 113 | #define ETMSQ32EVR (0x190) |
| 114 | #define ETMSQ13EVR (0x194) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 115 | #define ETMSQR (0x19C) |
| 116 | #define ETMEXTOUTEVRn(n) (0x1A0 + (n * 4)) |
| 117 | #define ETMCIDCVRn(n) (0x1B0 + (n * 4)) |
| 118 | #define ETMCIDCMR (0x1BC) |
| 119 | #define ETMIMPSPEC0 (0x1C0) |
| 120 | #define ETMIMPSPEC1 (0x1C4) |
| 121 | #define ETMIMPSPEC2 (0x1C8) |
| 122 | #define ETMIMPSPEC3 (0x1CC) |
| 123 | #define ETMIMPSPEC4 (0x1D0) |
| 124 | #define ETMIMPSPEC5 (0x1D4) |
| 125 | #define ETMIMPSPEC6 (0x1D8) |
| 126 | #define ETMIMPSPEC7 (0x1DC) |
| 127 | #define ETMSYNCFR (0x1E0) |
| 128 | #define ETMIDR (0x1E4) |
| 129 | #define ETMCCER (0x1E8) |
| 130 | #define ETMEXTINSELR (0x1EC) |
| 131 | #define ETMTESSEICR (0x1F0) |
| 132 | #define ETMEIBCR (0x1F4) |
| 133 | #define ETMTSEVR (0x1F8) |
| 134 | #define ETMAUXCR (0x1FC) |
| 135 | #define ETMTRACEIDR (0x200) |
Pratik Patel | d5bbc76 | 2012-01-29 14:13:21 -0800 | [diff] [blame] | 136 | #define ETMVMIDCVR (0x240) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 137 | /* Management registers (0x300-0x314) */ |
| 138 | #define ETMOSLAR (0x300) |
| 139 | #define ETMOSLSR (0x304) |
| 140 | #define ETMOSSRR (0x308) |
| 141 | #define ETMPDCR (0x310) |
| 142 | #define ETMPDSR (0x314) |
| 143 | |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 144 | #define ETM_MAX_ADDR_CMP (16) |
| 145 | #define ETM_MAX_CNTR (4) |
| 146 | #define ETM_MAX_CTXID_CMP (3) |
| 147 | |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 148 | #define ETM_MODE_EXCLUDE BIT(0) |
| 149 | #define ETM_MODE_CYCACC BIT(1) |
| 150 | #define ETM_MODE_STALL BIT(2) |
| 151 | #define ETM_MODE_TIMESTAMP BIT(3) |
| 152 | #define ETM_MODE_CTXID BIT(4) |
| 153 | #define ETM_MODE_ALL (0x1F) |
| 154 | |
| 155 | #define ETM_EVENT_MASK (0x1FFFF) |
| 156 | #define ETM_SYNC_MASK (0xFFF) |
| 157 | #define ETM_ALL_MASK (0xFFFFFFFF) |
| 158 | |
| 159 | #define ETM_SEQ_STATE_MAX_VAL (0x2) |
| 160 | |
Pratik Patel | 2647779 | 2012-09-07 01:35:36 -0700 | [diff] [blame] | 161 | #define ETM_REG_DUMP_VER_OFF (4) |
| 162 | #define ETM_REG_DUMP_VER (1) |
| 163 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 164 | enum etm_addr_type { |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 165 | ETM_ADDR_TYPE_NONE, |
| 166 | ETM_ADDR_TYPE_SINGLE, |
| 167 | ETM_ADDR_TYPE_RANGE, |
| 168 | ETM_ADDR_TYPE_START, |
| 169 | ETM_ADDR_TYPE_STOP, |
| 170 | }; |
| 171 | |
Pratik Patel | 29cba15 | 2012-01-03 11:40:26 -0800 | [diff] [blame] | 172 | #ifdef CONFIG_MSM_QDSS_ETM_DEFAULT_ENABLE |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 173 | static int boot_enable = 1; |
Pratik Patel | 29cba15 | 2012-01-03 11:40:26 -0800 | [diff] [blame] | 174 | #else |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 175 | static int boot_enable; |
Pratik Patel | 29cba15 | 2012-01-03 11:40:26 -0800 | [diff] [blame] | 176 | #endif |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 177 | module_param_named( |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 178 | boot_enable, boot_enable, int, S_IRUGO |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 179 | ); |
| 180 | |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 181 | #ifdef CONFIG_MSM_QDSS_ETM_PCSAVE_DEFAULT_ENABLE |
| 182 | static int boot_pcsave_enable = 1; |
| 183 | #else |
| 184 | static int boot_pcsave_enable; |
| 185 | #endif |
| 186 | module_param_named( |
| 187 | boot_pcsave_enable, boot_pcsave_enable, int, S_IRUGO |
| 188 | ); |
| 189 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 190 | struct etm_drvdata { |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 191 | void __iomem *base; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 192 | struct device *dev; |
| 193 | struct coresight_device *csdev; |
| 194 | struct clk *clk; |
| 195 | struct mutex mutex; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 196 | struct wake_lock wake_lock; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 197 | int cpu; |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 198 | uint8_t arch; |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 199 | bool enable; |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 200 | uint8_t nr_addr_cmp; |
| 201 | uint8_t nr_cntr; |
| 202 | uint8_t nr_ext_inp; |
| 203 | uint8_t nr_ext_out; |
| 204 | uint8_t nr_ctxid_cmp; |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 205 | uint8_t reset; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 206 | uint32_t mode; |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 207 | uint32_t ctrl; |
| 208 | uint32_t trigger_event; |
| 209 | uint32_t startstop_ctrl; |
| 210 | uint32_t enable_event; |
| 211 | uint32_t enable_ctrl1; |
| 212 | uint32_t fifofull_level; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 213 | uint8_t addr_idx; |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 214 | uint32_t addr_val[ETM_MAX_ADDR_CMP]; |
| 215 | uint32_t addr_acctype[ETM_MAX_ADDR_CMP]; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 216 | uint32_t addr_type[ETM_MAX_ADDR_CMP]; |
| 217 | uint8_t cntr_idx; |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 218 | uint32_t cntr_rld_val[ETM_MAX_CNTR]; |
| 219 | uint32_t cntr_event[ETM_MAX_CNTR]; |
| 220 | uint32_t cntr_rld_event[ETM_MAX_CNTR]; |
| 221 | uint32_t cntr_val[ETM_MAX_CNTR]; |
| 222 | uint32_t seq_12_event; |
| 223 | uint32_t seq_21_event; |
| 224 | uint32_t seq_23_event; |
| 225 | uint32_t seq_31_event; |
| 226 | uint32_t seq_32_event; |
| 227 | uint32_t seq_13_event; |
| 228 | uint32_t seq_curr_state; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 229 | uint8_t ctxid_idx; |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 230 | uint32_t ctxid_val[ETM_MAX_CTXID_CMP]; |
| 231 | uint32_t ctxid_mask; |
| 232 | uint32_t sync_freq; |
| 233 | uint32_t timestamp_event; |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 234 | bool pcsave_impl; |
| 235 | bool pcsave_enable; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 236 | }; |
| 237 | |
Pratik Patel | c14b4df | 2012-09-05 18:07:59 -0700 | [diff] [blame] | 238 | static struct etm_drvdata *etm0drvdata; |
| 239 | |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 240 | /* |
| 241 | * ETM clock is derived from the processor clock and gets enabled on a |
| 242 | * logical OR of below items on Krait (v2 onwards): |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 243 | * 1.CPMR[ETMCLKEN] is 1 |
| 244 | * 2.ETMCR[PD] is 0 |
| 245 | * 3.ETMPDCR[PU] is 1 |
| 246 | * 4.Reset is asserted (core or debug) |
| 247 | * 5.APB memory mapped requests (eg. EDAP access) |
| 248 | * |
| 249 | * 1., 2. and 3. above are permanent enables whereas 4. and 5. are temporary |
| 250 | * enables |
| 251 | * |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 252 | * We rely on 5. to be able to access ETMCR/ETMPDCR and then use 2./3. above |
| 253 | * for ETM clock vote in the driver and the save-restore code uses 1. above |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 254 | * for its vote |
| 255 | */ |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 256 | static void etm_set_pwrdwn(struct etm_drvdata *drvdata) |
| 257 | { |
| 258 | uint32_t etmcr; |
| 259 | |
| 260 | /* ensure pending cp14 accesses complete before setting pwrdwn */ |
| 261 | mb(); |
| 262 | isb(); |
| 263 | etmcr = etm_readl(drvdata, ETMCR); |
| 264 | etmcr |= BIT(0); |
| 265 | etm_writel(drvdata, etmcr, ETMCR); |
| 266 | } |
| 267 | |
| 268 | static void etm_clr_pwrdwn(struct etm_drvdata *drvdata) |
| 269 | { |
| 270 | uint32_t etmcr; |
| 271 | |
| 272 | etmcr = etm_readl(drvdata, ETMCR); |
| 273 | etmcr &= ~BIT(0); |
| 274 | etm_writel(drvdata, etmcr, ETMCR); |
| 275 | /* ensure pwrup completes before subsequent cp14 accesses */ |
| 276 | mb(); |
| 277 | isb(); |
| 278 | } |
| 279 | |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 280 | static void etm_set_pwrup(struct etm_drvdata *drvdata) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 281 | { |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 282 | uint32_t etmpdcr; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 283 | |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 284 | etmpdcr = etm_readl_mm(drvdata, ETMPDCR); |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 285 | etmpdcr |= BIT(3); |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 286 | etm_writel_mm(drvdata, etmpdcr, ETMPDCR); |
| 287 | /* ensure pwrup completes before subsequent cp14 accesses */ |
| 288 | mb(); |
| 289 | isb(); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 292 | static void etm_clr_pwrup(struct etm_drvdata *drvdata) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 293 | { |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 294 | uint32_t etmpdcr; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 295 | |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 296 | /* ensure pending cp14 accesses complete before clearing pwrup */ |
| 297 | mb(); |
| 298 | isb(); |
| 299 | etmpdcr = etm_readl_mm(drvdata, ETMPDCR); |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 300 | etmpdcr &= ~BIT(3); |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 301 | etm_writel_mm(drvdata, etmpdcr, ETMPDCR); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 304 | static void etm_set_prog(struct etm_drvdata *drvdata) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 305 | { |
| 306 | uint32_t etmcr; |
| 307 | int count; |
| 308 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 309 | etmcr = etm_readl(drvdata, ETMCR); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 310 | etmcr |= BIT(10); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 311 | etm_writel(drvdata, etmcr, ETMCR); |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 312 | /* recommended by spec for cp14 accesses to ensure etmcr write is |
| 313 | * complete before polling etmsr |
| 314 | */ |
| 315 | isb(); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 316 | for (count = TIMEOUT_US; BVAL(etm_readl(drvdata, ETMSR), 1) != 1 |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 317 | && count > 0; count--) |
| 318 | udelay(1); |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 319 | WARN(count == 0, "timeout while setting prog bit, ETMSR: %#x\n", |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 320 | etm_readl(drvdata, ETMSR)); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 323 | static void etm_clr_prog(struct etm_drvdata *drvdata) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 324 | { |
| 325 | uint32_t etmcr; |
| 326 | int count; |
| 327 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 328 | etmcr = etm_readl(drvdata, ETMCR); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 329 | etmcr &= ~BIT(10); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 330 | etm_writel(drvdata, etmcr, ETMCR); |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 331 | /* recommended by spec for cp14 accesses to ensure etmcr write is |
| 332 | * complete before polling etmsr |
| 333 | */ |
| 334 | isb(); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 335 | for (count = TIMEOUT_US; BVAL(etm_readl(drvdata, ETMSR), 1) != 0 |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 336 | && count > 0; count--) |
| 337 | udelay(1); |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 338 | WARN(count == 0, "timeout while clearing prog bit, ETMSR: %#x\n", |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 339 | etm_readl(drvdata, ETMSR)); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 342 | static void etm_enable_pcsave(void *info) |
| 343 | { |
| 344 | struct etm_drvdata *drvdata = info; |
| 345 | |
| 346 | ETM_UNLOCK(drvdata); |
| 347 | |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 348 | /* |
| 349 | * ETMPDCR is only accessible via memory mapped interface and so use |
| 350 | * it first to enable power/clock to allow subsequent cp14 accesses. |
| 351 | */ |
| 352 | etm_set_pwrup(drvdata); |
| 353 | etm_clr_pwrdwn(drvdata); |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 354 | |
| 355 | ETM_LOCK(drvdata); |
| 356 | } |
| 357 | |
| 358 | static void etm_disable_pcsave(void *info) |
| 359 | { |
| 360 | struct etm_drvdata *drvdata = info; |
| 361 | |
| 362 | ETM_UNLOCK(drvdata); |
| 363 | |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 364 | if (!drvdata->enable) { |
| 365 | etm_set_pwrdwn(drvdata); |
| 366 | etm_clr_pwrup(drvdata); |
| 367 | } |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 368 | |
| 369 | ETM_LOCK(drvdata); |
| 370 | } |
| 371 | |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 372 | static void __etm_enable(void *info) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 373 | { |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 374 | int i; |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 375 | uint32_t etmcr; |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 376 | struct etm_drvdata *drvdata = info; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 377 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 378 | ETM_UNLOCK(drvdata); |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 379 | /* |
| 380 | * Vote for ETM power/clock enable. ETMPDCR is only accessible via |
| 381 | * memory mapped interface and so use it first to enable power/clock |
| 382 | * to allow subsequent cp14 accesses. |
| 383 | */ |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 384 | etm_set_pwrup(drvdata); |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 385 | /* |
| 386 | * Clear power down bit since when this bit is set writes to |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 387 | * certain registers might be ignored. This is also a pre-requisite |
| 388 | * for trace enable. |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 389 | */ |
| 390 | etm_clr_pwrdwn(drvdata); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 391 | etm_set_prog(drvdata); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 392 | |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 393 | etmcr = etm_readl(drvdata, ETMCR); |
| 394 | etmcr &= (BIT(10) | BIT(0)); |
| 395 | etm_writel(drvdata, drvdata->ctrl | etmcr, ETMCR); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 396 | etm_writel(drvdata, drvdata->trigger_event, ETMTRIGGER); |
| 397 | etm_writel(drvdata, drvdata->startstop_ctrl, ETMTSSCR); |
| 398 | etm_writel(drvdata, drvdata->enable_event, ETMTEEVR); |
| 399 | etm_writel(drvdata, drvdata->enable_ctrl1, ETMTECR1); |
| 400 | etm_writel(drvdata, drvdata->fifofull_level, ETMFFLR); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 401 | for (i = 0; i < drvdata->nr_addr_cmp; i++) { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 402 | etm_writel(drvdata, drvdata->addr_val[i], ETMACVRn(i)); |
| 403 | etm_writel(drvdata, drvdata->addr_acctype[i], ETMACTRn(i)); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 404 | } |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 405 | for (i = 0; i < drvdata->nr_cntr; i++) { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 406 | etm_writel(drvdata, drvdata->cntr_rld_val[i], ETMCNTRLDVRn(i)); |
| 407 | etm_writel(drvdata, drvdata->cntr_event[i], ETMCNTENRn(i)); |
| 408 | etm_writel(drvdata, drvdata->cntr_rld_event[i], |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 409 | ETMCNTRLDEVRn(i)); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 410 | etm_writel(drvdata, drvdata->cntr_val[i], ETMCNTVRn(i)); |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 411 | } |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 412 | etm_writel(drvdata, drvdata->seq_12_event, ETMSQ12EVR); |
| 413 | etm_writel(drvdata, drvdata->seq_21_event, ETMSQ21EVR); |
| 414 | etm_writel(drvdata, drvdata->seq_23_event, ETMSQ23EVR); |
| 415 | etm_writel(drvdata, drvdata->seq_31_event, ETMSQ31EVR); |
| 416 | etm_writel(drvdata, drvdata->seq_32_event, ETMSQ32EVR); |
| 417 | etm_writel(drvdata, drvdata->seq_13_event, ETMSQ13EVR); |
| 418 | etm_writel(drvdata, drvdata->seq_curr_state, ETMSQR); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 419 | for (i = 0; i < drvdata->nr_ext_out; i++) |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 420 | etm_writel(drvdata, 0x0000406F, ETMEXTOUTEVRn(i)); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 421 | for (i = 0; i < drvdata->nr_ctxid_cmp; i++) |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 422 | etm_writel(drvdata, drvdata->ctxid_val[i], ETMCIDCVRn(i)); |
| 423 | etm_writel(drvdata, drvdata->ctxid_mask, ETMCIDCMR); |
| 424 | etm_writel(drvdata, drvdata->sync_freq, ETMSYNCFR); |
| 425 | etm_writel(drvdata, 0x00000000, ETMEXTINSELR); |
| 426 | etm_writel(drvdata, drvdata->timestamp_event, ETMTSEVR); |
| 427 | etm_writel(drvdata, 0x00000000, ETMAUXCR); |
| 428 | etm_writel(drvdata, drvdata->cpu + 1, ETMTRACEIDR); |
| 429 | etm_writel(drvdata, 0x00000000, ETMVMIDCVR); |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 430 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 431 | etm_clr_prog(drvdata); |
| 432 | ETM_LOCK(drvdata); |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 433 | |
| 434 | dev_dbg(drvdata->dev, "cpu: %d enable smp call done\n", drvdata->cpu); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 435 | } |
| 436 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 437 | static int etm_enable(struct coresight_device *csdev) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 438 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 439 | struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
| 440 | int ret; |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 441 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 442 | wake_lock(&drvdata->wake_lock); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 443 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 444 | ret = clk_prepare_enable(drvdata->clk); |
Pratik Patel | f17b147 | 2012-05-25 22:23:52 -0700 | [diff] [blame] | 445 | if (ret) |
| 446 | goto err_clk; |
| 447 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 448 | mutex_lock(&drvdata->mutex); |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 449 | /* |
| 450 | * Executing __etm_enable on the cpu whose ETM is being enabled |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 451 | * ensures that register writes occur when cpu is powered. |
| 452 | */ |
| 453 | smp_call_function_single(drvdata->cpu, __etm_enable, drvdata, 1); |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 454 | drvdata->enable = true; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 455 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 456 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 457 | wake_unlock(&drvdata->wake_lock); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 458 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 459 | dev_info(drvdata->dev, "ETM tracing enabled\n"); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 460 | return 0; |
Pratik Patel | f17b147 | 2012-05-25 22:23:52 -0700 | [diff] [blame] | 461 | err_clk: |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 462 | wake_unlock(&drvdata->wake_lock); |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 463 | return ret; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 464 | } |
| 465 | |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 466 | static void __etm_disable(void *info) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 467 | { |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 468 | struct etm_drvdata *drvdata = info; |
| 469 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 470 | ETM_UNLOCK(drvdata); |
| 471 | etm_set_prog(drvdata); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 472 | |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 473 | /* program trace enable to low by using always false event */ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 474 | etm_writel(drvdata, 0x6F | BIT(14), ETMTEEVR); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 475 | |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 476 | if (!drvdata->pcsave_enable) { |
| 477 | etm_set_pwrdwn(drvdata); |
| 478 | etm_clr_pwrup(drvdata); |
| 479 | } |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 480 | ETM_LOCK(drvdata); |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 481 | |
| 482 | dev_dbg(drvdata->dev, "cpu: %d disable smp call done\n", drvdata->cpu); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 485 | static void etm_disable(struct coresight_device *csdev) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 486 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 487 | struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 488 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 489 | wake_lock(&drvdata->wake_lock); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 490 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 491 | mutex_lock(&drvdata->mutex); |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 492 | /* |
| 493 | * Executing __etm_disable on the cpu whose ETM is being disabled |
Pratik Patel | 66e1a41 | 2012-09-06 11:07:06 -0700 | [diff] [blame] | 494 | * ensures that register writes occur when cpu is powered. |
| 495 | */ |
| 496 | smp_call_function_single(drvdata->cpu, __etm_disable, drvdata, 1); |
Pratik Patel | f3238df | 2012-10-19 16:19:12 -0700 | [diff] [blame] | 497 | drvdata->enable = false; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 498 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 499 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 500 | clk_disable_unprepare(drvdata->clk); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 501 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 502 | wake_unlock(&drvdata->wake_lock); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 503 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 504 | dev_info(drvdata->dev, "ETM tracing disabled\n"); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 505 | } |
| 506 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 507 | static const struct coresight_ops_source etm_source_ops = { |
| 508 | .enable = etm_enable, |
| 509 | .disable = etm_disable, |
| 510 | }; |
Pratik Patel | 17f3b82 | 2011-11-21 12:41:47 -0800 | [diff] [blame] | 511 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 512 | static const struct coresight_ops etm_cs_ops = { |
| 513 | .source_ops = &etm_source_ops, |
| 514 | }; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 515 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 516 | static ssize_t etm_show_nr_addr_cmp(struct device *dev, |
| 517 | struct device_attribute *attr, char *buf) |
| 518 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 519 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 520 | unsigned long val = drvdata->nr_addr_cmp; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 521 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 522 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 523 | } |
| 524 | static DEVICE_ATTR(nr_addr_cmp, S_IRUGO, etm_show_nr_addr_cmp, NULL); |
| 525 | |
| 526 | static ssize_t etm_show_nr_cntr(struct device *dev, |
| 527 | struct device_attribute *attr, char *buf) |
| 528 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 529 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 530 | unsigned long val = drvdata->nr_cntr; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 531 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 532 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 533 | } |
| 534 | static DEVICE_ATTR(nr_cntr, S_IRUGO, etm_show_nr_cntr, NULL); |
| 535 | |
| 536 | static ssize_t etm_show_nr_ctxid_cmp(struct device *dev, |
| 537 | struct device_attribute *attr, char *buf) |
| 538 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 539 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 540 | unsigned long val = drvdata->nr_ctxid_cmp; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 541 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 542 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 543 | } |
| 544 | static DEVICE_ATTR(nr_ctxid_cmp, S_IRUGO, etm_show_nr_ctxid_cmp, NULL); |
| 545 | |
| 546 | static ssize_t etm_show_reset(struct device *dev, struct device_attribute *attr, |
| 547 | char *buf) |
| 548 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 549 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 550 | unsigned long val = drvdata->reset; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 551 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 552 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 553 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 554 | |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 555 | /* Reset to trace everything i.e. exclude nothing. */ |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 556 | static ssize_t etm_store_reset(struct device *dev, |
| 557 | struct device_attribute *attr, const char *buf, |
| 558 | size_t size) |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 559 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 560 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 561 | int i; |
| 562 | unsigned long val; |
| 563 | |
| 564 | if (sscanf(buf, "%lx", &val) != 1) |
| 565 | return -EINVAL; |
| 566 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 567 | mutex_lock(&drvdata->mutex); |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 568 | if (val) { |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 569 | drvdata->mode = ETM_MODE_EXCLUDE; |
| 570 | drvdata->ctrl = 0x0; |
Pratik Patel | 2d0c7b6 | 2012-02-24 19:04:37 -0800 | [diff] [blame] | 571 | if (cpu_is_krait_v1()) { |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 572 | drvdata->mode |= ETM_MODE_CYCACC; |
| 573 | drvdata->ctrl |= BIT(12); |
Pratik Patel | 2d0c7b6 | 2012-02-24 19:04:37 -0800 | [diff] [blame] | 574 | } |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 575 | drvdata->trigger_event = 0x406F; |
| 576 | drvdata->startstop_ctrl = 0x0; |
| 577 | drvdata->enable_event = 0x6F; |
| 578 | drvdata->enable_ctrl1 = 0x1000000; |
| 579 | drvdata->fifofull_level = 0x28; |
| 580 | drvdata->addr_idx = 0x0; |
| 581 | for (i = 0; i < drvdata->nr_addr_cmp; i++) { |
| 582 | drvdata->addr_val[i] = 0x0; |
| 583 | drvdata->addr_acctype[i] = 0x0; |
| 584 | drvdata->addr_type[i] = ETM_ADDR_TYPE_NONE; |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 585 | } |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 586 | drvdata->cntr_idx = 0x0; |
| 587 | for (i = 0; i < drvdata->nr_cntr; i++) { |
| 588 | drvdata->cntr_rld_val[i] = 0x0; |
| 589 | drvdata->cntr_event[i] = 0x406F; |
| 590 | drvdata->cntr_rld_event[i] = 0x406F; |
| 591 | drvdata->cntr_val[i] = 0x0; |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 592 | } |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 593 | drvdata->seq_12_event = 0x406F; |
| 594 | drvdata->seq_21_event = 0x406F; |
| 595 | drvdata->seq_23_event = 0x406F; |
| 596 | drvdata->seq_31_event = 0x406F; |
| 597 | drvdata->seq_32_event = 0x406F; |
| 598 | drvdata->seq_13_event = 0x406F; |
| 599 | drvdata->seq_curr_state = 0x0; |
| 600 | drvdata->ctxid_idx = 0x0; |
| 601 | for (i = 0; i < drvdata->nr_ctxid_cmp; i++) |
| 602 | drvdata->ctxid_val[i] = 0x0; |
| 603 | drvdata->ctxid_mask = 0x0; |
Pratik Patel | 77b9063 | 2012-07-17 17:54:51 -0700 | [diff] [blame] | 604 | /* Bits[7:0] of ETMSYNCFR are reserved on Krait pass3 onwards */ |
| 605 | if (cpu_is_krait() && !cpu_is_krait_v1() && !cpu_is_krait_v2()) |
| 606 | drvdata->sync_freq = 0x100; |
| 607 | else |
| 608 | drvdata->sync_freq = 0x80; |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 609 | drvdata->timestamp_event = 0x406F; |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 610 | } |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 611 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 612 | return size; |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 613 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 614 | static DEVICE_ATTR(reset, S_IRUGO | S_IWUSR, etm_show_reset, etm_store_reset); |
Pratik Patel | d30deda | 2012-02-01 14:40:55 -0800 | [diff] [blame] | 615 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 616 | static ssize_t etm_show_mode(struct device *dev, struct device_attribute *attr, |
| 617 | char *buf) |
| 618 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 619 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 620 | unsigned long val = drvdata->mode; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 621 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 622 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 623 | } |
| 624 | |
| 625 | static ssize_t etm_store_mode(struct device *dev, struct device_attribute *attr, |
| 626 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 627 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 628 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 629 | unsigned long val; |
| 630 | |
| 631 | if (sscanf(buf, "%lx", &val) != 1) |
| 632 | return -EINVAL; |
| 633 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 634 | mutex_lock(&drvdata->mutex); |
| 635 | drvdata->mode = val & ETM_MODE_ALL; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 636 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 637 | if (drvdata->mode & ETM_MODE_EXCLUDE) |
| 638 | drvdata->enable_ctrl1 |= BIT(24); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 639 | else |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 640 | drvdata->enable_ctrl1 &= ~BIT(24); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 641 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 642 | if (drvdata->mode & ETM_MODE_CYCACC) |
| 643 | drvdata->ctrl |= BIT(12); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 644 | else |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 645 | drvdata->ctrl &= ~BIT(12); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 646 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 647 | if (drvdata->mode & ETM_MODE_STALL) |
| 648 | drvdata->ctrl |= BIT(7); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 649 | else |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 650 | drvdata->ctrl &= ~BIT(7); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 651 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 652 | if (drvdata->mode & ETM_MODE_TIMESTAMP) |
| 653 | drvdata->ctrl |= BIT(28); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 654 | else |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 655 | drvdata->ctrl &= ~BIT(28); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 656 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 657 | if (drvdata->mode & ETM_MODE_CTXID) |
| 658 | drvdata->ctrl |= (BIT(14) | BIT(15)); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 659 | else |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 660 | drvdata->ctrl &= ~(BIT(14) | BIT(15)); |
| 661 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 662 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 663 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 664 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 665 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, etm_show_mode, etm_store_mode); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 666 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 667 | static ssize_t etm_show_trigger_event(struct device *dev, |
| 668 | struct device_attribute *attr, char *buf) |
| 669 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 670 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 671 | unsigned long val = drvdata->trigger_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 672 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 673 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 674 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 675 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 676 | static ssize_t etm_store_trigger_event(struct device *dev, |
| 677 | struct device_attribute *attr, |
| 678 | const char *buf, size_t size) |
| 679 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 680 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 681 | unsigned long val; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 682 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 683 | if (sscanf(buf, "%lx", &val) != 1) |
| 684 | return -EINVAL; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 685 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 686 | drvdata->trigger_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 687 | return size; |
| 688 | } |
| 689 | static DEVICE_ATTR(trigger_event, S_IRUGO | S_IWUSR, etm_show_trigger_event, |
| 690 | etm_store_trigger_event); |
| 691 | |
| 692 | static ssize_t etm_show_enable_event(struct device *dev, |
| 693 | struct device_attribute *attr, char *buf) |
| 694 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 695 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 696 | unsigned long val = drvdata->enable_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 697 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 698 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 699 | } |
| 700 | |
| 701 | static ssize_t etm_store_enable_event(struct device *dev, |
| 702 | struct device_attribute *attr, |
| 703 | const char *buf, size_t size) |
| 704 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 705 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 706 | unsigned long val; |
| 707 | |
| 708 | if (sscanf(buf, "%lx", &val) != 1) |
| 709 | return -EINVAL; |
| 710 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 711 | drvdata->enable_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 712 | return size; |
| 713 | } |
| 714 | static DEVICE_ATTR(enable_event, S_IRUGO | S_IWUSR, etm_show_enable_event, |
| 715 | etm_store_enable_event); |
| 716 | |
| 717 | static ssize_t etm_show_fifofull_level(struct device *dev, |
| 718 | struct device_attribute *attr, char *buf) |
| 719 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 720 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 721 | unsigned long val = drvdata->fifofull_level; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 722 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 723 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 724 | } |
| 725 | |
| 726 | static ssize_t etm_store_fifofull_level(struct device *dev, |
| 727 | struct device_attribute *attr, |
| 728 | const char *buf, size_t size) |
| 729 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 730 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 731 | unsigned long val; |
| 732 | |
| 733 | if (sscanf(buf, "%lx", &val) != 1) |
| 734 | return -EINVAL; |
| 735 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 736 | drvdata->fifofull_level = val; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 737 | return size; |
| 738 | } |
| 739 | static DEVICE_ATTR(fifofull_level, S_IRUGO | S_IWUSR, etm_show_fifofull_level, |
| 740 | etm_store_fifofull_level); |
| 741 | |
| 742 | static ssize_t etm_show_addr_idx(struct device *dev, |
| 743 | struct device_attribute *attr, char *buf) |
| 744 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 745 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 746 | unsigned long val = drvdata->addr_idx; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 747 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 748 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 749 | } |
| 750 | |
| 751 | static ssize_t etm_store_addr_idx(struct device *dev, |
| 752 | struct device_attribute *attr, |
| 753 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 754 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 755 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 756 | unsigned long val; |
| 757 | |
| 758 | if (sscanf(buf, "%lx", &val) != 1) |
| 759 | return -EINVAL; |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 760 | if (val >= drvdata->nr_addr_cmp) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 761 | return -EINVAL; |
| 762 | |
| 763 | /* Use mutex to ensure index doesn't change while it gets dereferenced |
| 764 | * multiple times within a mutex block elsewhere. |
| 765 | */ |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 766 | mutex_lock(&drvdata->mutex); |
| 767 | drvdata->addr_idx = val; |
| 768 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 769 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 770 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 771 | static DEVICE_ATTR(addr_idx, S_IRUGO | S_IWUSR, etm_show_addr_idx, |
| 772 | etm_store_addr_idx); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 773 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 774 | static ssize_t etm_show_addr_single(struct device *dev, |
| 775 | struct device_attribute *attr, char *buf) |
| 776 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 777 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 778 | unsigned long val; |
| 779 | uint8_t idx; |
| 780 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 781 | mutex_lock(&drvdata->mutex); |
| 782 | idx = drvdata->addr_idx; |
| 783 | if (!(drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE || |
| 784 | drvdata->addr_type[idx] == ETM_ADDR_TYPE_SINGLE)) { |
| 785 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 786 | return -EPERM; |
| 787 | } |
| 788 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 789 | val = drvdata->addr_val[idx]; |
| 790 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 791 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 792 | } |
| 793 | |
| 794 | static ssize_t etm_store_addr_single(struct device *dev, |
| 795 | struct device_attribute *attr, |
| 796 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 797 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 798 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 799 | unsigned long val; |
| 800 | uint8_t idx; |
| 801 | |
| 802 | if (sscanf(buf, "%lx", &val) != 1) |
| 803 | return -EINVAL; |
| 804 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 805 | mutex_lock(&drvdata->mutex); |
| 806 | idx = drvdata->addr_idx; |
| 807 | if (!(drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE || |
| 808 | drvdata->addr_type[idx] == ETM_ADDR_TYPE_SINGLE)) { |
| 809 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 810 | return -EPERM; |
| 811 | } |
| 812 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 813 | drvdata->addr_val[idx] = val; |
| 814 | drvdata->addr_type[idx] = ETM_ADDR_TYPE_SINGLE; |
| 815 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 816 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 817 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 818 | static DEVICE_ATTR(addr_single, S_IRUGO | S_IWUSR, etm_show_addr_single, |
| 819 | etm_store_addr_single); |
| 820 | |
| 821 | static ssize_t etm_show_addr_range(struct device *dev, |
| 822 | struct device_attribute *attr, char *buf) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 823 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 824 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 825 | unsigned long val1, val2; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 826 | uint8_t idx; |
| 827 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 828 | mutex_lock(&drvdata->mutex); |
| 829 | idx = drvdata->addr_idx; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 830 | if (idx % 2 != 0) { |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 831 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 832 | return -EPERM; |
| 833 | } |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 834 | if (!((drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE && |
| 835 | drvdata->addr_type[idx + 1] == ETM_ADDR_TYPE_NONE) || |
| 836 | (drvdata->addr_type[idx] == ETM_ADDR_TYPE_RANGE && |
| 837 | drvdata->addr_type[idx + 1] == ETM_ADDR_TYPE_RANGE))) { |
| 838 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 839 | return -EPERM; |
| 840 | } |
| 841 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 842 | val1 = drvdata->addr_val[idx]; |
| 843 | val2 = drvdata->addr_val[idx + 1]; |
| 844 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 845 | return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 846 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 847 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 848 | static ssize_t etm_store_addr_range(struct device *dev, |
| 849 | struct device_attribute *attr, |
| 850 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 851 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 852 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 853 | unsigned long val1, val2; |
| 854 | uint8_t idx; |
| 855 | |
| 856 | if (sscanf(buf, "%lx %lx", &val1, &val2) != 2) |
| 857 | return -EINVAL; |
| 858 | /* lower address comparator cannot have a higher address value */ |
| 859 | if (val1 > val2) |
| 860 | return -EINVAL; |
| 861 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 862 | mutex_lock(&drvdata->mutex); |
| 863 | idx = drvdata->addr_idx; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 864 | if (idx % 2 != 0) { |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 865 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 866 | return -EPERM; |
| 867 | } |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 868 | if (!((drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE && |
| 869 | drvdata->addr_type[idx + 1] == ETM_ADDR_TYPE_NONE) || |
| 870 | (drvdata->addr_type[idx] == ETM_ADDR_TYPE_RANGE && |
| 871 | drvdata->addr_type[idx + 1] == ETM_ADDR_TYPE_RANGE))) { |
| 872 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 873 | return -EPERM; |
| 874 | } |
| 875 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 876 | drvdata->addr_val[idx] = val1; |
| 877 | drvdata->addr_type[idx] = ETM_ADDR_TYPE_RANGE; |
| 878 | drvdata->addr_val[idx + 1] = val2; |
| 879 | drvdata->addr_type[idx + 1] = ETM_ADDR_TYPE_RANGE; |
| 880 | drvdata->enable_ctrl1 |= (1 << (idx/2)); |
| 881 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 882 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 883 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 884 | static DEVICE_ATTR(addr_range, S_IRUGO | S_IWUSR, etm_show_addr_range, |
| 885 | etm_store_addr_range); |
| 886 | |
| 887 | static ssize_t etm_show_addr_start(struct device *dev, |
| 888 | struct device_attribute *attr, char *buf) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 889 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 890 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 891 | unsigned long val; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 892 | uint8_t idx; |
| 893 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 894 | mutex_lock(&drvdata->mutex); |
| 895 | idx = drvdata->addr_idx; |
| 896 | if (!(drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE || |
| 897 | drvdata->addr_type[idx] == ETM_ADDR_TYPE_START)) { |
| 898 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 899 | return -EPERM; |
| 900 | } |
| 901 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 902 | val = drvdata->addr_val[idx]; |
| 903 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 904 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 905 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 906 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 907 | static ssize_t etm_store_addr_start(struct device *dev, |
| 908 | struct device_attribute *attr, |
| 909 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 910 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 911 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 912 | unsigned long val; |
| 913 | uint8_t idx; |
| 914 | |
| 915 | if (sscanf(buf, "%lx", &val) != 1) |
| 916 | return -EINVAL; |
| 917 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 918 | mutex_lock(&drvdata->mutex); |
| 919 | idx = drvdata->addr_idx; |
| 920 | if (!(drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE || |
| 921 | drvdata->addr_type[idx] == ETM_ADDR_TYPE_START)) { |
| 922 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 923 | return -EPERM; |
| 924 | } |
| 925 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 926 | drvdata->addr_val[idx] = val; |
| 927 | drvdata->addr_type[idx] = ETM_ADDR_TYPE_START; |
| 928 | drvdata->startstop_ctrl |= (1 << idx); |
| 929 | drvdata->enable_ctrl1 |= BIT(25); |
| 930 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 931 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 932 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 933 | static DEVICE_ATTR(addr_start, S_IRUGO | S_IWUSR, etm_show_addr_start, |
| 934 | etm_store_addr_start); |
| 935 | |
| 936 | static ssize_t etm_show_addr_stop(struct device *dev, |
| 937 | struct device_attribute *attr, char *buf) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 938 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 939 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 940 | unsigned long val; |
| 941 | uint8_t idx; |
| 942 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 943 | mutex_lock(&drvdata->mutex); |
| 944 | idx = drvdata->addr_idx; |
| 945 | if (!(drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE || |
| 946 | drvdata->addr_type[idx] == ETM_ADDR_TYPE_STOP)) { |
| 947 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 948 | return -EPERM; |
| 949 | } |
| 950 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 951 | val = drvdata->addr_val[idx]; |
| 952 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 953 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 954 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 955 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 956 | static ssize_t etm_store_addr_stop(struct device *dev, |
| 957 | struct device_attribute *attr, |
| 958 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 959 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 960 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 961 | unsigned long val; |
| 962 | uint8_t idx; |
| 963 | |
| 964 | if (sscanf(buf, "%lx", &val) != 1) |
| 965 | return -EINVAL; |
| 966 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 967 | mutex_lock(&drvdata->mutex); |
| 968 | idx = drvdata->addr_idx; |
| 969 | if (!(drvdata->addr_type[idx] == ETM_ADDR_TYPE_NONE || |
| 970 | drvdata->addr_type[idx] == ETM_ADDR_TYPE_STOP)) { |
| 971 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 972 | return -EPERM; |
| 973 | } |
| 974 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 975 | drvdata->addr_val[idx] = val; |
| 976 | drvdata->addr_type[idx] = ETM_ADDR_TYPE_STOP; |
| 977 | drvdata->startstop_ctrl |= (1 << (idx + 16)); |
| 978 | drvdata->enable_ctrl1 |= BIT(25); |
| 979 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 980 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 981 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 982 | static DEVICE_ATTR(addr_stop, S_IRUGO | S_IWUSR, etm_show_addr_stop, |
| 983 | etm_store_addr_stop); |
| 984 | |
| 985 | static ssize_t etm_show_addr_acctype(struct device *dev, |
| 986 | struct device_attribute *attr, char *buf) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 987 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 988 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 989 | unsigned long val; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 990 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 991 | mutex_lock(&drvdata->mutex); |
| 992 | val = drvdata->addr_acctype[drvdata->addr_idx]; |
| 993 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 994 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 995 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 996 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 997 | static ssize_t etm_store_addr_acctype(struct device *dev, |
| 998 | struct device_attribute *attr, |
| 999 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1000 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1001 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1002 | unsigned long val; |
| 1003 | |
| 1004 | if (sscanf(buf, "%lx", &val) != 1) |
| 1005 | return -EINVAL; |
| 1006 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1007 | mutex_lock(&drvdata->mutex); |
| 1008 | drvdata->addr_acctype[drvdata->addr_idx] = val; |
| 1009 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1010 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1011 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1012 | static DEVICE_ATTR(addr_acctype, S_IRUGO | S_IWUSR, etm_show_addr_acctype, |
| 1013 | etm_store_addr_acctype); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1014 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1015 | static ssize_t etm_show_cntr_idx(struct device *dev, |
| 1016 | struct device_attribute *attr, char *buf) |
| 1017 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1018 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1019 | unsigned long val = drvdata->addr_idx; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1020 | |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1021 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1022 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1023 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1024 | static ssize_t etm_store_cntr_idx(struct device *dev, |
| 1025 | struct device_attribute *attr, |
| 1026 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1027 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1028 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1029 | unsigned long val; |
| 1030 | |
| 1031 | if (sscanf(buf, "%lx", &val) != 1) |
| 1032 | return -EINVAL; |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1033 | if (val >= drvdata->nr_cntr) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1034 | return -EINVAL; |
| 1035 | |
| 1036 | /* Use mutex to ensure index doesn't change while it gets dereferenced |
| 1037 | * multiple times within a mutex block elsewhere. |
| 1038 | */ |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1039 | mutex_lock(&drvdata->mutex); |
| 1040 | drvdata->cntr_idx = val; |
| 1041 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1042 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1043 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1044 | static DEVICE_ATTR(cntr_idx, S_IRUGO | S_IWUSR, etm_show_cntr_idx, |
| 1045 | etm_store_cntr_idx); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1046 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1047 | static ssize_t etm_show_cntr_rld_val(struct device *dev, |
| 1048 | struct device_attribute *attr, char *buf) |
| 1049 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1050 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1051 | unsigned long val; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1052 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1053 | mutex_lock(&drvdata->mutex); |
| 1054 | val = drvdata->cntr_rld_val[drvdata->cntr_idx]; |
| 1055 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1056 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1057 | } |
| 1058 | |
| 1059 | static ssize_t etm_store_cntr_rld_val(struct device *dev, |
| 1060 | struct device_attribute *attr, |
| 1061 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1062 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1063 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1064 | unsigned long val; |
| 1065 | |
| 1066 | if (sscanf(buf, "%lx", &val) != 1) |
| 1067 | return -EINVAL; |
| 1068 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1069 | mutex_lock(&drvdata->mutex); |
| 1070 | drvdata->cntr_rld_val[drvdata->cntr_idx] = val; |
| 1071 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1072 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1073 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1074 | static DEVICE_ATTR(cntr_rld_val, S_IRUGO | S_IWUSR, etm_show_cntr_rld_val, |
| 1075 | etm_store_cntr_rld_val); |
| 1076 | |
| 1077 | static ssize_t etm_show_cntr_event(struct device *dev, |
| 1078 | struct device_attribute *attr, char *buf) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1079 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1080 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1081 | unsigned long val; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1082 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1083 | mutex_lock(&drvdata->mutex); |
| 1084 | val = drvdata->cntr_event[drvdata->cntr_idx]; |
| 1085 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1086 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1087 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1088 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1089 | static ssize_t etm_store_cntr_event(struct device *dev, |
| 1090 | struct device_attribute *attr, |
| 1091 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1092 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1093 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1094 | unsigned long val; |
| 1095 | |
| 1096 | if (sscanf(buf, "%lx", &val) != 1) |
| 1097 | return -EINVAL; |
| 1098 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1099 | mutex_lock(&drvdata->mutex); |
| 1100 | drvdata->cntr_event[drvdata->cntr_idx] = val & ETM_EVENT_MASK; |
| 1101 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1102 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1103 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1104 | static DEVICE_ATTR(cntr_event, S_IRUGO | S_IWUSR, etm_show_cntr_event, |
| 1105 | etm_store_cntr_event); |
| 1106 | |
| 1107 | static ssize_t etm_show_cntr_rld_event(struct device *dev, |
| 1108 | struct device_attribute *attr, char *buf) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1109 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1110 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1111 | unsigned long val; |
| 1112 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1113 | mutex_lock(&drvdata->mutex); |
| 1114 | val = drvdata->cntr_rld_event[drvdata->cntr_idx]; |
| 1115 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1116 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1117 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1118 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1119 | static ssize_t etm_store_cntr_rld_event(struct device *dev, |
| 1120 | struct device_attribute *attr, |
| 1121 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1122 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1123 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1124 | unsigned long val; |
| 1125 | |
| 1126 | if (sscanf(buf, "%lx", &val) != 1) |
| 1127 | return -EINVAL; |
| 1128 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1129 | mutex_lock(&drvdata->mutex); |
| 1130 | drvdata->cntr_rld_event[drvdata->cntr_idx] = val & ETM_EVENT_MASK; |
| 1131 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1132 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1133 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1134 | static DEVICE_ATTR(cntr_rld_event, S_IRUGO | S_IWUSR, etm_show_cntr_rld_event, |
| 1135 | etm_store_cntr_rld_event); |
| 1136 | |
| 1137 | static ssize_t etm_show_cntr_val(struct device *dev, |
| 1138 | struct device_attribute *attr, char *buf) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1139 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1140 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1141 | unsigned long val; |
| 1142 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1143 | mutex_lock(&drvdata->mutex); |
| 1144 | val = drvdata->cntr_val[drvdata->cntr_idx]; |
| 1145 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1146 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1147 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1148 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1149 | static ssize_t etm_store_cntr_val(struct device *dev, |
| 1150 | struct device_attribute *attr, |
| 1151 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1152 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1153 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1154 | unsigned long val; |
| 1155 | |
| 1156 | if (sscanf(buf, "%lx", &val) != 1) |
| 1157 | return -EINVAL; |
| 1158 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1159 | mutex_lock(&drvdata->mutex); |
| 1160 | drvdata->cntr_val[drvdata->cntr_idx] = val; |
| 1161 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1162 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1163 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1164 | static DEVICE_ATTR(cntr_val, S_IRUGO | S_IWUSR, etm_show_cntr_val, |
| 1165 | etm_store_cntr_val); |
| 1166 | |
| 1167 | static ssize_t etm_show_seq_12_event(struct device *dev, |
| 1168 | struct device_attribute *attr, char *buf) |
| 1169 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1170 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1171 | unsigned long val = drvdata->seq_12_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1172 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1173 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1174 | } |
| 1175 | |
| 1176 | static ssize_t etm_store_seq_12_event(struct device *dev, |
| 1177 | struct device_attribute *attr, |
| 1178 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1179 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1180 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1181 | unsigned long val; |
| 1182 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1183 | if (sscanf(buf, "%lx", &val) != 1) |
| 1184 | return -EINVAL; |
| 1185 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1186 | drvdata->seq_12_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1187 | return size; |
| 1188 | } |
| 1189 | static DEVICE_ATTR(seq_12_event, S_IRUGO | S_IWUSR, etm_show_seq_12_event, |
| 1190 | etm_store_seq_12_event); |
| 1191 | |
| 1192 | static ssize_t etm_show_seq_21_event(struct device *dev, |
| 1193 | struct device_attribute *attr, char *buf) |
| 1194 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1195 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1196 | unsigned long val = drvdata->seq_21_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1197 | |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1198 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1199 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1200 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1201 | static ssize_t etm_store_seq_21_event(struct device *dev, |
| 1202 | struct device_attribute *attr, |
| 1203 | const char *buf, size_t size) |
| 1204 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1205 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1206 | unsigned long val; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1207 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1208 | if (sscanf(buf, "%lx", &val) != 1) |
| 1209 | return -EINVAL; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1210 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1211 | drvdata->seq_21_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1212 | return size; |
| 1213 | } |
| 1214 | static DEVICE_ATTR(seq_21_event, S_IRUGO | S_IWUSR, etm_show_seq_21_event, |
| 1215 | etm_store_seq_21_event); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1216 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1217 | static ssize_t etm_show_seq_23_event(struct device *dev, |
| 1218 | struct device_attribute *attr, char *buf) |
| 1219 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1220 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1221 | unsigned long val = drvdata->seq_23_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1222 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1223 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1224 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1225 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1226 | static ssize_t etm_store_seq_23_event(struct device *dev, |
| 1227 | struct device_attribute *attr, |
| 1228 | const char *buf, size_t size) |
| 1229 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1230 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1231 | unsigned long val; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1232 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1233 | if (sscanf(buf, "%lx", &val) != 1) |
| 1234 | return -EINVAL; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1235 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1236 | drvdata->seq_23_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1237 | return size; |
| 1238 | } |
| 1239 | static DEVICE_ATTR(seq_23_event, S_IRUGO | S_IWUSR, etm_show_seq_23_event, |
| 1240 | etm_store_seq_23_event); |
| 1241 | |
| 1242 | static ssize_t etm_show_seq_31_event(struct device *dev, |
| 1243 | struct device_attribute *attr, char *buf) |
| 1244 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1245 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1246 | unsigned long val = drvdata->seq_31_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1247 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1248 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1249 | } |
| 1250 | |
| 1251 | static ssize_t etm_store_seq_31_event(struct device *dev, |
| 1252 | struct device_attribute *attr, |
| 1253 | const char *buf, size_t size) |
| 1254 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1255 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1256 | unsigned long val; |
| 1257 | |
| 1258 | if (sscanf(buf, "%lx", &val) != 1) |
| 1259 | return -EINVAL; |
| 1260 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1261 | drvdata->seq_31_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1262 | return size; |
| 1263 | } |
| 1264 | static DEVICE_ATTR(seq_31_event, S_IRUGO | S_IWUSR, etm_show_seq_31_event, |
| 1265 | etm_store_seq_31_event); |
| 1266 | |
| 1267 | static ssize_t etm_show_seq_32_event(struct device *dev, |
| 1268 | struct device_attribute *attr, char *buf) |
| 1269 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1270 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1271 | unsigned long val = drvdata->seq_32_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1272 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1273 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1274 | } |
| 1275 | |
| 1276 | static ssize_t etm_store_seq_32_event(struct device *dev, |
| 1277 | struct device_attribute *attr, |
| 1278 | const char *buf, size_t size) |
| 1279 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1280 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1281 | unsigned long val; |
| 1282 | |
| 1283 | if (sscanf(buf, "%lx", &val) != 1) |
| 1284 | return -EINVAL; |
| 1285 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1286 | drvdata->seq_32_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1287 | return size; |
| 1288 | } |
| 1289 | static DEVICE_ATTR(seq_32_event, S_IRUGO | S_IWUSR, etm_show_seq_32_event, |
| 1290 | etm_store_seq_32_event); |
| 1291 | |
| 1292 | static ssize_t etm_show_seq_13_event(struct device *dev, |
| 1293 | struct device_attribute *attr, char *buf) |
| 1294 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1295 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1296 | unsigned long val = drvdata->seq_13_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1297 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1298 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1299 | } |
| 1300 | |
| 1301 | static ssize_t etm_store_seq_13_event(struct device *dev, |
| 1302 | struct device_attribute *attr, |
| 1303 | const char *buf, size_t size) |
| 1304 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1305 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1306 | unsigned long val; |
| 1307 | |
| 1308 | if (sscanf(buf, "%lx", &val) != 1) |
| 1309 | return -EINVAL; |
| 1310 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1311 | drvdata->seq_13_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1312 | return size; |
| 1313 | } |
| 1314 | static DEVICE_ATTR(seq_13_event, S_IRUGO | S_IWUSR, etm_show_seq_13_event, |
| 1315 | etm_store_seq_13_event); |
| 1316 | |
| 1317 | static ssize_t etm_show_seq_curr_state(struct device *dev, |
| 1318 | struct device_attribute *attr, char *buf) |
| 1319 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1320 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1321 | unsigned long val = drvdata->seq_curr_state; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1322 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1323 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1324 | } |
| 1325 | |
| 1326 | static ssize_t etm_store_seq_curr_state(struct device *dev, |
| 1327 | struct device_attribute *attr, |
| 1328 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1329 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1330 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1331 | unsigned long val; |
| 1332 | |
| 1333 | if (sscanf(buf, "%lx", &val) != 1) |
| 1334 | return -EINVAL; |
| 1335 | if (val > ETM_SEQ_STATE_MAX_VAL) |
| 1336 | return -EINVAL; |
| 1337 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1338 | drvdata->seq_curr_state = val; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1339 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1340 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1341 | static DEVICE_ATTR(seq_curr_state, S_IRUGO | S_IWUSR, etm_show_seq_curr_state, |
| 1342 | etm_store_seq_curr_state); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1343 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1344 | static ssize_t etm_show_ctxid_idx(struct device *dev, |
| 1345 | struct device_attribute *attr, char *buf) |
| 1346 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1347 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1348 | unsigned long val = drvdata->ctxid_idx; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1349 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1350 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1351 | } |
| 1352 | |
| 1353 | static ssize_t etm_store_ctxid_idx(struct device *dev, |
| 1354 | struct device_attribute *attr, |
| 1355 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1356 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1357 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1358 | unsigned long val; |
| 1359 | |
| 1360 | if (sscanf(buf, "%lx", &val) != 1) |
| 1361 | return -EINVAL; |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1362 | if (val >= drvdata->nr_ctxid_cmp) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1363 | return -EINVAL; |
| 1364 | |
| 1365 | /* Use mutex to ensure index doesn't change while it gets dereferenced |
| 1366 | * multiple times within a mutex block elsewhere. |
| 1367 | */ |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1368 | mutex_lock(&drvdata->mutex); |
| 1369 | drvdata->ctxid_idx = val; |
| 1370 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1371 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1372 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1373 | static DEVICE_ATTR(ctxid_idx, S_IRUGO | S_IWUSR, etm_show_ctxid_idx, |
| 1374 | etm_store_ctxid_idx); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1375 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1376 | static ssize_t etm_show_ctxid_val(struct device *dev, |
| 1377 | struct device_attribute *attr, char *buf) |
| 1378 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1379 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1380 | unsigned long val; |
| 1381 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1382 | mutex_lock(&drvdata->mutex); |
| 1383 | val = drvdata->ctxid_val[drvdata->ctxid_idx]; |
| 1384 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1385 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1386 | } |
| 1387 | |
| 1388 | static ssize_t etm_store_ctxid_val(struct device *dev, |
| 1389 | struct device_attribute *attr, |
| 1390 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1391 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1392 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1393 | unsigned long val; |
| 1394 | |
| 1395 | if (sscanf(buf, "%lx", &val) != 1) |
| 1396 | return -EINVAL; |
| 1397 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1398 | mutex_lock(&drvdata->mutex); |
| 1399 | drvdata->ctxid_val[drvdata->ctxid_idx] = val; |
| 1400 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1401 | return size; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1402 | } |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1403 | static DEVICE_ATTR(ctxid_val, S_IRUGO | S_IWUSR, etm_show_ctxid_val, |
| 1404 | etm_store_ctxid_val); |
| 1405 | |
| 1406 | static ssize_t etm_show_ctxid_mask(struct device *dev, |
| 1407 | struct device_attribute *attr, char *buf) |
| 1408 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1409 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1410 | unsigned long val = drvdata->ctxid_mask; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1411 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1412 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1413 | } |
| 1414 | |
| 1415 | static ssize_t etm_store_ctxid_mask(struct device *dev, |
| 1416 | struct device_attribute *attr, |
| 1417 | const char *buf, size_t size) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1418 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1419 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1420 | unsigned long val; |
| 1421 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1422 | if (sscanf(buf, "%lx", &val) != 1) |
| 1423 | return -EINVAL; |
| 1424 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1425 | drvdata->ctxid_mask = val; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1426 | return size; |
| 1427 | } |
| 1428 | static DEVICE_ATTR(ctxid_mask, S_IRUGO | S_IWUSR, etm_show_ctxid_mask, |
| 1429 | etm_store_ctxid_mask); |
| 1430 | |
| 1431 | static ssize_t etm_show_sync_freq(struct device *dev, |
| 1432 | struct device_attribute *attr, char *buf) |
| 1433 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1434 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1435 | unsigned long val = drvdata->sync_freq; |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1436 | |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1437 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1438 | } |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1439 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1440 | static ssize_t etm_store_sync_freq(struct device *dev, |
| 1441 | struct device_attribute *attr, |
| 1442 | const char *buf, size_t size) |
| 1443 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1444 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1445 | unsigned long val; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1446 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1447 | if (sscanf(buf, "%lx", &val) != 1) |
| 1448 | return -EINVAL; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1449 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1450 | drvdata->sync_freq = val & ETM_SYNC_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1451 | return size; |
| 1452 | } |
| 1453 | static DEVICE_ATTR(sync_freq, S_IRUGO | S_IWUSR, etm_show_sync_freq, |
| 1454 | etm_store_sync_freq); |
| 1455 | |
| 1456 | static ssize_t etm_show_timestamp_event(struct device *dev, |
| 1457 | struct device_attribute *attr, |
| 1458 | char *buf) |
| 1459 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1460 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1461 | unsigned long val = drvdata->timestamp_event; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1462 | |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1463 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1464 | } |
| 1465 | |
| 1466 | static ssize_t etm_store_timestamp_event(struct device *dev, |
| 1467 | struct device_attribute *attr, |
| 1468 | const char *buf, size_t size) |
| 1469 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1470 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1471 | unsigned long val; |
| 1472 | |
| 1473 | if (sscanf(buf, "%lx", &val) != 1) |
| 1474 | return -EINVAL; |
| 1475 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1476 | drvdata->timestamp_event = val & ETM_EVENT_MASK; |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1477 | return size; |
| 1478 | } |
| 1479 | static DEVICE_ATTR(timestamp_event, S_IRUGO | S_IWUSR, etm_show_timestamp_event, |
| 1480 | etm_store_timestamp_event); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1481 | |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1482 | static ssize_t etm_show_pcsave(struct device *dev, |
| 1483 | struct device_attribute *attr, char *buf) |
| 1484 | { |
| 1485 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
| 1486 | unsigned long val; |
| 1487 | |
| 1488 | val = drvdata->pcsave_enable; |
| 1489 | return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); |
| 1490 | } |
| 1491 | |
| 1492 | static int __etm_store_pcsave(struct etm_drvdata *drvdata, unsigned long val) |
| 1493 | { |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1494 | int ret = 0; |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1495 | |
| 1496 | ret = clk_prepare_enable(drvdata->clk); |
| 1497 | if (ret) |
| 1498 | return ret; |
| 1499 | |
| 1500 | mutex_lock(&drvdata->mutex); |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1501 | get_online_cpus(); |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1502 | if (val) { |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1503 | if (drvdata->pcsave_enable) |
| 1504 | goto out; |
| 1505 | |
| 1506 | ret = smp_call_function_single(drvdata->cpu, etm_enable_pcsave, |
| 1507 | drvdata, 1); |
| 1508 | if (ret) |
| 1509 | goto out; |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1510 | drvdata->pcsave_enable = true; |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1511 | |
| 1512 | dev_info(drvdata->dev, "PC save enabled\n"); |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1513 | } else { |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1514 | if (!drvdata->pcsave_enable) |
| 1515 | goto out; |
| 1516 | |
| 1517 | ret = smp_call_function_single(drvdata->cpu, etm_disable_pcsave, |
| 1518 | drvdata, 1); |
| 1519 | if (ret) |
| 1520 | goto out; |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1521 | drvdata->pcsave_enable = false; |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1522 | |
| 1523 | dev_info(drvdata->dev, "PC save disabled\n"); |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1524 | } |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1525 | out: |
| 1526 | put_online_cpus(); |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1527 | mutex_unlock(&drvdata->mutex); |
| 1528 | |
| 1529 | clk_disable_unprepare(drvdata->clk); |
Pratik Patel | 9dbfa37 | 2012-10-23 22:36:40 -0700 | [diff] [blame^] | 1530 | return ret; |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1531 | } |
| 1532 | |
| 1533 | static ssize_t etm_store_pcsave(struct device *dev, |
| 1534 | struct device_attribute *attr, |
| 1535 | const char *buf, size_t size) |
| 1536 | { |
| 1537 | struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); |
| 1538 | unsigned long val; |
| 1539 | int ret; |
| 1540 | |
| 1541 | if (sscanf(buf, "%lx", &val) != 1) |
| 1542 | return -EINVAL; |
| 1543 | |
| 1544 | ret = __etm_store_pcsave(drvdata, val); |
| 1545 | if (ret) |
| 1546 | return ret; |
| 1547 | |
| 1548 | return size; |
| 1549 | } |
| 1550 | static DEVICE_ATTR(pcsave, S_IRUGO | S_IWUSR, etm_show_pcsave, |
| 1551 | etm_store_pcsave); |
| 1552 | |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1553 | static struct attribute *etm_attrs[] = { |
Pratik Patel | a9c0e06 | 2012-05-28 13:45:35 -0700 | [diff] [blame] | 1554 | &dev_attr_nr_addr_cmp.attr, |
| 1555 | &dev_attr_nr_cntr.attr, |
| 1556 | &dev_attr_nr_ctxid_cmp.attr, |
| 1557 | &dev_attr_reset.attr, |
| 1558 | &dev_attr_mode.attr, |
| 1559 | &dev_attr_trigger_event.attr, |
| 1560 | &dev_attr_enable_event.attr, |
| 1561 | &dev_attr_fifofull_level.attr, |
| 1562 | &dev_attr_addr_idx.attr, |
| 1563 | &dev_attr_addr_single.attr, |
| 1564 | &dev_attr_addr_range.attr, |
| 1565 | &dev_attr_addr_start.attr, |
| 1566 | &dev_attr_addr_stop.attr, |
| 1567 | &dev_attr_addr_acctype.attr, |
| 1568 | &dev_attr_cntr_idx.attr, |
| 1569 | &dev_attr_cntr_rld_val.attr, |
| 1570 | &dev_attr_cntr_event.attr, |
| 1571 | &dev_attr_cntr_rld_event.attr, |
| 1572 | &dev_attr_cntr_val.attr, |
| 1573 | &dev_attr_seq_12_event.attr, |
| 1574 | &dev_attr_seq_21_event.attr, |
| 1575 | &dev_attr_seq_23_event.attr, |
| 1576 | &dev_attr_seq_31_event.attr, |
| 1577 | &dev_attr_seq_32_event.attr, |
| 1578 | &dev_attr_seq_13_event.attr, |
| 1579 | &dev_attr_seq_curr_state.attr, |
| 1580 | &dev_attr_ctxid_idx.attr, |
| 1581 | &dev_attr_ctxid_val.attr, |
| 1582 | &dev_attr_ctxid_mask.attr, |
| 1583 | &dev_attr_sync_freq.attr, |
| 1584 | &dev_attr_timestamp_event.attr, |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1585 | NULL, |
| 1586 | }; |
| 1587 | |
| 1588 | static struct attribute_group etm_attr_grp = { |
| 1589 | .attrs = etm_attrs, |
| 1590 | }; |
| 1591 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1592 | static const struct attribute_group *etm_attr_grps[] = { |
| 1593 | &etm_attr_grp, |
| 1594 | NULL, |
| 1595 | }; |
| 1596 | |
| 1597 | /* Memory mapped writes to clear os lock not supported */ |
| 1598 | static void etm_os_unlock(void *unused) |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1599 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1600 | unsigned long value = 0x0; |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1601 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1602 | asm("mcr p14, 1, %0, c1, c0, 4\n\t" : : "r" (value)); |
| 1603 | asm("isb\n\t"); |
Pratik Patel | 6630ebe | 2012-03-06 16:44:22 -0800 | [diff] [blame] | 1604 | } |
| 1605 | |
Stephen Boyd | a951050 | 2012-04-24 16:23:34 -0700 | [diff] [blame] | 1606 | static bool __devinit etm_arch_supported(uint8_t arch) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1607 | { |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 1608 | switch (arch) { |
| 1609 | case PFT_ARCH_V1_1: |
| 1610 | break; |
| 1611 | default: |
| 1612 | return false; |
| 1613 | } |
| 1614 | return true; |
| 1615 | } |
| 1616 | |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 1617 | static void __devinit etm_prepare_arch(struct etm_drvdata *drvdata) |
| 1618 | { |
| 1619 | /* Unlock OS lock first to allow memory mapped reads and writes. This |
| 1620 | * is required for Krait pass1 |
| 1621 | * */ |
| 1622 | etm_os_unlock(NULL); |
| 1623 | smp_call_function(etm_os_unlock, NULL, 1); |
| 1624 | } |
| 1625 | |
| 1626 | static void __devinit etm_init_arch_data(void *info) |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 1627 | { |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 1628 | uint32_t etmidr; |
| 1629 | uint32_t etmccr; |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 1630 | struct etm_drvdata *drvdata = info; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1631 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1632 | ETM_UNLOCK(drvdata); |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1633 | /* |
| 1634 | * Vote for ETM power/clock enable. ETMPDCR is only accessible via |
| 1635 | * memory mapped interface and so use it first to enable power/clock |
| 1636 | * to allow subsequent cp14 accesses. |
| 1637 | */ |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 1638 | etm_set_pwrup(drvdata); |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 1639 | /* |
| 1640 | * Clear power down bit since when this bit is set writes to |
| 1641 | * certain registers might be ignored. |
| 1642 | */ |
| 1643 | etm_clr_pwrdwn(drvdata); |
Pratik Patel | 61de730 | 2012-03-07 12:06:10 -0800 | [diff] [blame] | 1644 | /* Set prog bit. It will be set from reset but this is included to |
| 1645 | * ensure it is set |
| 1646 | */ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1647 | etm_set_prog(drvdata); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1648 | |
| 1649 | /* find all capabilities */ |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1650 | etmidr = etm_readl(drvdata, ETMIDR); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1651 | drvdata->arch = BMVAL(etmidr, 4, 11); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1652 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1653 | etmccr = etm_readl(drvdata, ETMCCR); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1654 | drvdata->nr_addr_cmp = BMVAL(etmccr, 0, 3) * 2; |
| 1655 | drvdata->nr_cntr = BMVAL(etmccr, 13, 15); |
| 1656 | drvdata->nr_ext_inp = BMVAL(etmccr, 17, 19); |
| 1657 | drvdata->nr_ext_out = BMVAL(etmccr, 20, 22); |
| 1658 | drvdata->nr_ctxid_cmp = BMVAL(etmccr, 24, 25); |
Pratik Patel | 2d0c7b6 | 2012-02-24 19:04:37 -0800 | [diff] [blame] | 1659 | |
Pratik Patel | d1d65c9 | 2012-09-25 23:37:43 -0700 | [diff] [blame] | 1660 | etm_set_pwrdwn(drvdata); |
Pratik Patel | ef6da29 | 2012-09-17 17:37:19 -0700 | [diff] [blame] | 1661 | etm_clr_pwrup(drvdata); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1662 | ETM_LOCK(drvdata); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1663 | } |
| 1664 | |
Pratik Patel | c14b4df | 2012-09-05 18:07:59 -0700 | [diff] [blame] | 1665 | static void __devinit etm_copy_arch_data(struct etm_drvdata *drvdata) |
| 1666 | { |
| 1667 | drvdata->arch = etm0drvdata->arch; |
| 1668 | drvdata->nr_addr_cmp = etm0drvdata->nr_addr_cmp; |
| 1669 | drvdata->nr_cntr = etm0drvdata->nr_cntr; |
| 1670 | drvdata->nr_ext_inp = etm0drvdata->nr_ext_inp; |
| 1671 | drvdata->nr_ext_out = etm0drvdata->nr_ext_out; |
| 1672 | drvdata->nr_ctxid_cmp = etm0drvdata->nr_ctxid_cmp; |
| 1673 | } |
| 1674 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1675 | static void __devinit etm_init_default_data(struct etm_drvdata *drvdata) |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1676 | { |
| 1677 | int i; |
| 1678 | |
| 1679 | drvdata->trigger_event = 0x406F; |
| 1680 | drvdata->enable_event = 0x6F; |
| 1681 | drvdata->enable_ctrl1 = 0x1; |
| 1682 | drvdata->fifofull_level = 0x28; |
| 1683 | if (drvdata->nr_addr_cmp >= 2) { |
| 1684 | drvdata->addr_val[0] = (uint32_t) _stext; |
| 1685 | drvdata->addr_val[1] = (uint32_t) _etext; |
| 1686 | drvdata->addr_type[0] = ETM_ADDR_TYPE_RANGE; |
| 1687 | drvdata->addr_type[1] = ETM_ADDR_TYPE_RANGE; |
| 1688 | } |
| 1689 | for (i = 0; i < drvdata->nr_cntr; i++) { |
| 1690 | drvdata->cntr_event[i] = 0x406F; |
| 1691 | drvdata->cntr_rld_event[i] = 0x406F; |
| 1692 | } |
| 1693 | drvdata->seq_12_event = 0x406F; |
| 1694 | drvdata->seq_21_event = 0x406F; |
| 1695 | drvdata->seq_23_event = 0x406F; |
| 1696 | drvdata->seq_31_event = 0x406F; |
| 1697 | drvdata->seq_32_event = 0x406F; |
| 1698 | drvdata->seq_13_event = 0x406F; |
Pratik Patel | 77b9063 | 2012-07-17 17:54:51 -0700 | [diff] [blame] | 1699 | /* Bits[7:0] of ETMSYNCFR are reserved on Krait pass3 onwards */ |
| 1700 | if (cpu_is_krait() && !cpu_is_krait_v1() && !cpu_is_krait_v2()) |
| 1701 | drvdata->sync_freq = 0x100; |
| 1702 | else |
| 1703 | drvdata->sync_freq = 0x80; |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1704 | drvdata->timestamp_event = 0x406F; |
| 1705 | |
| 1706 | /* Overrides for Krait pass1 */ |
| 1707 | if (cpu_is_krait_v1()) { |
| 1708 | /* Krait pass1 doesn't support include filtering and non-cycle |
| 1709 | * accurate tracing |
| 1710 | */ |
| 1711 | drvdata->mode = (ETM_MODE_EXCLUDE | ETM_MODE_CYCACC); |
| 1712 | drvdata->ctrl = 0x1000; |
| 1713 | drvdata->enable_ctrl1 = 0x1000000; |
| 1714 | for (i = 0; i < drvdata->nr_addr_cmp; i++) { |
| 1715 | drvdata->addr_val[i] = 0x0; |
| 1716 | drvdata->addr_acctype[i] = 0x0; |
| 1717 | drvdata->addr_type[i] = ETM_ADDR_TYPE_NONE; |
| 1718 | } |
| 1719 | } |
| 1720 | } |
| 1721 | |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame] | 1722 | static int __devinit etm_probe(struct platform_device *pdev) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1723 | { |
Pratik Patel | e577179 | 2011-09-17 18:33:54 -0700 | [diff] [blame] | 1724 | int ret; |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1725 | struct device *dev = &pdev->dev; |
Pratik Patel | 5f6d1af | 2012-06-13 15:48:13 -0700 | [diff] [blame] | 1726 | struct coresight_platform_data *pdata; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1727 | struct etm_drvdata *drvdata; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1728 | struct resource *res; |
Pratik Patel | 2647779 | 2012-09-07 01:35:36 -0700 | [diff] [blame] | 1729 | uint32_t reg_size; |
| 1730 | static int count; |
| 1731 | void *baddr; |
| 1732 | struct msm_client_dump dump; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1733 | struct coresight_desc *desc; |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1734 | |
Pratik Patel | 5f6d1af | 2012-06-13 15:48:13 -0700 | [diff] [blame] | 1735 | if (pdev->dev.of_node) { |
| 1736 | pdata = of_get_coresight_platform_data(dev, pdev->dev.of_node); |
| 1737 | if (IS_ERR(pdata)) |
| 1738 | return PTR_ERR(pdata); |
| 1739 | pdev->dev.platform_data = pdata; |
| 1740 | } |
| 1741 | |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1742 | drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); |
| 1743 | if (!drvdata) |
| 1744 | return -ENOMEM; |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1745 | drvdata->dev = &pdev->dev; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1746 | platform_set_drvdata(pdev, drvdata); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1747 | |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1748 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1749 | if (!res) |
| 1750 | return -ENODEV; |
Pratik Patel | 2647779 | 2012-09-07 01:35:36 -0700 | [diff] [blame] | 1751 | reg_size = resource_size(res); |
Pratik Patel | 2c09b76 | 2012-07-21 15:54:54 -0700 | [diff] [blame] | 1752 | |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1753 | drvdata->base = devm_ioremap(dev, res->start, resource_size(res)); |
| 1754 | if (!drvdata->base) |
| 1755 | return -ENOMEM; |
| 1756 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1757 | mutex_init(&drvdata->mutex); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1758 | wake_lock_init(&drvdata->wake_lock, WAKE_LOCK_SUSPEND, "coresight-etm"); |
Pratik Patel | e10a77c | 2012-03-20 10:35:16 -0700 | [diff] [blame] | 1759 | |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1760 | drvdata->clk = devm_clk_get(dev, "core_clk"); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1761 | if (IS_ERR(drvdata->clk)) { |
| 1762 | ret = PTR_ERR(drvdata->clk); |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1763 | goto err0; |
Pratik Patel | f17b147 | 2012-05-25 22:23:52 -0700 | [diff] [blame] | 1764 | } |
Pratik Patel | 2c09b76 | 2012-07-21 15:54:54 -0700 | [diff] [blame] | 1765 | |
Pratik Patel | 6fb3834 | 2012-06-03 14:51:38 -0700 | [diff] [blame] | 1766 | ret = clk_set_rate(drvdata->clk, CORESIGHT_CLK_RATE_TRACE); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1767 | if (ret) |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1768 | goto err0; |
| 1769 | |
Pratik Patel | 2647779 | 2012-09-07 01:35:36 -0700 | [diff] [blame] | 1770 | drvdata->cpu = count++; |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1771 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1772 | ret = clk_prepare_enable(drvdata->clk); |
Pratik Patel | f17b147 | 2012-05-25 22:23:52 -0700 | [diff] [blame] | 1773 | if (ret) |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1774 | goto err0; |
Pratik Patel | 2c09b76 | 2012-07-21 15:54:54 -0700 | [diff] [blame] | 1775 | |
Pratik Patel | c14b4df | 2012-09-05 18:07:59 -0700 | [diff] [blame] | 1776 | /* Use CPU0 to populate read-only configuration data for ETM0. For other |
| 1777 | * ETMs copy it over from ETM0. |
| 1778 | */ |
| 1779 | if (drvdata->cpu == 0) { |
Pratik Patel | e6e41da | 2012-09-12 12:50:29 -0700 | [diff] [blame] | 1780 | etm_prepare_arch(drvdata); |
| 1781 | smp_call_function_single(drvdata->cpu, etm_init_arch_data, |
| 1782 | drvdata, 1); |
Pratik Patel | c14b4df | 2012-09-05 18:07:59 -0700 | [diff] [blame] | 1783 | etm0drvdata = drvdata; |
| 1784 | } else { |
Pratik Patel | dc3a0a4 | 2012-09-11 17:48:23 -0700 | [diff] [blame] | 1785 | etm_copy_arch_data(drvdata); |
| 1786 | } |
| 1787 | if (etm_arch_supported(drvdata->arch) == false) { |
| 1788 | ret = -EINVAL; |
| 1789 | goto err1; |
Pratik Patel | c14b4df | 2012-09-05 18:07:59 -0700 | [diff] [blame] | 1790 | } |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1791 | etm_init_default_data(drvdata); |
Pratik Patel | 2c09b76 | 2012-07-21 15:54:54 -0700 | [diff] [blame] | 1792 | |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1793 | clk_disable_unprepare(drvdata->clk); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1794 | |
Pratik Patel | 2647779 | 2012-09-07 01:35:36 -0700 | [diff] [blame] | 1795 | baddr = devm_kzalloc(dev, PAGE_SIZE + reg_size, GFP_KERNEL); |
| 1796 | if (baddr) { |
| 1797 | *(uint32_t *)(baddr + ETM_REG_DUMP_VER_OFF) = ETM_REG_DUMP_VER; |
| 1798 | dump.id = MSM_ETM0_REG + drvdata->cpu; |
| 1799 | dump.start_addr = virt_to_phys(baddr); |
| 1800 | dump.end_addr = dump.start_addr + PAGE_SIZE + reg_size; |
| 1801 | ret = msm_dump_table_register(&dump); |
| 1802 | if (ret) { |
| 1803 | devm_kfree(dev, baddr); |
| 1804 | dev_err(dev, "ETM REG dump setup failed\n"); |
| 1805 | } |
| 1806 | } else { |
| 1807 | dev_err(dev, "ETM REG dump space allocation failed\n"); |
| 1808 | } |
| 1809 | |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1810 | desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1811 | if (!desc) { |
| 1812 | ret = -ENOMEM; |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1813 | goto err0; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1814 | } |
| 1815 | desc->type = CORESIGHT_DEV_TYPE_SOURCE; |
| 1816 | desc->subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC; |
| 1817 | desc->ops = &etm_cs_ops; |
| 1818 | desc->pdata = pdev->dev.platform_data; |
| 1819 | desc->dev = &pdev->dev; |
| 1820 | desc->groups = etm_attr_grps; |
| 1821 | desc->owner = THIS_MODULE; |
| 1822 | drvdata->csdev = coresight_register(desc); |
| 1823 | if (IS_ERR(drvdata->csdev)) { |
| 1824 | ret = PTR_ERR(drvdata->csdev); |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1825 | goto err0; |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1826 | } |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1827 | |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1828 | if (pdev->dev.of_node) |
| 1829 | drvdata->pcsave_impl = of_property_read_bool(pdev->dev.of_node, |
| 1830 | "qcom,pc-save"); |
| 1831 | if (drvdata->pcsave_impl) { |
| 1832 | ret = device_create_file(&drvdata->csdev->dev, |
| 1833 | &dev_attr_pcsave); |
| 1834 | if (ret) |
| 1835 | dev_err(dev, "ETM pcsave dev node creation failed\n"); |
| 1836 | } |
| 1837 | |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1838 | dev_info(dev, "ETM initialized\n"); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1839 | |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1840 | if (boot_enable) |
| 1841 | coresight_enable(drvdata->csdev); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1842 | |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1843 | if (drvdata->pcsave_impl && boot_pcsave_enable) |
| 1844 | __etm_store_pcsave(drvdata, true); |
| 1845 | |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1846 | return 0; |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1847 | err1: |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1848 | clk_disable_unprepare(drvdata->clk); |
Pratik Patel | 4a1b252 | 2012-06-17 15:31:15 -0700 | [diff] [blame] | 1849 | err0: |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1850 | wake_lock_destroy(&drvdata->wake_lock); |
| 1851 | mutex_destroy(&drvdata->mutex); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1852 | return ret; |
| 1853 | } |
| 1854 | |
Pratik Patel | f6fe918 | 2012-03-20 14:04:18 -0700 | [diff] [blame] | 1855 | static int __devexit etm_remove(struct platform_device *pdev) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1856 | { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1857 | struct etm_drvdata *drvdata = platform_get_drvdata(pdev); |
| 1858 | |
Pratik Patel | 938e1ff | 2012-09-28 23:21:46 -0700 | [diff] [blame] | 1859 | device_remove_file(&drvdata->csdev->dev, &dev_attr_pcsave); |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1860 | coresight_unregister(drvdata->csdev); |
Pratik Patel | 16aefdb | 2012-05-30 10:41:23 -0700 | [diff] [blame] | 1861 | wake_lock_destroy(&drvdata->wake_lock); |
| 1862 | mutex_destroy(&drvdata->mutex); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1863 | return 0; |
| 1864 | } |
| 1865 | |
Pratik Patel | 9eae482 | 2012-05-14 17:34:53 -0700 | [diff] [blame] | 1866 | static struct of_device_id etm_match[] = { |
Pratik Patel | 5f6d1af | 2012-06-13 15:48:13 -0700 | [diff] [blame] | 1867 | {.compatible = "arm,coresight-etm"}, |
Pratik Patel | 9eae482 | 2012-05-14 17:34:53 -0700 | [diff] [blame] | 1868 | {} |
| 1869 | }; |
| 1870 | |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame] | 1871 | static struct platform_driver etm_driver = { |
| 1872 | .probe = etm_probe, |
Pratik Patel | f6fe918 | 2012-03-20 14:04:18 -0700 | [diff] [blame] | 1873 | .remove = __devexit_p(etm_remove), |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1874 | .driver = { |
Pratik Patel | 3b0ca88 | 2012-06-01 16:54:14 -0700 | [diff] [blame] | 1875 | .name = "coresight-etm", |
Pratik Patel | 9eae482 | 2012-05-14 17:34:53 -0700 | [diff] [blame] | 1876 | .owner = THIS_MODULE, |
| 1877 | .of_match_table = etm_match, |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1878 | }, |
| 1879 | }; |
| 1880 | |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame] | 1881 | int __init etm_init(void) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1882 | { |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame] | 1883 | return platform_driver_register(&etm_driver); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1884 | } |
Pratik Patel | f6fe918 | 2012-03-20 14:04:18 -0700 | [diff] [blame] | 1885 | module_init(etm_init); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1886 | |
Pratik Patel | f6fe918 | 2012-03-20 14:04:18 -0700 | [diff] [blame] | 1887 | void __exit etm_exit(void) |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1888 | { |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame] | 1889 | platform_driver_unregister(&etm_driver); |
Pratik Patel | 7831c08 | 2011-06-08 21:44:37 -0700 | [diff] [blame] | 1890 | } |
Pratik Patel | f6fe918 | 2012-03-20 14:04:18 -0700 | [diff] [blame] | 1891 | module_exit(etm_exit); |
| 1892 | |
| 1893 | MODULE_LICENSE("GPL v2"); |
| 1894 | MODULE_DESCRIPTION("CoreSight Program Flow Trace driver"); |