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