Commit 650db9fa authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Bjorn Andersson

soc: qcom: icc-bwmon: store count unit per variant

Versions v4 and v5 of BWMON on SDM845 use different unit count, so allow
easier variant customization by storing its value in struct
icc_bwmon_data.

Cc: Rajendra Nayak <quic_rjendra@quicinc.com>
Cc: Sibi Sankar <quic_sibis@quicinc.com>
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: default avatarSibi Sankar <quic_sibis@quicinc.com>
Tested-by: default avatarSteev Klimaszewski <steev@kali.org>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220728113748.170548-7-krzysztof.kozlowski@linaro.org
parent 956deab5
...@@ -103,12 +103,11 @@ ...@@ -103,12 +103,11 @@
#define BWMON_THRESHOLD_COUNT_ZONE0_DEFAULT 0xff #define BWMON_THRESHOLD_COUNT_ZONE0_DEFAULT 0xff
#define BWMON_THRESHOLD_COUNT_ZONE2_DEFAULT 0xff #define BWMON_THRESHOLD_COUNT_ZONE2_DEFAULT 0xff
/* BWMONv4 count registers use count unit of 64 kB */
#define BWMON_COUNT_UNIT_KB 64
#define BWMON_ZONE_MAX(zone) (0x2e0 + 4 * (zone)) #define BWMON_ZONE_MAX(zone) (0x2e0 + 4 * (zone))
struct icc_bwmon_data { struct icc_bwmon_data {
unsigned int sample_ms; unsigned int sample_ms;
unsigned int count_unit_kb; /* kbytes */
unsigned int default_highbw_kbps; unsigned int default_highbw_kbps;
unsigned int default_medbw_kbps; unsigned int default_medbw_kbps;
unsigned int default_lowbw_kbps; unsigned int default_lowbw_kbps;
...@@ -192,9 +191,10 @@ static void bwmon_enable(struct icc_bwmon *bwmon, unsigned int irq_enable) ...@@ -192,9 +191,10 @@ static void bwmon_enable(struct icc_bwmon *bwmon, unsigned int irq_enable)
writel(BWMON_ENABLE_ENABLE, bwmon->base + BWMON_ENABLE); writel(BWMON_ENABLE_ENABLE, bwmon->base + BWMON_ENABLE);
} }
static unsigned int bwmon_kbps_to_count(unsigned int kbps) static unsigned int bwmon_kbps_to_count(struct icc_bwmon *bwmon,
unsigned int kbps)
{ {
return kbps / BWMON_COUNT_UNIT_KB; return kbps / bwmon->data->count_unit_kb;
} }
static void bwmon_set_threshold(struct icc_bwmon *bwmon, unsigned int reg, static void bwmon_set_threshold(struct icc_bwmon *bwmon, unsigned int reg,
...@@ -202,8 +202,8 @@ static void bwmon_set_threshold(struct icc_bwmon *bwmon, unsigned int reg, ...@@ -202,8 +202,8 @@ static void bwmon_set_threshold(struct icc_bwmon *bwmon, unsigned int reg,
{ {
unsigned int thres; unsigned int thres;
thres = mult_frac(bwmon_kbps_to_count(kbps), bwmon->data->sample_ms, thres = mult_frac(bwmon_kbps_to_count(bwmon, kbps),
MSEC_PER_SEC); bwmon->data->sample_ms, MSEC_PER_SEC);
writel_relaxed(thres, bwmon->base + reg); writel_relaxed(thres, bwmon->base + reg);
} }
...@@ -269,7 +269,7 @@ static irqreturn_t bwmon_intr(int irq, void *dev_id) ...@@ -269,7 +269,7 @@ static irqreturn_t bwmon_intr(int irq, void *dev_id)
* downstream) always increments the max bytes count by one. * downstream) always increments the max bytes count by one.
*/ */
max = readl(bwmon->base + BWMON_ZONE_MAX(zone)) + 1; max = readl(bwmon->base + BWMON_ZONE_MAX(zone)) + 1;
max *= BWMON_COUNT_UNIT_KB; max *= bwmon->data->count_unit_kb;
bwmon->target_kbps = mult_frac(max, MSEC_PER_SEC, bwmon->data->sample_ms); bwmon->target_kbps = mult_frac(max, MSEC_PER_SEC, bwmon->data->sample_ms);
return IRQ_WAKE_THREAD; return IRQ_WAKE_THREAD;
...@@ -391,6 +391,7 @@ static int bwmon_remove(struct platform_device *pdev) ...@@ -391,6 +391,7 @@ static int bwmon_remove(struct platform_device *pdev)
/* BWMON v4 */ /* BWMON v4 */
static const struct icc_bwmon_data msm8998_bwmon_data = { static const struct icc_bwmon_data msm8998_bwmon_data = {
.sample_ms = 4, .sample_ms = 4,
.count_unit_kb = 64,
.default_highbw_kbps = 4800 * 1024, /* 4.8 GBps */ .default_highbw_kbps = 4800 * 1024, /* 4.8 GBps */
.default_medbw_kbps = 512 * 1024, /* 512 MBps */ .default_medbw_kbps = 512 * 1024, /* 512 MBps */
.default_lowbw_kbps = 0, .default_lowbw_kbps = 0,
......
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