Skip to content

Commit 74002e6

Browse files
saschahauerchanwoochoi
authored andcommitted
PM / devfreq: rk3399_dmc,dfi: generalize DDRTYPE defines
The DDRTYPE defines are named to be RK3399 specific, but they can be used for other Rockchip SoCs as well, so replace the RK3399_PMUGRF_ prefix with ROCKCHIP_. They are defined in a SoC specific header file, so when generalizing the prefix also move the new defines to a SoC agnostic header file. While at it use GENMASK to define the DDRTYPE bitfield and give it a name including the full register name. Link: https://lore.kernel.org/all/[email protected]/ Reviewed-by: Sebastian Reichel <[email protected]> Acked-by: Chanwoo Choi <[email protected]> Acked-by: Heiko Stuebner <[email protected]> Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Chanwoo Choi <[email protected]>
1 parent 63dcf38 commit 74002e6

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

drivers/devfreq/event/rockchip-dfi.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
#include <linux/list.h>
1919
#include <linux/of.h>
2020
#include <linux/of_device.h>
21+
#include <linux/bitfield.h>
2122
#include <linux/bits.h>
2223

24+
#include <soc/rockchip/rockchip_grf.h>
2325
#include <soc/rockchip/rk3399_grf.h>
2426

2527
#define DMC_MAX_CHANNELS 2
@@ -75,9 +77,9 @@ static void rockchip_dfi_start_hardware_counter(struct devfreq_event_dev *edev)
7577
writel_relaxed(CLR_DDRMON_CTRL, dfi_regs + DDRMON_CTRL);
7678

7779
/* set ddr type to dfi */
78-
if (dfi->ddr_type == RK3399_PMUGRF_DDRTYPE_LPDDR3)
80+
if (dfi->ddr_type == ROCKCHIP_DDRTYPE_LPDDR3)
7981
writel_relaxed(LPDDR3_EN, dfi_regs + DDRMON_CTRL);
80-
else if (dfi->ddr_type == RK3399_PMUGRF_DDRTYPE_LPDDR4)
82+
else if (dfi->ddr_type == ROCKCHIP_DDRTYPE_LPDDR4)
8183
writel_relaxed(LPDDR4_EN, dfi_regs + DDRMON_CTRL);
8284

8385
/* enable count, use software mode */
@@ -192,8 +194,7 @@ static int rk3399_dfi_init(struct rockchip_dfi *dfi)
192194

193195
/* get ddr type */
194196
regmap_read(regmap_pmu, RK3399_PMUGRF_OS_REG2, &val);
195-
dfi->ddr_type = (val >> RK3399_PMUGRF_DDRTYPE_SHIFT) &
196-
RK3399_PMUGRF_DDRTYPE_MASK;
197+
dfi->ddr_type = FIELD_GET(RK3399_PMUGRF_OS_REG2_DDRTYPE, val);
197198

198199
dfi->channel_mask = GENMASK(1, 0);
199200
dfi->max_channels = 2;

drivers/devfreq/rk3399_dmc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/suspend.h>
2323

2424
#include <soc/rockchip/pm_domains.h>
25+
#include <soc/rockchip/rockchip_grf.h>
2526
#include <soc/rockchip/rk3399_grf.h>
2627
#include <soc/rockchip/rockchip_sip.h>
2728

@@ -381,17 +382,16 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
381382
}
382383

383384
regmap_read(data->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val);
384-
ddr_type = (val >> RK3399_PMUGRF_DDRTYPE_SHIFT) &
385-
RK3399_PMUGRF_DDRTYPE_MASK;
385+
ddr_type = FIELD_GET(RK3399_PMUGRF_OS_REG2_DDRTYPE, val);
386386

387387
switch (ddr_type) {
388-
case RK3399_PMUGRF_DDRTYPE_DDR3:
388+
case ROCKCHIP_DDRTYPE_DDR3:
389389
data->odt_dis_freq = data->ddr3_odt_dis_freq;
390390
break;
391-
case RK3399_PMUGRF_DDRTYPE_LPDDR3:
391+
case ROCKCHIP_DDRTYPE_LPDDR3:
392392
data->odt_dis_freq = data->lpddr3_odt_dis_freq;
393393
break;
394-
case RK3399_PMUGRF_DDRTYPE_LPDDR4:
394+
case ROCKCHIP_DDRTYPE_LPDDR4:
395395
data->odt_dis_freq = data->lpddr4_odt_dis_freq;
396396
break;
397397
default:

include/soc/rockchip/rk3399_grf.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111

1212
/* PMU GRF Registers */
1313
#define RK3399_PMUGRF_OS_REG2 0x308
14-
#define RK3399_PMUGRF_DDRTYPE_SHIFT 13
15-
#define RK3399_PMUGRF_DDRTYPE_MASK 7
16-
#define RK3399_PMUGRF_DDRTYPE_DDR3 3
17-
#define RK3399_PMUGRF_DDRTYPE_LPDDR2 5
18-
#define RK3399_PMUGRF_DDRTYPE_LPDDR3 6
19-
#define RK3399_PMUGRF_DDRTYPE_LPDDR4 7
14+
#define RK3399_PMUGRF_OS_REG2_DDRTYPE GENMASK(15, 13)
2015

2116
#endif

include/soc/rockchip/rockchip_grf.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ */
2+
/*
3+
* Rockchip General Register Files definitions
4+
*/
5+
6+
#ifndef __SOC_ROCKCHIP_GRF_H
7+
#define __SOC_ROCKCHIP_GRF_H
8+
9+
/* Rockchip DDRTYPE defines */
10+
enum {
11+
ROCKCHIP_DDRTYPE_DDR3 = 3,
12+
ROCKCHIP_DDRTYPE_LPDDR2 = 5,
13+
ROCKCHIP_DDRTYPE_LPDDR3 = 6,
14+
ROCKCHIP_DDRTYPE_LPDDR4 = 7,
15+
};
16+
17+
#endif /* __SOC_ROCKCHIP_GRF_H */

0 commit comments

Comments
 (0)