blob: 64cdc8cf0d4d2d5a7beb1aae5539f7cac8f11032 [file] [log] [blame]
Thomas Gleixner97fb5e82019-05-29 07:17:58 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Stephen Boyd45dd0e52015-08-06 16:07:42 +05302/*
Amit Nischal44dbeeb2018-04-09 14:11:44 +05303 * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
Stephen Boyd45dd0e52015-08-06 16:07:42 +05304 */
5
6#ifndef __QCOM_GDSC_H__
7#define __QCOM_GDSC_H__
8
9#include <linux/err.h>
10#include <linux/pm_domain.h>
11
12struct regmap;
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053013struct reset_controller_dev;
Stephen Boyd45dd0e52015-08-06 16:07:42 +053014
15/**
16 * struct gdsc - Globally Distributed Switch Controller
17 * @pd: generic power domain
18 * @regmap: regmap for MMIO accesses
19 * @gdscr: gsdc control register
Rajendra Nayak77b10672015-12-01 21:42:12 +053020 * @gds_hw_ctrl: gds_hw_ctrl register
Rajendra Nayak014e1932015-08-06 16:07:44 +053021 * @cxcs: offsets of branch registers to toggle mem/periph bits in
22 * @cxc_count: number of @cxcs
23 * @pwrsts: Possible powerdomain power states
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053024 * @resets: ids of resets associated with this gdsc
25 * @reset_count: number of @resets
26 * @rcdev: reset controller
Stephen Boyd45dd0e52015-08-06 16:07:42 +053027 */
28struct gdsc {
29 struct generic_pm_domain pd;
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053030 struct generic_pm_domain *parent;
Stephen Boyd45dd0e52015-08-06 16:07:42 +053031 struct regmap *regmap;
32 unsigned int gdscr;
Rajendra Nayak77b10672015-12-01 21:42:12 +053033 unsigned int gds_hw_ctrl;
Rajendra Nayake7cc4552016-10-20 15:08:06 +053034 unsigned int clamp_io_ctrl;
Rajendra Nayak014e1932015-08-06 16:07:44 +053035 unsigned int *cxcs;
36 unsigned int cxc_count;
37 const u8 pwrsts;
Rajendra Nayaka823bb92015-12-01 21:42:13 +053038/* Powerdomain allowable state bitfields */
39#define PWRSTS_OFF BIT(0)
40#define PWRSTS_RET BIT(1)
41#define PWRSTS_ON BIT(2)
42#define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON)
43#define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)
44 const u8 flags;
45#define VOTABLE BIT(0)
Rajendra Nayake7cc4552016-10-20 15:08:06 +053046#define CLAMP_IO BIT(1)
Rajendra Nayak904bb4f2016-11-18 17:58:26 +053047#define HW_CTRL BIT(2)
Amit Nischal44dbeeb2018-04-09 14:11:44 +053048#define SW_RESET BIT(3)
49#define AON_RESET BIT(4)
Amit Nischale892e172018-05-01 10:33:33 +053050#define POLL_CFG_GDSCR BIT(5)
Stephen Boyd77122d62018-06-04 12:34:51 -070051#define ALWAYS_ON BIT(6)
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053052 struct reset_controller_dev *rcdev;
53 unsigned int *resets;
54 unsigned int reset_count;
Stephen Boyd45dd0e52015-08-06 16:07:42 +053055};
56
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053057struct gdsc_desc {
58 struct device *dev;
59 struct gdsc **scs;
60 size_t num;
61};
62
Stephen Boyd45dd0e52015-08-06 16:07:42 +053063#ifdef CONFIG_QCOM_GDSC
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053064int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *,
65 struct regmap *);
66void gdsc_unregister(struct gdsc_desc *desc);
Stephen Boyd45dd0e52015-08-06 16:07:42 +053067#else
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053068static inline int gdsc_register(struct gdsc_desc *desc,
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053069 struct reset_controller_dev *rcdev,
Stephen Boyd45dd0e52015-08-06 16:07:42 +053070 struct regmap *r)
71{
72 return -ENOSYS;
73}
74
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053075static inline void gdsc_unregister(struct gdsc_desc *desc) {};
Stephen Boyd45dd0e52015-08-06 16:07:42 +053076#endif /* CONFIG_QCOM_GDSC */
77#endif /* __QCOM_GDSC_H__ */