Skip to content

Commit d3b0f6a

Browse files
saschahauerchanwoochoi
authored andcommitted
PM / devfreq: rockchip-dfi: Clean up DDR type register defines
Use the HIWORD_UPDATE() define known from other rockchip drivers to make the defines look less odd to the readers who've seen other rockchip drivers. The HIWORD registers have their functional bits in the lower 16 bits whereas the upper 16 bits contain a mask. Only the functional bits that have the corresponding mask bit set are modified during a write. Although the register writes look different, the end result should be the same, at least there's no functional change intended with this patch. Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Sascha Hauer <[email protected]> Reviewed-by: Sebastian Reichel <[email protected]> Acked-by: Chanwoo Choi <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 74002e6 commit d3b0f6a

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

drivers/devfreq/event/rockchip-dfi.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@
2626

2727
#define DMC_MAX_CHANNELS 2
2828

29+
#define HIWORD_UPDATE(val, mask) ((val) | (mask) << 16)
30+
2931
/* DDRMON_CTRL */
3032
#define DDRMON_CTRL 0x04
31-
#define CLR_DDRMON_CTRL (0x1f0000 << 0)
32-
#define LPDDR4_EN (0x10001 << 4)
33-
#define HARDWARE_EN (0x10001 << 3)
34-
#define LPDDR3_EN (0x10001 << 2)
35-
#define SOFTWARE_EN (0x10001 << 1)
36-
#define SOFTWARE_DIS (0x10000 << 1)
37-
#define TIME_CNT_EN (0x10001 << 0)
33+
#define DDRMON_CTRL_DDR4 BIT(5)
34+
#define DDRMON_CTRL_LPDDR4 BIT(4)
35+
#define DDRMON_CTRL_HARDWARE_EN BIT(3)
36+
#define DDRMON_CTRL_LPDDR23 BIT(2)
37+
#define DDRMON_CTRL_SOFTWARE_EN BIT(1)
38+
#define DDRMON_CTRL_TIMER_CNT_EN BIT(0)
39+
#define DDRMON_CTRL_DDR_TYPE_MASK (DDRMON_CTRL_DDR4 | \
40+
DDRMON_CTRL_LPDDR4 | \
41+
DDRMON_CTRL_LPDDR23)
3842

3943
#define DDRMON_CH0_COUNT_NUM 0x28
4044
#define DDRMON_CH0_DFI_ACCESS_NUM 0x2c
@@ -74,24 +78,29 @@ static void rockchip_dfi_start_hardware_counter(struct devfreq_event_dev *edev)
7478
void __iomem *dfi_regs = dfi->regs;
7579

7680
/* clear DDRMON_CTRL setting */
77-
writel_relaxed(CLR_DDRMON_CTRL, dfi_regs + DDRMON_CTRL);
81+
writel_relaxed(HIWORD_UPDATE(0, DDRMON_CTRL_TIMER_CNT_EN | DDRMON_CTRL_SOFTWARE_EN |
82+
DDRMON_CTRL_HARDWARE_EN), dfi_regs + DDRMON_CTRL);
7883

7984
/* set ddr type to dfi */
8085
if (dfi->ddr_type == ROCKCHIP_DDRTYPE_LPDDR3)
81-
writel_relaxed(LPDDR3_EN, dfi_regs + DDRMON_CTRL);
86+
writel_relaxed(HIWORD_UPDATE(DDRMON_CTRL_LPDDR23, DDRMON_CTRL_DDR_TYPE_MASK),
87+
dfi_regs + DDRMON_CTRL);
8288
else if (dfi->ddr_type == ROCKCHIP_DDRTYPE_LPDDR4)
83-
writel_relaxed(LPDDR4_EN, dfi_regs + DDRMON_CTRL);
89+
writel_relaxed(HIWORD_UPDATE(DDRMON_CTRL_LPDDR4, DDRMON_CTRL_DDR_TYPE_MASK),
90+
dfi_regs + DDRMON_CTRL);
8491

8592
/* enable count, use software mode */
86-
writel_relaxed(SOFTWARE_EN, dfi_regs + DDRMON_CTRL);
93+
writel_relaxed(HIWORD_UPDATE(DDRMON_CTRL_SOFTWARE_EN, DDRMON_CTRL_SOFTWARE_EN),
94+
dfi_regs + DDRMON_CTRL);
8795
}
8896

8997
static void rockchip_dfi_stop_hardware_counter(struct devfreq_event_dev *edev)
9098
{
9199
struct rockchip_dfi *dfi = devfreq_event_get_drvdata(edev);
92100
void __iomem *dfi_regs = dfi->regs;
93101

94-
writel_relaxed(SOFTWARE_DIS, dfi_regs + DDRMON_CTRL);
102+
writel_relaxed(HIWORD_UPDATE(0, DDRMON_CTRL_SOFTWARE_EN),
103+
dfi_regs + DDRMON_CTRL);
95104
}
96105

97106
static void rockchip_dfi_read_counters(struct devfreq_event_dev *edev, struct dmc_count *count)

0 commit comments

Comments
 (0)