Thomas Gleixner | 97fb5e8 | 2019-05-29 07:17:58 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
| 7 | |
| 8 | #include <linux/kernel.h> |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 9 | #include <linux/interrupt.h> |
Stephen Boyd | cced354 | 2014-02-26 10:59:20 -0800 | [diff] [blame] | 10 | #include <linux/irqchip/chained_irq.h> |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 11 | #include <linux/irq.h> |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 12 | #include <linux/irqdomain.h> |
Jingoo Han | ef310f4 | 2013-08-20 16:01:26 +0900 | [diff] [blame] | 13 | #include <linux/module.h> |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/slab.h> |
Abhijeet Dharmapurikar | c013f0a | 2011-04-05 14:40:53 -0700 | [diff] [blame] | 16 | #include <linux/err.h> |
David Brown | ce44bf5 | 2013-03-12 11:41:54 -0700 | [diff] [blame] | 17 | #include <linux/ssbi.h> |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 18 | #include <linux/regmap.h> |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 19 | #include <linux/of_platform.h> |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 20 | #include <linux/mfd/core.h> |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 21 | |
| 22 | #define SSBI_REG_ADDR_IRQ_BASE 0x1BB |
| 23 | |
| 24 | #define SSBI_REG_ADDR_IRQ_ROOT (SSBI_REG_ADDR_IRQ_BASE + 0) |
| 25 | #define SSBI_REG_ADDR_IRQ_M_STATUS1 (SSBI_REG_ADDR_IRQ_BASE + 1) |
| 26 | #define SSBI_REG_ADDR_IRQ_M_STATUS2 (SSBI_REG_ADDR_IRQ_BASE + 2) |
| 27 | #define SSBI_REG_ADDR_IRQ_M_STATUS3 (SSBI_REG_ADDR_IRQ_BASE + 3) |
| 28 | #define SSBI_REG_ADDR_IRQ_M_STATUS4 (SSBI_REG_ADDR_IRQ_BASE + 4) |
| 29 | #define SSBI_REG_ADDR_IRQ_BLK_SEL (SSBI_REG_ADDR_IRQ_BASE + 5) |
| 30 | #define SSBI_REG_ADDR_IRQ_IT_STATUS (SSBI_REG_ADDR_IRQ_BASE + 6) |
| 31 | #define SSBI_REG_ADDR_IRQ_CONFIG (SSBI_REG_ADDR_IRQ_BASE + 7) |
| 32 | #define SSBI_REG_ADDR_IRQ_RT_STATUS (SSBI_REG_ADDR_IRQ_BASE + 8) |
| 33 | |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 34 | #define PM8821_SSBI_REG_ADDR_IRQ_BASE 0x100 |
| 35 | #define PM8821_SSBI_REG_ADDR_IRQ_MASTER0 (PM8821_SSBI_REG_ADDR_IRQ_BASE + 0x30) |
| 36 | #define PM8821_SSBI_REG_ADDR_IRQ_MASTER1 (PM8821_SSBI_REG_ADDR_IRQ_BASE + 0xb0) |
| 37 | #define PM8821_SSBI_REG(m, b, offset) \ |
| 38 | ((m == 0) ? \ |
| 39 | (PM8821_SSBI_REG_ADDR_IRQ_MASTER0 + b + offset) : \ |
| 40 | (PM8821_SSBI_REG_ADDR_IRQ_MASTER1 + b + offset)) |
| 41 | #define PM8821_SSBI_ADDR_IRQ_ROOT(m, b) PM8821_SSBI_REG(m, b, 0x0) |
| 42 | #define PM8821_SSBI_ADDR_IRQ_CLEAR(m, b) PM8821_SSBI_REG(m, b, 0x01) |
| 43 | #define PM8821_SSBI_ADDR_IRQ_MASK(m, b) PM8821_SSBI_REG(m, b, 0x08) |
| 44 | #define PM8821_SSBI_ADDR_IRQ_RT_STATUS(m, b) PM8821_SSBI_REG(m, b, 0x0f) |
| 45 | |
| 46 | #define PM8821_BLOCKS_PER_MASTER 7 |
| 47 | |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 48 | #define PM_IRQF_LVL_SEL 0x01 /* level select */ |
| 49 | #define PM_IRQF_MASK_FE 0x02 /* mask falling edge */ |
| 50 | #define PM_IRQF_MASK_RE 0x04 /* mask rising edge */ |
| 51 | #define PM_IRQF_CLR 0x08 /* clear interrupt */ |
| 52 | #define PM_IRQF_BITS_MASK 0x70 |
| 53 | #define PM_IRQF_BITS_SHIFT 4 |
| 54 | #define PM_IRQF_WRITE 0x80 |
| 55 | |
| 56 | #define PM_IRQF_MASK_ALL (PM_IRQF_MASK_FE | \ |
| 57 | PM_IRQF_MASK_RE) |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 58 | |
| 59 | #define REG_HWREV 0x002 /* PMIC4 revision */ |
| 60 | #define REG_HWREV_2 0x0E8 /* PMIC4 revision 2 */ |
| 61 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 62 | #define PM8XXX_NR_IRQS 256 |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 63 | #define PM8821_NR_IRQS 112 |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 64 | |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 65 | struct pm_irq_data { |
| 66 | int num_irqs; |
| 67 | struct irq_chip *irq_chip; |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 68 | irq_handler_t irq_handler; |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 69 | }; |
| 70 | |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 71 | struct pm_irq_chip { |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 72 | struct regmap *regmap; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 73 | spinlock_t pm_irq_lock; |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 74 | struct irq_domain *irqdomain; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 75 | unsigned int num_blocks; |
| 76 | unsigned int num_masters; |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 77 | const struct pm_irq_data *pm_irq_data; |
| 78 | /* MUST BE AT THE END OF THIS STRUCT */ |
Gustavo A. R. Silva | 7235d9e | 2020-02-12 17:59:11 -0600 | [diff] [blame] | 79 | u8 config[]; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 82 | static int pm8xxx_read_block_irq(struct pm_irq_chip *chip, unsigned int bp, |
| 83 | unsigned int *ip) |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 84 | { |
| 85 | int rc; |
| 86 | |
| 87 | spin_lock(&chip->pm_irq_lock); |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 88 | rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, bp); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 89 | if (rc) { |
| 90 | pr_err("Failed Selecting Block %d rc=%d\n", bp, rc); |
| 91 | goto bail; |
| 92 | } |
| 93 | |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 94 | rc = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_IT_STATUS, ip); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 95 | if (rc) |
| 96 | pr_err("Failed Reading Status rc=%d\n", rc); |
| 97 | bail: |
| 98 | spin_unlock(&chip->pm_irq_lock); |
| 99 | return rc; |
| 100 | } |
| 101 | |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 102 | static int |
| 103 | pm8xxx_config_irq(struct pm_irq_chip *chip, unsigned int bp, unsigned int cp) |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 104 | { |
| 105 | int rc; |
| 106 | |
| 107 | spin_lock(&chip->pm_irq_lock); |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 108 | rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, bp); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 109 | if (rc) { |
| 110 | pr_err("Failed Selecting Block %d rc=%d\n", bp, rc); |
| 111 | goto bail; |
| 112 | } |
| 113 | |
| 114 | cp |= PM_IRQF_WRITE; |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 115 | rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_CONFIG, cp); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 116 | if (rc) |
| 117 | pr_err("Failed Configuring IRQ rc=%d\n", rc); |
| 118 | bail: |
| 119 | spin_unlock(&chip->pm_irq_lock); |
| 120 | return rc; |
| 121 | } |
| 122 | |
| 123 | static int pm8xxx_irq_block_handler(struct pm_irq_chip *chip, int block) |
| 124 | { |
Marc Zyngier | 3b0ccce | 2021-05-04 17:42:18 +0100 | [diff] [blame] | 125 | int pmirq, i, ret = 0; |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 126 | unsigned int bits; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 127 | |
| 128 | ret = pm8xxx_read_block_irq(chip, block, &bits); |
| 129 | if (ret) { |
| 130 | pr_err("Failed reading %d block ret=%d", block, ret); |
| 131 | return ret; |
| 132 | } |
| 133 | if (!bits) { |
| 134 | pr_err("block bit set in master but no irqs: %d", block); |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | /* Check IRQ bits */ |
| 139 | for (i = 0; i < 8; i++) { |
| 140 | if (bits & (1 << i)) { |
| 141 | pmirq = block * 8 + i; |
Marc Zyngier | 3b0ccce | 2021-05-04 17:42:18 +0100 | [diff] [blame] | 142 | generic_handle_domain_irq(chip->irqdomain, pmirq); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | static int pm8xxx_irq_master_handler(struct pm_irq_chip *chip, int master) |
| 149 | { |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 150 | unsigned int blockbits; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 151 | int block_number, i, ret = 0; |
| 152 | |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 153 | ret = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_M_STATUS1 + master, |
| 154 | &blockbits); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 155 | if (ret) { |
| 156 | pr_err("Failed to read master %d ret=%d\n", master, ret); |
| 157 | return ret; |
| 158 | } |
| 159 | if (!blockbits) { |
| 160 | pr_err("master bit set in root but no blocks: %d", master); |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | for (i = 0; i < 8; i++) |
| 165 | if (blockbits & (1 << i)) { |
| 166 | block_number = master * 8 + i; /* block # */ |
| 167 | ret |= pm8xxx_irq_block_handler(chip, block_number); |
| 168 | } |
| 169 | return ret; |
| 170 | } |
| 171 | |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 172 | static irqreturn_t pm8xxx_irq_handler(int irq, void *data) |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 173 | { |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 174 | struct pm_irq_chip *chip = data; |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 175 | unsigned int root; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 176 | int i, ret, masters = 0; |
| 177 | |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 178 | ret = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_ROOT, &root); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 179 | if (ret) { |
| 180 | pr_err("Can't read root status ret=%d\n", ret); |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 181 | return IRQ_NONE; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /* on pm8xxx series masters start from bit 1 of the root */ |
| 185 | masters = root >> 1; |
| 186 | |
| 187 | /* Read allowed masters for blocks. */ |
| 188 | for (i = 0; i < chip->num_masters; i++) |
| 189 | if (masters & (1 << i)) |
| 190 | pm8xxx_irq_master_handler(chip, i); |
| 191 | |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 192 | return IRQ_HANDLED; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 195 | static void pm8821_irq_block_handler(struct pm_irq_chip *chip, |
| 196 | int master, int block) |
| 197 | { |
Marc Zyngier | 3b0ccce | 2021-05-04 17:42:18 +0100 | [diff] [blame] | 198 | int pmirq, i, ret; |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 199 | unsigned int bits; |
| 200 | |
| 201 | ret = regmap_read(chip->regmap, |
| 202 | PM8821_SSBI_ADDR_IRQ_ROOT(master, block), &bits); |
| 203 | if (ret) { |
| 204 | pr_err("Reading block %d failed ret=%d", block, ret); |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | /* Convert block offset to global block number */ |
| 209 | block += (master * PM8821_BLOCKS_PER_MASTER) - 1; |
| 210 | |
| 211 | /* Check IRQ bits */ |
| 212 | for (i = 0; i < 8; i++) { |
| 213 | if (bits & BIT(i)) { |
| 214 | pmirq = block * 8 + i; |
Marc Zyngier | 3b0ccce | 2021-05-04 17:42:18 +0100 | [diff] [blame] | 215 | generic_handle_domain_irq(chip->irqdomain, pmirq); |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | static inline void pm8821_irq_master_handler(struct pm_irq_chip *chip, |
| 221 | int master, u8 master_val) |
| 222 | { |
| 223 | int block; |
| 224 | |
| 225 | for (block = 1; block < 8; block++) |
| 226 | if (master_val & BIT(block)) |
| 227 | pm8821_irq_block_handler(chip, master, block); |
| 228 | } |
| 229 | |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 230 | static irqreturn_t pm8821_irq_handler(int irq, void *data) |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 231 | { |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 232 | struct pm_irq_chip *chip = data; |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 233 | unsigned int master; |
| 234 | int ret; |
| 235 | |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 236 | ret = regmap_read(chip->regmap, |
| 237 | PM8821_SSBI_REG_ADDR_IRQ_MASTER0, &master); |
| 238 | if (ret) { |
| 239 | pr_err("Failed to read master 0 ret=%d\n", ret); |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 240 | return IRQ_NONE; |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | /* bits 1 through 7 marks the first 7 blocks in master 0 */ |
| 244 | if (master & GENMASK(7, 1)) |
| 245 | pm8821_irq_master_handler(chip, 0, master); |
| 246 | |
| 247 | /* bit 0 marks if master 1 contains any bits */ |
| 248 | if (!(master & BIT(0))) |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 249 | return IRQ_NONE; |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 250 | |
| 251 | ret = regmap_read(chip->regmap, |
| 252 | PM8821_SSBI_REG_ADDR_IRQ_MASTER1, &master); |
| 253 | if (ret) { |
| 254 | pr_err("Failed to read master 1 ret=%d\n", ret); |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 255 | return IRQ_NONE; |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | pm8821_irq_master_handler(chip, 1, master); |
| 259 | |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 260 | return IRQ_HANDLED; |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 263 | static void pm8xxx_irq_mask_ack(struct irq_data *d) |
| 264 | { |
| 265 | struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 266 | unsigned int pmirq = irqd_to_hwirq(d); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 267 | u8 block, config; |
| 268 | |
| 269 | block = pmirq / 8; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 270 | |
| 271 | config = chip->config[pmirq] | PM_IRQF_MASK_ALL | PM_IRQF_CLR; |
| 272 | pm8xxx_config_irq(chip, block, config); |
| 273 | } |
| 274 | |
| 275 | static void pm8xxx_irq_unmask(struct irq_data *d) |
| 276 | { |
| 277 | struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 278 | unsigned int pmirq = irqd_to_hwirq(d); |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 279 | u8 block, config; |
| 280 | |
| 281 | block = pmirq / 8; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 282 | |
| 283 | config = chip->config[pmirq]; |
| 284 | pm8xxx_config_irq(chip, block, config); |
| 285 | } |
| 286 | |
| 287 | static int pm8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type) |
| 288 | { |
| 289 | struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 290 | unsigned int pmirq = irqd_to_hwirq(d); |
| 291 | int irq_bit; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 292 | u8 block, config; |
| 293 | |
| 294 | block = pmirq / 8; |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 295 | irq_bit = pmirq % 8; |
| 296 | |
| 297 | chip->config[pmirq] = (irq_bit << PM_IRQF_BITS_SHIFT) |
| 298 | | PM_IRQF_MASK_ALL; |
| 299 | if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) { |
| 300 | if (flow_type & IRQF_TRIGGER_RISING) |
| 301 | chip->config[pmirq] &= ~PM_IRQF_MASK_RE; |
| 302 | if (flow_type & IRQF_TRIGGER_FALLING) |
| 303 | chip->config[pmirq] &= ~PM_IRQF_MASK_FE; |
| 304 | } else { |
| 305 | chip->config[pmirq] |= PM_IRQF_LVL_SEL; |
| 306 | |
| 307 | if (flow_type & IRQF_TRIGGER_HIGH) |
| 308 | chip->config[pmirq] &= ~PM_IRQF_MASK_RE; |
| 309 | else |
| 310 | chip->config[pmirq] &= ~PM_IRQF_MASK_FE; |
| 311 | } |
| 312 | |
| 313 | config = chip->config[pmirq] | PM_IRQF_CLR; |
| 314 | return pm8xxx_config_irq(chip, block, config); |
| 315 | } |
| 316 | |
Bjorn Andersson | f1837e4 | 2015-07-14 23:40:34 -0700 | [diff] [blame] | 317 | static int pm8xxx_irq_get_irqchip_state(struct irq_data *d, |
| 318 | enum irqchip_irq_state which, |
| 319 | bool *state) |
| 320 | { |
| 321 | struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); |
| 322 | unsigned int pmirq = irqd_to_hwirq(d); |
| 323 | unsigned int bits; |
| 324 | int irq_bit; |
| 325 | u8 block; |
| 326 | int rc; |
| 327 | |
| 328 | if (which != IRQCHIP_STATE_LINE_LEVEL) |
| 329 | return -EINVAL; |
| 330 | |
| 331 | block = pmirq / 8; |
| 332 | irq_bit = pmirq % 8; |
| 333 | |
| 334 | spin_lock(&chip->pm_irq_lock); |
| 335 | rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, block); |
| 336 | if (rc) { |
| 337 | pr_err("Failed Selecting Block %d rc=%d\n", block, rc); |
| 338 | goto bail; |
| 339 | } |
| 340 | |
| 341 | rc = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_RT_STATUS, &bits); |
| 342 | if (rc) { |
| 343 | pr_err("Failed Reading Status rc=%d\n", rc); |
| 344 | goto bail; |
| 345 | } |
| 346 | |
| 347 | *state = !!(bits & BIT(irq_bit)); |
| 348 | bail: |
| 349 | spin_unlock(&chip->pm_irq_lock); |
| 350 | |
| 351 | return rc; |
| 352 | } |
| 353 | |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 354 | static struct irq_chip pm8xxx_irq_chip = { |
| 355 | .name = "pm8xxx", |
| 356 | .irq_mask_ack = pm8xxx_irq_mask_ack, |
| 357 | .irq_unmask = pm8xxx_irq_unmask, |
| 358 | .irq_set_type = pm8xxx_irq_set_type, |
Bjorn Andersson | f1837e4 | 2015-07-14 23:40:34 -0700 | [diff] [blame] | 359 | .irq_get_irqchip_state = pm8xxx_irq_get_irqchip_state, |
Stephen Boyd | d2d24ad | 2014-03-04 10:48:52 -0800 | [diff] [blame] | 360 | .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE, |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 361 | }; |
| 362 | |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 363 | static void pm8xxx_irq_domain_map(struct pm_irq_chip *chip, |
| 364 | struct irq_domain *domain, unsigned int irq, |
| 365 | irq_hw_number_t hwirq, unsigned int type) |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 366 | { |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 367 | irq_domain_set_info(domain, irq, hwirq, chip->pm_irq_data->irq_chip, |
| 368 | chip, handle_level_irq, NULL, NULL); |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 369 | irq_set_noprobe(irq); |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | static int pm8xxx_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, |
| 373 | unsigned int nr_irqs, void *data) |
| 374 | { |
| 375 | struct pm_irq_chip *chip = domain->host_data; |
| 376 | struct irq_fwspec *fwspec = data; |
| 377 | irq_hw_number_t hwirq; |
| 378 | unsigned int type; |
| 379 | int ret, i; |
| 380 | |
| 381 | ret = irq_domain_translate_twocell(domain, fwspec, &hwirq, &type); |
| 382 | if (ret) |
| 383 | return ret; |
| 384 | |
| 385 | for (i = 0; i < nr_irqs; i++) |
| 386 | pm8xxx_irq_domain_map(chip, domain, virq + i, hwirq + i, type); |
Rob Herring | 9bd09f3 | 2015-07-27 15:55:20 -0500 | [diff] [blame] | 387 | |
Stephen Boyd | bc866fc | 2014-02-26 10:59:19 -0800 | [diff] [blame] | 388 | return 0; |
| 389 | } |
| 390 | |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 391 | static const struct irq_domain_ops pm8xxx_irq_domain_ops = { |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 392 | .alloc = pm8xxx_irq_domain_alloc, |
| 393 | .free = irq_domain_free_irqs_common, |
| 394 | .translate = irq_domain_translate_twocell, |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 395 | }; |
| 396 | |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 397 | static void pm8821_irq_mask_ack(struct irq_data *d) |
| 398 | { |
| 399 | struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); |
| 400 | unsigned int pmirq = irqd_to_hwirq(d); |
| 401 | u8 block, master; |
| 402 | int irq_bit, rc; |
| 403 | |
| 404 | block = pmirq / 8; |
| 405 | master = block / PM8821_BLOCKS_PER_MASTER; |
| 406 | irq_bit = pmirq % 8; |
| 407 | block %= PM8821_BLOCKS_PER_MASTER; |
| 408 | |
| 409 | rc = regmap_update_bits(chip->regmap, |
| 410 | PM8821_SSBI_ADDR_IRQ_MASK(master, block), |
| 411 | BIT(irq_bit), BIT(irq_bit)); |
| 412 | if (rc) { |
| 413 | pr_err("Failed to mask IRQ:%d rc=%d\n", pmirq, rc); |
| 414 | return; |
| 415 | } |
| 416 | |
| 417 | rc = regmap_update_bits(chip->regmap, |
| 418 | PM8821_SSBI_ADDR_IRQ_CLEAR(master, block), |
| 419 | BIT(irq_bit), BIT(irq_bit)); |
| 420 | if (rc) |
| 421 | pr_err("Failed to CLEAR IRQ:%d rc=%d\n", pmirq, rc); |
| 422 | } |
| 423 | |
| 424 | static void pm8821_irq_unmask(struct irq_data *d) |
| 425 | { |
| 426 | struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); |
| 427 | unsigned int pmirq = irqd_to_hwirq(d); |
| 428 | int irq_bit, rc; |
| 429 | u8 block, master; |
| 430 | |
| 431 | block = pmirq / 8; |
| 432 | master = block / PM8821_BLOCKS_PER_MASTER; |
| 433 | irq_bit = pmirq % 8; |
| 434 | block %= PM8821_BLOCKS_PER_MASTER; |
| 435 | |
| 436 | rc = regmap_update_bits(chip->regmap, |
| 437 | PM8821_SSBI_ADDR_IRQ_MASK(master, block), |
| 438 | BIT(irq_bit), ~BIT(irq_bit)); |
| 439 | if (rc) |
| 440 | pr_err("Failed to read/write unmask IRQ:%d rc=%d\n", pmirq, rc); |
| 441 | |
| 442 | } |
| 443 | |
| 444 | static int pm8821_irq_get_irqchip_state(struct irq_data *d, |
| 445 | enum irqchip_irq_state which, |
| 446 | bool *state) |
| 447 | { |
| 448 | struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); |
| 449 | int rc, pmirq = irqd_to_hwirq(d); |
| 450 | u8 block, irq_bit, master; |
| 451 | unsigned int bits; |
| 452 | |
| 453 | block = pmirq / 8; |
| 454 | master = block / PM8821_BLOCKS_PER_MASTER; |
| 455 | irq_bit = pmirq % 8; |
| 456 | block %= PM8821_BLOCKS_PER_MASTER; |
| 457 | |
| 458 | rc = regmap_read(chip->regmap, |
| 459 | PM8821_SSBI_ADDR_IRQ_RT_STATUS(master, block), &bits); |
| 460 | if (rc) { |
| 461 | pr_err("Reading Status of IRQ %d failed rc=%d\n", pmirq, rc); |
| 462 | return rc; |
| 463 | } |
| 464 | |
| 465 | *state = !!(bits & BIT(irq_bit)); |
| 466 | |
| 467 | return rc; |
| 468 | } |
| 469 | |
| 470 | static struct irq_chip pm8821_irq_chip = { |
| 471 | .name = "pm8821", |
| 472 | .irq_mask_ack = pm8821_irq_mask_ack, |
| 473 | .irq_unmask = pm8821_irq_unmask, |
| 474 | .irq_get_irqchip_state = pm8821_irq_get_irqchip_state, |
| 475 | .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE, |
| 476 | }; |
| 477 | |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 478 | static const struct regmap_config ssbi_regmap_config = { |
| 479 | .reg_bits = 16, |
| 480 | .val_bits = 8, |
| 481 | .max_register = 0x3ff, |
| 482 | .fast_io = true, |
| 483 | .reg_read = ssbi_reg_read, |
| 484 | .reg_write = ssbi_reg_write |
| 485 | }; |
| 486 | |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 487 | static const struct pm_irq_data pm8xxx_data = { |
| 488 | .num_irqs = PM8XXX_NR_IRQS, |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 489 | .irq_chip = &pm8xxx_irq_chip, |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 490 | .irq_handler = pm8xxx_irq_handler, |
| 491 | }; |
| 492 | |
| 493 | static const struct pm_irq_data pm8821_data = { |
| 494 | .num_irqs = PM8821_NR_IRQS, |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 495 | .irq_chip = &pm8821_irq_chip, |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 496 | .irq_handler = pm8821_irq_handler, |
| 497 | }; |
| 498 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 499 | static const struct of_device_id pm8xxx_id_table[] = { |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 500 | { .compatible = "qcom,pm8018", .data = &pm8xxx_data}, |
| 501 | { .compatible = "qcom,pm8058", .data = &pm8xxx_data}, |
| 502 | { .compatible = "qcom,pm8821", .data = &pm8821_data}, |
| 503 | { .compatible = "qcom,pm8921", .data = &pm8xxx_data}, |
Stephen Boyd | c5865a5 | 2014-02-26 10:59:24 -0800 | [diff] [blame] | 504 | { } |
| 505 | }; |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 506 | MODULE_DEVICE_TABLE(of, pm8xxx_id_table); |
Stephen Boyd | c5865a5 | 2014-02-26 10:59:24 -0800 | [diff] [blame] | 507 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 508 | static int pm8xxx_probe(struct platform_device *pdev) |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 509 | { |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 510 | const struct pm_irq_data *data; |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 511 | struct regmap *regmap; |
Josh Cartwright | 202f768 | 2014-03-05 13:34:25 -0600 | [diff] [blame] | 512 | int irq, rc; |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 513 | unsigned int val; |
Abhijeet Dharmapurikar | c013f0a | 2011-04-05 14:40:53 -0700 | [diff] [blame] | 514 | u32 rev; |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 515 | struct pm_irq_chip *chip; |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 516 | |
| 517 | data = of_device_get_match_data(&pdev->dev); |
| 518 | if (!data) { |
| 519 | dev_err(&pdev->dev, "No matching driver data found\n"); |
| 520 | return -EINVAL; |
| 521 | } |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 522 | |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 523 | irq = platform_get_irq(pdev, 0); |
| 524 | if (irq < 0) |
| 525 | return irq; |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 526 | |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 527 | regmap = devm_regmap_init(&pdev->dev, NULL, pdev->dev.parent, |
| 528 | &ssbi_regmap_config); |
| 529 | if (IS_ERR(regmap)) |
| 530 | return PTR_ERR(regmap); |
| 531 | |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 532 | /* Read PMIC chip revision */ |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 533 | rc = regmap_read(regmap, REG_HWREV, &val); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 534 | if (rc) { |
| 535 | pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); |
Jingoo Han | b2cdcfa | 2013-08-20 16:02:26 +0900 | [diff] [blame] | 536 | return rc; |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 537 | } |
| 538 | pr_info("PMIC revision 1: %02X\n", val); |
Abhijeet Dharmapurikar | c013f0a | 2011-04-05 14:40:53 -0700 | [diff] [blame] | 539 | rev = val; |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 540 | |
| 541 | /* Read PMIC chip revision 2 */ |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 542 | rc = regmap_read(regmap, REG_HWREV_2, &val); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 543 | if (rc) { |
| 544 | pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", |
| 545 | REG_HWREV_2, rc); |
Jingoo Han | b2cdcfa | 2013-08-20 16:02:26 +0900 | [diff] [blame] | 546 | return rc; |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 547 | } |
| 548 | pr_info("PMIC revision 2: %02X\n", val); |
Abhijeet Dharmapurikar | c013f0a | 2011-04-05 14:40:53 -0700 | [diff] [blame] | 549 | rev |= val << BITS_PER_BYTE; |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 550 | |
Kees Cook | 0ed2dd0 | 2018-05-08 16:08:53 -0700 | [diff] [blame] | 551 | chip = devm_kzalloc(&pdev->dev, |
| 552 | struct_size(chip, config, data->num_irqs), |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 553 | GFP_KERNEL); |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 554 | if (!chip) |
| 555 | return -ENOMEM; |
| 556 | |
Stephen Boyd | 3e87933 | 2014-04-08 17:14:15 -0700 | [diff] [blame] | 557 | platform_set_drvdata(pdev, chip); |
Stephen Boyd | e7b81fca | 2014-02-26 10:59:23 -0800 | [diff] [blame] | 558 | chip->regmap = regmap; |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 559 | chip->num_blocks = DIV_ROUND_UP(data->num_irqs, 8); |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 560 | chip->num_masters = DIV_ROUND_UP(chip->num_blocks, 8); |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 561 | chip->pm_irq_data = data; |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 562 | spin_lock_init(&chip->pm_irq_lock); |
| 563 | |
Srinivas Kandagatla | 953f432 | 2016-11-15 12:01:51 +0000 | [diff] [blame] | 564 | chip->irqdomain = irq_domain_add_linear(pdev->dev.of_node, |
| 565 | data->num_irqs, |
Brian Masney | 3324a7c | 2019-02-07 21:16:24 -0500 | [diff] [blame] | 566 | &pm8xxx_irq_domain_ops, |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 567 | chip); |
| 568 | if (!chip->irqdomain) |
| 569 | return -ENODEV; |
| 570 | |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 571 | rc = devm_request_irq(&pdev->dev, irq, data->irq_handler, 0, dev_name(&pdev->dev), chip); |
| 572 | if (rc) |
| 573 | return rc; |
| 574 | |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 575 | irq_set_irq_wake(irq, 1); |
| 576 | |
| 577 | rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); |
Dmitry Baryshkov | d3546cc | 2021-09-26 02:43:33 +0300 | [diff] [blame] | 578 | if (rc) |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 579 | irq_domain_remove(chip->irqdomain); |
Abhijeet Dharmapurikar | c013f0a | 2011-04-05 14:40:53 -0700 | [diff] [blame] | 580 | |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 581 | return rc; |
| 582 | } |
| 583 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 584 | static int pm8xxx_remove_child(struct device *dev, void *unused) |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 585 | { |
| 586 | platform_device_unregister(to_platform_device(dev)); |
| 587 | return 0; |
| 588 | } |
| 589 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 590 | static int pm8xxx_remove(struct platform_device *pdev) |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 591 | { |
Stephen Boyd | 3e87933 | 2014-04-08 17:14:15 -0700 | [diff] [blame] | 592 | struct pm_irq_chip *chip = platform_get_drvdata(pdev); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 593 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 594 | device_for_each_child(&pdev->dev, NULL, pm8xxx_remove_child); |
Stephen Boyd | dc1a95c | 2014-02-26 10:59:21 -0800 | [diff] [blame] | 595 | irq_domain_remove(chip->irqdomain); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 596 | |
| 597 | return 0; |
| 598 | } |
| 599 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 600 | static struct platform_driver pm8xxx_driver = { |
| 601 | .probe = pm8xxx_probe, |
| 602 | .remove = pm8xxx_remove, |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 603 | .driver = { |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 604 | .name = "pm8xxx-core", |
| 605 | .of_match_table = pm8xxx_id_table, |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 606 | }, |
| 607 | }; |
| 608 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 609 | static int __init pm8xxx_init(void) |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 610 | { |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 611 | return platform_driver_register(&pm8xxx_driver); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 612 | } |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 613 | subsys_initcall(pm8xxx_init); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 614 | |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 615 | static void __exit pm8xxx_exit(void) |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 616 | { |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 617 | platform_driver_unregister(&pm8xxx_driver); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 618 | } |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 619 | module_exit(pm8xxx_exit); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 620 | |
| 621 | MODULE_LICENSE("GPL v2"); |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 622 | MODULE_DESCRIPTION("PMIC 8xxx core driver"); |
Abhijeet Dharmapurikar | cbdb53e | 2011-04-05 14:40:52 -0700 | [diff] [blame] | 623 | MODULE_VERSION("1.0"); |
Linus Walleij | 40a3a0f | 2016-11-19 16:15:18 +0100 | [diff] [blame] | 624 | MODULE_ALIAS("platform:pm8xxx-core"); |