This source file includes following definitions.
- mtk_infracfg_set_bus_protection
- mtk_infracfg_clear_bus_protection
1
2
3
4
5
6 #include <linux/export.h>
7 #include <linux/jiffies.h>
8 #include <linux/regmap.h>
9 #include <linux/soc/mediatek/infracfg.h>
10 #include <asm/processor.h>
11
12 #define MTK_POLL_DELAY_US 10
13 #define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ))
14
15 #define INFRA_TOPAXI_PROTECTEN 0x0220
16 #define INFRA_TOPAXI_PROTECTSTA1 0x0228
17 #define INFRA_TOPAXI_PROTECTEN_SET 0x0260
18 #define INFRA_TOPAXI_PROTECTEN_CLR 0x0264
19
20
21
22
23
24
25
26
27
28
29
30
31
32 int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
33 bool reg_update)
34 {
35 u32 val;
36 int ret;
37
38 if (reg_update)
39 regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask,
40 mask);
41 else
42 regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask);
43
44 ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
45 val, (val & mask) == mask,
46 MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
47
48 return ret;
49 }
50
51
52
53
54
55
56
57
58
59
60
61
62
63 int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,
64 bool reg_update)
65 {
66 int ret;
67 u32 val;
68
69 if (reg_update)
70 regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0);
71 else
72 regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask);
73
74 ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
75 val, !(val & mask),
76 MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
77
78 return ret;
79 }