Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __MACH_SUNXI_CLK_FACTORS_H
0003 #define __MACH_SUNXI_CLK_FACTORS_H
0004 
0005 #include <linux/clk-provider.h>
0006 #include <linux/spinlock.h>
0007 
0008 #define SUNXI_FACTORS_NOT_APPLICABLE    (0)
0009 
0010 struct clk_factors_config {
0011     u8 nshift;
0012     u8 nwidth;
0013     u8 kshift;
0014     u8 kwidth;
0015     u8 mshift;
0016     u8 mwidth;
0017     u8 pshift;
0018     u8 pwidth;
0019     u8 n_start;
0020 };
0021 
0022 struct factors_request {
0023     unsigned long rate;
0024     unsigned long parent_rate;
0025     u8 parent_index;
0026     u8 n;
0027     u8 k;
0028     u8 m;
0029     u8 p;
0030 };
0031 
0032 struct factors_data {
0033     int enable;
0034     int mux;
0035     int muxmask;
0036     const struct clk_factors_config *table;
0037     void (*getter)(struct factors_request *req);
0038     void (*recalc)(struct factors_request *req);
0039     const char *name;
0040 };
0041 
0042 struct clk_factors {
0043     struct clk_hw hw;
0044     void __iomem *reg;
0045     const struct clk_factors_config *config;
0046     void (*get_factors)(struct factors_request *req);
0047     void (*recalc)(struct factors_request *req);
0048     spinlock_t *lock;
0049     /* for cleanup */
0050     struct clk_mux *mux;
0051     struct clk_gate *gate;
0052 };
0053 
0054 struct clk *sunxi_factors_register(struct device_node *node,
0055                    const struct factors_data *data,
0056                    spinlock_t *lock,
0057                    void __iomem *reg);
0058 struct clk *sunxi_factors_register_critical(struct device_node *node,
0059                         const struct factors_data *data,
0060                         spinlock_t *lock,
0061                         void __iomem *reg);
0062 
0063 void sunxi_factors_unregister(struct device_node *node, struct clk *clk);
0064 
0065 #endif