2 * Copyright (c) 2017 BayLibre, SAS.
3 * Author: Neil Armstrong <narmstrong@baylibre.com>
5 * SPDX-License-Identifier: GPL-2.0+
8 #include <linux/clk-provider.h>
9 #include <linux/bitfield.h>
10 #include <linux/regmap.h>
11 #include "gxbb-aoclk.h"
13 static int aoclk_gate_regmap_enable(struct clk_hw
*hw
)
15 struct aoclk_gate_regmap
*gate
= to_aoclk_gate_regmap(hw
);
17 return regmap_update_bits(gate
->regmap
, AO_RTI_GEN_CNTL_REG0
,
18 BIT(gate
->bit_idx
), BIT(gate
->bit_idx
));
21 static void aoclk_gate_regmap_disable(struct clk_hw
*hw
)
23 struct aoclk_gate_regmap
*gate
= to_aoclk_gate_regmap(hw
);
25 regmap_update_bits(gate
->regmap
, AO_RTI_GEN_CNTL_REG0
,
26 BIT(gate
->bit_idx
), 0);
29 static int aoclk_gate_regmap_is_enabled(struct clk_hw
*hw
)
31 struct aoclk_gate_regmap
*gate
= to_aoclk_gate_regmap(hw
);
35 ret
= regmap_read(gate
->regmap
, AO_RTI_GEN_CNTL_REG0
, &val
);
39 return (val
& BIT(gate
->bit_idx
)) != 0;
42 const struct clk_ops meson_aoclk_gate_regmap_ops
= {
43 .enable
= aoclk_gate_regmap_enable
,
44 .disable
= aoclk_gate_regmap_disable
,
45 .is_enabled
= aoclk_gate_regmap_is_enabled
,