blob: 39648348e5ec9afa02501e3e1f1c32d2802a78b8 [file] [log] [blame]
Stephen Boyd45dd0e52015-08-06 16:07:42 +05301/*
2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef __QCOM_GDSC_H__
15#define __QCOM_GDSC_H__
16
17#include <linux/err.h>
18#include <linux/pm_domain.h>
19
20struct regmap;
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053021struct reset_controller_dev;
Stephen Boyd45dd0e52015-08-06 16:07:42 +053022
23/**
24 * struct gdsc - Globally Distributed Switch Controller
25 * @pd: generic power domain
26 * @regmap: regmap for MMIO accesses
27 * @gdscr: gsdc control register
Rajendra Nayak77b10672015-12-01 21:42:12 +053028 * @gds_hw_ctrl: gds_hw_ctrl register
Rajendra Nayak014e1932015-08-06 16:07:44 +053029 * @cxcs: offsets of branch registers to toggle mem/periph bits in
30 * @cxc_count: number of @cxcs
31 * @pwrsts: Possible powerdomain power states
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053032 * @resets: ids of resets associated with this gdsc
33 * @reset_count: number of @resets
34 * @rcdev: reset controller
Stephen Boyd45dd0e52015-08-06 16:07:42 +053035 */
36struct gdsc {
37 struct generic_pm_domain pd;
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053038 struct generic_pm_domain *parent;
Stephen Boyd45dd0e52015-08-06 16:07:42 +053039 struct regmap *regmap;
40 unsigned int gdscr;
Rajendra Nayak77b10672015-12-01 21:42:12 +053041 unsigned int gds_hw_ctrl;
Rajendra Nayake7cc4552016-10-20 15:08:06 +053042 unsigned int clamp_io_ctrl;
Rajendra Nayak014e1932015-08-06 16:07:44 +053043 unsigned int *cxcs;
44 unsigned int cxc_count;
45 const u8 pwrsts;
Rajendra Nayaka823bb92015-12-01 21:42:13 +053046/* Powerdomain allowable state bitfields */
47#define PWRSTS_OFF BIT(0)
48#define PWRSTS_RET BIT(1)
49#define PWRSTS_ON BIT(2)
50#define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON)
51#define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)
52 const u8 flags;
53#define VOTABLE BIT(0)
Rajendra Nayake7cc4552016-10-20 15:08:06 +053054#define CLAMP_IO BIT(1)
Rajendra Nayak904bb4f2016-11-18 17:58:26 +053055#define HW_CTRL BIT(2)
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053056 struct reset_controller_dev *rcdev;
57 unsigned int *resets;
58 unsigned int reset_count;
Stephen Boyd45dd0e52015-08-06 16:07:42 +053059};
60
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053061struct gdsc_desc {
62 struct device *dev;
63 struct gdsc **scs;
64 size_t num;
65};
66
Stephen Boyd45dd0e52015-08-06 16:07:42 +053067#ifdef CONFIG_QCOM_GDSC
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053068int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *,
69 struct regmap *);
70void gdsc_unregister(struct gdsc_desc *desc);
Stephen Boyd45dd0e52015-08-06 16:07:42 +053071#else
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053072static inline int gdsc_register(struct gdsc_desc *desc,
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053073 struct reset_controller_dev *rcdev,
Stephen Boyd45dd0e52015-08-06 16:07:42 +053074 struct regmap *r)
75{
76 return -ENOSYS;
77}
78
Rajendra Nayakc2c7f0a2015-12-01 21:42:11 +053079static inline void gdsc_unregister(struct gdsc_desc *desc) {};
Stephen Boyd45dd0e52015-08-06 16:07:42 +053080#endif /* CONFIG_QCOM_GDSC */
81#endif /* __QCOM_GDSC_H__ */