| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | 2 | /* |
|---|
| 3 | | - * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
|---|
| 3 | + * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. |
|---|
| 4 | 4 | * |
|---|
| 5 | 5 | * Description: CoreSight Replicator driver |
|---|
| 6 | 6 | */ |
|---|
| 7 | 7 | |
|---|
| 8 | +#include <linux/acpi.h> |
|---|
| 9 | +#include <linux/amba/bus.h> |
|---|
| 8 | 10 | #include <linux/kernel.h> |
|---|
| 9 | 11 | #include <linux/device.h> |
|---|
| 10 | 12 | #include <linux/platform_device.h> |
|---|
| .. | .. |
|---|
| 12 | 14 | #include <linux/err.h> |
|---|
| 13 | 15 | #include <linux/slab.h> |
|---|
| 14 | 16 | #include <linux/pm_runtime.h> |
|---|
| 17 | +#include <linux/property.h> |
|---|
| 15 | 18 | #include <linux/clk.h> |
|---|
| 16 | 19 | #include <linux/of.h> |
|---|
| 17 | 20 | #include <linux/coresight.h> |
|---|
| 18 | 21 | |
|---|
| 19 | 22 | #include "coresight-priv.h" |
|---|
| 20 | 23 | |
|---|
| 24 | +#define REPLICATOR_IDFILTER0 0x000 |
|---|
| 25 | +#define REPLICATOR_IDFILTER1 0x004 |
|---|
| 26 | + |
|---|
| 27 | +DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); |
|---|
| 28 | + |
|---|
| 21 | 29 | /** |
|---|
| 22 | 30 | * struct replicator_drvdata - specifics associated to a replicator component |
|---|
| 23 | | - * @dev: the device entity associated with this component |
|---|
| 31 | + * @base: memory mapped base address for this component. Also indicates |
|---|
| 32 | + * whether this one is programmable or not. |
|---|
| 24 | 33 | * @atclk: optional clock for the core parts of the replicator. |
|---|
| 25 | 34 | * @csdev: component vitals needed by the framework |
|---|
| 35 | + * @spinlock: serialize enable/disable operations. |
|---|
| 36 | + * @check_idfilter_val: check if the context is lost upon clock removal. |
|---|
| 26 | 37 | */ |
|---|
| 27 | 38 | struct replicator_drvdata { |
|---|
| 28 | | - struct device *dev; |
|---|
| 39 | + void __iomem *base; |
|---|
| 29 | 40 | struct clk *atclk; |
|---|
| 30 | 41 | struct coresight_device *csdev; |
|---|
| 42 | + spinlock_t spinlock; |
|---|
| 43 | + bool check_idfilter_val; |
|---|
| 31 | 44 | }; |
|---|
| 45 | + |
|---|
| 46 | +static void dynamic_replicator_reset(struct replicator_drvdata *drvdata) |
|---|
| 47 | +{ |
|---|
| 48 | + struct coresight_device *csdev = drvdata->csdev; |
|---|
| 49 | + |
|---|
| 50 | + CS_UNLOCK(drvdata->base); |
|---|
| 51 | + |
|---|
| 52 | + if (!coresight_claim_device_unlocked(csdev)) { |
|---|
| 53 | + writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0); |
|---|
| 54 | + writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1); |
|---|
| 55 | + coresight_disclaim_device_unlocked(csdev); |
|---|
| 56 | + } |
|---|
| 57 | + |
|---|
| 58 | + CS_LOCK(drvdata->base); |
|---|
| 59 | +} |
|---|
| 60 | + |
|---|
| 61 | +/* |
|---|
| 62 | + * replicator_reset : Reset the replicator configuration to sane values. |
|---|
| 63 | + */ |
|---|
| 64 | +static inline void replicator_reset(struct replicator_drvdata *drvdata) |
|---|
| 65 | +{ |
|---|
| 66 | + if (drvdata->base) |
|---|
| 67 | + dynamic_replicator_reset(drvdata); |
|---|
| 68 | +} |
|---|
| 69 | + |
|---|
| 70 | +static int dynamic_replicator_enable(struct replicator_drvdata *drvdata, |
|---|
| 71 | + int inport, int outport) |
|---|
| 72 | +{ |
|---|
| 73 | + int rc = 0; |
|---|
| 74 | + u32 id0val, id1val; |
|---|
| 75 | + struct coresight_device *csdev = drvdata->csdev; |
|---|
| 76 | + |
|---|
| 77 | + CS_UNLOCK(drvdata->base); |
|---|
| 78 | + |
|---|
| 79 | + id0val = readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0); |
|---|
| 80 | + id1val = readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1); |
|---|
| 81 | + |
|---|
| 82 | + /* |
|---|
| 83 | + * Some replicator designs lose context when AMBA clocks are removed, |
|---|
| 84 | + * so have a check for this. |
|---|
| 85 | + */ |
|---|
| 86 | + if (drvdata->check_idfilter_val && id0val == 0x0 && id1val == 0x0) |
|---|
| 87 | + id0val = id1val = 0xff; |
|---|
| 88 | + |
|---|
| 89 | + if (id0val == 0xff && id1val == 0xff) |
|---|
| 90 | + rc = coresight_claim_device_unlocked(csdev); |
|---|
| 91 | + |
|---|
| 92 | + if (!rc) { |
|---|
| 93 | + switch (outport) { |
|---|
| 94 | + case 0: |
|---|
| 95 | + id0val = 0x0; |
|---|
| 96 | + break; |
|---|
| 97 | + case 1: |
|---|
| 98 | + id1val = 0x0; |
|---|
| 99 | + break; |
|---|
| 100 | + default: |
|---|
| 101 | + WARN_ON(1); |
|---|
| 102 | + rc = -EINVAL; |
|---|
| 103 | + } |
|---|
| 104 | + } |
|---|
| 105 | + |
|---|
| 106 | + /* Ensure that the outport is enabled. */ |
|---|
| 107 | + if (!rc) { |
|---|
| 108 | + writel_relaxed(id0val, drvdata->base + REPLICATOR_IDFILTER0); |
|---|
| 109 | + writel_relaxed(id1val, drvdata->base + REPLICATOR_IDFILTER1); |
|---|
| 110 | + } |
|---|
| 111 | + |
|---|
| 112 | + CS_LOCK(drvdata->base); |
|---|
| 113 | + |
|---|
| 114 | + return rc; |
|---|
| 115 | +} |
|---|
| 32 | 116 | |
|---|
| 33 | 117 | static int replicator_enable(struct coresight_device *csdev, int inport, |
|---|
| 34 | 118 | int outport) |
|---|
| 35 | 119 | { |
|---|
| 120 | + int rc = 0; |
|---|
| 36 | 121 | struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
|---|
| 122 | + unsigned long flags; |
|---|
| 123 | + bool first_enable = false; |
|---|
| 37 | 124 | |
|---|
| 38 | | - if (atomic_inc_return(&csdev->refcnt[outport]) == 1) |
|---|
| 39 | | - dev_dbg(drvdata->dev, "REPLICATOR enabled\n"); |
|---|
| 40 | | - return 0; |
|---|
| 125 | + spin_lock_irqsave(&drvdata->spinlock, flags); |
|---|
| 126 | + if (atomic_read(&csdev->refcnt[outport]) == 0) { |
|---|
| 127 | + if (drvdata->base) |
|---|
| 128 | + rc = dynamic_replicator_enable(drvdata, inport, |
|---|
| 129 | + outport); |
|---|
| 130 | + if (!rc) |
|---|
| 131 | + first_enable = true; |
|---|
| 132 | + } |
|---|
| 133 | + if (!rc) |
|---|
| 134 | + atomic_inc(&csdev->refcnt[outport]); |
|---|
| 135 | + spin_unlock_irqrestore(&drvdata->spinlock, flags); |
|---|
| 136 | + |
|---|
| 137 | + if (first_enable) |
|---|
| 138 | + dev_dbg(&csdev->dev, "REPLICATOR enabled\n"); |
|---|
| 139 | + return rc; |
|---|
| 140 | +} |
|---|
| 141 | + |
|---|
| 142 | +static void dynamic_replicator_disable(struct replicator_drvdata *drvdata, |
|---|
| 143 | + int inport, int outport) |
|---|
| 144 | +{ |
|---|
| 145 | + u32 reg; |
|---|
| 146 | + struct coresight_device *csdev = drvdata->csdev; |
|---|
| 147 | + |
|---|
| 148 | + switch (outport) { |
|---|
| 149 | + case 0: |
|---|
| 150 | + reg = REPLICATOR_IDFILTER0; |
|---|
| 151 | + break; |
|---|
| 152 | + case 1: |
|---|
| 153 | + reg = REPLICATOR_IDFILTER1; |
|---|
| 154 | + break; |
|---|
| 155 | + default: |
|---|
| 156 | + WARN_ON(1); |
|---|
| 157 | + return; |
|---|
| 158 | + } |
|---|
| 159 | + |
|---|
| 160 | + CS_UNLOCK(drvdata->base); |
|---|
| 161 | + |
|---|
| 162 | + /* disable the flow of ATB data through port */ |
|---|
| 163 | + writel_relaxed(0xff, drvdata->base + reg); |
|---|
| 164 | + |
|---|
| 165 | + if ((readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0) == 0xff) && |
|---|
| 166 | + (readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1) == 0xff)) |
|---|
| 167 | + coresight_disclaim_device_unlocked(csdev); |
|---|
| 168 | + CS_LOCK(drvdata->base); |
|---|
| 41 | 169 | } |
|---|
| 42 | 170 | |
|---|
| 43 | 171 | static void replicator_disable(struct coresight_device *csdev, int inport, |
|---|
| 44 | 172 | int outport) |
|---|
| 45 | 173 | { |
|---|
| 46 | 174 | struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
|---|
| 175 | + unsigned long flags; |
|---|
| 176 | + bool last_disable = false; |
|---|
| 47 | 177 | |
|---|
| 48 | | - if (atomic_dec_return(&csdev->refcnt[outport]) == 0) |
|---|
| 49 | | - dev_dbg(drvdata->dev, "REPLICATOR disabled\n"); |
|---|
| 178 | + spin_lock_irqsave(&drvdata->spinlock, flags); |
|---|
| 179 | + if (atomic_dec_return(&csdev->refcnt[outport]) == 0) { |
|---|
| 180 | + if (drvdata->base) |
|---|
| 181 | + dynamic_replicator_disable(drvdata, inport, outport); |
|---|
| 182 | + last_disable = true; |
|---|
| 183 | + } |
|---|
| 184 | + spin_unlock_irqrestore(&drvdata->spinlock, flags); |
|---|
| 185 | + |
|---|
| 186 | + if (last_disable) |
|---|
| 187 | + dev_dbg(&csdev->dev, "REPLICATOR disabled\n"); |
|---|
| 50 | 188 | } |
|---|
| 51 | 189 | |
|---|
| 52 | 190 | static const struct coresight_ops_link replicator_link_ops = { |
|---|
| .. | .. |
|---|
| 58 | 196 | .link_ops = &replicator_link_ops, |
|---|
| 59 | 197 | }; |
|---|
| 60 | 198 | |
|---|
| 61 | | -static int replicator_probe(struct platform_device *pdev) |
|---|
| 199 | +#define coresight_replicator_reg(name, offset) \ |
|---|
| 200 | + coresight_simple_reg32(struct replicator_drvdata, name, offset) |
|---|
| 201 | + |
|---|
| 202 | +coresight_replicator_reg(idfilter0, REPLICATOR_IDFILTER0); |
|---|
| 203 | +coresight_replicator_reg(idfilter1, REPLICATOR_IDFILTER1); |
|---|
| 204 | + |
|---|
| 205 | +static struct attribute *replicator_mgmt_attrs[] = { |
|---|
| 206 | + &dev_attr_idfilter0.attr, |
|---|
| 207 | + &dev_attr_idfilter1.attr, |
|---|
| 208 | + NULL, |
|---|
| 209 | +}; |
|---|
| 210 | + |
|---|
| 211 | +static const struct attribute_group replicator_mgmt_group = { |
|---|
| 212 | + .attrs = replicator_mgmt_attrs, |
|---|
| 213 | + .name = "mgmt", |
|---|
| 214 | +}; |
|---|
| 215 | + |
|---|
| 216 | +static const struct attribute_group *replicator_groups[] = { |
|---|
| 217 | + &replicator_mgmt_group, |
|---|
| 218 | + NULL, |
|---|
| 219 | +}; |
|---|
| 220 | + |
|---|
| 221 | +static int replicator_probe(struct device *dev, struct resource *res) |
|---|
| 62 | 222 | { |
|---|
| 63 | | - int ret; |
|---|
| 64 | | - struct device *dev = &pdev->dev; |
|---|
| 223 | + int ret = 0; |
|---|
| 65 | 224 | struct coresight_platform_data *pdata = NULL; |
|---|
| 66 | 225 | struct replicator_drvdata *drvdata; |
|---|
| 67 | 226 | struct coresight_desc desc = { 0 }; |
|---|
| 68 | | - struct device_node *np = pdev->dev.of_node; |
|---|
| 227 | + void __iomem *base; |
|---|
| 69 | 228 | |
|---|
| 70 | | - if (np) { |
|---|
| 71 | | - pdata = of_get_coresight_platform_data(dev, np); |
|---|
| 72 | | - if (IS_ERR(pdata)) |
|---|
| 73 | | - return PTR_ERR(pdata); |
|---|
| 74 | | - pdev->dev.platform_data = pdata; |
|---|
| 75 | | - } |
|---|
| 229 | + if (is_of_node(dev_fwnode(dev)) && |
|---|
| 230 | + of_device_is_compatible(dev->of_node, "arm,coresight-replicator")) |
|---|
| 231 | + dev_warn_once(dev, |
|---|
| 232 | + "Uses OBSOLETE CoreSight replicator binding\n"); |
|---|
| 233 | + |
|---|
| 234 | + desc.name = coresight_alloc_device_name(&replicator_devs, dev); |
|---|
| 235 | + if (!desc.name) |
|---|
| 236 | + return -ENOMEM; |
|---|
| 76 | 237 | |
|---|
| 77 | 238 | drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); |
|---|
| 78 | 239 | if (!drvdata) |
|---|
| 79 | 240 | return -ENOMEM; |
|---|
| 80 | 241 | |
|---|
| 81 | | - drvdata->dev = &pdev->dev; |
|---|
| 82 | | - drvdata->atclk = devm_clk_get(&pdev->dev, "atclk"); /* optional */ |
|---|
| 242 | + drvdata->atclk = devm_clk_get(dev, "atclk"); /* optional */ |
|---|
| 83 | 243 | if (!IS_ERR(drvdata->atclk)) { |
|---|
| 84 | 244 | ret = clk_prepare_enable(drvdata->atclk); |
|---|
| 85 | 245 | if (ret) |
|---|
| 86 | 246 | return ret; |
|---|
| 87 | 247 | } |
|---|
| 88 | | - pm_runtime_get_noresume(&pdev->dev); |
|---|
| 89 | | - pm_runtime_set_active(&pdev->dev); |
|---|
| 90 | | - pm_runtime_enable(&pdev->dev); |
|---|
| 91 | | - platform_set_drvdata(pdev, drvdata); |
|---|
| 92 | 248 | |
|---|
| 249 | + /* |
|---|
| 250 | + * Map the device base for dynamic-replicator, which has been |
|---|
| 251 | + * validated by AMBA core |
|---|
| 252 | + */ |
|---|
| 253 | + if (res) { |
|---|
| 254 | + base = devm_ioremap_resource(dev, res); |
|---|
| 255 | + if (IS_ERR(base)) { |
|---|
| 256 | + ret = PTR_ERR(base); |
|---|
| 257 | + goto out_disable_clk; |
|---|
| 258 | + } |
|---|
| 259 | + drvdata->base = base; |
|---|
| 260 | + desc.groups = replicator_groups; |
|---|
| 261 | + desc.access = CSDEV_ACCESS_IOMEM(base); |
|---|
| 262 | + } |
|---|
| 263 | + |
|---|
| 264 | + if (fwnode_property_present(dev_fwnode(dev), |
|---|
| 265 | + "qcom,replicator-loses-context")) |
|---|
| 266 | + drvdata->check_idfilter_val = true; |
|---|
| 267 | + |
|---|
| 268 | + dev_set_drvdata(dev, drvdata); |
|---|
| 269 | + |
|---|
| 270 | + pdata = coresight_get_platform_data(dev); |
|---|
| 271 | + if (IS_ERR(pdata)) { |
|---|
| 272 | + ret = PTR_ERR(pdata); |
|---|
| 273 | + goto out_disable_clk; |
|---|
| 274 | + } |
|---|
| 275 | + dev->platform_data = pdata; |
|---|
| 276 | + |
|---|
| 277 | + spin_lock_init(&drvdata->spinlock); |
|---|
| 93 | 278 | desc.type = CORESIGHT_DEV_TYPE_LINK; |
|---|
| 94 | 279 | desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; |
|---|
| 95 | 280 | desc.ops = &replicator_cs_ops; |
|---|
| 96 | | - desc.pdata = pdev->dev.platform_data; |
|---|
| 97 | | - desc.dev = &pdev->dev; |
|---|
| 281 | + desc.pdata = dev->platform_data; |
|---|
| 282 | + desc.dev = dev; |
|---|
| 283 | + |
|---|
| 98 | 284 | drvdata->csdev = coresight_register(&desc); |
|---|
| 99 | 285 | if (IS_ERR(drvdata->csdev)) { |
|---|
| 100 | 286 | ret = PTR_ERR(drvdata->csdev); |
|---|
| 101 | | - goto out_disable_pm; |
|---|
| 287 | + goto out_disable_clk; |
|---|
| 102 | 288 | } |
|---|
| 103 | 289 | |
|---|
| 104 | | - pm_runtime_put(&pdev->dev); |
|---|
| 290 | + replicator_reset(drvdata); |
|---|
| 291 | + pm_runtime_put(dev); |
|---|
| 105 | 292 | |
|---|
| 106 | | - return 0; |
|---|
| 107 | | - |
|---|
| 108 | | -out_disable_pm: |
|---|
| 109 | | - if (!IS_ERR(drvdata->atclk)) |
|---|
| 293 | +out_disable_clk: |
|---|
| 294 | + if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) |
|---|
| 110 | 295 | clk_disable_unprepare(drvdata->atclk); |
|---|
| 111 | | - pm_runtime_put_noidle(&pdev->dev); |
|---|
| 112 | | - pm_runtime_disable(&pdev->dev); |
|---|
| 296 | + return ret; |
|---|
| 297 | +} |
|---|
| 298 | + |
|---|
| 299 | +static int replicator_remove(struct device *dev) |
|---|
| 300 | +{ |
|---|
| 301 | + struct replicator_drvdata *drvdata = dev_get_drvdata(dev); |
|---|
| 302 | + |
|---|
| 303 | + coresight_unregister(drvdata->csdev); |
|---|
| 304 | + return 0; |
|---|
| 305 | +} |
|---|
| 306 | + |
|---|
| 307 | +static int static_replicator_probe(struct platform_device *pdev) |
|---|
| 308 | +{ |
|---|
| 309 | + int ret; |
|---|
| 310 | + |
|---|
| 311 | + pm_runtime_get_noresume(&pdev->dev); |
|---|
| 312 | + pm_runtime_set_active(&pdev->dev); |
|---|
| 313 | + pm_runtime_enable(&pdev->dev); |
|---|
| 314 | + |
|---|
| 315 | + /* Static replicators do not have programming base */ |
|---|
| 316 | + ret = replicator_probe(&pdev->dev, NULL); |
|---|
| 317 | + |
|---|
| 318 | + if (ret) { |
|---|
| 319 | + pm_runtime_put_noidle(&pdev->dev); |
|---|
| 320 | + pm_runtime_disable(&pdev->dev); |
|---|
| 321 | + } |
|---|
| 113 | 322 | |
|---|
| 114 | 323 | return ret; |
|---|
| 324 | +} |
|---|
| 325 | + |
|---|
| 326 | +static int static_replicator_remove(struct platform_device *pdev) |
|---|
| 327 | +{ |
|---|
| 328 | + replicator_remove(&pdev->dev); |
|---|
| 329 | + pm_runtime_disable(&pdev->dev); |
|---|
| 330 | + return 0; |
|---|
| 115 | 331 | } |
|---|
| 116 | 332 | |
|---|
| 117 | 333 | #ifdef CONFIG_PM |
|---|
| .. | .. |
|---|
| 141 | 357 | replicator_runtime_resume, NULL) |
|---|
| 142 | 358 | }; |
|---|
| 143 | 359 | |
|---|
| 144 | | -static const struct of_device_id replicator_match[] = { |
|---|
| 360 | +static const struct of_device_id static_replicator_match[] = { |
|---|
| 145 | 361 | {.compatible = "arm,coresight-replicator"}, |
|---|
| 362 | + {.compatible = "arm,coresight-static-replicator"}, |
|---|
| 146 | 363 | {} |
|---|
| 147 | 364 | }; |
|---|
| 148 | 365 | |
|---|
| 149 | | -static struct platform_driver replicator_driver = { |
|---|
| 150 | | - .probe = replicator_probe, |
|---|
| 366 | +MODULE_DEVICE_TABLE(of, static_replicator_match); |
|---|
| 367 | + |
|---|
| 368 | +#ifdef CONFIG_ACPI |
|---|
| 369 | +static const struct acpi_device_id static_replicator_acpi_ids[] = { |
|---|
| 370 | + {"ARMHC985", 0}, /* ARM CoreSight Static Replicator */ |
|---|
| 371 | + {} |
|---|
| 372 | +}; |
|---|
| 373 | + |
|---|
| 374 | +MODULE_DEVICE_TABLE(acpi, static_replicator_acpi_ids); |
|---|
| 375 | +#endif |
|---|
| 376 | + |
|---|
| 377 | +static struct platform_driver static_replicator_driver = { |
|---|
| 378 | + .probe = static_replicator_probe, |
|---|
| 379 | + .remove = static_replicator_remove, |
|---|
| 151 | 380 | .driver = { |
|---|
| 152 | | - .name = "coresight-replicator", |
|---|
| 153 | | - .of_match_table = replicator_match, |
|---|
| 381 | + .name = "coresight-static-replicator", |
|---|
| 382 | + .owner = THIS_MODULE, |
|---|
| 383 | + .of_match_table = of_match_ptr(static_replicator_match), |
|---|
| 384 | + .acpi_match_table = ACPI_PTR(static_replicator_acpi_ids), |
|---|
| 154 | 385 | .pm = &replicator_dev_pm_ops, |
|---|
| 155 | 386 | .suppress_bind_attrs = true, |
|---|
| 156 | 387 | }, |
|---|
| 157 | 388 | }; |
|---|
| 158 | | -builtin_platform_driver(replicator_driver); |
|---|
| 389 | + |
|---|
| 390 | +static int dynamic_replicator_probe(struct amba_device *adev, |
|---|
| 391 | + const struct amba_id *id) |
|---|
| 392 | +{ |
|---|
| 393 | + return replicator_probe(&adev->dev, &adev->res); |
|---|
| 394 | +} |
|---|
| 395 | + |
|---|
| 396 | +static void dynamic_replicator_remove(struct amba_device *adev) |
|---|
| 397 | +{ |
|---|
| 398 | + replicator_remove(&adev->dev); |
|---|
| 399 | +} |
|---|
| 400 | + |
|---|
| 401 | +static const struct amba_id dynamic_replicator_ids[] = { |
|---|
| 402 | + CS_AMBA_ID(0x000bb909), |
|---|
| 403 | + CS_AMBA_ID(0x000bb9ec), /* Coresight SoC-600 */ |
|---|
| 404 | + {}, |
|---|
| 405 | +}; |
|---|
| 406 | + |
|---|
| 407 | +MODULE_DEVICE_TABLE(amba, dynamic_replicator_ids); |
|---|
| 408 | + |
|---|
| 409 | +static struct amba_driver dynamic_replicator_driver = { |
|---|
| 410 | + .drv = { |
|---|
| 411 | + .name = "coresight-dynamic-replicator", |
|---|
| 412 | + .pm = &replicator_dev_pm_ops, |
|---|
| 413 | + .owner = THIS_MODULE, |
|---|
| 414 | + .suppress_bind_attrs = true, |
|---|
| 415 | + }, |
|---|
| 416 | + .probe = dynamic_replicator_probe, |
|---|
| 417 | + .remove = dynamic_replicator_remove, |
|---|
| 418 | + .id_table = dynamic_replicator_ids, |
|---|
| 419 | +}; |
|---|
| 420 | + |
|---|
| 421 | +static int __init replicator_init(void) |
|---|
| 422 | +{ |
|---|
| 423 | + int ret; |
|---|
| 424 | + |
|---|
| 425 | + ret = platform_driver_register(&static_replicator_driver); |
|---|
| 426 | + if (ret) { |
|---|
| 427 | + pr_info("Error registering platform driver\n"); |
|---|
| 428 | + return ret; |
|---|
| 429 | + } |
|---|
| 430 | + |
|---|
| 431 | + ret = amba_driver_register(&dynamic_replicator_driver); |
|---|
| 432 | + if (ret) { |
|---|
| 433 | + pr_info("Error registering amba driver\n"); |
|---|
| 434 | + platform_driver_unregister(&static_replicator_driver); |
|---|
| 435 | + } |
|---|
| 436 | + |
|---|
| 437 | + return ret; |
|---|
| 438 | +} |
|---|
| 439 | + |
|---|
| 440 | +static void __exit replicator_exit(void) |
|---|
| 441 | +{ |
|---|
| 442 | + platform_driver_unregister(&static_replicator_driver); |
|---|
| 443 | + amba_driver_unregister(&dynamic_replicator_driver); |
|---|
| 444 | +} |
|---|
| 445 | + |
|---|
| 446 | +module_init(replicator_init); |
|---|
| 447 | +module_exit(replicator_exit); |
|---|
| 448 | + |
|---|
| 449 | +MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>"); |
|---|
| 450 | +MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>"); |
|---|
| 451 | +MODULE_DESCRIPTION("Arm CoreSight Replicator Driver"); |
|---|
| 452 | +MODULE_LICENSE("GPL v2"); |
|---|