summaryrefslogtreecommitdiffstats
path: root/drivers/clk/visconti/clkc.h
blob: 09ed82ff64e45458de10688e2eb4a95215213afc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Toshiba Visconti clock controller
 *
 * Copyright (c) 2021 TOSHIBA CORPORATION
 * Copyright (c) 2021 Toshiba Electronic Devices & Storage Corporation
 *
 * Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
 */

#ifndef _VISCONTI_CLKC_H_
#define _VISCONTI_CLKC_H_

#include <linux/mfd/syscon.h>
#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/delay.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/io.h>
#include <linux/spinlock.h>

#include "reset.h"

struct visconti_clk_provider {
	struct device		*dev;
	struct regmap		*regmap;
	struct clk_hw_onecell_data clk_data;
};

struct visconti_clk_gate_table {
	unsigned int	id;
	const char	*name;
	const struct clk_parent_data *parent_data;
	u8		num_parents;
	u8		flags;
	u32		ckon_offset;
	u32		ckoff_offset;
	u8		ck_idx;
	unsigned int	div;
	u8		rs_id;
};

struct visconti_fixed_clk {
	unsigned int	id;
	const char	*name;
	const char	*parent;
	unsigned long	flag;
	unsigned int	mult;
	unsigned int	div;
};

struct visconti_clk_gate {
	struct clk_hw	hw;
	struct regmap	*regmap;
	u32		ckon_offset;
	u32		ckoff_offset;
	u8		ck_idx;
	u8		flags;
	u32		rson_offset;
	u32		rsoff_offset;
	u8		rs_idx;
	spinlock_t	*lock;
};

struct visconti_clk_provider *visconti_init_clk(struct device *dev,
						struct regmap *regmap,
						unsigned long nr_clks);
int visconti_clk_register_gates(struct visconti_clk_provider *data,
				 const struct visconti_clk_gate_table *clks,
				 int num_gate,
				 const struct visconti_reset_data *reset,
				 spinlock_t *lock);
#endif /* _VISCONTI_CLKC_H_ */