Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) ST-Ericsson SA 2010 |
| 3 | * |
| 4 | * License Terms: GNU General Public License v2 |
| 5 | * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> |
| 6 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> |
Mattias Wallin | adceed6 | 2011-03-02 11:51:11 +0100 | [diff] [blame] | 7 | * Author: Mattias Wallin <mattias.wallin@stericsson.com> |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/kernel.h> |
| 11 | #include <linux/slab.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/irq.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/mfd/core.h> |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 19 | #include <linux/mfd/abx500.h> |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 20 | #include <linux/mfd/ab8500.h> |
Sundar R Iyer | 549931f | 2010-07-13 11:51:28 +0530 | [diff] [blame] | 21 | #include <linux/regulator/ab8500.h> |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 22 | |
| 23 | /* |
| 24 | * Interrupt register offsets |
| 25 | * Bank : 0x0E |
| 26 | */ |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 27 | #define AB8500_IT_SOURCE1_REG 0x00 |
| 28 | #define AB8500_IT_SOURCE2_REG 0x01 |
| 29 | #define AB8500_IT_SOURCE3_REG 0x02 |
| 30 | #define AB8500_IT_SOURCE4_REG 0x03 |
| 31 | #define AB8500_IT_SOURCE5_REG 0x04 |
| 32 | #define AB8500_IT_SOURCE6_REG 0x05 |
| 33 | #define AB8500_IT_SOURCE7_REG 0x06 |
| 34 | #define AB8500_IT_SOURCE8_REG 0x07 |
| 35 | #define AB8500_IT_SOURCE19_REG 0x12 |
| 36 | #define AB8500_IT_SOURCE20_REG 0x13 |
| 37 | #define AB8500_IT_SOURCE21_REG 0x14 |
| 38 | #define AB8500_IT_SOURCE22_REG 0x15 |
| 39 | #define AB8500_IT_SOURCE23_REG 0x16 |
| 40 | #define AB8500_IT_SOURCE24_REG 0x17 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * latch registers |
| 44 | */ |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 45 | #define AB8500_IT_LATCH1_REG 0x20 |
| 46 | #define AB8500_IT_LATCH2_REG 0x21 |
| 47 | #define AB8500_IT_LATCH3_REG 0x22 |
| 48 | #define AB8500_IT_LATCH4_REG 0x23 |
| 49 | #define AB8500_IT_LATCH5_REG 0x24 |
| 50 | #define AB8500_IT_LATCH6_REG 0x25 |
| 51 | #define AB8500_IT_LATCH7_REG 0x26 |
| 52 | #define AB8500_IT_LATCH8_REG 0x27 |
| 53 | #define AB8500_IT_LATCH9_REG 0x28 |
| 54 | #define AB8500_IT_LATCH10_REG 0x29 |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 55 | #define AB8500_IT_LATCH12_REG 0x2B |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 56 | #define AB8500_IT_LATCH19_REG 0x32 |
| 57 | #define AB8500_IT_LATCH20_REG 0x33 |
| 58 | #define AB8500_IT_LATCH21_REG 0x34 |
| 59 | #define AB8500_IT_LATCH22_REG 0x35 |
| 60 | #define AB8500_IT_LATCH23_REG 0x36 |
| 61 | #define AB8500_IT_LATCH24_REG 0x37 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * mask registers |
| 65 | */ |
| 66 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 67 | #define AB8500_IT_MASK1_REG 0x40 |
| 68 | #define AB8500_IT_MASK2_REG 0x41 |
| 69 | #define AB8500_IT_MASK3_REG 0x42 |
| 70 | #define AB8500_IT_MASK4_REG 0x43 |
| 71 | #define AB8500_IT_MASK5_REG 0x44 |
| 72 | #define AB8500_IT_MASK6_REG 0x45 |
| 73 | #define AB8500_IT_MASK7_REG 0x46 |
| 74 | #define AB8500_IT_MASK8_REG 0x47 |
| 75 | #define AB8500_IT_MASK9_REG 0x48 |
| 76 | #define AB8500_IT_MASK10_REG 0x49 |
| 77 | #define AB8500_IT_MASK11_REG 0x4A |
| 78 | #define AB8500_IT_MASK12_REG 0x4B |
| 79 | #define AB8500_IT_MASK13_REG 0x4C |
| 80 | #define AB8500_IT_MASK14_REG 0x4D |
| 81 | #define AB8500_IT_MASK15_REG 0x4E |
| 82 | #define AB8500_IT_MASK16_REG 0x4F |
| 83 | #define AB8500_IT_MASK17_REG 0x50 |
| 84 | #define AB8500_IT_MASK18_REG 0x51 |
| 85 | #define AB8500_IT_MASK19_REG 0x52 |
| 86 | #define AB8500_IT_MASK20_REG 0x53 |
| 87 | #define AB8500_IT_MASK21_REG 0x54 |
| 88 | #define AB8500_IT_MASK22_REG 0x55 |
| 89 | #define AB8500_IT_MASK23_REG 0x56 |
| 90 | #define AB8500_IT_MASK24_REG 0x57 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 91 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 92 | #define AB8500_REV_REG 0x80 |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 93 | #define AB8500_SWITCH_OFF_STATUS 0x00 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 94 | |
| 95 | /* |
| 96 | * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt |
| 97 | * numbers are indexed into this array with (num / 8). |
| 98 | * |
| 99 | * This is one off from the register names, i.e. AB8500_IT_MASK1_REG is at |
| 100 | * offset 0. |
| 101 | */ |
| 102 | static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = { |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 103 | 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 104 | }; |
| 105 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 106 | static int ab8500_get_chip_id(struct device *dev) |
| 107 | { |
Mattias Wallin | 6bce7bf | 2010-12-02 15:08:32 +0100 | [diff] [blame] | 108 | struct ab8500 *ab8500; |
| 109 | |
| 110 | if (!dev) |
| 111 | return -EINVAL; |
| 112 | ab8500 = dev_get_drvdata(dev->parent); |
| 113 | return ab8500 ? (int)ab8500->chip_id : -EINVAL; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static int set_register_interruptible(struct ab8500 *ab8500, u8 bank, |
| 117 | u8 reg, u8 data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 118 | { |
| 119 | int ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 120 | /* |
| 121 | * Put the u8 bank and u8 register together into a an u16. |
| 122 | * The bank on higher 8 bits and register in lower 8 bits. |
| 123 | * */ |
| 124 | u16 addr = ((u16)bank) << 8 | reg; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 125 | |
| 126 | dev_vdbg(ab8500->dev, "wr: addr %#x <= %#x\n", addr, data); |
| 127 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 128 | ret = mutex_lock_interruptible(&ab8500->lock); |
| 129 | if (ret) |
| 130 | return ret; |
| 131 | |
| 132 | ret = ab8500->write(ab8500, addr, data); |
| 133 | if (ret < 0) |
| 134 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", |
| 135 | addr, ret); |
| 136 | mutex_unlock(&ab8500->lock); |
| 137 | |
| 138 | return ret; |
| 139 | } |
| 140 | |
| 141 | static int ab8500_set_register(struct device *dev, u8 bank, |
| 142 | u8 reg, u8 value) |
| 143 | { |
| 144 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
| 145 | |
| 146 | return set_register_interruptible(ab8500, bank, reg, value); |
| 147 | } |
| 148 | |
| 149 | static int get_register_interruptible(struct ab8500 *ab8500, u8 bank, |
| 150 | u8 reg, u8 *value) |
| 151 | { |
| 152 | int ret; |
| 153 | /* put the u8 bank and u8 reg together into a an u16. |
| 154 | * bank on higher 8 bits and reg in lower */ |
| 155 | u16 addr = ((u16)bank) << 8 | reg; |
| 156 | |
| 157 | ret = mutex_lock_interruptible(&ab8500->lock); |
| 158 | if (ret) |
| 159 | return ret; |
| 160 | |
| 161 | ret = ab8500->read(ab8500, addr); |
| 162 | if (ret < 0) |
| 163 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", |
| 164 | addr, ret); |
| 165 | else |
| 166 | *value = ret; |
| 167 | |
| 168 | mutex_unlock(&ab8500->lock); |
| 169 | dev_vdbg(ab8500->dev, "rd: addr %#x => data %#x\n", addr, ret); |
| 170 | |
| 171 | return ret; |
| 172 | } |
| 173 | |
| 174 | static int ab8500_get_register(struct device *dev, u8 bank, |
| 175 | u8 reg, u8 *value) |
| 176 | { |
| 177 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
| 178 | |
| 179 | return get_register_interruptible(ab8500, bank, reg, value); |
| 180 | } |
| 181 | |
| 182 | static int mask_and_set_register_interruptible(struct ab8500 *ab8500, u8 bank, |
| 183 | u8 reg, u8 bitmask, u8 bitvalues) |
| 184 | { |
| 185 | int ret; |
| 186 | u8 data; |
| 187 | /* put the u8 bank and u8 reg together into a an u16. |
| 188 | * bank on higher 8 bits and reg in lower */ |
| 189 | u16 addr = ((u16)bank) << 8 | reg; |
| 190 | |
| 191 | ret = mutex_lock_interruptible(&ab8500->lock); |
| 192 | if (ret) |
| 193 | return ret; |
| 194 | |
| 195 | ret = ab8500->read(ab8500, addr); |
| 196 | if (ret < 0) { |
| 197 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", |
| 198 | addr, ret); |
| 199 | goto out; |
| 200 | } |
| 201 | |
| 202 | data = (u8)ret; |
| 203 | data = (~bitmask & data) | (bitmask & bitvalues); |
| 204 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 205 | ret = ab8500->write(ab8500, addr, data); |
| 206 | if (ret < 0) |
| 207 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", |
| 208 | addr, ret); |
| 209 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 210 | dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, data); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 211 | out: |
| 212 | mutex_unlock(&ab8500->lock); |
| 213 | return ret; |
| 214 | } |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 215 | |
| 216 | static int ab8500_mask_and_set_register(struct device *dev, |
| 217 | u8 bank, u8 reg, u8 bitmask, u8 bitvalues) |
| 218 | { |
| 219 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
| 220 | |
| 221 | return mask_and_set_register_interruptible(ab8500, bank, reg, |
| 222 | bitmask, bitvalues); |
| 223 | |
| 224 | } |
| 225 | |
| 226 | static struct abx500_ops ab8500_ops = { |
| 227 | .get_chip_id = ab8500_get_chip_id, |
| 228 | .get_register = ab8500_get_register, |
| 229 | .set_register = ab8500_set_register, |
| 230 | .get_register_page = NULL, |
| 231 | .set_register_page = NULL, |
| 232 | .mask_and_set_register = ab8500_mask_and_set_register, |
| 233 | .event_registers_startup_state_get = NULL, |
| 234 | .startup_irq_enabled = NULL, |
| 235 | }; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 236 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 237 | static void ab8500_irq_lock(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 238 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 239 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 240 | |
| 241 | mutex_lock(&ab8500->irq_lock); |
| 242 | } |
| 243 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 244 | static void ab8500_irq_sync_unlock(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 245 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 246 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 247 | int i; |
| 248 | |
| 249 | for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { |
| 250 | u8 old = ab8500->oldmask[i]; |
| 251 | u8 new = ab8500->mask[i]; |
| 252 | int reg; |
| 253 | |
| 254 | if (new == old) |
| 255 | continue; |
| 256 | |
Linus Walleij | 863dde5 | 2011-05-08 00:54:45 +0200 | [diff] [blame] | 257 | /* Interrupt register 12 doesn't exist prior to version 2.0 */ |
| 258 | if (ab8500_irq_regoffset[i] == 11 && |
| 259 | ab8500->chip_id < AB8500_CUT2P0) |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 260 | continue; |
| 261 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 262 | ab8500->oldmask[i] = new; |
| 263 | |
| 264 | reg = AB8500_IT_MASK1_REG + ab8500_irq_regoffset[i]; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 265 | set_register_interruptible(ab8500, AB8500_INTERRUPT, reg, new); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | mutex_unlock(&ab8500->irq_lock); |
| 269 | } |
| 270 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 271 | static void ab8500_irq_mask(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 272 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 273 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
| 274 | int offset = data->irq - ab8500->irq_base; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 275 | int index = offset / 8; |
| 276 | int mask = 1 << (offset % 8); |
| 277 | |
| 278 | ab8500->mask[index] |= mask; |
| 279 | } |
| 280 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 281 | static void ab8500_irq_unmask(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 282 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 283 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
| 284 | int offset = data->irq - ab8500->irq_base; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 285 | int index = offset / 8; |
| 286 | int mask = 1 << (offset % 8); |
| 287 | |
| 288 | ab8500->mask[index] &= ~mask; |
| 289 | } |
| 290 | |
| 291 | static struct irq_chip ab8500_irq_chip = { |
| 292 | .name = "ab8500", |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 293 | .irq_bus_lock = ab8500_irq_lock, |
| 294 | .irq_bus_sync_unlock = ab8500_irq_sync_unlock, |
| 295 | .irq_mask = ab8500_irq_mask, |
| 296 | .irq_unmask = ab8500_irq_unmask, |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | static irqreturn_t ab8500_irq(int irq, void *dev) |
| 300 | { |
| 301 | struct ab8500 *ab8500 = dev; |
| 302 | int i; |
| 303 | |
| 304 | dev_vdbg(ab8500->dev, "interrupt\n"); |
| 305 | |
| 306 | for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { |
| 307 | int regoffset = ab8500_irq_regoffset[i]; |
| 308 | int status; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 309 | u8 value; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 310 | |
Linus Walleij | 863dde5 | 2011-05-08 00:54:45 +0200 | [diff] [blame] | 311 | /* Interrupt register 12 doesn't exist prior to version 2.0 */ |
| 312 | if (regoffset == 11 && ab8500->chip_id < AB8500_CUT2P0) |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 313 | continue; |
| 314 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 315 | status = get_register_interruptible(ab8500, AB8500_INTERRUPT, |
| 316 | AB8500_IT_LATCH1_REG + regoffset, &value); |
| 317 | if (status < 0 || value == 0) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 318 | continue; |
| 319 | |
| 320 | do { |
Mattias Wallin | 88aec4f | 2010-12-02 15:06:49 +0100 | [diff] [blame] | 321 | int bit = __ffs(value); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 322 | int line = i * 8 + bit; |
| 323 | |
| 324 | handle_nested_irq(ab8500->irq_base + line); |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 325 | value &= ~(1 << bit); |
| 326 | } while (value); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | return IRQ_HANDLED; |
| 330 | } |
| 331 | |
| 332 | static int ab8500_irq_init(struct ab8500 *ab8500) |
| 333 | { |
| 334 | int base = ab8500->irq_base; |
| 335 | int irq; |
| 336 | |
| 337 | for (irq = base; irq < base + AB8500_NR_IRQS; irq++) { |
Thomas Gleixner | d5bb122 | 2011-03-25 11:12:32 +0000 | [diff] [blame] | 338 | irq_set_chip_data(irq, ab8500); |
| 339 | irq_set_chip_and_handler(irq, &ab8500_irq_chip, |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 340 | handle_simple_irq); |
Thomas Gleixner | d5bb122 | 2011-03-25 11:12:32 +0000 | [diff] [blame] | 341 | irq_set_nested_thread(irq, 1); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 342 | #ifdef CONFIG_ARM |
| 343 | set_irq_flags(irq, IRQF_VALID); |
| 344 | #else |
Thomas Gleixner | d5bb122 | 2011-03-25 11:12:32 +0000 | [diff] [blame] | 345 | irq_set_noprobe(irq); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 346 | #endif |
| 347 | } |
| 348 | |
| 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | static void ab8500_irq_remove(struct ab8500 *ab8500) |
| 353 | { |
| 354 | int base = ab8500->irq_base; |
| 355 | int irq; |
| 356 | |
| 357 | for (irq = base; irq < base + AB8500_NR_IRQS; irq++) { |
| 358 | #ifdef CONFIG_ARM |
| 359 | set_irq_flags(irq, 0); |
| 360 | #endif |
Thomas Gleixner | d5bb122 | 2011-03-25 11:12:32 +0000 | [diff] [blame] | 361 | irq_set_chip_and_handler(irq, NULL, NULL); |
| 362 | irq_set_chip_data(irq, NULL); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 363 | } |
| 364 | } |
| 365 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 366 | static struct resource __devinitdata ab8500_gpio_resources[] = { |
Bibek Basu | 0cb3fcd | 2011-02-09 11:02:35 +0530 | [diff] [blame] | 367 | { |
| 368 | .name = "GPIO_INT6", |
| 369 | .start = AB8500_INT_GPIO6R, |
| 370 | .end = AB8500_INT_GPIO41F, |
| 371 | .flags = IORESOURCE_IRQ, |
| 372 | } |
| 373 | }; |
| 374 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 375 | static struct resource __devinitdata ab8500_gpadc_resources[] = { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 376 | { |
| 377 | .name = "HW_CONV_END", |
| 378 | .start = AB8500_INT_GP_HW_ADC_CONV_END, |
| 379 | .end = AB8500_INT_GP_HW_ADC_CONV_END, |
| 380 | .flags = IORESOURCE_IRQ, |
| 381 | }, |
| 382 | { |
| 383 | .name = "SW_CONV_END", |
| 384 | .start = AB8500_INT_GP_SW_ADC_CONV_END, |
| 385 | .end = AB8500_INT_GP_SW_ADC_CONV_END, |
| 386 | .flags = IORESOURCE_IRQ, |
| 387 | }, |
| 388 | }; |
| 389 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 390 | static struct resource __devinitdata ab8500_rtc_resources[] = { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 391 | { |
| 392 | .name = "60S", |
| 393 | .start = AB8500_INT_RTC_60S, |
| 394 | .end = AB8500_INT_RTC_60S, |
| 395 | .flags = IORESOURCE_IRQ, |
| 396 | }, |
| 397 | { |
| 398 | .name = "ALARM", |
| 399 | .start = AB8500_INT_RTC_ALARM, |
| 400 | .end = AB8500_INT_RTC_ALARM, |
| 401 | .flags = IORESOURCE_IRQ, |
| 402 | }, |
| 403 | }; |
| 404 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 405 | static struct resource __devinitdata ab8500_poweronkey_db_resources[] = { |
Sundar R Iyer | 7768651 | 2010-09-05 12:18:47 -0700 | [diff] [blame] | 406 | { |
| 407 | .name = "ONKEY_DBF", |
| 408 | .start = AB8500_INT_PON_KEY1DB_F, |
| 409 | .end = AB8500_INT_PON_KEY1DB_F, |
| 410 | .flags = IORESOURCE_IRQ, |
| 411 | }, |
| 412 | { |
| 413 | .name = "ONKEY_DBR", |
| 414 | .start = AB8500_INT_PON_KEY1DB_R, |
| 415 | .end = AB8500_INT_PON_KEY1DB_R, |
| 416 | .flags = IORESOURCE_IRQ, |
| 417 | }, |
| 418 | }; |
| 419 | |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 420 | static struct resource __devinitdata ab8500_av_acc_detect_resources[] = { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 421 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 422 | .name = "ACC_DETECT_1DB_F", |
| 423 | .start = AB8500_INT_ACC_DETECT_1DB_F, |
| 424 | .end = AB8500_INT_ACC_DETECT_1DB_F, |
| 425 | .flags = IORESOURCE_IRQ, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 426 | }, |
| 427 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 428 | .name = "ACC_DETECT_1DB_R", |
| 429 | .start = AB8500_INT_ACC_DETECT_1DB_R, |
| 430 | .end = AB8500_INT_ACC_DETECT_1DB_R, |
| 431 | .flags = IORESOURCE_IRQ, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 432 | }, |
| 433 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 434 | .name = "ACC_DETECT_21DB_F", |
| 435 | .start = AB8500_INT_ACC_DETECT_21DB_F, |
| 436 | .end = AB8500_INT_ACC_DETECT_21DB_F, |
| 437 | .flags = IORESOURCE_IRQ, |
| 438 | }, |
| 439 | { |
| 440 | .name = "ACC_DETECT_21DB_R", |
| 441 | .start = AB8500_INT_ACC_DETECT_21DB_R, |
| 442 | .end = AB8500_INT_ACC_DETECT_21DB_R, |
| 443 | .flags = IORESOURCE_IRQ, |
| 444 | }, |
| 445 | { |
| 446 | .name = "ACC_DETECT_22DB_F", |
| 447 | .start = AB8500_INT_ACC_DETECT_22DB_F, |
| 448 | .end = AB8500_INT_ACC_DETECT_22DB_F, |
| 449 | .flags = IORESOURCE_IRQ, |
| 450 | }, |
| 451 | { |
| 452 | .name = "ACC_DETECT_22DB_R", |
| 453 | .start = AB8500_INT_ACC_DETECT_22DB_R, |
| 454 | .end = AB8500_INT_ACC_DETECT_22DB_R, |
| 455 | .flags = IORESOURCE_IRQ, |
| 456 | }, |
| 457 | }; |
| 458 | |
| 459 | static struct resource __devinitdata ab8500_charger_resources[] = { |
| 460 | { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 461 | .name = "MAIN_CH_UNPLUG_DET", |
| 462 | .start = AB8500_INT_MAIN_CH_UNPLUG_DET, |
| 463 | .end = AB8500_INT_MAIN_CH_UNPLUG_DET, |
| 464 | .flags = IORESOURCE_IRQ, |
| 465 | }, |
| 466 | { |
| 467 | .name = "MAIN_CHARGE_PLUG_DET", |
| 468 | .start = AB8500_INT_MAIN_CH_PLUG_DET, |
| 469 | .end = AB8500_INT_MAIN_CH_PLUG_DET, |
| 470 | .flags = IORESOURCE_IRQ, |
| 471 | }, |
| 472 | { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 473 | .name = "VBUS_DET_R", |
| 474 | .start = AB8500_INT_VBUS_DET_R, |
| 475 | .end = AB8500_INT_VBUS_DET_R, |
| 476 | .flags = IORESOURCE_IRQ, |
| 477 | }, |
| 478 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 479 | .name = "VBUS_DET_F", |
| 480 | .start = AB8500_INT_VBUS_DET_F, |
| 481 | .end = AB8500_INT_VBUS_DET_F, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 482 | .flags = IORESOURCE_IRQ, |
| 483 | }, |
| 484 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 485 | .name = "USB_LINK_STATUS", |
| 486 | .start = AB8500_INT_USB_LINK_STATUS, |
| 487 | .end = AB8500_INT_USB_LINK_STATUS, |
| 488 | .flags = IORESOURCE_IRQ, |
| 489 | }, |
| 490 | { |
| 491 | .name = "USB_CHARGE_DET_DONE", |
| 492 | .start = AB8500_INT_USB_CHG_DET_DONE, |
| 493 | .end = AB8500_INT_USB_CHG_DET_DONE, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 494 | .flags = IORESOURCE_IRQ, |
| 495 | }, |
| 496 | { |
| 497 | .name = "VBUS_OVV", |
| 498 | .start = AB8500_INT_VBUS_OVV, |
| 499 | .end = AB8500_INT_VBUS_OVV, |
| 500 | .flags = IORESOURCE_IRQ, |
| 501 | }, |
| 502 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 503 | .name = "USB_CH_TH_PROT_R", |
| 504 | .start = AB8500_INT_USB_CH_TH_PROT_R, |
| 505 | .end = AB8500_INT_USB_CH_TH_PROT_R, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 506 | .flags = IORESOURCE_IRQ, |
| 507 | }, |
| 508 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 509 | .name = "USB_CH_TH_PROT_F", |
| 510 | .start = AB8500_INT_USB_CH_TH_PROT_F, |
| 511 | .end = AB8500_INT_USB_CH_TH_PROT_F, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 512 | .flags = IORESOURCE_IRQ, |
| 513 | }, |
| 514 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 515 | .name = "MAIN_EXT_CH_NOT_OK", |
| 516 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 517 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 518 | .flags = IORESOURCE_IRQ, |
| 519 | }, |
| 520 | { |
| 521 | .name = "MAIN_CH_TH_PROT_R", |
| 522 | .start = AB8500_INT_MAIN_CH_TH_PROT_R, |
| 523 | .end = AB8500_INT_MAIN_CH_TH_PROT_R, |
| 524 | .flags = IORESOURCE_IRQ, |
| 525 | }, |
| 526 | { |
| 527 | .name = "MAIN_CH_TH_PROT_F", |
| 528 | .start = AB8500_INT_MAIN_CH_TH_PROT_F, |
| 529 | .end = AB8500_INT_MAIN_CH_TH_PROT_F, |
| 530 | .flags = IORESOURCE_IRQ, |
| 531 | }, |
| 532 | { |
| 533 | .name = "USB_CHARGER_NOT_OKR", |
| 534 | .start = AB8500_INT_USB_CHARGER_NOT_OK, |
| 535 | .end = AB8500_INT_USB_CHARGER_NOT_OK, |
| 536 | .flags = IORESOURCE_IRQ, |
| 537 | }, |
| 538 | { |
| 539 | .name = "USB_CHARGER_NOT_OKF", |
| 540 | .start = AB8500_INT_USB_CHARGER_NOT_OKF, |
| 541 | .end = AB8500_INT_USB_CHARGER_NOT_OKF, |
| 542 | .flags = IORESOURCE_IRQ, |
| 543 | }, |
| 544 | { |
| 545 | .name = "CH_WD_EXP", |
| 546 | .start = AB8500_INT_CH_WD_EXP, |
| 547 | .end = AB8500_INT_CH_WD_EXP, |
| 548 | .flags = IORESOURCE_IRQ, |
| 549 | }, |
| 550 | }; |
| 551 | |
| 552 | static struct resource __devinitdata ab8500_btemp_resources[] = { |
| 553 | { |
| 554 | .name = "BAT_CTRL_INDB", |
| 555 | .start = AB8500_INT_BAT_CTRL_INDB, |
| 556 | .end = AB8500_INT_BAT_CTRL_INDB, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 557 | .flags = IORESOURCE_IRQ, |
| 558 | }, |
| 559 | { |
| 560 | .name = "BTEMP_LOW", |
| 561 | .start = AB8500_INT_BTEMP_LOW, |
| 562 | .end = AB8500_INT_BTEMP_LOW, |
| 563 | .flags = IORESOURCE_IRQ, |
| 564 | }, |
| 565 | { |
| 566 | .name = "BTEMP_HIGH", |
| 567 | .start = AB8500_INT_BTEMP_HIGH, |
| 568 | .end = AB8500_INT_BTEMP_HIGH, |
| 569 | .flags = IORESOURCE_IRQ, |
| 570 | }, |
| 571 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 572 | .name = "BTEMP_LOW_MEDIUM", |
| 573 | .start = AB8500_INT_BTEMP_LOW_MEDIUM, |
| 574 | .end = AB8500_INT_BTEMP_LOW_MEDIUM, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 575 | .flags = IORESOURCE_IRQ, |
| 576 | }, |
| 577 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 578 | .name = "BTEMP_MEDIUM_HIGH", |
| 579 | .start = AB8500_INT_BTEMP_MEDIUM_HIGH, |
| 580 | .end = AB8500_INT_BTEMP_MEDIUM_HIGH, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 581 | .flags = IORESOURCE_IRQ, |
| 582 | }, |
| 583 | }; |
| 584 | |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 585 | static struct resource __devinitdata ab8500_fg_resources[] = { |
| 586 | { |
| 587 | .name = "NCONV_ACCU", |
| 588 | .start = AB8500_INT_CCN_CONV_ACC, |
| 589 | .end = AB8500_INT_CCN_CONV_ACC, |
| 590 | .flags = IORESOURCE_IRQ, |
| 591 | }, |
| 592 | { |
| 593 | .name = "BATT_OVV", |
| 594 | .start = AB8500_INT_BATT_OVV, |
| 595 | .end = AB8500_INT_BATT_OVV, |
| 596 | .flags = IORESOURCE_IRQ, |
| 597 | }, |
| 598 | { |
| 599 | .name = "LOW_BAT_F", |
| 600 | .start = AB8500_INT_LOW_BAT_F, |
| 601 | .end = AB8500_INT_LOW_BAT_F, |
| 602 | .flags = IORESOURCE_IRQ, |
| 603 | }, |
| 604 | { |
| 605 | .name = "LOW_BAT_R", |
| 606 | .start = AB8500_INT_LOW_BAT_R, |
| 607 | .end = AB8500_INT_LOW_BAT_R, |
| 608 | .flags = IORESOURCE_IRQ, |
| 609 | }, |
| 610 | { |
| 611 | .name = "CC_INT_CALIB", |
| 612 | .start = AB8500_INT_CC_INT_CALIB, |
| 613 | .end = AB8500_INT_CC_INT_CALIB, |
| 614 | .flags = IORESOURCE_IRQ, |
| 615 | }, |
| 616 | }; |
| 617 | |
| 618 | static struct resource __devinitdata ab8500_chargalg_resources[] = {}; |
| 619 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 620 | static struct resource __devinitdata ab8500_debug_resources[] = { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 621 | { |
| 622 | .name = "IRQ_FIRST", |
| 623 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 624 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 625 | .flags = IORESOURCE_IRQ, |
| 626 | }, |
| 627 | { |
| 628 | .name = "IRQ_LAST", |
| 629 | .start = AB8500_INT_USB_CHARGER_NOT_OKF, |
| 630 | .end = AB8500_INT_USB_CHARGER_NOT_OKF, |
| 631 | .flags = IORESOURCE_IRQ, |
| 632 | }, |
| 633 | }; |
| 634 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 635 | static struct resource __devinitdata ab8500_usb_resources[] = { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 636 | { |
| 637 | .name = "ID_WAKEUP_R", |
| 638 | .start = AB8500_INT_ID_WAKEUP_R, |
| 639 | .end = AB8500_INT_ID_WAKEUP_R, |
| 640 | .flags = IORESOURCE_IRQ, |
| 641 | }, |
| 642 | { |
| 643 | .name = "ID_WAKEUP_F", |
| 644 | .start = AB8500_INT_ID_WAKEUP_F, |
| 645 | .end = AB8500_INT_ID_WAKEUP_F, |
| 646 | .flags = IORESOURCE_IRQ, |
| 647 | }, |
| 648 | { |
| 649 | .name = "VBUS_DET_F", |
| 650 | .start = AB8500_INT_VBUS_DET_F, |
| 651 | .end = AB8500_INT_VBUS_DET_F, |
| 652 | .flags = IORESOURCE_IRQ, |
| 653 | }, |
| 654 | { |
| 655 | .name = "VBUS_DET_R", |
| 656 | .start = AB8500_INT_VBUS_DET_R, |
| 657 | .end = AB8500_INT_VBUS_DET_R, |
| 658 | .flags = IORESOURCE_IRQ, |
| 659 | }, |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 660 | { |
| 661 | .name = "USB_LINK_STATUS", |
| 662 | .start = AB8500_INT_USB_LINK_STATUS, |
| 663 | .end = AB8500_INT_USB_LINK_STATUS, |
| 664 | .flags = IORESOURCE_IRQ, |
| 665 | }, |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 666 | { |
| 667 | .name = "USB_ADP_PROBE_PLUG", |
| 668 | .start = AB8500_INT_ADP_PROBE_PLUG, |
| 669 | .end = AB8500_INT_ADP_PROBE_PLUG, |
| 670 | .flags = IORESOURCE_IRQ, |
| 671 | }, |
| 672 | { |
| 673 | .name = "USB_ADP_PROBE_UNPLUG", |
| 674 | .start = AB8500_INT_ADP_PROBE_UNPLUG, |
| 675 | .end = AB8500_INT_ADP_PROBE_UNPLUG, |
| 676 | .flags = IORESOURCE_IRQ, |
| 677 | }, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 678 | }; |
| 679 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 680 | static struct resource __devinitdata ab8500_temp_resources[] = { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 681 | { |
| 682 | .name = "AB8500_TEMP_WARM", |
| 683 | .start = AB8500_INT_TEMP_WARM, |
| 684 | .end = AB8500_INT_TEMP_WARM, |
| 685 | .flags = IORESOURCE_IRQ, |
| 686 | }, |
| 687 | }; |
| 688 | |
Robert Rosengren | 5cef8df | 2011-06-09 23:57:33 +0200 | [diff] [blame] | 689 | static struct mfd_cell __devinitdata ab8500_devs[] = { |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 690 | #ifdef CONFIG_DEBUG_FS |
| 691 | { |
| 692 | .name = "ab8500-debug", |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 693 | .num_resources = ARRAY_SIZE(ab8500_debug_resources), |
| 694 | .resources = ab8500_debug_resources, |
Mattias Wallin | 5814fc3 | 2010-09-13 16:05:04 +0200 | [diff] [blame] | 695 | }, |
| 696 | #endif |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 697 | { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 698 | .name = "ab8500-sysctrl", |
| 699 | }, |
| 700 | { |
| 701 | .name = "ab8500-regulator", |
| 702 | }, |
| 703 | { |
Bibek Basu | 0cb3fcd | 2011-02-09 11:02:35 +0530 | [diff] [blame] | 704 | .name = "ab8500-gpio", |
| 705 | .num_resources = ARRAY_SIZE(ab8500_gpio_resources), |
| 706 | .resources = ab8500_gpio_resources, |
| 707 | }, |
| 708 | { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 709 | .name = "ab8500-gpadc", |
| 710 | .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), |
| 711 | .resources = ab8500_gpadc_resources, |
| 712 | }, |
| 713 | { |
| 714 | .name = "ab8500-rtc", |
| 715 | .num_resources = ARRAY_SIZE(ab8500_rtc_resources), |
| 716 | .resources = ab8500_rtc_resources, |
| 717 | }, |
Arun Murthy | f0f05b1 | 2010-09-06 12:24:52 +0530 | [diff] [blame] | 718 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 719 | .name = "ab8500-charger", |
| 720 | .num_resources = ARRAY_SIZE(ab8500_charger_resources), |
| 721 | .resources = ab8500_charger_resources, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 722 | }, |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 723 | { |
| 724 | .name = "ab8500-btemp", |
| 725 | .num_resources = ARRAY_SIZE(ab8500_btemp_resources), |
| 726 | .resources = ab8500_btemp_resources, |
| 727 | }, |
| 728 | { |
| 729 | .name = "ab8500-fg", |
| 730 | .num_resources = ARRAY_SIZE(ab8500_fg_resources), |
| 731 | .resources = ab8500_fg_resources, |
| 732 | }, |
| 733 | { |
| 734 | .name = "ab8500-chargalg", |
| 735 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), |
| 736 | .resources = ab8500_chargalg_resources, |
| 737 | }, |
| 738 | { |
| 739 | .name = "ab8500-acc-det", |
| 740 | .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), |
| 741 | .resources = ab8500_av_acc_detect_resources, |
| 742 | }, |
| 743 | { |
| 744 | .name = "ab8500-codec", |
| 745 | }, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 746 | { |
| 747 | .name = "ab8500-usb", |
| 748 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), |
| 749 | .resources = ab8500_usb_resources, |
| 750 | }, |
| 751 | { |
| 752 | .name = "ab8500-poweron-key", |
| 753 | .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), |
| 754 | .resources = ab8500_poweronkey_db_resources, |
| 755 | }, |
| 756 | { |
Arun Murthy | f0f05b1 | 2010-09-06 12:24:52 +0530 | [diff] [blame] | 757 | .name = "ab8500-pwm", |
| 758 | .id = 1, |
| 759 | }, |
| 760 | { |
| 761 | .name = "ab8500-pwm", |
| 762 | .id = 2, |
| 763 | }, |
| 764 | { |
| 765 | .name = "ab8500-pwm", |
| 766 | .id = 3, |
| 767 | }, |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 768 | { .name = "ab8500-leds", }, |
Sundar R Iyer | 7768651 | 2010-09-05 12:18:47 -0700 | [diff] [blame] | 769 | { |
Mattias Wallin | e098ade | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 770 | .name = "ab8500-denc", |
| 771 | }, |
| 772 | { |
| 773 | .name = "ab8500-temp", |
| 774 | .num_resources = ARRAY_SIZE(ab8500_temp_resources), |
| 775 | .resources = ab8500_temp_resources, |
Sundar R Iyer | 7768651 | 2010-09-05 12:18:47 -0700 | [diff] [blame] | 776 | }, |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 777 | }; |
| 778 | |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 779 | static ssize_t show_chip_id(struct device *dev, |
| 780 | struct device_attribute *attr, char *buf) |
| 781 | { |
| 782 | struct ab8500 *ab8500; |
| 783 | |
| 784 | ab8500 = dev_get_drvdata(dev); |
| 785 | return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); |
| 786 | } |
| 787 | |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 788 | /* |
| 789 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): |
| 790 | * 0x01 Swoff bit programming |
| 791 | * 0x02 Thermal protection activation |
| 792 | * 0x04 Vbat lower then BattOk falling threshold |
| 793 | * 0x08 Watchdog expired |
| 794 | * 0x10 Non presence of 32kHz clock |
| 795 | * 0x20 Battery level lower than power on reset threshold |
| 796 | * 0x40 Power on key 1 pressed longer than 10 seconds |
| 797 | * 0x80 DB8500 thermal shutdown |
| 798 | */ |
| 799 | static ssize_t show_switch_off_status(struct device *dev, |
| 800 | struct device_attribute *attr, char *buf) |
| 801 | { |
| 802 | int ret; |
| 803 | u8 value; |
| 804 | struct ab8500 *ab8500; |
| 805 | |
| 806 | ab8500 = dev_get_drvdata(dev); |
| 807 | ret = get_register_interruptible(ab8500, AB8500_RTC, |
| 808 | AB8500_SWITCH_OFF_STATUS, &value); |
| 809 | if (ret < 0) |
| 810 | return ret; |
| 811 | return sprintf(buf, "%#x\n", value); |
| 812 | } |
| 813 | |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 814 | static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 815 | static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL); |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 816 | |
| 817 | static struct attribute *ab8500_sysfs_entries[] = { |
| 818 | &dev_attr_chip_id.attr, |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 819 | &dev_attr_switch_off_status.attr, |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 820 | NULL, |
| 821 | }; |
| 822 | |
| 823 | static struct attribute_group ab8500_attr_group = { |
| 824 | .attrs = ab8500_sysfs_entries, |
| 825 | }; |
| 826 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 827 | int __devinit ab8500_init(struct ab8500 *ab8500) |
| 828 | { |
| 829 | struct ab8500_platform_data *plat = dev_get_platdata(ab8500->dev); |
| 830 | int ret; |
| 831 | int i; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 832 | u8 value; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 833 | |
| 834 | if (plat) |
| 835 | ab8500->irq_base = plat->irq_base; |
| 836 | |
| 837 | mutex_init(&ab8500->lock); |
| 838 | mutex_init(&ab8500->irq_lock); |
| 839 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 840 | ret = get_register_interruptible(ab8500, AB8500_MISC, |
| 841 | AB8500_REV_REG, &value); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 842 | if (ret < 0) |
| 843 | return ret; |
| 844 | |
Linus Walleij | 863dde5 | 2011-05-08 00:54:45 +0200 | [diff] [blame] | 845 | switch (value) { |
| 846 | case AB8500_CUTEARLY: |
| 847 | case AB8500_CUT1P0: |
| 848 | case AB8500_CUT1P1: |
| 849 | case AB8500_CUT2P0: |
| 850 | case AB8500_CUT3P0: |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 851 | dev_info(ab8500->dev, "detected chip, revision: %#x\n", value); |
Linus Walleij | 863dde5 | 2011-05-08 00:54:45 +0200 | [diff] [blame] | 852 | break; |
| 853 | default: |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 854 | dev_err(ab8500->dev, "unknown chip, revision: %#x\n", value); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 855 | return -EINVAL; |
| 856 | } |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 857 | ab8500->chip_id = value; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 858 | |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 859 | /* |
| 860 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): |
| 861 | * 0x01 Swoff bit programming |
| 862 | * 0x02 Thermal protection activation |
| 863 | * 0x04 Vbat lower then BattOk falling threshold |
| 864 | * 0x08 Watchdog expired |
| 865 | * 0x10 Non presence of 32kHz clock |
| 866 | * 0x20 Battery level lower than power on reset threshold |
| 867 | * 0x40 Power on key 1 pressed longer than 10 seconds |
| 868 | * 0x80 DB8500 thermal shutdown |
| 869 | */ |
| 870 | |
| 871 | ret = get_register_interruptible(ab8500, AB8500_RTC, |
| 872 | AB8500_SWITCH_OFF_STATUS, &value); |
| 873 | if (ret < 0) |
| 874 | return ret; |
| 875 | dev_info(ab8500->dev, "switch off status: %#x", value); |
| 876 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 877 | if (plat && plat->init) |
| 878 | plat->init(ab8500); |
| 879 | |
| 880 | /* Clear and mask all interrupts */ |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 881 | for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) { |
Linus Walleij | 863dde5 | 2011-05-08 00:54:45 +0200 | [diff] [blame] | 882 | /* Interrupt register 12 doesn't exist prior to version 2.0 */ |
| 883 | if (ab8500_irq_regoffset[i] == 11 && |
| 884 | ab8500->chip_id < AB8500_CUT2P0) |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 885 | continue; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 886 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 887 | get_register_interruptible(ab8500, AB8500_INTERRUPT, |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 888 | AB8500_IT_LATCH1_REG + ab8500_irq_regoffset[i], |
| 889 | &value); |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 890 | set_register_interruptible(ab8500, AB8500_INTERRUPT, |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 891 | AB8500_IT_MASK1_REG + ab8500_irq_regoffset[i], 0xff); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 892 | } |
| 893 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 894 | ret = abx500_register_ops(ab8500->dev, &ab8500_ops); |
| 895 | if (ret) |
| 896 | return ret; |
| 897 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 898 | for (i = 0; i < AB8500_NUM_IRQ_REGS; i++) |
| 899 | ab8500->mask[i] = ab8500->oldmask[i] = 0xff; |
| 900 | |
| 901 | if (ab8500->irq_base) { |
| 902 | ret = ab8500_irq_init(ab8500); |
| 903 | if (ret) |
| 904 | return ret; |
| 905 | |
| 906 | ret = request_threaded_irq(ab8500->irq, NULL, ab8500_irq, |
Mattias Wallin | 4f07998 | 2010-12-02 15:10:27 +0100 | [diff] [blame] | 907 | IRQF_ONESHOT | IRQF_NO_SUSPEND, |
| 908 | "ab8500", ab8500); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 909 | if (ret) |
| 910 | goto out_removeirq; |
| 911 | } |
| 912 | |
Sundar R Iyer | 549931f | 2010-07-13 11:51:28 +0530 | [diff] [blame] | 913 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 914 | ARRAY_SIZE(ab8500_devs), NULL, |
| 915 | ab8500->irq_base); |
| 916 | if (ret) |
| 917 | goto out_freeirq; |
| 918 | |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 919 | ret = sysfs_create_group(&ab8500->dev->kobj, &ab8500_attr_group); |
| 920 | if (ret) |
| 921 | dev_err(ab8500->dev, "error creating sysfs entries\n"); |
| 922 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 923 | return ret; |
| 924 | |
| 925 | out_freeirq: |
| 926 | if (ab8500->irq_base) { |
| 927 | free_irq(ab8500->irq, ab8500); |
| 928 | out_removeirq: |
| 929 | ab8500_irq_remove(ab8500); |
| 930 | } |
| 931 | return ret; |
| 932 | } |
| 933 | |
| 934 | int __devexit ab8500_exit(struct ab8500 *ab8500) |
| 935 | { |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 936 | sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 937 | mfd_remove_devices(ab8500->dev); |
| 938 | if (ab8500->irq_base) { |
| 939 | free_irq(ab8500->irq, ab8500); |
| 940 | ab8500_irq_remove(ab8500); |
| 941 | } |
| 942 | |
| 943 | return 0; |
| 944 | } |
| 945 | |
Mattias Wallin | adceed6 | 2011-03-02 11:51:11 +0100 | [diff] [blame] | 946 | MODULE_AUTHOR("Mattias Wallin, Srinidhi Kasagar, Rabin Vincent"); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 947 | MODULE_DESCRIPTION("AB8500 MFD core"); |
| 948 | MODULE_LICENSE("GPL v2"); |