gdsc.h 2.0 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0-only */
S
Stephen Boyd 已提交
2
/*
3
 * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
S
Stephen Boyd 已提交
4 5 6 7 8 9 10 11 12
 */

#ifndef __QCOM_GDSC_H__
#define __QCOM_GDSC_H__

#include <linux/err.h>
#include <linux/pm_domain.h>

struct regmap;
13
struct reset_controller_dev;
S
Stephen Boyd 已提交
14 15 16 17 18 19

/**
 * struct gdsc - Globally Distributed Switch Controller
 * @pd: generic power domain
 * @regmap: regmap for MMIO accesses
 * @gdscr: gsdc control register
20
 * @gds_hw_ctrl: gds_hw_ctrl register
21 22 23
 * @cxcs: offsets of branch registers to toggle mem/periph bits in
 * @cxc_count: number of @cxcs
 * @pwrsts: Possible powerdomain power states
24 25 26
 * @resets: ids of resets associated with this gdsc
 * @reset_count: number of @resets
 * @rcdev: reset controller
S
Stephen Boyd 已提交
27 28 29
 */
struct gdsc {
	struct generic_pm_domain	pd;
30
	struct generic_pm_domain	*parent;
S
Stephen Boyd 已提交
31 32
	struct regmap			*regmap;
	unsigned int			gdscr;
33
	unsigned int			gds_hw_ctrl;
34
	unsigned int			clamp_io_ctrl;
35 36 37
	unsigned int			*cxcs;
	unsigned int			cxc_count;
	const u8			pwrsts;
38 39 40 41 42 43 44 45
/* Powerdomain allowable state bitfields */
#define PWRSTS_OFF		BIT(0)
#define PWRSTS_RET		BIT(1)
#define PWRSTS_ON		BIT(2)
#define PWRSTS_OFF_ON		(PWRSTS_OFF | PWRSTS_ON)
#define PWRSTS_RET_ON		(PWRSTS_RET | PWRSTS_ON)
	const u8			flags;
#define VOTABLE		BIT(0)
46
#define CLAMP_IO	BIT(1)
47
#define HW_CTRL		BIT(2)
48 49
#define SW_RESET	BIT(3)
#define AON_RESET	BIT(4)
50
#define POLL_CFG_GDSCR	BIT(5)
51
#define ALWAYS_ON	BIT(6)
52 53 54
	struct reset_controller_dev	*rcdev;
	unsigned int			*resets;
	unsigned int			reset_count;
S
Stephen Boyd 已提交
55 56
};

57 58 59 60 61 62
struct gdsc_desc {
	struct device *dev;
	struct gdsc **scs;
	size_t num;
};

S
Stephen Boyd 已提交
63
#ifdef CONFIG_QCOM_GDSC
64 65 66
int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *,
		  struct regmap *);
void gdsc_unregister(struct gdsc_desc *desc);
S
Stephen Boyd 已提交
67
#else
68
static inline int gdsc_register(struct gdsc_desc *desc,
69
				struct reset_controller_dev *rcdev,
S
Stephen Boyd 已提交
70 71 72 73 74
				struct regmap *r)
{
	return -ENOSYS;
}

75
static inline void gdsc_unregister(struct gdsc_desc *desc) {};
S
Stephen Boyd 已提交
76 77
#endif /* CONFIG_QCOM_GDSC */
#endif /* __QCOM_GDSC_H__ */