2013-02-25 18:44:26 +04:00
|
|
|
#ifndef __MACH_SUNXI_CLK_FACTORS_H
|
|
|
|
#define __MACH_SUNXI_CLK_FACTORS_H
|
|
|
|
|
|
|
|
#include <linux/clk-provider.h>
|
2014-07-05 00:24:52 +04:00
|
|
|
#include <linux/spinlock.h>
|
2013-02-25 18:44:26 +04:00
|
|
|
|
|
|
|
#define SUNXI_FACTORS_NOT_APPLICABLE (0)
|
|
|
|
|
|
|
|
struct clk_factors_config {
|
|
|
|
u8 nshift;
|
|
|
|
u8 nwidth;
|
|
|
|
u8 kshift;
|
|
|
|
u8 kwidth;
|
|
|
|
u8 mshift;
|
|
|
|
u8 mwidth;
|
|
|
|
u8 pshift;
|
|
|
|
u8 pwidth;
|
2014-06-26 19:55:41 +04:00
|
|
|
u8 n_start;
|
2013-02-25 18:44:26 +04:00
|
|
|
};
|
|
|
|
|
2016-01-25 16:15:42 +03:00
|
|
|
struct factors_request {
|
|
|
|
unsigned long rate;
|
|
|
|
unsigned long parent_rate;
|
2016-01-25 16:15:43 +03:00
|
|
|
u8 parent_index;
|
2016-01-25 16:15:42 +03:00
|
|
|
u8 n;
|
|
|
|
u8 k;
|
|
|
|
u8 m;
|
|
|
|
u8 p;
|
|
|
|
};
|
|
|
|
|
2014-07-05 00:24:52 +04:00
|
|
|
struct factors_data {
|
|
|
|
int enable;
|
|
|
|
int mux;
|
2014-10-20 18:10:26 +04:00
|
|
|
int muxmask;
|
2016-01-25 16:15:38 +03:00
|
|
|
const struct clk_factors_config *table;
|
2016-01-25 16:15:42 +03:00
|
|
|
void (*getter)(struct factors_request *req);
|
2016-01-25 16:15:43 +03:00
|
|
|
void (*recalc)(struct factors_request *req);
|
2014-07-05 00:24:52 +04:00
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
2013-12-23 07:32:32 +04:00
|
|
|
struct clk_factors {
|
|
|
|
struct clk_hw hw;
|
|
|
|
void __iomem *reg;
|
2016-01-25 16:15:38 +03:00
|
|
|
const struct clk_factors_config *config;
|
2016-01-25 16:15:42 +03:00
|
|
|
void (*get_factors)(struct factors_request *req);
|
2016-01-25 16:15:43 +03:00
|
|
|
void (*recalc)(struct factors_request *req);
|
2013-12-23 07:32:32 +04:00
|
|
|
spinlock_t *lock;
|
2016-01-25 16:15:40 +03:00
|
|
|
/* for cleanup */
|
|
|
|
struct clk_mux *mux;
|
|
|
|
struct clk_gate *gate;
|
2013-12-23 07:32:32 +04:00
|
|
|
};
|
|
|
|
|
2014-11-23 16:38:07 +03:00
|
|
|
struct clk *sunxi_factors_register(struct device_node *node,
|
|
|
|
const struct factors_data *data,
|
|
|
|
spinlock_t *lock,
|
|
|
|
void __iomem *reg);
|
2014-07-05 00:24:52 +04:00
|
|
|
|
2016-01-25 16:15:40 +03:00
|
|
|
void sunxi_factors_unregister(struct device_node *node, struct clk *clk);
|
|
|
|
|
2013-02-25 18:44:26 +04:00
|
|
|
#endif
|