mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 07:34:12 +08:00
72ea48610d
Add clock drivers for hi6220 SoC, this driver controls the SoC registers to supply different clocks to different IPs in the SoC. We add one divider clock for hi6220 because the divider in hi6220 also has a mask bit but it doesnot obey the rule defined by flag "CLK_DIVIDER_HIWORD_MASK", we can not get index of the mask bit by left shift fixed bits (e.g. 16 bits), so we add this divider clock to handle it. Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org> Signed-off-by: Bintian Wang <bintian.wang@huawei.com> Acked-by: Haojian Zhuang <haojian.zhuang@linaro.org> Reviewed-by: Zhangfei Gao <zhangfei.gao@linaro.org> Tested-by: Will Deacon <will.deacon@arm.com> Tested-by: Tyler Baker <tyler.baker@linaro.org> Tested-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Michael Turquette <mturquette@linaro.org>
129 lines
3.4 KiB
C
129 lines
3.4 KiB
C
/*
|
|
* Hisilicon Hi3620 clock gate driver
|
|
*
|
|
* Copyright (c) 2012-2013 Hisilicon Limited.
|
|
* Copyright (c) 2012-2013 Linaro Limited.
|
|
*
|
|
* Author: Haojian Zhuang <haojian.zhuang@linaro.org>
|
|
* Xin Li <li.xin@linaro.org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef __HISI_CLK_H
|
|
#define __HISI_CLK_H
|
|
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/io.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
struct hisi_clock_data {
|
|
struct clk_onecell_data clk_data;
|
|
void __iomem *base;
|
|
};
|
|
|
|
struct hisi_fixed_rate_clock {
|
|
unsigned int id;
|
|
char *name;
|
|
const char *parent_name;
|
|
unsigned long flags;
|
|
unsigned long fixed_rate;
|
|
};
|
|
|
|
struct hisi_fixed_factor_clock {
|
|
unsigned int id;
|
|
char *name;
|
|
const char *parent_name;
|
|
unsigned long mult;
|
|
unsigned long div;
|
|
unsigned long flags;
|
|
};
|
|
|
|
struct hisi_mux_clock {
|
|
unsigned int id;
|
|
const char *name;
|
|
const char **parent_names;
|
|
u8 num_parents;
|
|
unsigned long flags;
|
|
unsigned long offset;
|
|
u8 shift;
|
|
u8 width;
|
|
u8 mux_flags;
|
|
u32 *table;
|
|
const char *alias;
|
|
};
|
|
|
|
struct hisi_divider_clock {
|
|
unsigned int id;
|
|
const char *name;
|
|
const char *parent_name;
|
|
unsigned long flags;
|
|
unsigned long offset;
|
|
u8 shift;
|
|
u8 width;
|
|
u8 div_flags;
|
|
struct clk_div_table *table;
|
|
const char *alias;
|
|
};
|
|
|
|
struct hi6220_divider_clock {
|
|
unsigned int id;
|
|
const char *name;
|
|
const char *parent_name;
|
|
unsigned long flags;
|
|
unsigned long offset;
|
|
u8 shift;
|
|
u8 width;
|
|
u32 mask_bit;
|
|
const char *alias;
|
|
};
|
|
|
|
struct hisi_gate_clock {
|
|
unsigned int id;
|
|
const char *name;
|
|
const char *parent_name;
|
|
unsigned long flags;
|
|
unsigned long offset;
|
|
u8 bit_idx;
|
|
u8 gate_flags;
|
|
const char *alias;
|
|
};
|
|
|
|
struct clk *hisi_register_clkgate_sep(struct device *, const char *,
|
|
const char *, unsigned long,
|
|
void __iomem *, u8,
|
|
u8, spinlock_t *);
|
|
struct clk *hi6220_register_clkdiv(struct device *dev, const char *name,
|
|
const char *parent_name, unsigned long flags, void __iomem *reg,
|
|
u8 shift, u8 width, u32 mask_bit, spinlock_t *lock);
|
|
|
|
struct hisi_clock_data *hisi_clk_init(struct device_node *, int);
|
|
void hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *,
|
|
int, struct hisi_clock_data *);
|
|
void hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *,
|
|
int, struct hisi_clock_data *);
|
|
void hisi_clk_register_mux(struct hisi_mux_clock *, int,
|
|
struct hisi_clock_data *);
|
|
void hisi_clk_register_divider(struct hisi_divider_clock *,
|
|
int, struct hisi_clock_data *);
|
|
void hisi_clk_register_gate(struct hisi_gate_clock *,
|
|
int, struct hisi_clock_data *);
|
|
void hisi_clk_register_gate_sep(struct hisi_gate_clock *,
|
|
int, struct hisi_clock_data *);
|
|
void hi6220_clk_register_divider(struct hi6220_divider_clock *,
|
|
int, struct hisi_clock_data *);
|
|
#endif /* __HISI_CLK_H */
|