Krzysztof Kozlowski | 39b27ad | 2018-08-07 18:11:22 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // |
| 3 | // Copyright (c) 2011-2014 Samsung Electronics Co., Ltd |
| 4 | // http://www.samsung.com |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 5 | |
| 6 | #include <linux/device.h> |
| 7 | #include <linux/interrupt.h> |
| 8 | #include <linux/irq.h> |
Krzysztof Kozlowski | eef0594 | 2018-08-07 18:11:25 +0200 | [diff] [blame] | 9 | #include <linux/module.h> |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 10 | #include <linux/regmap.h> |
| 11 | |
Sangbeom Kim | 54227bc | 2012-07-11 21:07:16 +0900 | [diff] [blame] | 12 | #include <linux/mfd/samsung/core.h> |
| 13 | #include <linux/mfd/samsung/irq.h> |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 14 | #include <linux/mfd/samsung/s2mps11.h> |
Krzysztof Kozlowski | dc69196 | 2014-02-28 11:41:44 +0100 | [diff] [blame] | 15 | #include <linux/mfd/samsung/s2mps14.h> |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 16 | #include <linux/mfd/samsung/s2mpu02.h> |
Sangbeom Kim | 54227bc | 2012-07-11 21:07:16 +0900 | [diff] [blame] | 17 | #include <linux/mfd/samsung/s5m8763.h> |
| 18 | #include <linux/mfd/samsung/s5m8767.h> |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 19 | |
Krzysztof Kozlowski | a30fffb | 2013-11-28 09:09:43 +0100 | [diff] [blame] | 20 | static const struct regmap_irq s2mps11_irqs[] = { |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 21 | [S2MPS11_IRQ_PWRONF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 22 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 23 | .mask = S2MPS11_IRQ_PWRONF_MASK, |
| 24 | }, |
| 25 | [S2MPS11_IRQ_PWRONR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 26 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 27 | .mask = S2MPS11_IRQ_PWRONR_MASK, |
| 28 | }, |
| 29 | [S2MPS11_IRQ_JIGONBF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 30 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 31 | .mask = S2MPS11_IRQ_JIGONBF_MASK, |
| 32 | }, |
| 33 | [S2MPS11_IRQ_JIGONBR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 34 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 35 | .mask = S2MPS11_IRQ_JIGONBR_MASK, |
| 36 | }, |
| 37 | [S2MPS11_IRQ_ACOKBF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 38 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 39 | .mask = S2MPS11_IRQ_ACOKBF_MASK, |
| 40 | }, |
| 41 | [S2MPS11_IRQ_ACOKBR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 42 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 43 | .mask = S2MPS11_IRQ_ACOKBR_MASK, |
| 44 | }, |
| 45 | [S2MPS11_IRQ_PWRON1S] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 46 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 47 | .mask = S2MPS11_IRQ_PWRON1S_MASK, |
| 48 | }, |
| 49 | [S2MPS11_IRQ_MRB] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 50 | .reg_offset = 0, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 51 | .mask = S2MPS11_IRQ_MRB_MASK, |
| 52 | }, |
| 53 | [S2MPS11_IRQ_RTC60S] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 54 | .reg_offset = 1, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 55 | .mask = S2MPS11_IRQ_RTC60S_MASK, |
| 56 | }, |
| 57 | [S2MPS11_IRQ_RTCA1] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 58 | .reg_offset = 1, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 59 | .mask = S2MPS11_IRQ_RTCA1_MASK, |
| 60 | }, |
Krzysztof Kozlowski | e554a99 | 2015-04-02 16:36:15 +0200 | [diff] [blame] | 61 | [S2MPS11_IRQ_RTCA0] = { |
| 62 | .reg_offset = 1, |
| 63 | .mask = S2MPS11_IRQ_RTCA0_MASK, |
| 64 | }, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 65 | [S2MPS11_IRQ_SMPL] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 66 | .reg_offset = 1, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 67 | .mask = S2MPS11_IRQ_SMPL_MASK, |
| 68 | }, |
| 69 | [S2MPS11_IRQ_RTC1S] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 70 | .reg_offset = 1, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 71 | .mask = S2MPS11_IRQ_RTC1S_MASK, |
| 72 | }, |
| 73 | [S2MPS11_IRQ_WTSR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 74 | .reg_offset = 1, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 75 | .mask = S2MPS11_IRQ_WTSR_MASK, |
| 76 | }, |
| 77 | [S2MPS11_IRQ_INT120C] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 78 | .reg_offset = 2, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 79 | .mask = S2MPS11_IRQ_INT120C_MASK, |
| 80 | }, |
| 81 | [S2MPS11_IRQ_INT140C] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 82 | .reg_offset = 2, |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 83 | .mask = S2MPS11_IRQ_INT140C_MASK, |
| 84 | }, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 85 | }; |
| 86 | |
Krzysztof Kozlowski | dc69196 | 2014-02-28 11:41:44 +0100 | [diff] [blame] | 87 | static const struct regmap_irq s2mps14_irqs[] = { |
| 88 | [S2MPS14_IRQ_PWRONF] = { |
| 89 | .reg_offset = 0, |
| 90 | .mask = S2MPS11_IRQ_PWRONF_MASK, |
| 91 | }, |
| 92 | [S2MPS14_IRQ_PWRONR] = { |
| 93 | .reg_offset = 0, |
| 94 | .mask = S2MPS11_IRQ_PWRONR_MASK, |
| 95 | }, |
| 96 | [S2MPS14_IRQ_JIGONBF] = { |
| 97 | .reg_offset = 0, |
| 98 | .mask = S2MPS11_IRQ_JIGONBF_MASK, |
| 99 | }, |
| 100 | [S2MPS14_IRQ_JIGONBR] = { |
| 101 | .reg_offset = 0, |
| 102 | .mask = S2MPS11_IRQ_JIGONBR_MASK, |
| 103 | }, |
| 104 | [S2MPS14_IRQ_ACOKBF] = { |
| 105 | .reg_offset = 0, |
| 106 | .mask = S2MPS11_IRQ_ACOKBF_MASK, |
| 107 | }, |
| 108 | [S2MPS14_IRQ_ACOKBR] = { |
| 109 | .reg_offset = 0, |
| 110 | .mask = S2MPS11_IRQ_ACOKBR_MASK, |
| 111 | }, |
| 112 | [S2MPS14_IRQ_PWRON1S] = { |
| 113 | .reg_offset = 0, |
| 114 | .mask = S2MPS11_IRQ_PWRON1S_MASK, |
| 115 | }, |
| 116 | [S2MPS14_IRQ_MRB] = { |
| 117 | .reg_offset = 0, |
| 118 | .mask = S2MPS11_IRQ_MRB_MASK, |
| 119 | }, |
| 120 | [S2MPS14_IRQ_RTC60S] = { |
| 121 | .reg_offset = 1, |
| 122 | .mask = S2MPS11_IRQ_RTC60S_MASK, |
| 123 | }, |
| 124 | [S2MPS14_IRQ_RTCA1] = { |
| 125 | .reg_offset = 1, |
| 126 | .mask = S2MPS11_IRQ_RTCA1_MASK, |
| 127 | }, |
| 128 | [S2MPS14_IRQ_RTCA0] = { |
| 129 | .reg_offset = 1, |
| 130 | .mask = S2MPS11_IRQ_RTCA0_MASK, |
| 131 | }, |
| 132 | [S2MPS14_IRQ_SMPL] = { |
| 133 | .reg_offset = 1, |
| 134 | .mask = S2MPS11_IRQ_SMPL_MASK, |
| 135 | }, |
| 136 | [S2MPS14_IRQ_RTC1S] = { |
| 137 | .reg_offset = 1, |
| 138 | .mask = S2MPS11_IRQ_RTC1S_MASK, |
| 139 | }, |
| 140 | [S2MPS14_IRQ_WTSR] = { |
| 141 | .reg_offset = 1, |
| 142 | .mask = S2MPS11_IRQ_WTSR_MASK, |
| 143 | }, |
| 144 | [S2MPS14_IRQ_INT120C] = { |
| 145 | .reg_offset = 2, |
| 146 | .mask = S2MPS11_IRQ_INT120C_MASK, |
| 147 | }, |
| 148 | [S2MPS14_IRQ_INT140C] = { |
| 149 | .reg_offset = 2, |
| 150 | .mask = S2MPS11_IRQ_INT140C_MASK, |
| 151 | }, |
| 152 | [S2MPS14_IRQ_TSD] = { |
| 153 | .reg_offset = 2, |
| 154 | .mask = S2MPS14_IRQ_TSD_MASK, |
| 155 | }, |
| 156 | }; |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 157 | |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 158 | static const struct regmap_irq s2mpu02_irqs[] = { |
| 159 | [S2MPU02_IRQ_PWRONF] = { |
| 160 | .reg_offset = 0, |
| 161 | .mask = S2MPS11_IRQ_PWRONF_MASK, |
| 162 | }, |
| 163 | [S2MPU02_IRQ_PWRONR] = { |
| 164 | .reg_offset = 0, |
| 165 | .mask = S2MPS11_IRQ_PWRONR_MASK, |
| 166 | }, |
| 167 | [S2MPU02_IRQ_JIGONBF] = { |
| 168 | .reg_offset = 0, |
| 169 | .mask = S2MPS11_IRQ_JIGONBF_MASK, |
| 170 | }, |
| 171 | [S2MPU02_IRQ_JIGONBR] = { |
| 172 | .reg_offset = 0, |
| 173 | .mask = S2MPS11_IRQ_JIGONBR_MASK, |
| 174 | }, |
| 175 | [S2MPU02_IRQ_ACOKBF] = { |
| 176 | .reg_offset = 0, |
| 177 | .mask = S2MPS11_IRQ_ACOKBF_MASK, |
| 178 | }, |
| 179 | [S2MPU02_IRQ_ACOKBR] = { |
| 180 | .reg_offset = 0, |
| 181 | .mask = S2MPS11_IRQ_ACOKBR_MASK, |
| 182 | }, |
| 183 | [S2MPU02_IRQ_PWRON1S] = { |
| 184 | .reg_offset = 0, |
| 185 | .mask = S2MPS11_IRQ_PWRON1S_MASK, |
| 186 | }, |
| 187 | [S2MPU02_IRQ_MRB] = { |
| 188 | .reg_offset = 0, |
| 189 | .mask = S2MPS11_IRQ_MRB_MASK, |
| 190 | }, |
| 191 | [S2MPU02_IRQ_RTC60S] = { |
| 192 | .reg_offset = 1, |
| 193 | .mask = S2MPS11_IRQ_RTC60S_MASK, |
| 194 | }, |
| 195 | [S2MPU02_IRQ_RTCA1] = { |
| 196 | .reg_offset = 1, |
| 197 | .mask = S2MPS11_IRQ_RTCA1_MASK, |
| 198 | }, |
| 199 | [S2MPU02_IRQ_RTCA0] = { |
| 200 | .reg_offset = 1, |
| 201 | .mask = S2MPS11_IRQ_RTCA0_MASK, |
| 202 | }, |
| 203 | [S2MPU02_IRQ_SMPL] = { |
| 204 | .reg_offset = 1, |
| 205 | .mask = S2MPS11_IRQ_SMPL_MASK, |
| 206 | }, |
| 207 | [S2MPU02_IRQ_RTC1S] = { |
| 208 | .reg_offset = 1, |
| 209 | .mask = S2MPS11_IRQ_RTC1S_MASK, |
| 210 | }, |
| 211 | [S2MPU02_IRQ_WTSR] = { |
| 212 | .reg_offset = 1, |
| 213 | .mask = S2MPS11_IRQ_WTSR_MASK, |
| 214 | }, |
| 215 | [S2MPU02_IRQ_INT120C] = { |
| 216 | .reg_offset = 2, |
| 217 | .mask = S2MPS11_IRQ_INT120C_MASK, |
| 218 | }, |
| 219 | [S2MPU02_IRQ_INT140C] = { |
| 220 | .reg_offset = 2, |
| 221 | .mask = S2MPS11_IRQ_INT140C_MASK, |
| 222 | }, |
| 223 | [S2MPU02_IRQ_TSD] = { |
| 224 | .reg_offset = 2, |
| 225 | .mask = S2MPS14_IRQ_TSD_MASK, |
| 226 | }, |
| 227 | }; |
| 228 | |
Krzysztof Kozlowski | a30fffb | 2013-11-28 09:09:43 +0100 | [diff] [blame] | 229 | static const struct regmap_irq s5m8767_irqs[] = { |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 230 | [S5M8767_IRQ_PWRR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 231 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 232 | .mask = S5M8767_IRQ_PWRR_MASK, |
| 233 | }, |
| 234 | [S5M8767_IRQ_PWRF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 235 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 236 | .mask = S5M8767_IRQ_PWRF_MASK, |
| 237 | }, |
| 238 | [S5M8767_IRQ_PWR1S] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 239 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 240 | .mask = S5M8767_IRQ_PWR1S_MASK, |
| 241 | }, |
| 242 | [S5M8767_IRQ_JIGR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 243 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 244 | .mask = S5M8767_IRQ_JIGR_MASK, |
| 245 | }, |
| 246 | [S5M8767_IRQ_JIGF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 247 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 248 | .mask = S5M8767_IRQ_JIGF_MASK, |
| 249 | }, |
| 250 | [S5M8767_IRQ_LOWBAT2] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 251 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 252 | .mask = S5M8767_IRQ_LOWBAT2_MASK, |
| 253 | }, |
| 254 | [S5M8767_IRQ_LOWBAT1] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 255 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 256 | .mask = S5M8767_IRQ_LOWBAT1_MASK, |
| 257 | }, |
| 258 | [S5M8767_IRQ_MRB] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 259 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 260 | .mask = S5M8767_IRQ_MRB_MASK, |
| 261 | }, |
| 262 | [S5M8767_IRQ_DVSOK2] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 263 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 264 | .mask = S5M8767_IRQ_DVSOK2_MASK, |
| 265 | }, |
| 266 | [S5M8767_IRQ_DVSOK3] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 267 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 268 | .mask = S5M8767_IRQ_DVSOK3_MASK, |
| 269 | }, |
| 270 | [S5M8767_IRQ_DVSOK4] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 271 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 272 | .mask = S5M8767_IRQ_DVSOK4_MASK, |
| 273 | }, |
| 274 | [S5M8767_IRQ_RTC60S] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 275 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 276 | .mask = S5M8767_IRQ_RTC60S_MASK, |
| 277 | }, |
| 278 | [S5M8767_IRQ_RTCA1] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 279 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 280 | .mask = S5M8767_IRQ_RTCA1_MASK, |
| 281 | }, |
| 282 | [S5M8767_IRQ_RTCA2] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 283 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 284 | .mask = S5M8767_IRQ_RTCA2_MASK, |
| 285 | }, |
| 286 | [S5M8767_IRQ_SMPL] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 287 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 288 | .mask = S5M8767_IRQ_SMPL_MASK, |
| 289 | }, |
| 290 | [S5M8767_IRQ_RTC1S] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 291 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 292 | .mask = S5M8767_IRQ_RTC1S_MASK, |
| 293 | }, |
| 294 | [S5M8767_IRQ_WTSR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 295 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 296 | .mask = S5M8767_IRQ_WTSR_MASK, |
| 297 | }, |
| 298 | }; |
| 299 | |
Krzysztof Kozlowski | a30fffb | 2013-11-28 09:09:43 +0100 | [diff] [blame] | 300 | static const struct regmap_irq s5m8763_irqs[] = { |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 301 | [S5M8763_IRQ_DCINF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 302 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 303 | .mask = S5M8763_IRQ_DCINF_MASK, |
| 304 | }, |
| 305 | [S5M8763_IRQ_DCINR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 306 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 307 | .mask = S5M8763_IRQ_DCINR_MASK, |
| 308 | }, |
| 309 | [S5M8763_IRQ_JIGF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 310 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 311 | .mask = S5M8763_IRQ_JIGF_MASK, |
| 312 | }, |
| 313 | [S5M8763_IRQ_JIGR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 314 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 315 | .mask = S5M8763_IRQ_JIGR_MASK, |
| 316 | }, |
| 317 | [S5M8763_IRQ_PWRONF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 318 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 319 | .mask = S5M8763_IRQ_PWRONF_MASK, |
| 320 | }, |
| 321 | [S5M8763_IRQ_PWRONR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 322 | .reg_offset = 0, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 323 | .mask = S5M8763_IRQ_PWRONR_MASK, |
| 324 | }, |
| 325 | [S5M8763_IRQ_WTSREVNT] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 326 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 327 | .mask = S5M8763_IRQ_WTSREVNT_MASK, |
| 328 | }, |
| 329 | [S5M8763_IRQ_SMPLEVNT] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 330 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 331 | .mask = S5M8763_IRQ_SMPLEVNT_MASK, |
| 332 | }, |
| 333 | [S5M8763_IRQ_ALARM1] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 334 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 335 | .mask = S5M8763_IRQ_ALARM1_MASK, |
| 336 | }, |
| 337 | [S5M8763_IRQ_ALARM0] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 338 | .reg_offset = 1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 339 | .mask = S5M8763_IRQ_ALARM0_MASK, |
| 340 | }, |
| 341 | [S5M8763_IRQ_ONKEY1S] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 342 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 343 | .mask = S5M8763_IRQ_ONKEY1S_MASK, |
| 344 | }, |
| 345 | [S5M8763_IRQ_TOPOFFR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 346 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 347 | .mask = S5M8763_IRQ_TOPOFFR_MASK, |
| 348 | }, |
| 349 | [S5M8763_IRQ_DCINOVPR] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 350 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 351 | .mask = S5M8763_IRQ_DCINOVPR_MASK, |
| 352 | }, |
| 353 | [S5M8763_IRQ_CHGRSTF] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 354 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 355 | .mask = S5M8763_IRQ_CHGRSTF_MASK, |
| 356 | }, |
| 357 | [S5M8763_IRQ_DONER] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 358 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 359 | .mask = S5M8763_IRQ_DONER_MASK, |
| 360 | }, |
| 361 | [S5M8763_IRQ_CHGFAULT] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 362 | .reg_offset = 2, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 363 | .mask = S5M8763_IRQ_CHGFAULT_MASK, |
| 364 | }, |
| 365 | [S5M8763_IRQ_LOBAT1] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 366 | .reg_offset = 3, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 367 | .mask = S5M8763_IRQ_LOBAT1_MASK, |
| 368 | }, |
| 369 | [S5M8763_IRQ_LOBAT2] = { |
Inderpal Singh | 5e393a22 | 2012-10-17 11:48:55 +0530 | [diff] [blame] | 370 | .reg_offset = 3, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 371 | .mask = S5M8763_IRQ_LOBAT2_MASK, |
| 372 | }, |
| 373 | }; |
| 374 | |
Krzysztof Kozlowski | a30fffb | 2013-11-28 09:09:43 +0100 | [diff] [blame] | 375 | static const struct regmap_irq_chip s2mps11_irq_chip = { |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 376 | .name = "s2mps11", |
| 377 | .irqs = s2mps11_irqs, |
| 378 | .num_irqs = ARRAY_SIZE(s2mps11_irqs), |
| 379 | .num_regs = 3, |
| 380 | .status_base = S2MPS11_REG_INT1, |
| 381 | .mask_base = S2MPS11_REG_INT1M, |
| 382 | .ack_base = S2MPS11_REG_INT1, |
| 383 | }; |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 384 | |
Chanwoo Choi | 3bc2ee9 | 2014-11-18 17:59:39 +0900 | [diff] [blame] | 385 | #define S2MPS1X_IRQ_CHIP_COMMON_DATA \ |
| 386 | .irqs = s2mps14_irqs, \ |
| 387 | .num_irqs = ARRAY_SIZE(s2mps14_irqs), \ |
| 388 | .num_regs = 3, \ |
| 389 | .status_base = S2MPS14_REG_INT1, \ |
| 390 | .mask_base = S2MPS14_REG_INT1M, \ |
| 391 | .ack_base = S2MPS14_REG_INT1 \ |
| 392 | |
| 393 | static const struct regmap_irq_chip s2mps13_irq_chip = { |
| 394 | .name = "s2mps13", |
| 395 | S2MPS1X_IRQ_CHIP_COMMON_DATA, |
| 396 | }; |
| 397 | |
Krzysztof Kozlowski | dc69196 | 2014-02-28 11:41:44 +0100 | [diff] [blame] | 398 | static const struct regmap_irq_chip s2mps14_irq_chip = { |
| 399 | .name = "s2mps14", |
Chanwoo Choi | 3bc2ee9 | 2014-11-18 17:59:39 +0900 | [diff] [blame] | 400 | S2MPS1X_IRQ_CHIP_COMMON_DATA, |
Krzysztof Kozlowski | dc69196 | 2014-02-28 11:41:44 +0100 | [diff] [blame] | 401 | }; |
| 402 | |
Thomas Abraham | 9e4808d | 2015-11-20 16:07:51 +0530 | [diff] [blame] | 403 | static const struct regmap_irq_chip s2mps15_irq_chip = { |
| 404 | .name = "s2mps15", |
| 405 | S2MPS1X_IRQ_CHIP_COMMON_DATA, |
| 406 | }; |
| 407 | |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 408 | static const struct regmap_irq_chip s2mpu02_irq_chip = { |
| 409 | .name = "s2mpu02", |
| 410 | .irqs = s2mpu02_irqs, |
| 411 | .num_irqs = ARRAY_SIZE(s2mpu02_irqs), |
| 412 | .num_regs = 3, |
| 413 | .status_base = S2MPU02_REG_INT1, |
| 414 | .mask_base = S2MPU02_REG_INT1M, |
| 415 | .ack_base = S2MPU02_REG_INT1, |
| 416 | }; |
| 417 | |
Krzysztof Kozlowski | a30fffb | 2013-11-28 09:09:43 +0100 | [diff] [blame] | 418 | static const struct regmap_irq_chip s5m8767_irq_chip = { |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 419 | .name = "s5m8767", |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 420 | .irqs = s5m8767_irqs, |
| 421 | .num_irqs = ARRAY_SIZE(s5m8767_irqs), |
| 422 | .num_regs = 3, |
| 423 | .status_base = S5M8767_REG_INT1, |
| 424 | .mask_base = S5M8767_REG_INT1M, |
| 425 | .ack_base = S5M8767_REG_INT1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 426 | }; |
| 427 | |
Krzysztof Kozlowski | a30fffb | 2013-11-28 09:09:43 +0100 | [diff] [blame] | 428 | static const struct regmap_irq_chip s5m8763_irq_chip = { |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 429 | .name = "s5m8763", |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 430 | .irqs = s5m8763_irqs, |
| 431 | .num_irqs = ARRAY_SIZE(s5m8763_irqs), |
| 432 | .num_regs = 4, |
| 433 | .status_base = S5M8763_REG_IRQ1, |
| 434 | .mask_base = S5M8763_REG_IRQM1, |
| 435 | .ack_base = S5M8763_REG_IRQ1, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 436 | }; |
| 437 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 438 | int sec_irq_init(struct sec_pmic_dev *sec_pmic) |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 439 | { |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 440 | int ret = 0; |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 441 | int type = sec_pmic->device_type; |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 442 | const struct regmap_irq_chip *sec_irq_chip; |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 443 | |
Sangbeom Kim | 63063bf | 2012-07-11 21:06:55 +0900 | [diff] [blame] | 444 | if (!sec_pmic->irq) { |
| 445 | dev_warn(sec_pmic->dev, |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 446 | "No interrupt specified, no interrupts\n"); |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 447 | return 0; |
| 448 | } |
| 449 | |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 450 | switch (type) { |
| 451 | case S5M8763X: |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 452 | sec_irq_chip = &s5m8763_irq_chip; |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 453 | break; |
| 454 | case S5M8767X: |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 455 | sec_irq_chip = &s5m8767_irq_chip; |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 456 | break; |
Stuart Menefy | ec85d4a | 2019-02-13 22:24:02 +0000 | [diff] [blame] | 457 | case S2MPA01: |
| 458 | sec_irq_chip = &s2mps14_irq_chip; |
| 459 | break; |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 460 | case S2MPS11X: |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 461 | sec_irq_chip = &s2mps11_irq_chip; |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 462 | break; |
Chanwoo Choi | 3bc2ee9 | 2014-11-18 17:59:39 +0900 | [diff] [blame] | 463 | case S2MPS13X: |
| 464 | sec_irq_chip = &s2mps13_irq_chip; |
| 465 | break; |
Krzysztof Kozlowski | dc69196 | 2014-02-28 11:41:44 +0100 | [diff] [blame] | 466 | case S2MPS14X: |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 467 | sec_irq_chip = &s2mps14_irq_chip; |
| 468 | break; |
Thomas Abraham | 9e4808d | 2015-11-20 16:07:51 +0530 | [diff] [blame] | 469 | case S2MPS15X: |
| 470 | sec_irq_chip = &s2mps15_irq_chip; |
| 471 | break; |
Chanwoo Choi | 54e8827 | 2014-06-25 16:14:44 +0900 | [diff] [blame] | 472 | case S2MPU02: |
| 473 | sec_irq_chip = &s2mpu02_irq_chip; |
Krzysztof Kozlowski | dc69196 | 2014-02-28 11:41:44 +0100 | [diff] [blame] | 474 | break; |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 475 | default: |
Krzysztof Kozlowski | 9549b5f | 2014-04-23 16:13:05 +0200 | [diff] [blame] | 476 | dev_err(sec_pmic->dev, "Unknown device type %lu\n", |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 477 | sec_pmic->device_type); |
Jonghwan Choi | c7a1fcf | 2012-02-20 16:22:56 +0100 | [diff] [blame] | 478 | return -EINVAL; |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 479 | } |
| 480 | |
Laxman Dewangan | 3dc6f4a | 2016-04-21 17:55:56 +0530 | [diff] [blame] | 481 | ret = devm_regmap_add_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic, |
Krzysztof Kozlowski | 6854a10 | 2021-06-02 13:04:42 +0200 | [diff] [blame] | 482 | sec_pmic->irq, IRQF_ONESHOT, |
Krzysztof Kozlowski | c1d3ab3 | 2021-05-26 08:47:09 -0400 | [diff] [blame] | 483 | 0, sec_irq_chip, &sec_pmic->irq_data); |
Sangbeom Kim | 6445b84 | 2012-07-11 21:08:11 +0900 | [diff] [blame] | 484 | if (ret != 0) { |
| 485 | dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret); |
Jonghwan Choi | c7a1fcf | 2012-02-20 16:22:56 +0100 | [diff] [blame] | 486 | return ret; |
| 487 | } |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 488 | |
Krzysztof Kozlowski | e554a99 | 2015-04-02 16:36:15 +0200 | [diff] [blame] | 489 | /* |
| 490 | * The rtc-s5m driver requests S2MPS14_IRQ_RTCA0 also for S2MPS11 |
| 491 | * so the interrupt number must be consistent. |
| 492 | */ |
| 493 | BUILD_BUG_ON(((enum s2mps14_irq)S2MPS11_IRQ_RTCA0) != S2MPS14_IRQ_RTCA0); |
| 494 | |
Sangbeom Kim | 5ac2ffa7 | 2011-12-23 17:28:09 +0900 | [diff] [blame] | 495 | return 0; |
| 496 | } |
Krzysztof Kozlowski | eef0594 | 2018-08-07 18:11:25 +0200 | [diff] [blame] | 497 | EXPORT_SYMBOL_GPL(sec_irq_init); |
| 498 | |
| 499 | MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>"); |
| 500 | MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>"); |
| 501 | MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>"); |
| 502 | MODULE_DESCRIPTION("Interrupt support for the S5M MFD"); |
| 503 | MODULE_LICENSE("GPL"); |