mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
coresight: etm4x: Change etm4_platform_driver driver for MMIO devices
Add support for handling MMIO based devices via platform driver. We need to make sure that : 1) The APB clock, if present is enabled at probe and via runtime_pm ops 2) Use the ETM4x architecture or CoreSight architecture registers to identify a device as CoreSight ETM4x, instead of relying a white list of "Peripheral IDs" The driver doesn't get to handle the devices yet, until we wire the ACPI changes to move the devices to be handled via platform driver than the etm4_amba driver. Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Acked-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20230710062500.45147-5-anshuman.khandual@arm.com
This commit is contained in:
committed by
Suzuki K Poulose
parent
5a1c709747
commit
73d779a03a
@@ -6,6 +6,8 @@
|
||||
#ifndef _LINUX_CORESIGHT_H
|
||||
#define _LINUX_CORESIGHT_H
|
||||
|
||||
#include <linux/amba/bus.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/perf_event.h>
|
||||
@@ -386,6 +388,51 @@ static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa,
|
||||
return csa->read(offset, true, false);
|
||||
}
|
||||
|
||||
#define CORESIGHT_CIDRn(i) (0xFF0 + ((i) * 4))
|
||||
|
||||
static inline u32 coresight_get_cid(void __iomem *base)
|
||||
{
|
||||
u32 i, cid = 0;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
cid |= readl(base + CORESIGHT_CIDRn(i)) << (i * 8);
|
||||
|
||||
return cid;
|
||||
}
|
||||
|
||||
static inline bool is_coresight_device(void __iomem *base)
|
||||
{
|
||||
u32 cid = coresight_get_cid(base);
|
||||
|
||||
return cid == CORESIGHT_CID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to find and enable "APB clock" for the given device
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* clk - Clock is found and enabled
|
||||
* NULL - clock is not found
|
||||
* ERROR - Clock is found but failed to enable
|
||||
*/
|
||||
static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev)
|
||||
{
|
||||
struct clk *pclk;
|
||||
int ret;
|
||||
|
||||
pclk = clk_get(dev, "apb_pclk");
|
||||
if (IS_ERR(pclk))
|
||||
return NULL;
|
||||
|
||||
ret = clk_prepare_enable(pclk);
|
||||
if (ret) {
|
||||
clk_put(pclk);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
return pclk;
|
||||
}
|
||||
|
||||
#define CORESIGHT_PIDRn(i) (0xFE0 + ((i) * 4))
|
||||
|
||||
static inline u32 coresight_get_pid(struct csdev_access *csa)
|
||||
|
||||
Reference in New Issue
Block a user