summaryrefslogtreecommitdiffstats
path: root/drivers/clk/baikal-t1/ccu-rst.h
blob: d6e8b2f671f4d9a4f2be7f463ff2ffe49696ec2e (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
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2021 BAIKAL ELECTRONICS, JSC
 *
 * Baikal-T1 CCU Resets interface driver
 */
#ifndef __CLK_BT1_CCU_RST_H__
#define __CLK_BT1_CCU_RST_H__

#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/reset-controller.h>

struct ccu_rst_info;

/*
 * enum ccu_rst_type - CCU Reset types
 * @CCU_RST_TRIG: Self-deasserted reset signal.
 * @CCU_RST_DIR: Directly controlled reset signal.
 */
enum ccu_rst_type {
	CCU_RST_TRIG,
	CCU_RST_DIR,
};

/*
 * struct ccu_rst_init_data - CCU Resets initialization data
 * @sys_regs: Baikal-T1 System Controller registers map.
 * @np: Pointer to the node with the System CCU block.
 */
struct ccu_rst_init_data {
	struct regmap *sys_regs;
	struct device_node *np;
};

/*
 * struct ccu_rst - CCU Reset descriptor
 * @rcdev: Reset controller descriptor.
 * @sys_regs: Baikal-T1 System Controller registers map.
 * @rsts_info: Reset flag info (base address and mask).
 */
struct ccu_rst {
	struct reset_controller_dev rcdev;
	struct regmap *sys_regs;
	const struct ccu_rst_info *rsts_info;
};
#define to_ccu_rst(_rcdev) container_of(_rcdev, struct ccu_rst, rcdev)

#ifdef CONFIG_CLK_BT1_CCU_RST

struct ccu_rst *ccu_rst_hw_register(const struct ccu_rst_init_data *init);

void ccu_rst_hw_unregister(struct ccu_rst *rst);

#else

static inline
struct ccu_rst *ccu_rst_hw_register(const struct ccu_rst_init_data *init)
{
	return NULL;
}

static inline void ccu_rst_hw_unregister(struct ccu_rst *rst) {}

#endif

#endif /* __CLK_BT1_CCU_RST_H__ */