coresight: stm: Allow to build coresight-stm as a module

- Kconfig becomes a tristate, to allow =m
- add a stm_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Suzuki K Poulose <Suzuki.Poulose@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Russell King <linux@armlinux.org.uk>
Tested-by: Mike Leach <mike.leach@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Kim Phillips <kim.phillips@arm.com>
Signed-off-by: Tingwei Zhang <tingwei@codeaurora.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200928163513.70169-8-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tingwei Zhang 2020-09-28 10:34:55 -06:00 committed by Greg Kroah-Hartman
parent 32b0707a41
commit 8b0cf82677
2 changed files with 23 additions and 2 deletions

View File

@ -86,7 +86,7 @@ config CORESIGHT_SOURCE_ETM4X
data tracing may also be available. data tracing may also be available.
config CORESIGHT_STM config CORESIGHT_STM
bool "CoreSight System Trace Macrocell driver" tristate "CoreSight System Trace Macrocell driver"
depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) || ARM64 depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) || ARM64
select CORESIGHT_LINKS_AND_SINKS select CORESIGHT_LINKS_AND_SINKS
select STM select STM
@ -96,6 +96,9 @@ config CORESIGHT_STM
logging useful software events or data coming from various entities logging useful software events or data coming from various entities
in the system, possibly running different OSs in the system, possibly running different OSs
To compile this driver as a module, choose M here: the
module will be called coresight-stm.
config CORESIGHT_CPU_DEBUG config CORESIGHT_CPU_DEBUG
tristate "CoreSight CPU Debug driver" tristate "CoreSight CPU Debug driver"
depends on ARM || ARM64 depends on ARM || ARM64

View File

@ -951,6 +951,17 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
return ret; return ret;
} }
static int __exit stm_remove(struct amba_device *adev)
{
struct stm_drvdata *drvdata = dev_get_drvdata(&adev->dev);
coresight_unregister(drvdata->csdev);
stm_unregister_device(&drvdata->stm);
return 0;
}
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int stm_runtime_suspend(struct device *dev) static int stm_runtime_suspend(struct device *dev)
{ {
@ -983,6 +994,8 @@ static const struct amba_id stm_ids[] = {
{ 0, 0}, { 0, 0},
}; };
MODULE_DEVICE_TABLE(amba, stm_ids);
static struct amba_driver stm_driver = { static struct amba_driver stm_driver = {
.drv = { .drv = {
.name = "coresight-stm", .name = "coresight-stm",
@ -991,7 +1004,12 @@ static struct amba_driver stm_driver = {
.suppress_bind_attrs = true, .suppress_bind_attrs = true,
}, },
.probe = stm_probe, .probe = stm_probe,
.remove = stm_remove,
.id_table = stm_ids, .id_table = stm_ids,
}; };
builtin_amba_driver(stm_driver); module_amba_driver(stm_driver);
MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
MODULE_DESCRIPTION("Arm CoreSight System Trace Macrocell driver");
MODULE_LICENSE("GPL v2");