xref: /linux/drivers/clk/visconti/clkc.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b4cbe606SNobuhiro Iwamatsu /* SPDX-License-Identifier: GPL-2.0-only */
2b4cbe606SNobuhiro Iwamatsu /*
3b4cbe606SNobuhiro Iwamatsu  * Toshiba Visconti clock controller
4b4cbe606SNobuhiro Iwamatsu  *
5b4cbe606SNobuhiro Iwamatsu  * Copyright (c) 2021 TOSHIBA CORPORATION
6b4cbe606SNobuhiro Iwamatsu  * Copyright (c) 2021 Toshiba Electronic Devices & Storage Corporation
7b4cbe606SNobuhiro Iwamatsu  *
8b4cbe606SNobuhiro Iwamatsu  * Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
9b4cbe606SNobuhiro Iwamatsu  */
10b4cbe606SNobuhiro Iwamatsu 
11b4cbe606SNobuhiro Iwamatsu #ifndef _VISCONTI_CLKC_H_
12b4cbe606SNobuhiro Iwamatsu #define _VISCONTI_CLKC_H_
13b4cbe606SNobuhiro Iwamatsu 
14b4cbe606SNobuhiro Iwamatsu #include <linux/mfd/syscon.h>
15b4cbe606SNobuhiro Iwamatsu #include <linux/clk-provider.h>
16b4cbe606SNobuhiro Iwamatsu #include <linux/of.h>
17b4cbe606SNobuhiro Iwamatsu #include <linux/of_address.h>
18b4cbe606SNobuhiro Iwamatsu #include <linux/delay.h>
19b4cbe606SNobuhiro Iwamatsu #include <linux/regmap.h>
20b4cbe606SNobuhiro Iwamatsu #include <linux/slab.h>
21b4cbe606SNobuhiro Iwamatsu #include <linux/string.h>
22b4cbe606SNobuhiro Iwamatsu #include <linux/io.h>
23b4cbe606SNobuhiro Iwamatsu #include <linux/spinlock.h>
24b4cbe606SNobuhiro Iwamatsu 
25b4cbe606SNobuhiro Iwamatsu #include "reset.h"
26b4cbe606SNobuhiro Iwamatsu 
27b4cbe606SNobuhiro Iwamatsu struct visconti_clk_provider {
28b4cbe606SNobuhiro Iwamatsu 	struct device		*dev;
29b4cbe606SNobuhiro Iwamatsu 	struct regmap		*regmap;
30b4cbe606SNobuhiro Iwamatsu 	struct clk_hw_onecell_data clk_data;
31b4cbe606SNobuhiro Iwamatsu };
32b4cbe606SNobuhiro Iwamatsu 
33b4cbe606SNobuhiro Iwamatsu struct visconti_clk_gate_table {
34b4cbe606SNobuhiro Iwamatsu 	unsigned int	id;
35b4cbe606SNobuhiro Iwamatsu 	const char	*name;
36b4cbe606SNobuhiro Iwamatsu 	const struct clk_parent_data *parent_data;
37b4cbe606SNobuhiro Iwamatsu 	u8		num_parents;
38b4cbe606SNobuhiro Iwamatsu 	u8		flags;
39b4cbe606SNobuhiro Iwamatsu 	u32		ckon_offset;
40b4cbe606SNobuhiro Iwamatsu 	u32		ckoff_offset;
41b4cbe606SNobuhiro Iwamatsu 	u8		ck_idx;
42b4cbe606SNobuhiro Iwamatsu 	unsigned int	div;
43b4cbe606SNobuhiro Iwamatsu 	u8		rs_id;
44b4cbe606SNobuhiro Iwamatsu };
45b4cbe606SNobuhiro Iwamatsu 
46b4cbe606SNobuhiro Iwamatsu struct visconti_fixed_clk {
47b4cbe606SNobuhiro Iwamatsu 	unsigned int	id;
48b4cbe606SNobuhiro Iwamatsu 	const char	*name;
49b4cbe606SNobuhiro Iwamatsu 	const char	*parent;
50b4cbe606SNobuhiro Iwamatsu 	unsigned long	flag;
51b4cbe606SNobuhiro Iwamatsu 	unsigned int	mult;
52b4cbe606SNobuhiro Iwamatsu 	unsigned int	div;
53b4cbe606SNobuhiro Iwamatsu };
54b4cbe606SNobuhiro Iwamatsu 
55b4cbe606SNobuhiro Iwamatsu struct visconti_clk_gate {
56b4cbe606SNobuhiro Iwamatsu 	struct clk_hw	hw;
57b4cbe606SNobuhiro Iwamatsu 	struct regmap	*regmap;
58b4cbe606SNobuhiro Iwamatsu 	u32		ckon_offset;
59b4cbe606SNobuhiro Iwamatsu 	u32		ckoff_offset;
60b4cbe606SNobuhiro Iwamatsu 	u8		ck_idx;
61b4cbe606SNobuhiro Iwamatsu 	u8		flags;
62b4cbe606SNobuhiro Iwamatsu 	u32		rson_offset;
63b4cbe606SNobuhiro Iwamatsu 	u32		rsoff_offset;
64b4cbe606SNobuhiro Iwamatsu 	u8		rs_idx;
65b4cbe606SNobuhiro Iwamatsu 	spinlock_t	*lock;
66b4cbe606SNobuhiro Iwamatsu };
67b4cbe606SNobuhiro Iwamatsu 
68b4cbe606SNobuhiro Iwamatsu struct visconti_clk_provider *visconti_init_clk(struct device *dev,
69b4cbe606SNobuhiro Iwamatsu 						struct regmap *regmap,
70b4cbe606SNobuhiro Iwamatsu 						unsigned long nr_clks);
71b4cbe606SNobuhiro Iwamatsu int visconti_clk_register_gates(struct visconti_clk_provider *data,
72b4cbe606SNobuhiro Iwamatsu 				 const struct visconti_clk_gate_table *clks,
73b4cbe606SNobuhiro Iwamatsu 				 int num_gate,
74b4cbe606SNobuhiro Iwamatsu 				 const struct visconti_reset_data *reset,
75b4cbe606SNobuhiro Iwamatsu 				 spinlock_t *lock);
76*c5601e07SDan Carpenter 
77*c5601e07SDan Carpenter #define NO_RESET 0xFF
78*c5601e07SDan Carpenter 
79b4cbe606SNobuhiro Iwamatsu #endif /* _VISCONTI_CLKC_H_ */
80