blob: 5ded26884f08e936dddb3fdc9105d3b8e476abcd [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
Rajendra Nayak014e1932015-08-06 16:07:44 +053023/* Powerdomain allowable state bitfields */
24#define PWRSTS_OFF BIT(0)
25#define PWRSTS_RET BIT(1)
26#define PWRSTS_ON BIT(2)
27#define PWRSTS_OFF_ON (PWRSTS_OFF | PWRSTS_ON)
28#define PWRSTS_RET_ON (PWRSTS_RET | PWRSTS_ON)
29
Stephen Boyd45dd0e52015-08-06 16:07:42 +053030/**
31 * struct gdsc - Globally Distributed Switch Controller
32 * @pd: generic power domain
33 * @regmap: regmap for MMIO accesses
34 * @gdscr: gsdc control register
Rajendra Nayak014e1932015-08-06 16:07:44 +053035 * @cxcs: offsets of branch registers to toggle mem/periph bits in
36 * @cxc_count: number of @cxcs
37 * @pwrsts: Possible powerdomain power states
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053038 * @resets: ids of resets associated with this gdsc
39 * @reset_count: number of @resets
40 * @rcdev: reset controller
Stephen Boyd45dd0e52015-08-06 16:07:42 +053041 */
42struct gdsc {
43 struct generic_pm_domain pd;
44 struct regmap *regmap;
45 unsigned int gdscr;
Rajendra Nayak014e1932015-08-06 16:07:44 +053046 unsigned int *cxcs;
47 unsigned int cxc_count;
48 const u8 pwrsts;
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053049 struct reset_controller_dev *rcdev;
50 unsigned int *resets;
51 unsigned int reset_count;
Stephen Boyd45dd0e52015-08-06 16:07:42 +053052};
53
54#ifdef CONFIG_QCOM_GDSC
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053055int gdsc_register(struct device *, struct gdsc **, size_t n,
56 struct reset_controller_dev *, struct regmap *);
Stephen Boyd45dd0e52015-08-06 16:07:42 +053057void gdsc_unregister(struct device *);
58#else
59static inline int gdsc_register(struct device *d, struct gdsc **g, size_t n,
Rajendra Nayak3c53f5e2015-08-06 16:07:45 +053060 struct reset_controller_dev *rcdev,
Stephen Boyd45dd0e52015-08-06 16:07:42 +053061 struct regmap *r)
62{
63 return -ENOSYS;
64}
65
66static inline void gdsc_unregister(struct device *d) {};
67#endif /* CONFIG_QCOM_GDSC */
68#endif /* __QCOM_GDSC_H__ */