Thomas Gleixner | 97fb5e8 | 2019-05-29 07:17:58 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 2 | /* |
Amit Nischal | 44dbeeb | 2018-04-09 14:11:44 +0530 | [diff] [blame] | 3 | * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved. |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 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; |
Rajendra Nayak | 3c53f5e | 2015-08-06 16:07:45 +0530 | [diff] [blame] | 13 | struct reset_controller_dev; |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 14 | |
| 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 Nayak | 77b1067 | 2015-12-01 21:42:12 +0530 | [diff] [blame] | 20 | * @gds_hw_ctrl: gds_hw_ctrl register |
Rajendra Nayak | 014e193 | 2015-08-06 16:07:44 +0530 | [diff] [blame] | 21 | * @cxcs: offsets of branch registers to toggle mem/periph bits in |
| 22 | * @cxc_count: number of @cxcs |
| 23 | * @pwrsts: Possible powerdomain power states |
Rajendra Nayak | 3c53f5e | 2015-08-06 16:07:45 +0530 | [diff] [blame] | 24 | * @resets: ids of resets associated with this gdsc |
| 25 | * @reset_count: number of @resets |
| 26 | * @rcdev: reset controller |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 27 | */ |
| 28 | struct gdsc { |
| 29 | struct generic_pm_domain pd; |
Rajendra Nayak | c2c7f0a | 2015-12-01 21:42:11 +0530 | [diff] [blame] | 30 | struct generic_pm_domain *parent; |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 31 | struct regmap *regmap; |
| 32 | unsigned int gdscr; |
Rajendra Nayak | 77b1067 | 2015-12-01 21:42:12 +0530 | [diff] [blame] | 33 | unsigned int gds_hw_ctrl; |
Rajendra Nayak | e7cc455 | 2016-10-20 15:08:06 +0530 | [diff] [blame] | 34 | unsigned int clamp_io_ctrl; |
Rajendra Nayak | 014e193 | 2015-08-06 16:07:44 +0530 | [diff] [blame] | 35 | unsigned int *cxcs; |
| 36 | unsigned int cxc_count; |
| 37 | const u8 pwrsts; |
Rajendra Nayak | a823bb9 | 2015-12-01 21:42:13 +0530 | [diff] [blame] | 38 | /* 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 Nayak | e7cc455 | 2016-10-20 15:08:06 +0530 | [diff] [blame] | 46 | #define CLAMP_IO BIT(1) |
Rajendra Nayak | 904bb4f | 2016-11-18 17:58:26 +0530 | [diff] [blame] | 47 | #define HW_CTRL BIT(2) |
Amit Nischal | 44dbeeb | 2018-04-09 14:11:44 +0530 | [diff] [blame] | 48 | #define SW_RESET BIT(3) |
| 49 | #define AON_RESET BIT(4) |
Amit Nischal | e892e17 | 2018-05-01 10:33:33 +0530 | [diff] [blame] | 50 | #define POLL_CFG_GDSCR BIT(5) |
Stephen Boyd | 77122d6 | 2018-06-04 12:34:51 -0700 | [diff] [blame] | 51 | #define ALWAYS_ON BIT(6) |
Rajendra Nayak | 3c53f5e | 2015-08-06 16:07:45 +0530 | [diff] [blame] | 52 | struct reset_controller_dev *rcdev; |
| 53 | unsigned int *resets; |
| 54 | unsigned int reset_count; |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 55 | }; |
| 56 | |
Rajendra Nayak | c2c7f0a | 2015-12-01 21:42:11 +0530 | [diff] [blame] | 57 | struct gdsc_desc { |
| 58 | struct device *dev; |
| 59 | struct gdsc **scs; |
| 60 | size_t num; |
| 61 | }; |
| 62 | |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 63 | #ifdef CONFIG_QCOM_GDSC |
Rajendra Nayak | c2c7f0a | 2015-12-01 21:42:11 +0530 | [diff] [blame] | 64 | int gdsc_register(struct gdsc_desc *desc, struct reset_controller_dev *, |
| 65 | struct regmap *); |
| 66 | void gdsc_unregister(struct gdsc_desc *desc); |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 67 | #else |
Rajendra Nayak | c2c7f0a | 2015-12-01 21:42:11 +0530 | [diff] [blame] | 68 | static inline int gdsc_register(struct gdsc_desc *desc, |
Rajendra Nayak | 3c53f5e | 2015-08-06 16:07:45 +0530 | [diff] [blame] | 69 | struct reset_controller_dev *rcdev, |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 70 | struct regmap *r) |
| 71 | { |
| 72 | return -ENOSYS; |
| 73 | } |
| 74 | |
Rajendra Nayak | c2c7f0a | 2015-12-01 21:42:11 +0530 | [diff] [blame] | 75 | static inline void gdsc_unregister(struct gdsc_desc *desc) {}; |
Stephen Boyd | 45dd0e5 | 2015-08-06 16:07:42 +0530 | [diff] [blame] | 76 | #endif /* CONFIG_QCOM_GDSC */ |
| 77 | #endif /* __QCOM_GDSC_H__ */ |