Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 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> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/err.h> |
| 20 | #include <linux/slab.h> |
| 21 | #include <linux/mutex.h> |
| 22 | #include <linux/clk.h> |
| 23 | #include <linux/of_coresight.h> |
| 24 | #include <linux/coresight.h> |
| 25 | #include <linux/coresight-cti.h> |
| 26 | |
| 27 | #include "coresight-priv.h" |
| 28 | |
| 29 | #define cti_writel(drvdata, val, off) __raw_writel((val), drvdata->base + off) |
| 30 | #define cti_readl(drvdata, off) __raw_readl(drvdata->base + off) |
| 31 | |
| 32 | #define CTI_LOCK(drvdata) \ |
| 33 | do { \ |
| 34 | mb(); \ |
| 35 | cti_writel(drvdata, 0x0, CORESIGHT_LAR); \ |
| 36 | } while (0) |
| 37 | #define CTI_UNLOCK(drvdata) \ |
| 38 | do { \ |
| 39 | cti_writel(drvdata, CORESIGHT_UNLOCK, CORESIGHT_LAR); \ |
| 40 | mb(); \ |
| 41 | } while (0) |
| 42 | |
| 43 | #define CTICONTROL (0x000) |
| 44 | #define CTIINTACK (0x010) |
| 45 | #define CTIAPPSET (0x014) |
| 46 | #define CTIAPPCLEAR (0x018) |
| 47 | #define CTIAPPPULSE (0x01C) |
| 48 | #define CTIINEN(n) (0x020 + (n * 4)) |
| 49 | #define CTIOUTEN(n) (0x0A0 + (n * 4)) |
| 50 | #define CTITRIGINSTATUS (0x130) |
| 51 | #define CTITRIGOUTSTATUS (0x134) |
| 52 | #define CTICHINSTATUS (0x138) |
| 53 | #define CTICHOUTSTATUS (0x13C) |
| 54 | #define CTIGATE (0x140) |
| 55 | #define ASICCTL (0x144) |
| 56 | #define ITCHINACK (0xEDC) |
| 57 | #define ITTRIGINACK (0xEE0) |
| 58 | #define ITCHOUT (0xEE4) |
| 59 | #define ITTRIGOUT (0xEE8) |
| 60 | #define ITCHOUTACK (0xEEC) |
| 61 | #define ITTRIGOUTACK (0xEF0) |
| 62 | #define ITCHIN (0xEF4) |
| 63 | #define ITTRIGIN (0xEF8) |
| 64 | |
| 65 | #define CTI_MAX_TRIGGERS (8) |
| 66 | #define CTI_MAX_CHANNELS (4) |
| 67 | |
| 68 | #define to_cti_drvdata(c) container_of(c, struct cti_drvdata, cti) |
| 69 | |
| 70 | struct cti_drvdata { |
| 71 | void __iomem *base; |
| 72 | struct device *dev; |
| 73 | struct coresight_device *csdev; |
| 74 | struct clk *clk; |
| 75 | struct mutex mutex; |
| 76 | struct coresight_cti cti; |
| 77 | int refcnt; |
| 78 | }; |
| 79 | |
| 80 | static LIST_HEAD(cti_list); |
| 81 | static DEFINE_MUTEX(cti_lock); |
| 82 | |
| 83 | static int cti_verify_bounds(int trig, int ch) |
| 84 | { |
| 85 | if (trig >= CTI_MAX_TRIGGERS) |
| 86 | return -EINVAL; |
| 87 | |
| 88 | if (ch >= CTI_MAX_CHANNELS) |
| 89 | return -EINVAL; |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | static int cti_enable(struct cti_drvdata *drvdata) |
| 95 | { |
| 96 | int ret; |
| 97 | |
| 98 | ret = clk_prepare_enable(drvdata->clk); |
| 99 | if (ret) |
| 100 | return ret; |
| 101 | |
| 102 | CTI_UNLOCK(drvdata); |
| 103 | |
| 104 | cti_writel(drvdata, 0x1, CTICONTROL); |
| 105 | |
| 106 | CTI_LOCK(drvdata); |
| 107 | return 0; |
| 108 | } |
| 109 | |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 110 | static int __cti_map_trigin(struct cti_drvdata *drvdata, int trig, int ch) |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 111 | { |
| 112 | uint32_t ctien; |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 113 | int ret; |
| 114 | |
| 115 | if (drvdata->refcnt == 0) { |
| 116 | ret = cti_enable(drvdata); |
| 117 | if (ret) |
| 118 | return ret; |
| 119 | } |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 120 | |
| 121 | CTI_UNLOCK(drvdata); |
| 122 | |
| 123 | ctien = cti_readl(drvdata, CTIINEN(trig)); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 124 | if (ctien & (0x1 << ch)) |
| 125 | goto out; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 126 | cti_writel(drvdata, (ctien | 0x1 << ch), CTIINEN(trig)); |
| 127 | |
| 128 | CTI_LOCK(drvdata); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 129 | |
| 130 | drvdata->refcnt++; |
| 131 | return 0; |
| 132 | out: |
| 133 | CTI_LOCK(drvdata); |
| 134 | return 0; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | int coresight_cti_map_trigin(struct coresight_cti *cti, int trig, int ch) |
| 138 | { |
| 139 | struct cti_drvdata *drvdata; |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 140 | int ret; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 141 | |
| 142 | if (IS_ERR_OR_NULL(cti)) |
| 143 | return -EINVAL; |
| 144 | |
| 145 | ret = cti_verify_bounds(trig, ch); |
| 146 | if (ret) |
| 147 | return ret; |
| 148 | |
| 149 | drvdata = to_cti_drvdata(cti); |
| 150 | |
| 151 | mutex_lock(&drvdata->mutex); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 152 | ret = __cti_map_trigin(drvdata, trig, ch); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 153 | mutex_unlock(&drvdata->mutex); |
| 154 | return ret; |
| 155 | } |
| 156 | EXPORT_SYMBOL(coresight_cti_map_trigin); |
| 157 | |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 158 | static int __cti_map_trigout(struct cti_drvdata *drvdata, int trig, int ch) |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 159 | { |
| 160 | uint32_t ctien; |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 161 | int ret; |
| 162 | |
| 163 | if (drvdata->refcnt == 0) { |
| 164 | ret = cti_enable(drvdata); |
| 165 | if (ret) |
| 166 | return ret; |
| 167 | } |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 168 | |
| 169 | CTI_UNLOCK(drvdata); |
| 170 | |
| 171 | ctien = cti_readl(drvdata, CTIOUTEN(trig)); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 172 | if (ctien & (0x1 << ch)) |
| 173 | goto out; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 174 | cti_writel(drvdata, (ctien | 0x1 << ch), CTIOUTEN(trig)); |
| 175 | |
| 176 | CTI_LOCK(drvdata); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 177 | |
| 178 | drvdata->refcnt++; |
| 179 | return 0; |
| 180 | out: |
| 181 | CTI_LOCK(drvdata); |
| 182 | return 0; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | int coresight_cti_map_trigout(struct coresight_cti *cti, int trig, int ch) |
| 186 | { |
| 187 | struct cti_drvdata *drvdata; |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 188 | int ret; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 189 | |
| 190 | if (IS_ERR_OR_NULL(cti)) |
| 191 | return -EINVAL; |
| 192 | |
| 193 | ret = cti_verify_bounds(trig, ch); |
| 194 | if (ret) |
| 195 | return ret; |
| 196 | |
| 197 | drvdata = to_cti_drvdata(cti); |
| 198 | |
| 199 | mutex_lock(&drvdata->mutex); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 200 | ret = __cti_map_trigout(drvdata, trig, ch); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 201 | mutex_unlock(&drvdata->mutex); |
| 202 | return ret; |
| 203 | } |
| 204 | EXPORT_SYMBOL(coresight_cti_map_trigout); |
| 205 | |
| 206 | static void cti_disable(struct cti_drvdata *drvdata) |
| 207 | { |
| 208 | CTI_UNLOCK(drvdata); |
| 209 | |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 210 | cti_writel(drvdata, 0x0, CTICONTROL); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 211 | |
| 212 | CTI_LOCK(drvdata); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 213 | |
| 214 | clk_disable_unprepare(drvdata->clk); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | static void __cti_unmap_trigin(struct cti_drvdata *drvdata, int trig, int ch) |
| 218 | { |
| 219 | uint32_t ctien; |
| 220 | |
| 221 | CTI_UNLOCK(drvdata); |
| 222 | |
| 223 | ctien = cti_readl(drvdata, CTIINEN(trig)); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 224 | if (!(ctien & (0x1 << ch))) |
| 225 | goto out; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 226 | cti_writel(drvdata, (ctien & ~(0x1 << ch)), CTIINEN(trig)); |
| 227 | |
| 228 | CTI_LOCK(drvdata); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 229 | |
| 230 | if (drvdata->refcnt == 1) |
| 231 | cti_disable(drvdata); |
| 232 | drvdata->refcnt--; |
| 233 | return; |
| 234 | out: |
| 235 | CTI_LOCK(drvdata); |
| 236 | return; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | void coresight_cti_unmap_trigin(struct coresight_cti *cti, int trig, int ch) |
| 240 | { |
| 241 | struct cti_drvdata *drvdata; |
| 242 | |
| 243 | if (IS_ERR_OR_NULL(cti)) |
| 244 | return; |
| 245 | |
| 246 | if (cti_verify_bounds(trig, ch)) |
| 247 | return; |
| 248 | |
| 249 | drvdata = to_cti_drvdata(cti); |
| 250 | |
| 251 | mutex_lock(&drvdata->mutex); |
| 252 | __cti_unmap_trigin(drvdata, trig, ch); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 253 | mutex_unlock(&drvdata->mutex); |
| 254 | |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 255 | } |
| 256 | EXPORT_SYMBOL(coresight_cti_unmap_trigin); |
| 257 | |
| 258 | static void __cti_unmap_trigout(struct cti_drvdata *drvdata, int trig, int ch) |
| 259 | { |
| 260 | uint32_t ctien; |
| 261 | |
| 262 | CTI_UNLOCK(drvdata); |
| 263 | |
| 264 | ctien = cti_readl(drvdata, CTIOUTEN(trig)); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 265 | if (!(ctien & (0x1 << ch))) |
| 266 | goto out; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 267 | cti_writel(drvdata, (ctien & ~(0x1 << ch)), CTIOUTEN(trig)); |
| 268 | |
| 269 | CTI_LOCK(drvdata); |
Aparna Das | 9093f88 | 2013-07-17 18:42:51 -0700 | [diff] [blame] | 270 | |
| 271 | if (drvdata->refcnt == 1) |
| 272 | cti_disable(drvdata); |
| 273 | drvdata->refcnt--; |
| 274 | return; |
| 275 | out: |
| 276 | CTI_LOCK(drvdata); |
| 277 | return; |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | void coresight_cti_unmap_trigout(struct coresight_cti *cti, int trig, int ch) |
| 281 | { |
| 282 | struct cti_drvdata *drvdata; |
| 283 | |
| 284 | if (IS_ERR_OR_NULL(cti)) |
| 285 | return; |
| 286 | |
| 287 | if (cti_verify_bounds(trig, ch)) |
| 288 | return; |
| 289 | |
| 290 | drvdata = to_cti_drvdata(cti); |
| 291 | |
| 292 | mutex_lock(&drvdata->mutex); |
| 293 | __cti_unmap_trigout(drvdata, trig, ch); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 294 | mutex_unlock(&drvdata->mutex); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 295 | } |
| 296 | EXPORT_SYMBOL(coresight_cti_unmap_trigout); |
| 297 | |
| 298 | struct coresight_cti *coresight_cti_get(const char *name) |
| 299 | { |
| 300 | struct coresight_cti *cti; |
| 301 | |
| 302 | mutex_lock(&cti_lock); |
| 303 | list_for_each_entry(cti, &cti_list, link) { |
| 304 | if (!strncmp(cti->name, name, strlen(cti->name) + 1)) { |
| 305 | mutex_unlock(&cti_lock); |
| 306 | return cti; |
| 307 | } |
| 308 | } |
| 309 | mutex_unlock(&cti_lock); |
| 310 | |
| 311 | return ERR_PTR(-EINVAL); |
| 312 | } |
| 313 | EXPORT_SYMBOL(coresight_cti_get); |
| 314 | |
| 315 | void coresight_cti_put(struct coresight_cti *cti) |
| 316 | { |
| 317 | } |
| 318 | EXPORT_SYMBOL(coresight_cti_put); |
| 319 | |
| 320 | static ssize_t cti_store_map_trigin(struct device *dev, |
| 321 | struct device_attribute *attr, |
| 322 | const char *buf, size_t size) |
| 323 | { |
| 324 | struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); |
| 325 | unsigned long val1, val2; |
| 326 | int ret; |
| 327 | |
| 328 | if (sscanf(buf, "%lx %lx", &val1, &val2) != 2) |
| 329 | return -EINVAL; |
| 330 | |
| 331 | ret = coresight_cti_map_trigin(&drvdata->cti, val1, val2); |
| 332 | |
| 333 | if (ret) |
| 334 | return ret; |
| 335 | return size; |
| 336 | } |
| 337 | static DEVICE_ATTR(map_trigin, S_IWUSR, NULL, cti_store_map_trigin); |
| 338 | |
| 339 | static ssize_t cti_store_map_trigout(struct device *dev, |
| 340 | struct device_attribute *attr, |
| 341 | const char *buf, size_t size) |
| 342 | { |
| 343 | struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); |
| 344 | unsigned long val1, val2; |
| 345 | int ret; |
| 346 | |
| 347 | if (sscanf(buf, "%lx %lx", &val1, &val2) != 2) |
| 348 | return -EINVAL; |
| 349 | |
| 350 | ret = coresight_cti_map_trigout(&drvdata->cti, val1, val2); |
| 351 | |
| 352 | if (ret) |
| 353 | return ret; |
| 354 | return size; |
| 355 | } |
| 356 | static DEVICE_ATTR(map_trigout, S_IWUSR, NULL, cti_store_map_trigout); |
| 357 | |
| 358 | static ssize_t cti_store_unmap_trigin(struct device *dev, |
| 359 | struct device_attribute *attr, |
| 360 | const char *buf, size_t size) |
| 361 | { |
| 362 | struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); |
| 363 | unsigned long val1, val2; |
| 364 | |
| 365 | if (sscanf(buf, "%lx %lx", &val1, &val2) != 2) |
| 366 | return -EINVAL; |
| 367 | |
| 368 | coresight_cti_unmap_trigin(&drvdata->cti, val1, val2); |
| 369 | |
| 370 | return size; |
| 371 | } |
| 372 | static DEVICE_ATTR(unmap_trigin, S_IWUSR, NULL, cti_store_unmap_trigin); |
| 373 | |
| 374 | static ssize_t cti_store_unmap_trigout(struct device *dev, |
| 375 | struct device_attribute *attr, |
| 376 | const char *buf, size_t size) |
| 377 | { |
| 378 | struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); |
| 379 | unsigned long val1, val2; |
| 380 | |
| 381 | if (sscanf(buf, "%lx %lx", &val1, &val2) != 2) |
| 382 | return -EINVAL; |
| 383 | |
| 384 | coresight_cti_unmap_trigout(&drvdata->cti, val1, val2); |
| 385 | |
| 386 | return size; |
| 387 | } |
| 388 | static DEVICE_ATTR(unmap_trigout, S_IWUSR, NULL, cti_store_unmap_trigout); |
| 389 | |
| 390 | static struct attribute *cti_attrs[] = { |
| 391 | &dev_attr_map_trigin.attr, |
| 392 | &dev_attr_map_trigout.attr, |
| 393 | &dev_attr_unmap_trigin.attr, |
| 394 | &dev_attr_unmap_trigout.attr, |
| 395 | NULL, |
| 396 | }; |
| 397 | |
| 398 | static struct attribute_group cti_attr_grp = { |
| 399 | .attrs = cti_attrs, |
| 400 | }; |
| 401 | |
| 402 | static const struct attribute_group *cti_attr_grps[] = { |
| 403 | &cti_attr_grp, |
| 404 | NULL, |
| 405 | }; |
| 406 | |
| 407 | static int __devinit cti_probe(struct platform_device *pdev) |
| 408 | { |
| 409 | int ret; |
| 410 | struct device *dev = &pdev->dev; |
| 411 | struct coresight_platform_data *pdata; |
| 412 | struct cti_drvdata *drvdata; |
| 413 | struct resource *res; |
| 414 | struct coresight_desc *desc; |
| 415 | |
Pratik Patel | 4930640 | 2013-06-14 01:02:08 -0700 | [diff] [blame] | 416 | if (coresight_fuse_access_disabled()) |
| 417 | return -EPERM; |
| 418 | |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 419 | if (pdev->dev.of_node) { |
| 420 | pdata = of_get_coresight_platform_data(dev, pdev->dev.of_node); |
| 421 | if (IS_ERR(pdata)) |
| 422 | return PTR_ERR(pdata); |
| 423 | pdev->dev.platform_data = pdata; |
| 424 | } |
| 425 | |
| 426 | drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); |
| 427 | if (!drvdata) |
| 428 | return -ENOMEM; |
| 429 | /* Store the driver data pointer for use in exported functions */ |
| 430 | drvdata->dev = &pdev->dev; |
| 431 | platform_set_drvdata(pdev, drvdata); |
| 432 | |
Aparna Das | c990751 | 2013-03-08 10:20:52 -0800 | [diff] [blame] | 433 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cti-base"); |
Pratik Patel | d944cc7 | 2013-02-08 11:52:12 -0800 | [diff] [blame] | 434 | if (!res) |
| 435 | return -ENODEV; |
| 436 | |
| 437 | drvdata->base = devm_ioremap(dev, res->start, resource_size(res)); |
| 438 | if (!drvdata->base) |
| 439 | return -ENOMEM; |
| 440 | |
| 441 | mutex_init(&drvdata->mutex); |
| 442 | |
| 443 | drvdata->clk = devm_clk_get(dev, "core_clk"); |
| 444 | if (IS_ERR(drvdata->clk)) |
| 445 | return PTR_ERR(drvdata->clk); |
| 446 | |
| 447 | ret = clk_set_rate(drvdata->clk, CORESIGHT_CLK_RATE_TRACE); |
| 448 | if (ret) |
| 449 | return ret; |
| 450 | |
| 451 | mutex_lock(&cti_lock); |
| 452 | drvdata->cti.name = ((struct coresight_platform_data *) |
| 453 | (pdev->dev.platform_data))->name; |
| 454 | list_add_tail(&drvdata->cti.link, &cti_list); |
| 455 | mutex_unlock(&cti_lock); |
| 456 | |
| 457 | desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); |
| 458 | if (!desc) |
| 459 | return -ENOMEM; |
| 460 | desc->type = CORESIGHT_DEV_TYPE_NONE; |
| 461 | desc->pdata = pdev->dev.platform_data; |
| 462 | desc->dev = &pdev->dev; |
| 463 | desc->groups = cti_attr_grps; |
| 464 | desc->owner = THIS_MODULE; |
| 465 | drvdata->csdev = coresight_register(desc); |
| 466 | if (IS_ERR(drvdata->csdev)) |
| 467 | return PTR_ERR(drvdata->csdev); |
| 468 | |
| 469 | dev_info(dev, "CTI initialized\n"); |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | static int __devexit cti_remove(struct platform_device *pdev) |
| 474 | { |
| 475 | struct cti_drvdata *drvdata = platform_get_drvdata(pdev); |
| 476 | |
| 477 | coresight_unregister(drvdata->csdev); |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | static struct of_device_id cti_match[] = { |
| 482 | {.compatible = "arm,coresight-cti"}, |
| 483 | {} |
| 484 | }; |
| 485 | |
| 486 | static struct platform_driver cti_driver = { |
| 487 | .probe = cti_probe, |
| 488 | .remove = __devexit_p(cti_remove), |
| 489 | .driver = { |
| 490 | .name = "coresight-cti", |
| 491 | .owner = THIS_MODULE, |
| 492 | .of_match_table = cti_match, |
| 493 | }, |
| 494 | }; |
| 495 | |
| 496 | static int __init cti_init(void) |
| 497 | { |
| 498 | return platform_driver_register(&cti_driver); |
| 499 | } |
| 500 | module_init(cti_init); |
| 501 | |
| 502 | static void __exit cti_exit(void) |
| 503 | { |
| 504 | platform_driver_unregister(&cti_driver); |
| 505 | } |
| 506 | module_exit(cti_exit); |
| 507 | |
| 508 | MODULE_LICENSE("GPL v2"); |
| 509 | MODULE_DESCRIPTION("CoreSight CTI driver"); |