#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/mfd/rk808.h>
struct clk_hw clkout1_hw;
struct clk_hw clkout2_hw;
static unsigned long rk808_clkout_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
static int rk808_clkout2_enable(struct clk_hw *hw, bool enable)
struct rk808_clkout *rk808_clkout = container_of(hw,
struct rk808 *rk808 = rk808_clkout->rk808;
return regmap_update_bits(rk808->regmap, RK808_CLK32OUT_REG,
CLK32KOUT2_EN, enable ? CLK32KOUT2_EN : 0);
static int rk808_clkout2_prepare(struct clk_hw *hw)
return rk808_clkout2_enable(hw, true);
static void rk808_clkout2_unprepare(struct clk_hw *hw)
rk808_clkout2_enable(hw, false);
static int rk808_clkout2_is_prepared(struct clk_hw *hw)
struct rk808_clkout *rk808_clkout = container_of(hw,
struct rk808 *rk808 = rk808_clkout->rk808;
int ret = regmap_read(rk808->regmap, RK808_CLK32OUT_REG, &val);
return (val & CLK32KOUT2_EN) ? 1 : 0;
static const struct clk_ops rk808_clkout1_ops = {
.recalc_rate = rk808_clkout_recalc_rate,
static const struct clk_ops rk808_clkout2_ops = {
.prepare = rk808_clkout2_prepare,
.unprepare = rk808_clkout2_unprepare,
.is_prepared = rk808_clkout2_is_prepared,
.recalc_rate = rk808_clkout_recalc_rate,
of_clk_rk808_get(struct of_phandle_args *clkspec, void *data)
struct rk808_clkout *rk808_clkout = data;
unsigned int idx = clkspec->args[0];
pr_err("%s: invalid index %u\n", __func__, idx);