1616#include "clk-mtk.h"
1717#include "clk-gate.h"
1818
19- static int mtk_cg_bit_is_cleared (struct clk_hw * hw )
19+ static u32 mtk_get_clockgating (struct clk_hw * hw )
2020{
2121 struct mtk_clk_gate * cg = to_mtk_clk_gate (hw );
2222 u32 val ;
2323
2424 regmap_read (cg -> regmap , cg -> sta_ofs , & val );
2525
26- val &= BIT (cg -> bit );
26+ return val & BIT (cg -> bit );
27+ }
2728
28- return val == 0 ;
29+ static int mtk_cg_bit_is_cleared (struct clk_hw * hw )
30+ {
31+ return mtk_get_clockgating (hw ) == 0 ;
2932}
3033
3134static int mtk_cg_bit_is_set (struct clk_hw * hw )
3235{
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 ;
4137}
4238
4339static void mtk_cg_set_bit (struct clk_hw * hw )
@@ -57,17 +53,15 @@ static void mtk_cg_clr_bit(struct clk_hw *hw)
5753static void mtk_cg_set_bit_no_setclr (struct clk_hw * hw )
5854{
5955 struct mtk_clk_gate * cg = to_mtk_clk_gate (hw );
60- u32 cgbit = BIT (cg -> bit );
6156
62- regmap_update_bits (cg -> regmap , cg -> sta_ofs , cgbit , cgbit );
57+ regmap_set_bits (cg -> regmap , cg -> sta_ofs , BIT ( cg -> bit ) );
6358}
6459
6560static void mtk_cg_clr_bit_no_setclr (struct clk_hw * hw )
6661{
6762 struct mtk_clk_gate * cg = to_mtk_clk_gate (hw );
68- u32 cgbit = BIT (cg -> bit );
6963
70- regmap_update_bits (cg -> regmap , cg -> sta_ofs , cgbit , 0 );
64+ regmap_clear_bits (cg -> regmap , cg -> sta_ofs , BIT ( cg -> bit ) );
7165}
7266
7367static int mtk_cg_enable (struct clk_hw * hw )
0 commit comments