2016-06-30 03:05:26 +08:00
|
|
|
#ifndef _CCU_MUX_H_
|
|
|
|
#define _CCU_MUX_H_
|
|
|
|
|
|
|
|
#include <linux/clk-provider.h>
|
|
|
|
|
|
|
|
#include "ccu_common.h"
|
|
|
|
|
2016-08-25 14:21:57 +08:00
|
|
|
struct ccu_mux_fixed_prediv {
|
|
|
|
u8 index;
|
|
|
|
u16 div;
|
|
|
|
};
|
|
|
|
|
2016-06-30 03:05:26 +08:00
|
|
|
struct ccu_mux_internal {
|
2016-08-25 14:21:56 +08:00
|
|
|
u8 shift;
|
|
|
|
u8 width;
|
|
|
|
const u8 *table;
|
2016-06-30 03:05:26 +08:00
|
|
|
|
2016-08-25 14:21:57 +08:00
|
|
|
const struct ccu_mux_fixed_prediv *fixed_predivs;
|
|
|
|
u8 n_predivs;
|
2016-06-30 03:05:26 +08:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u8 index;
|
|
|
|
u8 shift;
|
|
|
|
u8 width;
|
|
|
|
} variable_prediv;
|
|
|
|
};
|
|
|
|
|
2016-08-25 14:21:56 +08:00
|
|
|
#define _SUNXI_CCU_MUX_TABLE(_shift, _width, _table) \
|
|
|
|
{ \
|
|
|
|
.shift = _shift, \
|
|
|
|
.width = _width, \
|
|
|
|
.table = _table, \
|
2016-06-30 03:05:26 +08:00
|
|
|
}
|
|
|
|
|
2016-08-25 14:21:56 +08:00
|
|
|
#define _SUNXI_CCU_MUX(_shift, _width) \
|
|
|
|
_SUNXI_CCU_MUX_TABLE(_shift, _width, NULL)
|
|
|
|
|
2016-06-30 03:05:26 +08:00
|
|
|
struct ccu_mux {
|
|
|
|
u16 reg;
|
|
|
|
u32 enable;
|
|
|
|
|
|
|
|
struct ccu_mux_internal mux;
|
|
|
|
struct ccu_common common;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SUNXI_CCU_MUX(_struct, _name, _parents, _reg, _shift, _width, _flags) \
|
|
|
|
struct ccu_mux _struct = { \
|
2016-07-21 05:45:35 +08:00
|
|
|
.mux = _SUNXI_CCU_MUX(_shift, _width), \
|
2016-06-30 03:05:26 +08:00
|
|
|
.common = { \
|
|
|
|
.reg = _reg, \
|
|
|
|
.hw.init = CLK_HW_INIT_PARENTS(_name, \
|
|
|
|
_parents, \
|
|
|
|
&ccu_mux_ops, \
|
|
|
|
_flags), \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SUNXI_CCU_MUX_WITH_GATE(_struct, _name, _parents, _reg, \
|
|
|
|
_shift, _width, _gate, _flags) \
|
|
|
|
struct ccu_mux _struct = { \
|
|
|
|
.enable = _gate, \
|
2016-07-21 05:45:35 +08:00
|
|
|
.mux = _SUNXI_CCU_MUX(_shift, _width), \
|
2016-06-30 03:05:26 +08:00
|
|
|
.common = { \
|
|
|
|
.reg = _reg, \
|
|
|
|
.hw.init = CLK_HW_INIT_PARENTS(_name, \
|
|
|
|
_parents, \
|
|
|
|
&ccu_mux_ops, \
|
|
|
|
_flags), \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw)
|
|
|
|
{
|
|
|
|
struct ccu_common *common = hw_to_ccu_common(hw);
|
|
|
|
|
|
|
|
return container_of(common, struct ccu_mux, common);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern const struct clk_ops ccu_mux_ops;
|
|
|
|
|
|
|
|
void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common,
|
|
|
|
struct ccu_mux_internal *cm,
|
|
|
|
int parent_index,
|
|
|
|
unsigned long *parent_rate);
|
|
|
|
int ccu_mux_helper_determine_rate(struct ccu_common *common,
|
|
|
|
struct ccu_mux_internal *cm,
|
|
|
|
struct clk_rate_request *req,
|
|
|
|
unsigned long (*round)(struct ccu_mux_internal *,
|
|
|
|
unsigned long,
|
|
|
|
unsigned long,
|
|
|
|
void *),
|
|
|
|
void *data);
|
|
|
|
u8 ccu_mux_helper_get_parent(struct ccu_common *common,
|
|
|
|
struct ccu_mux_internal *cm);
|
|
|
|
int ccu_mux_helper_set_parent(struct ccu_common *common,
|
|
|
|
struct ccu_mux_internal *cm,
|
|
|
|
u8 index);
|
|
|
|
|
|
|
|
#endif /* _CCU_MUX_H_ */
|