Commit f5bd5236 authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Greg Kroah-Hartman

coresight: etm4x: Convert all register accesses

Convert all register accesses from etm4x driver to use a wrapper
to allow switching the access at runtime with little overhead.

co-developed by sed tool ;-), mostly equivalent to :

s/readl\(_relaxed\)\?(drvdata->base + \(.*\))/etm4x_\1_read32(csdev, \2)
s/writel\(_relaxed\)\?(\(.*\), drvdata->base + \(.*\))/etm4x_\1_write32(csdev, \2, \3)

We don't want to replace them with the csdev_access_* to
avoid a function call for every register access for system
register access. This is a prepartory step to add system
register access later where the support is available.

Link: https://lore.kernel.org/r/20210110224850.1880240-9-suzuki.poulose@arm.com
Cc: Mike Leach <mike.leach@linaro.org>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20210201181351.1475223-11-mathieu.poirier@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5e2acf9d
...@@ -2319,7 +2319,8 @@ static struct attribute *coresight_etmv4_attrs[] = { ...@@ -2319,7 +2319,8 @@ static struct attribute *coresight_etmv4_attrs[] = {
}; };
struct etmv4_reg { struct etmv4_reg {
void __iomem *addr; struct coresight_device *csdev;
u32 offset;
u32 data; u32 data;
}; };
...@@ -2327,7 +2328,7 @@ static void do_smp_cross_read(void *data) ...@@ -2327,7 +2328,7 @@ static void do_smp_cross_read(void *data)
{ {
struct etmv4_reg *reg = data; struct etmv4_reg *reg = data;
reg->data = readl_relaxed(reg->addr); reg->data = etm4x_relaxed_read32(&reg->csdev->access, reg->offset);
} }
static u32 etmv4_cross_read(const struct device *dev, u32 offset) static u32 etmv4_cross_read(const struct device *dev, u32 offset)
...@@ -2335,7 +2336,9 @@ static u32 etmv4_cross_read(const struct device *dev, u32 offset) ...@@ -2335,7 +2336,9 @@ static u32 etmv4_cross_read(const struct device *dev, u32 offset)
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev); struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
struct etmv4_reg reg; struct etmv4_reg reg;
reg.addr = drvdata->base + offset; reg.offset = offset;
reg.csdev = drvdata->csdev;
/* /*
* smp cross call ensures the CPU will be powered up before * smp cross call ensures the CPU will be powered up before
* accessing the ETMv4 trace core registers * accessing the ETMv4 trace core registers
......
...@@ -121,6 +121,30 @@ ...@@ -121,6 +121,30 @@
#define TRCCIDR2 0xFF8 #define TRCCIDR2 0xFF8
#define TRCCIDR3 0xFFC #define TRCCIDR3 0xFFC
#define etm4x_relaxed_read32(csa, offset) \
readl_relaxed((csa)->base + (offset))
#define etm4x_read32(csa, offset) \
readl((csa)->base + (offset))
#define etm4x_relaxed_write32(csa, val, offset) \
writel_relaxed((val), (csa)->base + (offset))
#define etm4x_write32(csa, val, offset) \
writel((val), (csa)->base + (offset))
#define etm4x_relaxed_read64(csa, offset) \
readq_relaxed((csa)->base + (offset))
#define etm4x_read64(csa, offset) \
readq((csa)->base + (offset))
#define etm4x_relaxed_write64(csa, val, offset) \
writeq_relaxed((val), (csa)->base + (offset))
#define etm4x_write64(csa, val, offset) \
writeq((val), (csa)->base + (offset))
/* ETMv4 resources */ /* ETMv4 resources */
#define ETM_MAX_NR_PE 8 #define ETM_MAX_NR_PE 8
#define ETMv4_MAX_CNTR 4 #define ETMv4_MAX_CNTR 4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment