16
16
#include "clk-mtk.h"
17
17
#include "clk-gate.h"
18
18
19
- static int mtk_cg_bit_is_cleared (struct clk_hw * hw )
19
+ static u32 mtk_get_clockgating (struct clk_hw * hw )
20
20
{
21
21
struct mtk_clk_gate * cg = to_mtk_clk_gate (hw );
22
22
u32 val ;
23
23
24
24
regmap_read (cg -> regmap , cg -> sta_ofs , & val );
25
25
26
- val &= BIT (cg -> bit );
26
+ return val & BIT (cg -> bit );
27
+ }
27
28
28
- return val == 0 ;
29
+ static int mtk_cg_bit_is_cleared (struct clk_hw * hw )
30
+ {
31
+ return mtk_get_clockgating (hw ) == 0 ;
29
32
}
30
33
31
34
static int mtk_cg_bit_is_set (struct clk_hw * hw )
32
35
{
33
- struct mtk_clk_gate * cg = to_mtk_clk_gate (hw );
34
- u32 val ;
35
-
36
- regmap_read (cg -> regmap , cg -> sta_ofs , & val );
37
-
38
- val &= BIT (cg -> bit );
39
-
40
- return val != 0 ;
36
+ return mtk_get_clockgating (hw ) != 0 ;
41
37
}
42
38
43
39
static void mtk_cg_set_bit (struct clk_hw * hw )
@@ -57,17 +53,15 @@ static void mtk_cg_clr_bit(struct clk_hw *hw)
57
53
static void mtk_cg_set_bit_no_setclr (struct clk_hw * hw )
58
54
{
59
55
struct mtk_clk_gate * cg = to_mtk_clk_gate (hw );
60
- u32 cgbit = BIT (cg -> bit );
61
56
62
- regmap_update_bits (cg -> regmap , cg -> sta_ofs , cgbit , cgbit );
57
+ regmap_set_bits (cg -> regmap , cg -> sta_ofs , BIT ( cg -> bit ) );
63
58
}
64
59
65
60
static void mtk_cg_clr_bit_no_setclr (struct clk_hw * hw )
66
61
{
67
62
struct mtk_clk_gate * cg = to_mtk_clk_gate (hw );
68
- u32 cgbit = BIT (cg -> bit );
69
63
70
- regmap_update_bits (cg -> regmap , cg -> sta_ofs , cgbit , 0 );
64
+ regmap_clear_bits (cg -> regmap , cg -> sta_ofs , BIT ( cg -> bit ) );
71
65
}
72
66
73
67
static int mtk_cg_enable (struct clk_hw * hw )
0 commit comments