xref: /openbmc/linux/drivers/clk/qcom/gdsc.h (revision 59b4412f)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef __QCOM_GDSC_H__
7 #define __QCOM_GDSC_H__
8 
9 #include <linux/err.h>
10 #include <linux/pm_domain.h>
11 
12 struct regmap;
13 struct regulator;
14 struct reset_controller_dev;
15 
16 /**
17  * struct gdsc - Globally Distributed Switch Controller
18  * @pd: generic power domain
19  * @regmap: regmap for MMIO accesses
20  * @gdscr: gsdc control register
21  * @gds_hw_ctrl: gds_hw_ctrl register
22  * @cxcs: offsets of branch registers to toggle mem/periph bits in
23  * @cxc_count: number of @cxcs
24  * @pwrsts: Possible powerdomain power states
25  * @resets: ids of resets associated with this gdsc
26  * @reset_count: number of @resets
27  * @rcdev: reset controller
28  */
29 struct gdsc {
30 	struct generic_pm_domain	pd;
31 	struct generic_pm_domain	*parent;
32 	struct regmap			*regmap;
33 	unsigned int			gdscr;
34 	unsigned int			gds_hw_ctrl;
35 	unsigned int			clamp_io_ctrl;
36 	unsigned int			*cxcs;
37 	unsigned int			cxc_count;
38 	const u8			pwrsts;
39 /* Powerdomain allowable state bitfields */
40 #define PWRSTS_OFF		BIT(0)
41 #define PWRSTS_RET		BIT(1)
42 #define PWRSTS_ON		BIT(2)
43 #define PWRSTS_OFF_ON		(PWRSTS_OFF | PWRSTS_ON)
44 #define PWRSTS_RET_ON		(PWRSTS_RET | PWRSTS_ON)
45 	const u8			flags;
46 #define VOTABLE		BIT(0)
47 #define CLAMP_IO	BIT(1)
48 #define HW_CTRL		BIT(2)
49 #define SW_RESET	BIT(3)
50 #define AON_RESET	BIT(4)
51 #define POLL_CFG_GDSCR	BIT(5)
52 #define ALWAYS_ON	BIT(6)
53 	struct reset_controller_dev	*rcdev;
54 	unsigned int			*resets;
55 	unsigned int			reset_count;
56 
57 	const char 			*supply;
58 	struct regulator		*rsupply;
59 };
60 
61 struct gdsc_desc {
62 	struct device *dev;
63 	struct gdsc **scs;
64 	size_t num;
65 };
66 
67 #ifdef CONFIG_QCOM_GDSC
68 int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *,
69 		  struct regmap *);
70 void gdsc_unregister(struct gdsc_desc *desc);
71 #else
72 static inline int gdsc_register(struct gdsc_desc *desc,
73 				struct reset_controller_dev *rcdev,
74 				struct regmap *r)
75 {
76 	return -ENOSYS;
77 }
78 
79 static inline void gdsc_unregister(struct gdsc_desc *desc) {};
80 #endif /* CONFIG_QCOM_GDSC */
81 #endif /* __QCOM_GDSC_H__ */
82