1 /* 2 * Hisilicon Hi3620 clock gate driver 3 * 4 * Copyright (c) 2012-2013 Hisilicon Limited. 5 * Copyright (c) 2012-2013 Linaro Limited. 6 * 7 * Author: Haojian Zhuang <haojian.zhuang@linaro.org> 8 * Xin Li <li.xin@linaro.org> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License along 21 * with this program; if not, write to the Free Software Foundation, Inc., 22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 * 24 */ 25 26 #ifndef __HISI_CLK_H 27 #define __HISI_CLK_H 28 29 #include <linux/clk-provider.h> 30 #include <linux/io.h> 31 #include <linux/spinlock.h> 32 33 struct hisi_clock_data { 34 struct clk_onecell_data clk_data; 35 void __iomem *base; 36 }; 37 38 struct hisi_fixed_rate_clock { 39 unsigned int id; 40 char *name; 41 const char *parent_name; 42 unsigned long flags; 43 unsigned long fixed_rate; 44 }; 45 46 struct hisi_fixed_factor_clock { 47 unsigned int id; 48 char *name; 49 const char *parent_name; 50 unsigned long mult; 51 unsigned long div; 52 unsigned long flags; 53 }; 54 55 struct hisi_mux_clock { 56 unsigned int id; 57 const char *name; 58 const char **parent_names; 59 u8 num_parents; 60 unsigned long flags; 61 unsigned long offset; 62 u8 shift; 63 u8 width; 64 u8 mux_flags; 65 const char *alias; 66 }; 67 68 struct hisi_divider_clock { 69 unsigned int id; 70 const char *name; 71 const char *parent_name; 72 unsigned long flags; 73 unsigned long offset; 74 u8 shift; 75 u8 width; 76 u8 div_flags; 77 struct clk_div_table *table; 78 const char *alias; 79 }; 80 81 struct hisi_gate_clock { 82 unsigned int id; 83 const char *name; 84 const char *parent_name; 85 unsigned long flags; 86 unsigned long offset; 87 u8 bit_idx; 88 u8 gate_flags; 89 const char *alias; 90 }; 91 92 struct clk *hisi_register_clkgate_sep(struct device *, const char *, 93 const char *, unsigned long, 94 void __iomem *, u8, 95 u8, spinlock_t *); 96 97 struct hisi_clock_data __init *hisi_clk_init(struct device_node *, int); 98 void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *, 99 int, struct hisi_clock_data *); 100 void __init hisi_clk_register_fixed_factor(struct hisi_fixed_factor_clock *, 101 int, struct hisi_clock_data *); 102 void __init hisi_clk_register_mux(struct hisi_mux_clock *, int, 103 struct hisi_clock_data *); 104 void __init hisi_clk_register_divider(struct hisi_divider_clock *, 105 int, struct hisi_clock_data *); 106 void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *, 107 int, struct hisi_clock_data *); 108 #endif /* __HISI_CLK_H */ 109