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> |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 14 | #include <linux/irqdomain.h> |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 15 | #include <linux/delay.h> |
| 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/mfd/core.h> |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 20 | #include <linux/mfd/abx500.h> |
Linus Walleij | ee66e65 | 2011-12-02 14:16:33 +0100 | [diff] [blame] | 21 | #include <linux/mfd/abx500/ab8500.h> |
Lee Jones | 00441b5 | 2013-01-09 10:06:03 +0000 | [diff] [blame] | 22 | #include <linux/mfd/abx500/ab8500-bm.h> |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 23 | #include <linux/mfd/dbx500-prcmu.h> |
Sundar R Iyer | 549931f | 2010-07-13 11:51:28 +0530 | [diff] [blame] | 24 | #include <linux/regulator/ab8500.h> |
Lee Jones | 6bc4a56 | 2012-05-17 14:45:13 +0100 | [diff] [blame] | 25 | #include <linux/of.h> |
| 26 | #include <linux/of_device.h> |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 27 | |
| 28 | /* |
| 29 | * Interrupt register offsets |
| 30 | * Bank : 0x0E |
| 31 | */ |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 32 | #define AB8500_IT_SOURCE1_REG 0x00 |
| 33 | #define AB8500_IT_SOURCE2_REG 0x01 |
| 34 | #define AB8500_IT_SOURCE3_REG 0x02 |
| 35 | #define AB8500_IT_SOURCE4_REG 0x03 |
| 36 | #define AB8500_IT_SOURCE5_REG 0x04 |
| 37 | #define AB8500_IT_SOURCE6_REG 0x05 |
| 38 | #define AB8500_IT_SOURCE7_REG 0x06 |
| 39 | #define AB8500_IT_SOURCE8_REG 0x07 |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 40 | #define AB9540_IT_SOURCE13_REG 0x0C |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 41 | #define AB8500_IT_SOURCE19_REG 0x12 |
| 42 | #define AB8500_IT_SOURCE20_REG 0x13 |
| 43 | #define AB8500_IT_SOURCE21_REG 0x14 |
| 44 | #define AB8500_IT_SOURCE22_REG 0x15 |
| 45 | #define AB8500_IT_SOURCE23_REG 0x16 |
| 46 | #define AB8500_IT_SOURCE24_REG 0x17 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | * latch registers |
| 50 | */ |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 51 | #define AB8500_IT_LATCH1_REG 0x20 |
| 52 | #define AB8500_IT_LATCH2_REG 0x21 |
| 53 | #define AB8500_IT_LATCH3_REG 0x22 |
| 54 | #define AB8500_IT_LATCH4_REG 0x23 |
| 55 | #define AB8500_IT_LATCH5_REG 0x24 |
| 56 | #define AB8500_IT_LATCH6_REG 0x25 |
| 57 | #define AB8500_IT_LATCH7_REG 0x26 |
| 58 | #define AB8500_IT_LATCH8_REG 0x27 |
| 59 | #define AB8500_IT_LATCH9_REG 0x28 |
| 60 | #define AB8500_IT_LATCH10_REG 0x29 |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 61 | #define AB8500_IT_LATCH12_REG 0x2B |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 62 | #define AB9540_IT_LATCH13_REG 0x2C |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 63 | #define AB8500_IT_LATCH19_REG 0x32 |
| 64 | #define AB8500_IT_LATCH20_REG 0x33 |
| 65 | #define AB8500_IT_LATCH21_REG 0x34 |
| 66 | #define AB8500_IT_LATCH22_REG 0x35 |
| 67 | #define AB8500_IT_LATCH23_REG 0x36 |
| 68 | #define AB8500_IT_LATCH24_REG 0x37 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * mask registers |
| 72 | */ |
| 73 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 74 | #define AB8500_IT_MASK1_REG 0x40 |
| 75 | #define AB8500_IT_MASK2_REG 0x41 |
| 76 | #define AB8500_IT_MASK3_REG 0x42 |
| 77 | #define AB8500_IT_MASK4_REG 0x43 |
| 78 | #define AB8500_IT_MASK5_REG 0x44 |
| 79 | #define AB8500_IT_MASK6_REG 0x45 |
| 80 | #define AB8500_IT_MASK7_REG 0x46 |
| 81 | #define AB8500_IT_MASK8_REG 0x47 |
| 82 | #define AB8500_IT_MASK9_REG 0x48 |
| 83 | #define AB8500_IT_MASK10_REG 0x49 |
| 84 | #define AB8500_IT_MASK11_REG 0x4A |
| 85 | #define AB8500_IT_MASK12_REG 0x4B |
| 86 | #define AB8500_IT_MASK13_REG 0x4C |
| 87 | #define AB8500_IT_MASK14_REG 0x4D |
| 88 | #define AB8500_IT_MASK15_REG 0x4E |
| 89 | #define AB8500_IT_MASK16_REG 0x4F |
| 90 | #define AB8500_IT_MASK17_REG 0x50 |
| 91 | #define AB8500_IT_MASK18_REG 0x51 |
| 92 | #define AB8500_IT_MASK19_REG 0x52 |
| 93 | #define AB8500_IT_MASK20_REG 0x53 |
| 94 | #define AB8500_IT_MASK21_REG 0x54 |
| 95 | #define AB8500_IT_MASK22_REG 0x55 |
| 96 | #define AB8500_IT_MASK23_REG 0x56 |
| 97 | #define AB8500_IT_MASK24_REG 0x57 |
Lee Jones | a29264b | 2013-02-25 14:34:26 +0000 | [diff] [blame] | 98 | #define AB8500_IT_MASK25_REG 0x58 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 99 | |
Michel JAOUEN | 7ccfe9b | 2012-05-07 15:02:03 +0200 | [diff] [blame] | 100 | /* |
| 101 | * latch hierarchy registers |
| 102 | */ |
| 103 | #define AB8500_IT_LATCHHIER1_REG 0x60 |
| 104 | #define AB8500_IT_LATCHHIER2_REG 0x61 |
| 105 | #define AB8500_IT_LATCHHIER3_REG 0x62 |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 106 | #define AB8540_IT_LATCHHIER4_REG 0x63 |
Michel JAOUEN | 7ccfe9b | 2012-05-07 15:02:03 +0200 | [diff] [blame] | 107 | |
| 108 | #define AB8500_IT_LATCHHIER_NUM 3 |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 109 | #define AB8540_IT_LATCHHIER_NUM 4 |
Michel JAOUEN | 7ccfe9b | 2012-05-07 15:02:03 +0200 | [diff] [blame] | 110 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 111 | #define AB8500_REV_REG 0x80 |
Linus Walleij | 0f620837 | 2012-02-20 21:42:10 +0100 | [diff] [blame] | 112 | #define AB8500_IC_NAME_REG 0x82 |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 113 | #define AB8500_SWITCH_OFF_STATUS 0x00 |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 114 | |
Andrew Lynn | b4a3103 | 2011-10-11 10:49:47 +0200 | [diff] [blame] | 115 | #define AB8500_TURN_ON_STATUS 0x00 |
| 116 | |
Rajkumar Kasirajan | f04a9d8 | 2012-05-30 16:32:37 +0530 | [diff] [blame] | 117 | #define AB8500_CH_USBCH_STAT1_REG 0x02 |
| 118 | #define VBUS_DET_DBNC100 0x02 |
| 119 | #define VBUS_DET_DBNC1 0x01 |
| 120 | |
| 121 | static DEFINE_SPINLOCK(on_stat_lock); |
| 122 | static u8 turn_on_stat_mask = 0xFF; |
| 123 | static u8 turn_on_stat_set; |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 124 | static bool no_bm; /* No battery management */ |
| 125 | module_param(no_bm, bool, S_IRUGO); |
| 126 | |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 127 | #define AB9540_MODEM_CTRL2_REG 0x23 |
| 128 | #define AB9540_MODEM_CTRL2_SWDBBRSTN_BIT BIT(2) |
| 129 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 130 | /* |
| 131 | * Map interrupt numbers to the LATCH and MASK register offsets, Interrupt |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 132 | * numbers are indexed into this array with (num / 8). The interupts are |
| 133 | * defined in linux/mfd/ab8500.h |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 134 | * |
| 135 | * This is one off from the register names, i.e. AB8500_IT_MASK1_REG is at |
| 136 | * offset 0. |
| 137 | */ |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 138 | /* AB8500 support */ |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 139 | static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = { |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 140 | 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] | 141 | }; |
| 142 | |
Lee Jones | a29264b | 2013-02-25 14:34:26 +0000 | [diff] [blame] | 143 | /* AB9540 / AB8505 support */ |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 144 | static const int ab9540_irq_regoffset[AB9540_NUM_IRQ_REGS] = { |
Lee Jones | a29264b | 2013-02-25 14:34:26 +0000 | [diff] [blame] | 145 | 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 18, 19, 20, 21, 12, 13, 24, 5, 22, 23 |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 146 | }; |
| 147 | |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 148 | /* AB8540 support */ |
| 149 | static const int ab8540_irq_regoffset[AB8540_NUM_IRQ_REGS] = { |
| 150 | 0, 1, 2, 3, 4, -1, -1, -1, -1, 11, 18, 19, 20, 21, 12, 13, 24, 5, 22, 23, |
| 151 | 25, 26, 27, 28, 29, 30, 31, |
| 152 | }; |
| 153 | |
Linus Walleij | 0f620837 | 2012-02-20 21:42:10 +0100 | [diff] [blame] | 154 | static const char ab8500_version_str[][7] = { |
| 155 | [AB8500_VERSION_AB8500] = "AB8500", |
| 156 | [AB8500_VERSION_AB8505] = "AB8505", |
| 157 | [AB8500_VERSION_AB9540] = "AB9540", |
| 158 | [AB8500_VERSION_AB8540] = "AB8540", |
| 159 | }; |
| 160 | |
Lee Jones | 822672a | 2012-06-20 13:56:38 +0100 | [diff] [blame] | 161 | static int ab8500_prcmu_write(struct ab8500 *ab8500, u16 addr, u8 data) |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 162 | { |
| 163 | int ret; |
| 164 | |
| 165 | ret = prcmu_abb_write((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1); |
| 166 | if (ret < 0) |
| 167 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); |
| 168 | return ret; |
| 169 | } |
| 170 | |
Lee Jones | 822672a | 2012-06-20 13:56:38 +0100 | [diff] [blame] | 171 | static int ab8500_prcmu_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask, |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 172 | u8 data) |
| 173 | { |
| 174 | int ret; |
| 175 | |
| 176 | ret = prcmu_abb_write_masked((u8)(addr >> 8), (u8)(addr & 0xFF), &data, |
| 177 | &mask, 1); |
| 178 | if (ret < 0) |
| 179 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); |
| 180 | return ret; |
| 181 | } |
| 182 | |
Lee Jones | 822672a | 2012-06-20 13:56:38 +0100 | [diff] [blame] | 183 | static int ab8500_prcmu_read(struct ab8500 *ab8500, u16 addr) |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 184 | { |
| 185 | int ret; |
| 186 | u8 data; |
| 187 | |
| 188 | ret = prcmu_abb_read((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1); |
| 189 | if (ret < 0) { |
| 190 | dev_err(ab8500->dev, "prcmu i2c error %d\n", ret); |
| 191 | return ret; |
| 192 | } |
| 193 | return (int)data; |
| 194 | } |
| 195 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 196 | static int ab8500_get_chip_id(struct device *dev) |
| 197 | { |
Mattias Wallin | 6bce7bf | 2010-12-02 15:08:32 +0100 | [diff] [blame] | 198 | struct ab8500 *ab8500; |
| 199 | |
| 200 | if (!dev) |
| 201 | return -EINVAL; |
| 202 | ab8500 = dev_get_drvdata(dev->parent); |
| 203 | return ab8500 ? (int)ab8500->chip_id : -EINVAL; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | static int set_register_interruptible(struct ab8500 *ab8500, u8 bank, |
| 207 | u8 reg, u8 data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 208 | { |
| 209 | int ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 210 | /* |
| 211 | * Put the u8 bank and u8 register together into a an u16. |
| 212 | * The bank on higher 8 bits and register in lower 8 bits. |
| 213 | * */ |
| 214 | u16 addr = ((u16)bank) << 8 | reg; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 215 | |
| 216 | dev_vdbg(ab8500->dev, "wr: addr %#x <= %#x\n", addr, data); |
| 217 | |
Rabin Vincent | 392cbd1 | 2012-03-08 14:01:46 +0100 | [diff] [blame] | 218 | mutex_lock(&ab8500->lock); |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 219 | |
| 220 | ret = ab8500->write(ab8500, addr, data); |
| 221 | if (ret < 0) |
| 222 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", |
| 223 | addr, ret); |
| 224 | mutex_unlock(&ab8500->lock); |
| 225 | |
| 226 | return ret; |
| 227 | } |
| 228 | |
| 229 | static int ab8500_set_register(struct device *dev, u8 bank, |
| 230 | u8 reg, u8 value) |
| 231 | { |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 232 | int ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 233 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
| 234 | |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 235 | atomic_inc(&ab8500->transfer_ongoing); |
| 236 | ret = set_register_interruptible(ab8500, bank, reg, value); |
| 237 | atomic_dec(&ab8500->transfer_ongoing); |
| 238 | return ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | static int get_register_interruptible(struct ab8500 *ab8500, u8 bank, |
| 242 | u8 reg, u8 *value) |
| 243 | { |
| 244 | int ret; |
| 245 | /* put the u8 bank and u8 reg together into a an u16. |
| 246 | * bank on higher 8 bits and reg in lower */ |
| 247 | u16 addr = ((u16)bank) << 8 | reg; |
| 248 | |
Rabin Vincent | 392cbd1 | 2012-03-08 14:01:46 +0100 | [diff] [blame] | 249 | mutex_lock(&ab8500->lock); |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 250 | |
| 251 | ret = ab8500->read(ab8500, addr); |
| 252 | if (ret < 0) |
| 253 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", |
| 254 | addr, ret); |
| 255 | else |
| 256 | *value = ret; |
| 257 | |
| 258 | mutex_unlock(&ab8500->lock); |
| 259 | dev_vdbg(ab8500->dev, "rd: addr %#x => data %#x\n", addr, ret); |
| 260 | |
| 261 | return ret; |
| 262 | } |
| 263 | |
| 264 | static int ab8500_get_register(struct device *dev, u8 bank, |
| 265 | u8 reg, u8 *value) |
| 266 | { |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 267 | int ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 268 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
| 269 | |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 270 | atomic_inc(&ab8500->transfer_ongoing); |
| 271 | ret = get_register_interruptible(ab8500, bank, reg, value); |
| 272 | atomic_dec(&ab8500->transfer_ongoing); |
| 273 | return ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | static int mask_and_set_register_interruptible(struct ab8500 *ab8500, u8 bank, |
| 277 | u8 reg, u8 bitmask, u8 bitvalues) |
| 278 | { |
| 279 | int ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 280 | /* put the u8 bank and u8 reg together into a an u16. |
| 281 | * bank on higher 8 bits and reg in lower */ |
| 282 | u16 addr = ((u16)bank) << 8 | reg; |
| 283 | |
Rabin Vincent | 392cbd1 | 2012-03-08 14:01:46 +0100 | [diff] [blame] | 284 | mutex_lock(&ab8500->lock); |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 285 | |
Mattias Nilsson | bc628fd | 2012-03-08 14:02:20 +0100 | [diff] [blame] | 286 | if (ab8500->write_masked == NULL) { |
| 287 | u8 data; |
| 288 | |
| 289 | ret = ab8500->read(ab8500, addr); |
| 290 | if (ret < 0) { |
| 291 | dev_err(ab8500->dev, "failed to read reg %#x: %d\n", |
| 292 | addr, ret); |
| 293 | goto out; |
| 294 | } |
| 295 | |
| 296 | data = (u8)ret; |
| 297 | data = (~bitmask & data) | (bitmask & bitvalues); |
| 298 | |
| 299 | ret = ab8500->write(ab8500, addr, data); |
| 300 | if (ret < 0) |
| 301 | dev_err(ab8500->dev, "failed to write reg %#x: %d\n", |
| 302 | addr, ret); |
| 303 | |
| 304 | dev_vdbg(ab8500->dev, "mask: addr %#x => data %#x\n", addr, |
| 305 | data); |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 306 | goto out; |
| 307 | } |
Mattias Nilsson | bc628fd | 2012-03-08 14:02:20 +0100 | [diff] [blame] | 308 | ret = ab8500->write_masked(ab8500, addr, bitmask, bitvalues); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 309 | if (ret < 0) |
Mattias Nilsson | bc628fd | 2012-03-08 14:02:20 +0100 | [diff] [blame] | 310 | dev_err(ab8500->dev, "failed to modify reg %#x: %d\n", addr, |
| 311 | ret); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 312 | out: |
| 313 | mutex_unlock(&ab8500->lock); |
| 314 | return ret; |
| 315 | } |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 316 | |
| 317 | static int ab8500_mask_and_set_register(struct device *dev, |
| 318 | u8 bank, u8 reg, u8 bitmask, u8 bitvalues) |
| 319 | { |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 320 | int ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 321 | struct ab8500 *ab8500 = dev_get_drvdata(dev->parent); |
| 322 | |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 323 | atomic_inc(&ab8500->transfer_ongoing); |
| 324 | ret= mask_and_set_register_interruptible(ab8500, bank, reg, |
| 325 | bitmask, bitvalues); |
| 326 | atomic_dec(&ab8500->transfer_ongoing); |
| 327 | return ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | static struct abx500_ops ab8500_ops = { |
| 331 | .get_chip_id = ab8500_get_chip_id, |
| 332 | .get_register = ab8500_get_register, |
| 333 | .set_register = ab8500_set_register, |
| 334 | .get_register_page = NULL, |
| 335 | .set_register_page = NULL, |
| 336 | .mask_and_set_register = ab8500_mask_and_set_register, |
| 337 | .event_registers_startup_state_get = NULL, |
| 338 | .startup_irq_enabled = NULL, |
Mian Yousaf Kaukab | 1d843a6 | 2012-01-27 11:35:41 +0100 | [diff] [blame] | 339 | .dump_all_banks = ab8500_dump_all_banks, |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 340 | }; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 341 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 342 | static void ab8500_irq_lock(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 343 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 344 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 345 | |
| 346 | mutex_lock(&ab8500->irq_lock); |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 347 | atomic_inc(&ab8500->transfer_ongoing); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 348 | } |
| 349 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 350 | static void ab8500_irq_sync_unlock(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 351 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 352 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 353 | int i; |
| 354 | |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 355 | for (i = 0; i < ab8500->mask_size; i++) { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 356 | u8 old = ab8500->oldmask[i]; |
| 357 | u8 new = ab8500->mask[i]; |
| 358 | int reg; |
| 359 | |
| 360 | if (new == old) |
| 361 | continue; |
| 362 | |
Linus Walleij | 0f620837 | 2012-02-20 21:42:10 +0100 | [diff] [blame] | 363 | /* |
| 364 | * Interrupt register 12 doesn't exist prior to AB8500 version |
| 365 | * 2.0 |
| 366 | */ |
| 367 | if (ab8500->irq_reg_offset[i] == 11 && |
| 368 | is_ab8500_1p1_or_earlier(ab8500)) |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 369 | continue; |
| 370 | |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 371 | if (ab8500->irq_reg_offset[i] < 0) |
| 372 | continue; |
| 373 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 374 | ab8500->oldmask[i] = new; |
| 375 | |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 376 | reg = AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i]; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 377 | set_register_interruptible(ab8500, AB8500_INTERRUPT, reg, new); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 378 | } |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 379 | atomic_dec(&ab8500->transfer_ongoing); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 380 | mutex_unlock(&ab8500->irq_lock); |
| 381 | } |
| 382 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 383 | static void ab8500_irq_mask(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 384 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 385 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 386 | int offset = data->hwirq; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 387 | int index = offset / 8; |
| 388 | int mask = 1 << (offset % 8); |
| 389 | |
| 390 | ab8500->mask[index] |= mask; |
Lee Jones | 9c677b9 | 2012-12-20 11:23:42 +0000 | [diff] [blame] | 391 | |
| 392 | /* The AB8500 GPIOs have two interrupts each (rising & falling). */ |
| 393 | if (offset >= AB8500_INT_GPIO6R && offset <= AB8500_INT_GPIO41R) |
| 394 | ab8500->mask[index + 2] |= mask; |
| 395 | if (offset >= AB9540_INT_GPIO50R && offset <= AB9540_INT_GPIO54R) |
| 396 | ab8500->mask[index + 1] |= mask; |
| 397 | if (offset == AB8540_INT_GPIO43R || offset == AB8540_INT_GPIO44R) |
Linus Walleij | e2ddf46 | 2013-02-06 21:54:34 +0100 | [diff] [blame] | 398 | /* Here the falling IRQ is one bit lower */ |
| 399 | ab8500->mask[index] |= (mask << 1); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 400 | } |
| 401 | |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 402 | static void ab8500_irq_unmask(struct irq_data *data) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 403 | { |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 404 | struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); |
Lee Jones | 9c677b9 | 2012-12-20 11:23:42 +0000 | [diff] [blame] | 405 | unsigned int type = irqd_get_trigger_type(data); |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 406 | int offset = data->hwirq; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 407 | int index = offset / 8; |
| 408 | int mask = 1 << (offset % 8); |
| 409 | |
Lee Jones | 9c677b9 | 2012-12-20 11:23:42 +0000 | [diff] [blame] | 410 | if (type & IRQ_TYPE_EDGE_RISING) |
| 411 | ab8500->mask[index] &= ~mask; |
| 412 | |
| 413 | /* The AB8500 GPIOs have two interrupts each (rising & falling). */ |
| 414 | if (type & IRQ_TYPE_EDGE_FALLING) { |
| 415 | if (offset >= AB8500_INT_GPIO6R && offset <= AB8500_INT_GPIO41R) |
| 416 | ab8500->mask[index + 2] &= ~mask; |
| 417 | else if (offset >= AB9540_INT_GPIO50R && offset <= AB9540_INT_GPIO54R) |
| 418 | ab8500->mask[index + 1] &= ~mask; |
| 419 | else if (offset == AB8540_INT_GPIO43R || offset == AB8540_INT_GPIO44R) |
Linus Walleij | e2ddf46 | 2013-02-06 21:54:34 +0100 | [diff] [blame] | 420 | /* Here the falling IRQ is one bit lower */ |
| 421 | ab8500->mask[index] &= ~(mask << 1); |
Lee Jones | 9c677b9 | 2012-12-20 11:23:42 +0000 | [diff] [blame] | 422 | else |
| 423 | ab8500->mask[index] &= ~mask; |
Linus Walleij | e2ddf46 | 2013-02-06 21:54:34 +0100 | [diff] [blame] | 424 | } else { |
Lee Jones | 9c677b9 | 2012-12-20 11:23:42 +0000 | [diff] [blame] | 425 | /* Satisfies the case where type is not set. */ |
| 426 | ab8500->mask[index] &= ~mask; |
Linus Walleij | e2ddf46 | 2013-02-06 21:54:34 +0100 | [diff] [blame] | 427 | } |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 428 | } |
| 429 | |
Lee Jones | 40f6e5a | 2013-01-07 12:23:48 +0000 | [diff] [blame] | 430 | static int ab8500_irq_set_type(struct irq_data *data, unsigned int type) |
| 431 | { |
| 432 | return 0; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | static struct irq_chip ab8500_irq_chip = { |
| 436 | .name = "ab8500", |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 437 | .irq_bus_lock = ab8500_irq_lock, |
| 438 | .irq_bus_sync_unlock = ab8500_irq_sync_unlock, |
| 439 | .irq_mask = ab8500_irq_mask, |
Virupax Sadashivpetimath | e6f9306 | 2011-10-11 10:49:17 +0200 | [diff] [blame] | 440 | .irq_disable = ab8500_irq_mask, |
Mark Brown | 9505a0a | 2010-12-11 13:16:08 +0000 | [diff] [blame] | 441 | .irq_unmask = ab8500_irq_unmask, |
Lee Jones | 40f6e5a | 2013-01-07 12:23:48 +0000 | [diff] [blame] | 442 | .irq_set_type = ab8500_irq_set_type, |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 443 | }; |
| 444 | |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 445 | static void update_latch_offset(u8 *offset, int i) |
| 446 | { |
| 447 | /* Fix inconsistent ITFromLatch25 bit mapping... */ |
| 448 | if (unlikely(*offset == 17)) |
| 449 | *offset = 24; |
| 450 | /* Fix inconsistent ab8540 bit mapping... */ |
| 451 | if (unlikely(*offset == 16)) |
| 452 | *offset = 25; |
| 453 | if ((i==3) && (*offset >= 24)) |
| 454 | *offset += 2; |
| 455 | } |
| 456 | |
Michel JAOUEN | 7ccfe9b | 2012-05-07 15:02:03 +0200 | [diff] [blame] | 457 | static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500, |
| 458 | int latch_offset, u8 latch_val) |
| 459 | { |
| 460 | int int_bit = __ffs(latch_val); |
| 461 | int line, i; |
| 462 | |
| 463 | do { |
| 464 | int_bit = __ffs(latch_val); |
| 465 | |
| 466 | for (i = 0; i < ab8500->mask_size; i++) |
| 467 | if (ab8500->irq_reg_offset[i] == latch_offset) |
| 468 | break; |
| 469 | |
| 470 | if (i >= ab8500->mask_size) { |
| 471 | dev_err(ab8500->dev, "Register offset 0x%2x not declared\n", |
| 472 | latch_offset); |
| 473 | return -ENXIO; |
| 474 | } |
| 475 | |
| 476 | line = (i << 3) + int_bit; |
| 477 | latch_val &= ~(1 << int_bit); |
| 478 | |
Linus Walleij | e2ddf46 | 2013-02-06 21:54:34 +0100 | [diff] [blame] | 479 | /* |
| 480 | * This handles the falling edge hwirqs from the GPIO |
| 481 | * lines. Route them back to the line registered for the |
| 482 | * rising IRQ, as this is merely a flag for the same IRQ |
| 483 | * in linux terms. |
| 484 | */ |
| 485 | if (line >= AB8500_INT_GPIO6F && line <= AB8500_INT_GPIO41F) |
| 486 | line -= 16; |
| 487 | if (line >= AB9540_INT_GPIO50F && line <= AB9540_INT_GPIO54F) |
| 488 | line -= 8; |
| 489 | if (line == AB8540_INT_GPIO43F || line == AB8540_INT_GPIO44F) |
| 490 | line += 1; |
| 491 | |
Michel JAOUEN | 7ccfe9b | 2012-05-07 15:02:03 +0200 | [diff] [blame] | 492 | handle_nested_irq(ab8500->irq_base + line); |
| 493 | } while (latch_val); |
| 494 | |
| 495 | return 0; |
| 496 | } |
| 497 | |
| 498 | static int ab8500_handle_hierarchical_latch(struct ab8500 *ab8500, |
| 499 | int hier_offset, u8 hier_val) |
| 500 | { |
| 501 | int latch_bit, status; |
| 502 | u8 latch_offset, latch_val; |
| 503 | |
| 504 | do { |
| 505 | latch_bit = __ffs(hier_val); |
| 506 | latch_offset = (hier_offset << 3) + latch_bit; |
| 507 | |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 508 | update_latch_offset(&latch_offset, hier_offset); |
Michel JAOUEN | 7ccfe9b | 2012-05-07 15:02:03 +0200 | [diff] [blame] | 509 | |
| 510 | status = get_register_interruptible(ab8500, |
| 511 | AB8500_INTERRUPT, |
| 512 | AB8500_IT_LATCH1_REG + latch_offset, |
| 513 | &latch_val); |
| 514 | if (status < 0 || latch_val == 0) |
| 515 | goto discard; |
| 516 | |
| 517 | status = ab8500_handle_hierarchical_line(ab8500, |
| 518 | latch_offset, latch_val); |
| 519 | if (status < 0) |
| 520 | return status; |
| 521 | discard: |
| 522 | hier_val &= ~(1 << latch_bit); |
| 523 | } while (hier_val); |
| 524 | |
| 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | static irqreturn_t ab8500_hierarchical_irq(int irq, void *dev) |
| 529 | { |
| 530 | struct ab8500 *ab8500 = dev; |
| 531 | u8 i; |
| 532 | |
| 533 | dev_vdbg(ab8500->dev, "interrupt\n"); |
| 534 | |
| 535 | /* Hierarchical interrupt version */ |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 536 | for (i = 0; i < (ab8500->it_latchhier_num); i++) { |
Michel JAOUEN | 7ccfe9b | 2012-05-07 15:02:03 +0200 | [diff] [blame] | 537 | int status; |
| 538 | u8 hier_val; |
| 539 | |
| 540 | status = get_register_interruptible(ab8500, AB8500_INTERRUPT, |
| 541 | AB8500_IT_LATCHHIER1_REG + i, &hier_val); |
| 542 | if (status < 0 || hier_val == 0) |
| 543 | continue; |
| 544 | |
| 545 | status = ab8500_handle_hierarchical_latch(ab8500, i, hier_val); |
| 546 | if (status < 0) |
| 547 | break; |
| 548 | } |
| 549 | return IRQ_HANDLED; |
| 550 | } |
| 551 | |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 552 | static int ab8500_irq_map(struct irq_domain *d, unsigned int virq, |
| 553 | irq_hw_number_t hwirq) |
| 554 | { |
| 555 | struct ab8500 *ab8500 = d->host_data; |
| 556 | |
| 557 | if (!ab8500) |
| 558 | return -EINVAL; |
| 559 | |
| 560 | irq_set_chip_data(virq, ab8500); |
| 561 | irq_set_chip_and_handler(virq, &ab8500_irq_chip, |
| 562 | handle_simple_irq); |
| 563 | irq_set_nested_thread(virq, 1); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 564 | #ifdef CONFIG_ARM |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 565 | set_irq_flags(virq, IRQF_VALID); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 566 | #else |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 567 | irq_set_noprobe(virq); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 568 | #endif |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 569 | |
| 570 | return 0; |
| 571 | } |
| 572 | |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 573 | static struct irq_domain_ops ab8500_irq_ops = { |
| 574 | .map = ab8500_irq_map, |
| 575 | .xlate = irq_domain_xlate_twocell, |
| 576 | }; |
| 577 | |
| 578 | static int ab8500_irq_init(struct ab8500 *ab8500, struct device_node *np) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 579 | { |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 580 | int num_irqs; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 581 | |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 582 | if (is_ab8540(ab8500)) |
| 583 | num_irqs = AB8540_NR_IRQS; |
| 584 | else if (is_ab9540(ab8500)) |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 585 | num_irqs = AB9540_NR_IRQS; |
Bengt Jonsson | a982362 | 2012-03-08 14:01:57 +0100 | [diff] [blame] | 586 | else if (is_ab8505(ab8500)) |
| 587 | num_irqs = AB8505_NR_IRQS; |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 588 | else |
| 589 | num_irqs = AB8500_NR_IRQS; |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 590 | |
Linus Walleij | f1d11f3 | 2012-10-18 18:18:44 +0200 | [diff] [blame] | 591 | /* If ->irq_base is zero this will give a linear mapping */ |
| 592 | ab8500->domain = irq_domain_add_simple(NULL, |
| 593 | num_irqs, ab8500->irq_base, |
| 594 | &ab8500_irq_ops, ab8500); |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 595 | |
| 596 | if (!ab8500->domain) { |
| 597 | dev_err(ab8500->dev, "Failed to create irqdomain\n"); |
| 598 | return -ENOSYS; |
| 599 | } |
| 600 | |
| 601 | return 0; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 602 | } |
| 603 | |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 604 | int ab8500_suspend(struct ab8500 *ab8500) |
| 605 | { |
| 606 | if (atomic_read(&ab8500->transfer_ongoing)) |
| 607 | return -EINVAL; |
| 608 | else |
| 609 | return 0; |
| 610 | } |
| 611 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 612 | static struct resource ab8500_gpadc_resources[] = { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 613 | { |
| 614 | .name = "HW_CONV_END", |
| 615 | .start = AB8500_INT_GP_HW_ADC_CONV_END, |
| 616 | .end = AB8500_INT_GP_HW_ADC_CONV_END, |
| 617 | .flags = IORESOURCE_IRQ, |
| 618 | }, |
| 619 | { |
| 620 | .name = "SW_CONV_END", |
| 621 | .start = AB8500_INT_GP_SW_ADC_CONV_END, |
| 622 | .end = AB8500_INT_GP_SW_ADC_CONV_END, |
| 623 | .flags = IORESOURCE_IRQ, |
| 624 | }, |
| 625 | }; |
| 626 | |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 627 | static struct resource ab8505_gpadc_resources[] = { |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 628 | { |
| 629 | .name = "SW_CONV_END", |
| 630 | .start = AB8500_INT_GP_SW_ADC_CONV_END, |
| 631 | .end = AB8500_INT_GP_SW_ADC_CONV_END, |
| 632 | .flags = IORESOURCE_IRQ, |
| 633 | }, |
| 634 | }; |
| 635 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 636 | static struct resource ab8500_rtc_resources[] = { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 637 | { |
| 638 | .name = "60S", |
| 639 | .start = AB8500_INT_RTC_60S, |
| 640 | .end = AB8500_INT_RTC_60S, |
| 641 | .flags = IORESOURCE_IRQ, |
| 642 | }, |
| 643 | { |
| 644 | .name = "ALARM", |
| 645 | .start = AB8500_INT_RTC_ALARM, |
| 646 | .end = AB8500_INT_RTC_ALARM, |
| 647 | .flags = IORESOURCE_IRQ, |
| 648 | }, |
| 649 | }; |
| 650 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 651 | static struct resource ab8500_poweronkey_db_resources[] = { |
Sundar R Iyer | 7768651 | 2010-09-05 12:18:47 -0700 | [diff] [blame] | 652 | { |
| 653 | .name = "ONKEY_DBF", |
| 654 | .start = AB8500_INT_PON_KEY1DB_F, |
| 655 | .end = AB8500_INT_PON_KEY1DB_F, |
| 656 | .flags = IORESOURCE_IRQ, |
| 657 | }, |
| 658 | { |
| 659 | .name = "ONKEY_DBR", |
| 660 | .start = AB8500_INT_PON_KEY1DB_R, |
| 661 | .end = AB8500_INT_PON_KEY1DB_R, |
| 662 | .flags = IORESOURCE_IRQ, |
| 663 | }, |
| 664 | }; |
| 665 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 666 | static struct resource ab8500_av_acc_detect_resources[] = { |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 667 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 668 | .name = "ACC_DETECT_1DB_F", |
| 669 | .start = AB8500_INT_ACC_DETECT_1DB_F, |
| 670 | .end = AB8500_INT_ACC_DETECT_1DB_F, |
| 671 | .flags = IORESOURCE_IRQ, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 672 | }, |
| 673 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 674 | .name = "ACC_DETECT_1DB_R", |
| 675 | .start = AB8500_INT_ACC_DETECT_1DB_R, |
| 676 | .end = AB8500_INT_ACC_DETECT_1DB_R, |
| 677 | .flags = IORESOURCE_IRQ, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 678 | }, |
| 679 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 680 | .name = "ACC_DETECT_21DB_F", |
| 681 | .start = AB8500_INT_ACC_DETECT_21DB_F, |
| 682 | .end = AB8500_INT_ACC_DETECT_21DB_F, |
| 683 | .flags = IORESOURCE_IRQ, |
| 684 | }, |
| 685 | { |
| 686 | .name = "ACC_DETECT_21DB_R", |
| 687 | .start = AB8500_INT_ACC_DETECT_21DB_R, |
| 688 | .end = AB8500_INT_ACC_DETECT_21DB_R, |
| 689 | .flags = IORESOURCE_IRQ, |
| 690 | }, |
| 691 | { |
| 692 | .name = "ACC_DETECT_22DB_F", |
| 693 | .start = AB8500_INT_ACC_DETECT_22DB_F, |
| 694 | .end = AB8500_INT_ACC_DETECT_22DB_F, |
| 695 | .flags = IORESOURCE_IRQ, |
| 696 | }, |
| 697 | { |
| 698 | .name = "ACC_DETECT_22DB_R", |
| 699 | .start = AB8500_INT_ACC_DETECT_22DB_R, |
| 700 | .end = AB8500_INT_ACC_DETECT_22DB_R, |
| 701 | .flags = IORESOURCE_IRQ, |
| 702 | }, |
| 703 | }; |
| 704 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 705 | static struct resource ab8500_charger_resources[] = { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 706 | { |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 707 | .name = "MAIN_CH_UNPLUG_DET", |
| 708 | .start = AB8500_INT_MAIN_CH_UNPLUG_DET, |
| 709 | .end = AB8500_INT_MAIN_CH_UNPLUG_DET, |
| 710 | .flags = IORESOURCE_IRQ, |
| 711 | }, |
| 712 | { |
| 713 | .name = "MAIN_CHARGE_PLUG_DET", |
| 714 | .start = AB8500_INT_MAIN_CH_PLUG_DET, |
| 715 | .end = AB8500_INT_MAIN_CH_PLUG_DET, |
| 716 | .flags = IORESOURCE_IRQ, |
| 717 | }, |
| 718 | { |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 719 | .name = "VBUS_DET_R", |
| 720 | .start = AB8500_INT_VBUS_DET_R, |
| 721 | .end = AB8500_INT_VBUS_DET_R, |
| 722 | .flags = IORESOURCE_IRQ, |
| 723 | }, |
| 724 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 725 | .name = "VBUS_DET_F", |
| 726 | .start = AB8500_INT_VBUS_DET_F, |
| 727 | .end = AB8500_INT_VBUS_DET_F, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 728 | .flags = IORESOURCE_IRQ, |
| 729 | }, |
| 730 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 731 | .name = "USB_LINK_STATUS", |
| 732 | .start = AB8500_INT_USB_LINK_STATUS, |
| 733 | .end = AB8500_INT_USB_LINK_STATUS, |
| 734 | .flags = IORESOURCE_IRQ, |
| 735 | }, |
| 736 | { |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 737 | .name = "VBUS_OVV", |
| 738 | .start = AB8500_INT_VBUS_OVV, |
| 739 | .end = AB8500_INT_VBUS_OVV, |
| 740 | .flags = IORESOURCE_IRQ, |
| 741 | }, |
| 742 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 743 | .name = "USB_CH_TH_PROT_R", |
| 744 | .start = AB8500_INT_USB_CH_TH_PROT_R, |
| 745 | .end = AB8500_INT_USB_CH_TH_PROT_R, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 746 | .flags = IORESOURCE_IRQ, |
| 747 | }, |
| 748 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 749 | .name = "USB_CH_TH_PROT_F", |
| 750 | .start = AB8500_INT_USB_CH_TH_PROT_F, |
| 751 | .end = AB8500_INT_USB_CH_TH_PROT_F, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 752 | .flags = IORESOURCE_IRQ, |
| 753 | }, |
| 754 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 755 | .name = "MAIN_EXT_CH_NOT_OK", |
| 756 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 757 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 758 | .flags = IORESOURCE_IRQ, |
| 759 | }, |
| 760 | { |
| 761 | .name = "MAIN_CH_TH_PROT_R", |
| 762 | .start = AB8500_INT_MAIN_CH_TH_PROT_R, |
| 763 | .end = AB8500_INT_MAIN_CH_TH_PROT_R, |
| 764 | .flags = IORESOURCE_IRQ, |
| 765 | }, |
| 766 | { |
| 767 | .name = "MAIN_CH_TH_PROT_F", |
| 768 | .start = AB8500_INT_MAIN_CH_TH_PROT_F, |
| 769 | .end = AB8500_INT_MAIN_CH_TH_PROT_F, |
| 770 | .flags = IORESOURCE_IRQ, |
| 771 | }, |
| 772 | { |
| 773 | .name = "USB_CHARGER_NOT_OKR", |
Bengt Jonsson | a982362 | 2012-03-08 14:01:57 +0100 | [diff] [blame] | 774 | .start = AB8500_INT_USB_CHARGER_NOT_OKR, |
| 775 | .end = AB8500_INT_USB_CHARGER_NOT_OKR, |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 776 | .flags = IORESOURCE_IRQ, |
| 777 | }, |
| 778 | { |
| 779 | .name = "CH_WD_EXP", |
| 780 | .start = AB8500_INT_CH_WD_EXP, |
| 781 | .end = AB8500_INT_CH_WD_EXP, |
| 782 | .flags = IORESOURCE_IRQ, |
| 783 | }, |
Paer-Olof Haakansson | 34c11a7 | 2012-02-22 19:07:51 +0100 | [diff] [blame] | 784 | { |
| 785 | .name = "VBUS_CH_DROP_END", |
| 786 | .start = AB8500_INT_VBUS_CH_DROP_END, |
| 787 | .end = AB8500_INT_VBUS_CH_DROP_END, |
| 788 | .flags = IORESOURCE_IRQ, |
| 789 | }, |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 790 | }; |
| 791 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 792 | static struct resource ab8500_btemp_resources[] = { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 793 | { |
| 794 | .name = "BAT_CTRL_INDB", |
| 795 | .start = AB8500_INT_BAT_CTRL_INDB, |
| 796 | .end = AB8500_INT_BAT_CTRL_INDB, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 797 | .flags = IORESOURCE_IRQ, |
| 798 | }, |
| 799 | { |
| 800 | .name = "BTEMP_LOW", |
| 801 | .start = AB8500_INT_BTEMP_LOW, |
| 802 | .end = AB8500_INT_BTEMP_LOW, |
| 803 | .flags = IORESOURCE_IRQ, |
| 804 | }, |
| 805 | { |
| 806 | .name = "BTEMP_HIGH", |
| 807 | .start = AB8500_INT_BTEMP_HIGH, |
| 808 | .end = AB8500_INT_BTEMP_HIGH, |
| 809 | .flags = IORESOURCE_IRQ, |
| 810 | }, |
| 811 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 812 | .name = "BTEMP_LOW_MEDIUM", |
| 813 | .start = AB8500_INT_BTEMP_LOW_MEDIUM, |
| 814 | .end = AB8500_INT_BTEMP_LOW_MEDIUM, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 815 | .flags = IORESOURCE_IRQ, |
| 816 | }, |
| 817 | { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 818 | .name = "BTEMP_MEDIUM_HIGH", |
| 819 | .start = AB8500_INT_BTEMP_MEDIUM_HIGH, |
| 820 | .end = AB8500_INT_BTEMP_MEDIUM_HIGH, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 821 | .flags = IORESOURCE_IRQ, |
| 822 | }, |
| 823 | }; |
| 824 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 825 | static struct resource ab8500_fg_resources[] = { |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 826 | { |
| 827 | .name = "NCONV_ACCU", |
| 828 | .start = AB8500_INT_CCN_CONV_ACC, |
| 829 | .end = AB8500_INT_CCN_CONV_ACC, |
| 830 | .flags = IORESOURCE_IRQ, |
| 831 | }, |
| 832 | { |
| 833 | .name = "BATT_OVV", |
| 834 | .start = AB8500_INT_BATT_OVV, |
| 835 | .end = AB8500_INT_BATT_OVV, |
| 836 | .flags = IORESOURCE_IRQ, |
| 837 | }, |
| 838 | { |
| 839 | .name = "LOW_BAT_F", |
| 840 | .start = AB8500_INT_LOW_BAT_F, |
| 841 | .end = AB8500_INT_LOW_BAT_F, |
| 842 | .flags = IORESOURCE_IRQ, |
| 843 | }, |
| 844 | { |
| 845 | .name = "LOW_BAT_R", |
| 846 | .start = AB8500_INT_LOW_BAT_R, |
| 847 | .end = AB8500_INT_LOW_BAT_R, |
| 848 | .flags = IORESOURCE_IRQ, |
| 849 | }, |
| 850 | { |
| 851 | .name = "CC_INT_CALIB", |
| 852 | .start = AB8500_INT_CC_INT_CALIB, |
| 853 | .end = AB8500_INT_CC_INT_CALIB, |
| 854 | .flags = IORESOURCE_IRQ, |
| 855 | }, |
Bengt Jonsson | a982362 | 2012-03-08 14:01:57 +0100 | [diff] [blame] | 856 | { |
| 857 | .name = "CCEOC", |
| 858 | .start = AB8500_INT_CCEOC, |
| 859 | .end = AB8500_INT_CCEOC, |
| 860 | .flags = IORESOURCE_IRQ, |
| 861 | }, |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 862 | }; |
| 863 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 864 | static struct resource ab8500_chargalg_resources[] = {}; |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 865 | |
Axel Lin | df72064 | 2011-11-10 09:56:18 +0800 | [diff] [blame] | 866 | #ifdef CONFIG_DEBUG_FS |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 867 | static struct resource ab8500_debug_resources[] = { |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 868 | { |
| 869 | .name = "IRQ_FIRST", |
| 870 | .start = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 871 | .end = AB8500_INT_MAIN_EXT_CH_NOT_OK, |
| 872 | .flags = IORESOURCE_IRQ, |
| 873 | }, |
| 874 | { |
| 875 | .name = "IRQ_LAST", |
Bengt Jonsson | a982362 | 2012-03-08 14:01:57 +0100 | [diff] [blame] | 876 | .start = AB8500_INT_XTAL32K_KO, |
| 877 | .end = AB8500_INT_XTAL32K_KO, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 878 | .flags = IORESOURCE_IRQ, |
| 879 | }, |
| 880 | }; |
Axel Lin | df72064 | 2011-11-10 09:56:18 +0800 | [diff] [blame] | 881 | #endif |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 882 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 883 | static struct resource ab8500_usb_resources[] = { |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 884 | { |
| 885 | .name = "ID_WAKEUP_R", |
| 886 | .start = AB8500_INT_ID_WAKEUP_R, |
| 887 | .end = AB8500_INT_ID_WAKEUP_R, |
| 888 | .flags = IORESOURCE_IRQ, |
| 889 | }, |
| 890 | { |
| 891 | .name = "ID_WAKEUP_F", |
| 892 | .start = AB8500_INT_ID_WAKEUP_F, |
| 893 | .end = AB8500_INT_ID_WAKEUP_F, |
| 894 | .flags = IORESOURCE_IRQ, |
| 895 | }, |
| 896 | { |
| 897 | .name = "VBUS_DET_F", |
| 898 | .start = AB8500_INT_VBUS_DET_F, |
| 899 | .end = AB8500_INT_VBUS_DET_F, |
| 900 | .flags = IORESOURCE_IRQ, |
| 901 | }, |
| 902 | { |
| 903 | .name = "VBUS_DET_R", |
| 904 | .start = AB8500_INT_VBUS_DET_R, |
| 905 | .end = AB8500_INT_VBUS_DET_R, |
| 906 | .flags = IORESOURCE_IRQ, |
| 907 | }, |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 908 | { |
| 909 | .name = "USB_LINK_STATUS", |
| 910 | .start = AB8500_INT_USB_LINK_STATUS, |
| 911 | .end = AB8500_INT_USB_LINK_STATUS, |
| 912 | .flags = IORESOURCE_IRQ, |
| 913 | }, |
Linus Walleij | 6af75ec | 2011-06-09 23:57:45 +0200 | [diff] [blame] | 914 | { |
| 915 | .name = "USB_ADP_PROBE_PLUG", |
| 916 | .start = AB8500_INT_ADP_PROBE_PLUG, |
| 917 | .end = AB8500_INT_ADP_PROBE_PLUG, |
| 918 | .flags = IORESOURCE_IRQ, |
| 919 | }, |
| 920 | { |
| 921 | .name = "USB_ADP_PROBE_UNPLUG", |
| 922 | .start = AB8500_INT_ADP_PROBE_UNPLUG, |
| 923 | .end = AB8500_INT_ADP_PROBE_UNPLUG, |
| 924 | .flags = IORESOURCE_IRQ, |
| 925 | }, |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 926 | }; |
| 927 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 928 | static struct resource ab8505_iddet_resources[] = { |
Virupax Sadashivpetimath | 44f72e5 | 2012-04-17 09:30:14 +0200 | [diff] [blame] | 929 | { |
| 930 | .name = "KeyDeglitch", |
| 931 | .start = AB8505_INT_KEYDEGLITCH, |
| 932 | .end = AB8505_INT_KEYDEGLITCH, |
| 933 | .flags = IORESOURCE_IRQ, |
| 934 | }, |
| 935 | { |
| 936 | .name = "KP", |
| 937 | .start = AB8505_INT_KP, |
| 938 | .end = AB8505_INT_KP, |
| 939 | .flags = IORESOURCE_IRQ, |
| 940 | }, |
| 941 | { |
| 942 | .name = "IKP", |
| 943 | .start = AB8505_INT_IKP, |
| 944 | .end = AB8505_INT_IKP, |
| 945 | .flags = IORESOURCE_IRQ, |
| 946 | }, |
| 947 | { |
| 948 | .name = "IKR", |
| 949 | .start = AB8505_INT_IKR, |
| 950 | .end = AB8505_INT_IKR, |
| 951 | .flags = IORESOURCE_IRQ, |
| 952 | }, |
| 953 | { |
| 954 | .name = "KeyStuck", |
| 955 | .start = AB8505_INT_KEYSTUCK, |
| 956 | .end = AB8505_INT_KEYSTUCK, |
| 957 | .flags = IORESOURCE_IRQ, |
| 958 | }, |
Lee Jones | 492390c | 2013-02-25 15:06:18 +0000 | [diff] [blame] | 959 | { |
| 960 | .name = "VBUS_DET_R", |
| 961 | .start = AB8500_INT_VBUS_DET_R, |
| 962 | .end = AB8500_INT_VBUS_DET_R, |
| 963 | .flags = IORESOURCE_IRQ, |
| 964 | }, |
| 965 | { |
| 966 | .name = "VBUS_DET_F", |
| 967 | .start = AB8500_INT_VBUS_DET_F, |
| 968 | .end = AB8500_INT_VBUS_DET_F, |
| 969 | .flags = IORESOURCE_IRQ, |
| 970 | }, |
| 971 | { |
| 972 | .name = "ID_DET_PLUGR", |
| 973 | .start = AB8500_INT_ID_DET_PLUGR, |
| 974 | .end = AB8500_INT_ID_DET_PLUGR, |
| 975 | .flags = IORESOURCE_IRQ, |
| 976 | }, |
| 977 | { |
| 978 | .name = "ID_DET_PLUGF", |
| 979 | .start = AB8500_INT_ID_DET_PLUGF, |
| 980 | .end = AB8500_INT_ID_DET_PLUGF, |
| 981 | .flags = IORESOURCE_IRQ, |
| 982 | }, |
Virupax Sadashivpetimath | 44f72e5 | 2012-04-17 09:30:14 +0200 | [diff] [blame] | 983 | }; |
| 984 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 985 | static struct resource ab8500_temp_resources[] = { |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 986 | { |
Hongbo Zhang | 151621a | 2013-01-30 18:21:27 +0800 | [diff] [blame] | 987 | .name = "ABX500_TEMP_WARM", |
Mattias Wallin | e098aded7 | 2010-12-02 15:40:31 +0100 | [diff] [blame] | 988 | .start = AB8500_INT_TEMP_WARM, |
| 989 | .end = AB8500_INT_TEMP_WARM, |
| 990 | .flags = IORESOURCE_IRQ, |
| 991 | }, |
| 992 | }; |
| 993 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 994 | static struct mfd_cell ab8500_bm_devs[] = { |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 995 | { |
| 996 | .name = "ab8500-charger", |
Rajanikanth H.V | 4aef72d | 2012-11-18 19:17:47 -0800 | [diff] [blame] | 997 | .of_compatible = "stericsson,ab8500-charger", |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 998 | .num_resources = ARRAY_SIZE(ab8500_charger_resources), |
| 999 | .resources = ab8500_charger_resources, |
Rajanikanth H.V | 4aef72d | 2012-11-18 19:17:47 -0800 | [diff] [blame] | 1000 | .platform_data = &ab8500_bm_data, |
| 1001 | .pdata_size = sizeof(ab8500_bm_data), |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1002 | }, |
| 1003 | { |
| 1004 | .name = "ab8500-btemp", |
Rajanikanth H.V | bd9e8ab | 2012-11-18 19:16:58 -0800 | [diff] [blame] | 1005 | .of_compatible = "stericsson,ab8500-btemp", |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1006 | .num_resources = ARRAY_SIZE(ab8500_btemp_resources), |
| 1007 | .resources = ab8500_btemp_resources, |
Rajanikanth H.V | bd9e8ab | 2012-11-18 19:16:58 -0800 | [diff] [blame] | 1008 | .platform_data = &ab8500_bm_data, |
| 1009 | .pdata_size = sizeof(ab8500_bm_data), |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1010 | }, |
| 1011 | { |
| 1012 | .name = "ab8500-fg", |
Rajanikanth H.V | e0f1abe | 2012-11-18 18:45:41 -0800 | [diff] [blame] | 1013 | .of_compatible = "stericsson,ab8500-fg", |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1014 | .num_resources = ARRAY_SIZE(ab8500_fg_resources), |
| 1015 | .resources = ab8500_fg_resources, |
Rajanikanth H.V | e0f1abe | 2012-11-18 18:45:41 -0800 | [diff] [blame] | 1016 | .platform_data = &ab8500_bm_data, |
| 1017 | .pdata_size = sizeof(ab8500_bm_data), |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1018 | }, |
| 1019 | { |
| 1020 | .name = "ab8500-chargalg", |
Rajanikanth H.V | a12810a | 2012-10-31 15:40:33 +0000 | [diff] [blame] | 1021 | .of_compatible = "stericsson,ab8500-chargalg", |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1022 | .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), |
| 1023 | .resources = ab8500_chargalg_resources, |
Rajanikanth H.V | a12810a | 2012-10-31 15:40:33 +0000 | [diff] [blame] | 1024 | .platform_data = &ab8500_bm_data, |
| 1025 | .pdata_size = sizeof(ab8500_bm_data), |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1026 | }, |
| 1027 | }; |
| 1028 | |
Bill Pemberton | a9e9ce4 | 2012-11-19 13:24:21 -0500 | [diff] [blame] | 1029 | static struct mfd_cell ab8500_devs[] = { |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1030 | #ifdef CONFIG_DEBUG_FS |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1031 | { |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1032 | .name = "ab8500-debug", |
| 1033 | .of_compatible = "stericsson,ab8500-debug", |
| 1034 | .num_resources = ARRAY_SIZE(ab8500_debug_resources), |
| 1035 | .resources = ab8500_debug_resources, |
| 1036 | }, |
| 1037 | #endif |
| 1038 | { |
| 1039 | .name = "ab8500-sysctrl", |
| 1040 | .of_compatible = "stericsson,ab8500-sysctrl", |
| 1041 | }, |
| 1042 | { |
| 1043 | .name = "ab8500-regulator", |
| 1044 | .of_compatible = "stericsson,ab8500-regulator", |
| 1045 | }, |
| 1046 | { |
| 1047 | .name = "abx500-clk", |
| 1048 | .of_compatible = "stericsson,abx500-clk", |
| 1049 | }, |
| 1050 | { |
| 1051 | .name = "ab8500-gpadc", |
| 1052 | .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), |
| 1053 | .resources = ab8500_gpadc_resources, |
| 1054 | }, |
| 1055 | { |
| 1056 | .name = "ab8500-rtc", |
| 1057 | .of_compatible = "stericsson,ab8500-rtc", |
| 1058 | .num_resources = ARRAY_SIZE(ab8500_rtc_resources), |
| 1059 | .resources = ab8500_rtc_resources, |
| 1060 | }, |
| 1061 | { |
| 1062 | .name = "ab8500-acc-det", |
| 1063 | .of_compatible = "stericsson,ab8500-acc-det", |
| 1064 | .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), |
| 1065 | .resources = ab8500_av_acc_detect_resources, |
| 1066 | }, |
| 1067 | { |
| 1068 | |
| 1069 | .name = "ab8500-poweron-key", |
| 1070 | .of_compatible = "stericsson,ab8500-poweron-key", |
| 1071 | .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), |
| 1072 | .resources = ab8500_poweronkey_db_resources, |
| 1073 | }, |
| 1074 | { |
| 1075 | .name = "ab8500-pwm", |
| 1076 | .of_compatible = "stericsson,ab8500-pwm", |
| 1077 | .id = 1, |
| 1078 | }, |
| 1079 | { |
| 1080 | .name = "ab8500-pwm", |
| 1081 | .of_compatible = "stericsson,ab8500-pwm", |
| 1082 | .id = 2, |
| 1083 | }, |
| 1084 | { |
| 1085 | .name = "ab8500-pwm", |
| 1086 | .of_compatible = "stericsson,ab8500-pwm", |
| 1087 | .id = 3, |
| 1088 | }, |
| 1089 | { |
| 1090 | .name = "ab8500-leds", |
| 1091 | .of_compatible = "stericsson,ab8500-leds", |
| 1092 | }, |
| 1093 | { |
| 1094 | .name = "ab8500-denc", |
| 1095 | .of_compatible = "stericsson,ab8500-denc", |
| 1096 | }, |
| 1097 | { |
| 1098 | .name = "ab8500-gpio", |
Lee Jones | bad7699 | 2012-07-02 17:10:56 +0200 | [diff] [blame] | 1099 | .of_compatible = "stericsson,ab8500-gpio", |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1100 | }, |
| 1101 | { |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1102 | .name = "abx500-temp", |
| 1103 | .of_compatible = "stericsson,abx500-temp", |
| 1104 | .num_resources = ARRAY_SIZE(ab8500_temp_resources), |
| 1105 | .resources = ab8500_temp_resources, |
| 1106 | }, |
| 1107 | { |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1108 | .name = "ab8500-usb", |
| 1109 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), |
| 1110 | .resources = ab8500_usb_resources, |
| 1111 | }, |
Virupax Sadashivpetimath | 44f72e5 | 2012-04-17 09:30:14 +0200 | [diff] [blame] | 1112 | { |
| 1113 | .name = "ab8500-codec", |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1114 | }, |
| 1115 | }; |
| 1116 | |
| 1117 | static struct mfd_cell ab9540_devs[] = { |
| 1118 | #ifdef CONFIG_DEBUG_FS |
| 1119 | { |
| 1120 | .name = "ab8500-debug", |
| 1121 | .num_resources = ARRAY_SIZE(ab8500_debug_resources), |
| 1122 | .resources = ab8500_debug_resources, |
| 1123 | }, |
| 1124 | #endif |
| 1125 | { |
| 1126 | .name = "ab8500-sysctrl", |
| 1127 | }, |
| 1128 | { |
| 1129 | .name = "ab8500-regulator", |
Virupax Sadashivpetimath | 44f72e5 | 2012-04-17 09:30:14 +0200 | [diff] [blame] | 1130 | }, |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1131 | { |
Ulf Hansson | 9ee1767 | 2012-11-20 14:57:25 +0100 | [diff] [blame] | 1132 | .name = "abx500-clk", |
| 1133 | .of_compatible = "stericsson,abx500-clk", |
| 1134 | }, |
| 1135 | { |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1136 | .name = "ab8500-gpadc", |
| 1137 | .of_compatible = "stericsson,ab8500-gpadc", |
| 1138 | .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), |
| 1139 | .resources = ab8500_gpadc_resources, |
| 1140 | }, |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1141 | { |
| 1142 | .name = "ab8500-rtc", |
| 1143 | .num_resources = ARRAY_SIZE(ab8500_rtc_resources), |
| 1144 | .resources = ab8500_rtc_resources, |
| 1145 | }, |
| 1146 | { |
| 1147 | .name = "ab8500-acc-det", |
| 1148 | .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), |
| 1149 | .resources = ab8500_av_acc_detect_resources, |
| 1150 | }, |
| 1151 | { |
| 1152 | .name = "ab8500-poweron-key", |
| 1153 | .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), |
| 1154 | .resources = ab8500_poweronkey_db_resources, |
| 1155 | }, |
| 1156 | { |
| 1157 | .name = "ab8500-pwm", |
| 1158 | .id = 1, |
| 1159 | }, |
| 1160 | { |
| 1161 | .name = "ab8500-leds", |
| 1162 | }, |
| 1163 | { |
| 1164 | .name = "abx500-temp", |
| 1165 | .num_resources = ARRAY_SIZE(ab8500_temp_resources), |
| 1166 | .resources = ab8500_temp_resources, |
| 1167 | }, |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1168 | { |
Lee Jones | e64d905 | 2013-01-16 15:09:36 +0000 | [diff] [blame] | 1169 | .name = "pinctrl-ab9540", |
| 1170 | .of_compatible = "stericsson,ab9540-gpio", |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1171 | }, |
| 1172 | { |
| 1173 | .name = "ab9540-usb", |
| 1174 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), |
| 1175 | .resources = ab8500_usb_resources, |
| 1176 | }, |
Virupax Sadashivpetimath | 44f72e5 | 2012-04-17 09:30:14 +0200 | [diff] [blame] | 1177 | { |
| 1178 | .name = "ab9540-codec", |
| 1179 | }, |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1180 | { |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1181 | .name = "ab-iddet", |
| 1182 | .num_resources = ARRAY_SIZE(ab8505_iddet_resources), |
| 1183 | .resources = ab8505_iddet_resources, |
| 1184 | }, |
Virupax Sadashivpetimath | 44f72e5 | 2012-04-17 09:30:14 +0200 | [diff] [blame] | 1185 | }; |
| 1186 | |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1187 | /* Device list for ab8505 */ |
| 1188 | static struct mfd_cell ab8505_devs[] = { |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1189 | #ifdef CONFIG_DEBUG_FS |
| 1190 | { |
| 1191 | .name = "ab8500-debug", |
| 1192 | .num_resources = ARRAY_SIZE(ab8500_debug_resources), |
| 1193 | .resources = ab8500_debug_resources, |
| 1194 | }, |
| 1195 | #endif |
| 1196 | { |
| 1197 | .name = "ab8500-sysctrl", |
| 1198 | }, |
| 1199 | { |
| 1200 | .name = "ab8500-regulator", |
| 1201 | }, |
| 1202 | { |
Ulf Hansson | 9ee1767 | 2012-11-20 14:57:25 +0100 | [diff] [blame] | 1203 | .name = "abx500-clk", |
| 1204 | .of_compatible = "stericsson,abx500-clk", |
| 1205 | }, |
| 1206 | { |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1207 | .name = "ab8500-gpadc", |
| 1208 | .num_resources = ARRAY_SIZE(ab8505_gpadc_resources), |
| 1209 | .resources = ab8505_gpadc_resources, |
| 1210 | }, |
| 1211 | { |
| 1212 | .name = "ab8500-rtc", |
| 1213 | .num_resources = ARRAY_SIZE(ab8500_rtc_resources), |
| 1214 | .resources = ab8500_rtc_resources, |
| 1215 | }, |
| 1216 | { |
| 1217 | .name = "ab8500-acc-det", |
| 1218 | .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), |
| 1219 | .resources = ab8500_av_acc_detect_resources, |
| 1220 | }, |
| 1221 | { |
| 1222 | .name = "ab8500-poweron-key", |
| 1223 | .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), |
| 1224 | .resources = ab8500_poweronkey_db_resources, |
| 1225 | }, |
| 1226 | { |
| 1227 | .name = "ab8500-pwm", |
| 1228 | .id = 1, |
| 1229 | }, |
| 1230 | { |
| 1231 | .name = "ab8500-leds", |
| 1232 | }, |
| 1233 | { |
| 1234 | .name = "ab8500-gpio", |
| 1235 | }, |
| 1236 | { |
| 1237 | .name = "ab8500-usb", |
| 1238 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), |
| 1239 | .resources = ab8500_usb_resources, |
| 1240 | }, |
| 1241 | { |
| 1242 | .name = "ab8500-codec", |
| 1243 | }, |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1244 | { |
| 1245 | .name = "ab-iddet", |
| 1246 | .num_resources = ARRAY_SIZE(ab8505_iddet_resources), |
| 1247 | .resources = ab8505_iddet_resources, |
| 1248 | }, |
| 1249 | }; |
| 1250 | |
| 1251 | static struct mfd_cell ab8540_devs[] = { |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1252 | #ifdef CONFIG_DEBUG_FS |
| 1253 | { |
| 1254 | .name = "ab8500-debug", |
| 1255 | .num_resources = ARRAY_SIZE(ab8500_debug_resources), |
| 1256 | .resources = ab8500_debug_resources, |
| 1257 | }, |
| 1258 | #endif |
| 1259 | { |
| 1260 | .name = "ab8500-sysctrl", |
| 1261 | }, |
| 1262 | { |
| 1263 | .name = "ab8500-regulator", |
| 1264 | }, |
| 1265 | { |
Ulf Hansson | 9ee1767 | 2012-11-20 14:57:25 +0100 | [diff] [blame] | 1266 | .name = "abx500-clk", |
| 1267 | .of_compatible = "stericsson,abx500-clk", |
| 1268 | }, |
| 1269 | { |
Lee Jones | 4b106fb | 2013-02-25 14:42:00 +0000 | [diff] [blame] | 1270 | .name = "ab8500-gpadc", |
| 1271 | .num_resources = ARRAY_SIZE(ab8505_gpadc_resources), |
| 1272 | .resources = ab8505_gpadc_resources, |
| 1273 | }, |
| 1274 | { |
| 1275 | .name = "ab8500-rtc", |
| 1276 | .num_resources = ARRAY_SIZE(ab8500_rtc_resources), |
| 1277 | .resources = ab8500_rtc_resources, |
| 1278 | }, |
| 1279 | { |
| 1280 | .name = "ab8500-acc-det", |
| 1281 | .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), |
| 1282 | .resources = ab8500_av_acc_detect_resources, |
| 1283 | }, |
| 1284 | { |
| 1285 | .name = "ab8500-poweron-key", |
| 1286 | .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), |
| 1287 | .resources = ab8500_poweronkey_db_resources, |
| 1288 | }, |
| 1289 | { |
| 1290 | .name = "ab8500-pwm", |
| 1291 | .id = 1, |
| 1292 | }, |
| 1293 | { |
| 1294 | .name = "ab8500-leds", |
| 1295 | }, |
| 1296 | { |
| 1297 | .name = "abx500-temp", |
| 1298 | .num_resources = ARRAY_SIZE(ab8500_temp_resources), |
| 1299 | .resources = ab8500_temp_resources, |
| 1300 | }, |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1301 | { |
| 1302 | .name = "ab8500-gpio", |
| 1303 | }, |
| 1304 | { |
| 1305 | .name = "ab8540-usb", |
| 1306 | .num_resources = ARRAY_SIZE(ab8500_usb_resources), |
| 1307 | .resources = ab8500_usb_resources, |
| 1308 | }, |
| 1309 | { |
| 1310 | .name = "ab8540-codec", |
| 1311 | }, |
| 1312 | { |
Virupax Sadashivpetimath | 44f72e5 | 2012-04-17 09:30:14 +0200 | [diff] [blame] | 1313 | .name = "ab-iddet", |
| 1314 | .num_resources = ARRAY_SIZE(ab8505_iddet_resources), |
| 1315 | .resources = ab8505_iddet_resources, |
| 1316 | }, |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1317 | }; |
| 1318 | |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 1319 | static ssize_t show_chip_id(struct device *dev, |
| 1320 | struct device_attribute *attr, char *buf) |
| 1321 | { |
| 1322 | struct ab8500 *ab8500; |
| 1323 | |
| 1324 | ab8500 = dev_get_drvdata(dev); |
Lee Jones | e436ddf | 2013-02-26 10:09:41 +0000 | [diff] [blame] | 1325 | |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 1326 | return sprintf(buf, "%#x\n", ab8500 ? ab8500->chip_id : -EINVAL); |
| 1327 | } |
| 1328 | |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 1329 | /* |
| 1330 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): |
| 1331 | * 0x01 Swoff bit programming |
| 1332 | * 0x02 Thermal protection activation |
| 1333 | * 0x04 Vbat lower then BattOk falling threshold |
| 1334 | * 0x08 Watchdog expired |
| 1335 | * 0x10 Non presence of 32kHz clock |
| 1336 | * 0x20 Battery level lower than power on reset threshold |
| 1337 | * 0x40 Power on key 1 pressed longer than 10 seconds |
| 1338 | * 0x80 DB8500 thermal shutdown |
| 1339 | */ |
| 1340 | static ssize_t show_switch_off_status(struct device *dev, |
| 1341 | struct device_attribute *attr, char *buf) |
| 1342 | { |
| 1343 | int ret; |
| 1344 | u8 value; |
| 1345 | struct ab8500 *ab8500; |
| 1346 | |
| 1347 | ab8500 = dev_get_drvdata(dev); |
| 1348 | ret = get_register_interruptible(ab8500, AB8500_RTC, |
| 1349 | AB8500_SWITCH_OFF_STATUS, &value); |
| 1350 | if (ret < 0) |
| 1351 | return ret; |
| 1352 | return sprintf(buf, "%#x\n", value); |
| 1353 | } |
| 1354 | |
Rajkumar Kasirajan | f04a9d8 | 2012-05-30 16:32:37 +0530 | [diff] [blame] | 1355 | /* use mask and set to override the register turn_on_stat value */ |
| 1356 | void ab8500_override_turn_on_stat(u8 mask, u8 set) |
| 1357 | { |
| 1358 | spin_lock(&on_stat_lock); |
| 1359 | turn_on_stat_mask = mask; |
| 1360 | turn_on_stat_set = set; |
| 1361 | spin_unlock(&on_stat_lock); |
| 1362 | } |
| 1363 | |
Andrew Lynn | b4a3103 | 2011-10-11 10:49:47 +0200 | [diff] [blame] | 1364 | /* |
| 1365 | * ab8500 has turned on due to (TURN_ON_STATUS): |
| 1366 | * 0x01 PORnVbat |
| 1367 | * 0x02 PonKey1dbF |
| 1368 | * 0x04 PonKey2dbF |
| 1369 | * 0x08 RTCAlarm |
| 1370 | * 0x10 MainChDet |
| 1371 | * 0x20 VbusDet |
| 1372 | * 0x40 UsbIDDetect |
| 1373 | * 0x80 Reserved |
| 1374 | */ |
| 1375 | static ssize_t show_turn_on_status(struct device *dev, |
| 1376 | struct device_attribute *attr, char *buf) |
| 1377 | { |
| 1378 | int ret; |
| 1379 | u8 value; |
| 1380 | struct ab8500 *ab8500; |
| 1381 | |
| 1382 | ab8500 = dev_get_drvdata(dev); |
| 1383 | ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, |
| 1384 | AB8500_TURN_ON_STATUS, &value); |
| 1385 | if (ret < 0) |
| 1386 | return ret; |
Rajkumar Kasirajan | f04a9d8 | 2012-05-30 16:32:37 +0530 | [diff] [blame] | 1387 | |
| 1388 | /* |
| 1389 | * In L9540, turn_on_status register is not updated correctly if |
| 1390 | * the device is rebooted with AC/USB charger connected. Due to |
| 1391 | * this, the device boots android instead of entering into charge |
| 1392 | * only mode. Read the AC/USB status register to detect the charger |
| 1393 | * presence and update the turn on status manually. |
| 1394 | */ |
| 1395 | if (is_ab9540(ab8500)) { |
| 1396 | spin_lock(&on_stat_lock); |
| 1397 | value = (value & turn_on_stat_mask) | turn_on_stat_set; |
| 1398 | spin_unlock(&on_stat_lock); |
| 1399 | } |
| 1400 | |
Andrew Lynn | b4a3103 | 2011-10-11 10:49:47 +0200 | [diff] [blame] | 1401 | return sprintf(buf, "%#x\n", value); |
| 1402 | } |
| 1403 | |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1404 | static ssize_t show_ab9540_dbbrstn(struct device *dev, |
| 1405 | struct device_attribute *attr, char *buf) |
| 1406 | { |
| 1407 | struct ab8500 *ab8500; |
| 1408 | int ret; |
| 1409 | u8 value; |
| 1410 | |
| 1411 | ab8500 = dev_get_drvdata(dev); |
| 1412 | |
| 1413 | ret = get_register_interruptible(ab8500, AB8500_REGU_CTRL2, |
| 1414 | AB9540_MODEM_CTRL2_REG, &value); |
| 1415 | if (ret < 0) |
| 1416 | return ret; |
| 1417 | |
| 1418 | return sprintf(buf, "%d\n", |
| 1419 | (value & AB9540_MODEM_CTRL2_SWDBBRSTN_BIT) ? 1 : 0); |
| 1420 | } |
| 1421 | |
| 1422 | static ssize_t store_ab9540_dbbrstn(struct device *dev, |
| 1423 | struct device_attribute *attr, const char *buf, size_t count) |
| 1424 | { |
| 1425 | struct ab8500 *ab8500; |
| 1426 | int ret = count; |
| 1427 | int err; |
| 1428 | u8 bitvalues; |
| 1429 | |
| 1430 | ab8500 = dev_get_drvdata(dev); |
| 1431 | |
| 1432 | if (count > 0) { |
| 1433 | switch (buf[0]) { |
| 1434 | case '0': |
| 1435 | bitvalues = 0; |
| 1436 | break; |
| 1437 | case '1': |
| 1438 | bitvalues = AB9540_MODEM_CTRL2_SWDBBRSTN_BIT; |
| 1439 | break; |
| 1440 | default: |
| 1441 | goto exit; |
| 1442 | } |
| 1443 | |
| 1444 | err = mask_and_set_register_interruptible(ab8500, |
| 1445 | AB8500_REGU_CTRL2, AB9540_MODEM_CTRL2_REG, |
| 1446 | AB9540_MODEM_CTRL2_SWDBBRSTN_BIT, bitvalues); |
| 1447 | if (err) |
| 1448 | dev_info(ab8500->dev, |
| 1449 | "Failed to set DBBRSTN %c, err %#x\n", |
| 1450 | buf[0], err); |
| 1451 | } |
| 1452 | |
| 1453 | exit: |
| 1454 | return ret; |
| 1455 | } |
| 1456 | |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 1457 | static DEVICE_ATTR(chip_id, S_IRUGO, show_chip_id, NULL); |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 1458 | static DEVICE_ATTR(switch_off_status, S_IRUGO, show_switch_off_status, NULL); |
Andrew Lynn | b4a3103 | 2011-10-11 10:49:47 +0200 | [diff] [blame] | 1459 | static DEVICE_ATTR(turn_on_status, S_IRUGO, show_turn_on_status, NULL); |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1460 | static DEVICE_ATTR(dbbrstn, S_IRUGO | S_IWUSR, |
| 1461 | show_ab9540_dbbrstn, store_ab9540_dbbrstn); |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 1462 | |
| 1463 | static struct attribute *ab8500_sysfs_entries[] = { |
| 1464 | &dev_attr_chip_id.attr, |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 1465 | &dev_attr_switch_off_status.attr, |
Andrew Lynn | b4a3103 | 2011-10-11 10:49:47 +0200 | [diff] [blame] | 1466 | &dev_attr_turn_on_status.attr, |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 1467 | NULL, |
| 1468 | }; |
| 1469 | |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1470 | static struct attribute *ab9540_sysfs_entries[] = { |
| 1471 | &dev_attr_chip_id.attr, |
| 1472 | &dev_attr_switch_off_status.attr, |
| 1473 | &dev_attr_turn_on_status.attr, |
| 1474 | &dev_attr_dbbrstn.attr, |
| 1475 | NULL, |
| 1476 | }; |
| 1477 | |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 1478 | static struct attribute_group ab8500_attr_group = { |
| 1479 | .attrs = ab8500_sysfs_entries, |
| 1480 | }; |
| 1481 | |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1482 | static struct attribute_group ab9540_attr_group = { |
| 1483 | .attrs = ab9540_sysfs_entries, |
| 1484 | }; |
| 1485 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 1486 | static int ab8500_probe(struct platform_device *pdev) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1487 | { |
Jonas Aaberg | b04c530c | 2012-06-29 17:46:12 +0200 | [diff] [blame] | 1488 | static char *switch_off_status[] = { |
| 1489 | "Swoff bit programming", |
| 1490 | "Thermal protection activation", |
| 1491 | "Vbat lower then BattOk falling threshold", |
| 1492 | "Watchdog expired", |
| 1493 | "Non presence of 32kHz clock", |
| 1494 | "Battery level lower than power on reset threshold", |
| 1495 | "Power on key 1 pressed longer than 10 seconds", |
| 1496 | "DB8500 thermal shutdown"}; |
Mattias Wallin | abee26c | 2012-09-28 09:34:24 +0200 | [diff] [blame] | 1497 | static char *turn_on_status[] = { |
| 1498 | "Battery rising (Vbat)", |
| 1499 | "Power On Key 1 dbF", |
| 1500 | "Power On Key 2 dbF", |
| 1501 | "RTC Alarm", |
| 1502 | "Main Charger Detect", |
| 1503 | "Vbus Detect (USB)", |
| 1504 | "USB ID Detect", |
| 1505 | "UART Factory Mode Detect"}; |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1506 | struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev); |
| 1507 | const struct platform_device_id *platid = platform_get_device_id(pdev); |
Lee Jones | 6bc4a56 | 2012-05-17 14:45:13 +0100 | [diff] [blame] | 1508 | enum ab8500_version version = AB8500_VERSION_UNDEFINED; |
| 1509 | struct device_node *np = pdev->dev.of_node; |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1510 | struct ab8500 *ab8500; |
| 1511 | struct resource *resource; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1512 | int ret; |
| 1513 | int i; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 1514 | u8 value; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1515 | |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1516 | ab8500 = devm_kzalloc(&pdev->dev, sizeof *ab8500, GFP_KERNEL); |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1517 | if (!ab8500) |
| 1518 | return -ENOMEM; |
| 1519 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1520 | if (plat) |
| 1521 | ab8500->irq_base = plat->irq_base; |
| 1522 | |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1523 | ab8500->dev = &pdev->dev; |
| 1524 | |
| 1525 | resource = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1526 | if (!resource) |
| 1527 | return -ENODEV; |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1528 | |
| 1529 | ab8500->irq = resource->start; |
| 1530 | |
Lee Jones | 822672a | 2012-06-20 13:56:38 +0100 | [diff] [blame] | 1531 | ab8500->read = ab8500_prcmu_read; |
| 1532 | ab8500->write = ab8500_prcmu_write; |
| 1533 | ab8500->write_masked = ab8500_prcmu_write_masked; |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1534 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1535 | mutex_init(&ab8500->lock); |
| 1536 | mutex_init(&ab8500->irq_lock); |
Jonas Aaberg | 112a80d | 2012-04-17 09:30:33 +0200 | [diff] [blame] | 1537 | atomic_set(&ab8500->transfer_ongoing, 0); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1538 | |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1539 | platform_set_drvdata(pdev, ab8500); |
| 1540 | |
Lee Jones | 6bc4a56 | 2012-05-17 14:45:13 +0100 | [diff] [blame] | 1541 | if (platid) |
| 1542 | version = platid->driver_data; |
Lee Jones | 6bc4a56 | 2012-05-17 14:45:13 +0100 | [diff] [blame] | 1543 | |
Linus Walleij | 0f620837 | 2012-02-20 21:42:10 +0100 | [diff] [blame] | 1544 | if (version != AB8500_VERSION_UNDEFINED) |
| 1545 | ab8500->version = version; |
| 1546 | else { |
| 1547 | ret = get_register_interruptible(ab8500, AB8500_MISC, |
| 1548 | AB8500_IC_NAME_REG, &value); |
| 1549 | if (ret < 0) |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1550 | return ret; |
Linus Walleij | 0f620837 | 2012-02-20 21:42:10 +0100 | [diff] [blame] | 1551 | |
| 1552 | ab8500->version = value; |
| 1553 | } |
| 1554 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 1555 | ret = get_register_interruptible(ab8500, AB8500_MISC, |
| 1556 | AB8500_REV_REG, &value); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1557 | if (ret < 0) |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1558 | return ret; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1559 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 1560 | ab8500->chip_id = value; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1561 | |
Linus Walleij | 0f620837 | 2012-02-20 21:42:10 +0100 | [diff] [blame] | 1562 | dev_info(ab8500->dev, "detected chip, %s rev. %1x.%1x\n", |
| 1563 | ab8500_version_str[ab8500->version], |
| 1564 | ab8500->chip_id >> 4, |
| 1565 | ab8500->chip_id & 0x0F); |
| 1566 | |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 1567 | /* Configure AB8540 */ |
| 1568 | if (is_ab8540(ab8500)) { |
| 1569 | ab8500->mask_size = AB8540_NUM_IRQ_REGS; |
| 1570 | ab8500->irq_reg_offset = ab8540_irq_regoffset; |
| 1571 | ab8500->it_latchhier_num = AB8540_IT_LATCHHIER_NUM; |
| 1572 | }/* Configure AB8500 or AB9540 IRQ */ |
| 1573 | else if (is_ab9540(ab8500) || is_ab8505(ab8500)) { |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1574 | ab8500->mask_size = AB9540_NUM_IRQ_REGS; |
| 1575 | ab8500->irq_reg_offset = ab9540_irq_regoffset; |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 1576 | ab8500->it_latchhier_num = AB8500_IT_LATCHHIER_NUM; |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1577 | } else { |
| 1578 | ab8500->mask_size = AB8500_NUM_IRQ_REGS; |
| 1579 | ab8500->irq_reg_offset = ab8500_irq_regoffset; |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 1580 | ab8500->it_latchhier_num = AB8500_IT_LATCHHIER_NUM; |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1581 | } |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1582 | ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 1583 | if (!ab8500->mask) |
| 1584 | return -ENOMEM; |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1585 | ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); |
| 1586 | if (!ab8500->oldmask) |
| 1587 | return -ENOMEM; |
| 1588 | |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 1589 | /* |
| 1590 | * ab8500 has switched off due to (SWITCH_OFF_STATUS): |
| 1591 | * 0x01 Swoff bit programming |
| 1592 | * 0x02 Thermal protection activation |
| 1593 | * 0x04 Vbat lower then BattOk falling threshold |
| 1594 | * 0x08 Watchdog expired |
| 1595 | * 0x10 Non presence of 32kHz clock |
| 1596 | * 0x20 Battery level lower than power on reset threshold |
| 1597 | * 0x40 Power on key 1 pressed longer than 10 seconds |
| 1598 | * 0x80 DB8500 thermal shutdown |
| 1599 | */ |
| 1600 | |
| 1601 | ret = get_register_interruptible(ab8500, AB8500_RTC, |
| 1602 | AB8500_SWITCH_OFF_STATUS, &value); |
| 1603 | if (ret < 0) |
| 1604 | return ret; |
Jonas Aaberg | b04c530c | 2012-06-29 17:46:12 +0200 | [diff] [blame] | 1605 | dev_info(ab8500->dev, "switch off cause(s) (%#x): ", value); |
| 1606 | |
| 1607 | if (value) { |
| 1608 | for (i = 0; i < ARRAY_SIZE(switch_off_status); i++) { |
| 1609 | if (value & 1) |
| 1610 | printk(KERN_CONT " \"%s\"", |
| 1611 | switch_off_status[i]); |
| 1612 | value = value >> 1; |
| 1613 | |
| 1614 | } |
| 1615 | printk(KERN_CONT "\n"); |
| 1616 | } else { |
| 1617 | printk(KERN_CONT " None\n"); |
| 1618 | } |
Mattias Wallin | abee26c | 2012-09-28 09:34:24 +0200 | [diff] [blame] | 1619 | ret = get_register_interruptible(ab8500, AB8500_SYS_CTRL1_BLOCK, |
| 1620 | AB8500_TURN_ON_STATUS, &value); |
| 1621 | if (ret < 0) |
| 1622 | return ret; |
| 1623 | dev_info(ab8500->dev, "turn on reason(s) (%#x): ", value); |
| 1624 | |
| 1625 | if (value) { |
| 1626 | for (i = 0; i < ARRAY_SIZE(turn_on_status); i++) { |
| 1627 | if (value & 1) |
| 1628 | printk("\"%s\" ", turn_on_status[i]); |
| 1629 | value = value >> 1; |
| 1630 | } |
| 1631 | printk("\n"); |
| 1632 | } else { |
| 1633 | printk("None\n"); |
| 1634 | } |
Mattias Wallin | e5c238c | 2011-03-02 11:52:36 +0100 | [diff] [blame] | 1635 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1636 | if (plat && plat->init) |
| 1637 | plat->init(ab8500); |
Mattias Wallin | abee26c | 2012-09-28 09:34:24 +0200 | [diff] [blame] | 1638 | |
Rajkumar Kasirajan | f04a9d8 | 2012-05-30 16:32:37 +0530 | [diff] [blame] | 1639 | if (is_ab9540(ab8500)) { |
| 1640 | ret = get_register_interruptible(ab8500, AB8500_CHARGER, |
| 1641 | AB8500_CH_USBCH_STAT1_REG, &value); |
| 1642 | if (ret < 0) |
| 1643 | return ret; |
| 1644 | if ((value & VBUS_DET_DBNC1) && (value & VBUS_DET_DBNC100)) |
| 1645 | ab8500_override_turn_on_stat(~AB8500_POW_KEY_1_ON, |
| 1646 | AB8500_VBUS_DET); |
| 1647 | } |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1648 | |
| 1649 | /* Clear and mask all interrupts */ |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 1650 | for (i = 0; i < ab8500->mask_size; i++) { |
Linus Walleij | 0f620837 | 2012-02-20 21:42:10 +0100 | [diff] [blame] | 1651 | /* |
| 1652 | * Interrupt register 12 doesn't exist prior to AB8500 version |
| 1653 | * 2.0 |
| 1654 | */ |
| 1655 | if (ab8500->irq_reg_offset[i] == 11 && |
| 1656 | is_ab8500_1p1_or_earlier(ab8500)) |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 1657 | continue; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1658 | |
Lee Jones | 3e1a498 | 2013-02-25 14:57:35 +0000 | [diff] [blame] | 1659 | if (ab8500->irq_reg_offset[i] < 0) |
| 1660 | continue; |
| 1661 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 1662 | get_register_interruptible(ab8500, AB8500_INTERRUPT, |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 1663 | AB8500_IT_LATCH1_REG + ab8500->irq_reg_offset[i], |
Mattias Wallin | 92d50a4 | 2010-12-07 11:20:47 +0100 | [diff] [blame] | 1664 | &value); |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 1665 | set_register_interruptible(ab8500, AB8500_INTERRUPT, |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 1666 | AB8500_IT_MASK1_REG + ab8500->irq_reg_offset[i], 0xff); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1667 | } |
| 1668 | |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 1669 | ret = abx500_register_ops(ab8500->dev, &ab8500_ops); |
| 1670 | if (ret) |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1671 | return ret; |
Mattias Wallin | 47c1697 | 2010-09-10 17:47:56 +0200 | [diff] [blame] | 1672 | |
Linus Walleij | 2ced445 | 2012-02-20 21:42:17 +0100 | [diff] [blame] | 1673 | for (i = 0; i < ab8500->mask_size; i++) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1674 | ab8500->mask[i] = ab8500->oldmask[i] = 0xff; |
| 1675 | |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 1676 | ret = ab8500_irq_init(ab8500, np); |
| 1677 | if (ret) |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1678 | return ret; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1679 | |
Dariusz Szymczak | f348fef | 2012-11-26 13:31:26 +0100 | [diff] [blame^] | 1680 | ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, |
| 1681 | ab8500_hierarchical_irq, |
| 1682 | IRQF_ONESHOT | IRQF_NO_SUSPEND, |
| 1683 | "ab8500", ab8500); |
| 1684 | if (ret) |
| 1685 | return ret; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1686 | |
Lee Jones | bad7699 | 2012-07-02 17:10:56 +0200 | [diff] [blame] | 1687 | if (is_ab9540(ab8500)) |
| 1688 | ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, |
| 1689 | ARRAY_SIZE(ab9540_devs), NULL, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 1690 | ab8500->irq_base, ab8500->domain); |
Lee Jones | c0eda9a | 2013-02-12 15:04:09 +0000 | [diff] [blame] | 1691 | else if (is_ab8540(ab8500)) |
| 1692 | ret = mfd_add_devices(ab8500->dev, 0, ab8540_devs, |
| 1693 | ARRAY_SIZE(ab8540_devs), NULL, |
| 1694 | ab8500->irq_base, ab8500->domain); |
| 1695 | else if (is_ab8505(ab8500)) |
| 1696 | ret = mfd_add_devices(ab8500->dev, 0, ab8505_devs, |
| 1697 | ARRAY_SIZE(ab8505_devs), NULL, |
| 1698 | ab8500->irq_base, ab8500->domain); |
Lee Jones | bad7699 | 2012-07-02 17:10:56 +0200 | [diff] [blame] | 1699 | else |
| 1700 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, |
| 1701 | ARRAY_SIZE(ab8500_devs), NULL, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 1702 | ab8500->irq_base, ab8500->domain); |
Lee Jones | bad7699 | 2012-07-02 17:10:56 +0200 | [diff] [blame] | 1703 | if (ret) |
Lee Jones | 8c4203c | 2012-11-05 16:10:35 +0100 | [diff] [blame] | 1704 | return ret; |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1705 | |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1706 | if (!no_bm) { |
| 1707 | /* Add battery management devices */ |
| 1708 | ret = mfd_add_devices(ab8500->dev, 0, ab8500_bm_devs, |
| 1709 | ARRAY_SIZE(ab8500_bm_devs), NULL, |
Mark Brown | 55692af | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 1710 | ab8500->irq_base, ab8500->domain); |
Rickard Andersson | 6ef9418 | 2012-04-17 09:30:57 +0200 | [diff] [blame] | 1711 | if (ret) |
| 1712 | dev_err(ab8500->dev, "error adding bm devices\n"); |
| 1713 | } |
| 1714 | |
Lee Jones | e436ddf | 2013-02-26 10:09:41 +0000 | [diff] [blame] | 1715 | if (((is_ab8505(ab8500) || is_ab9540(ab8500)) && |
| 1716 | ab8500->chip_id >= AB8500_CUT2P0) || is_ab8540(ab8500)) |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1717 | ret = sysfs_create_group(&ab8500->dev->kobj, |
| 1718 | &ab9540_attr_group); |
| 1719 | else |
| 1720 | ret = sysfs_create_group(&ab8500->dev->kobj, |
| 1721 | &ab8500_attr_group); |
Mattias Wallin | cca69b6 | 2010-12-02 15:09:36 +0100 | [diff] [blame] | 1722 | if (ret) |
| 1723 | dev_err(ab8500->dev, "error creating sysfs entries\n"); |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 1724 | |
| 1725 | return ret; |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1726 | } |
| 1727 | |
Bill Pemberton | 4740f73 | 2012-11-19 13:26:01 -0500 | [diff] [blame] | 1728 | static int ab8500_remove(struct platform_device *pdev) |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1729 | { |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1730 | struct ab8500 *ab8500 = platform_get_drvdata(pdev); |
| 1731 | |
Lee Jones | e436ddf | 2013-02-26 10:09:41 +0000 | [diff] [blame] | 1732 | if (((is_ab8505(ab8500) || is_ab9540(ab8500)) && |
| 1733 | ab8500->chip_id >= AB8500_CUT2P0) || is_ab8540(ab8500)) |
Linus Walleij | d625552 | 2012-02-20 21:42:24 +0100 | [diff] [blame] | 1734 | sysfs_remove_group(&ab8500->dev->kobj, &ab9540_attr_group); |
| 1735 | else |
| 1736 | sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); |
Lee Jones | 06e589e | 2012-06-20 13:56:37 +0100 | [diff] [blame] | 1737 | |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1738 | mfd_remove_devices(ab8500->dev); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1739 | |
| 1740 | return 0; |
| 1741 | } |
| 1742 | |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1743 | static const struct platform_device_id ab8500_id[] = { |
| 1744 | { "ab8500-core", AB8500_VERSION_AB8500 }, |
| 1745 | { "ab8505-i2c", AB8500_VERSION_AB8505 }, |
| 1746 | { "ab9540-i2c", AB8500_VERSION_AB9540 }, |
| 1747 | { "ab8540-i2c", AB8500_VERSION_AB8540 }, |
| 1748 | { } |
| 1749 | }; |
| 1750 | |
| 1751 | static struct platform_driver ab8500_core_driver = { |
| 1752 | .driver = { |
| 1753 | .name = "ab8500-core", |
| 1754 | .owner = THIS_MODULE, |
| 1755 | }, |
| 1756 | .probe = ab8500_probe, |
Bill Pemberton | 8444921 | 2012-11-19 13:20:24 -0500 | [diff] [blame] | 1757 | .remove = ab8500_remove, |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1758 | .id_table = ab8500_id, |
| 1759 | }; |
| 1760 | |
| 1761 | static int __init ab8500_core_init(void) |
| 1762 | { |
| 1763 | return platform_driver_register(&ab8500_core_driver); |
| 1764 | } |
| 1765 | |
| 1766 | static void __exit ab8500_core_exit(void) |
| 1767 | { |
| 1768 | platform_driver_unregister(&ab8500_core_driver); |
| 1769 | } |
Lee Jones | ba7cbc3 | 2012-06-11 16:25:00 +0100 | [diff] [blame] | 1770 | core_initcall(ab8500_core_init); |
Lee Jones | d28f1db | 2012-05-19 17:21:37 +0200 | [diff] [blame] | 1771 | module_exit(ab8500_core_exit); |
| 1772 | |
Mattias Wallin | adceed6 | 2011-03-02 11:51:11 +0100 | [diff] [blame] | 1773 | MODULE_AUTHOR("Mattias Wallin, Srinidhi Kasagar, Rabin Vincent"); |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 1774 | MODULE_DESCRIPTION("AB8500 MFD core"); |
| 1775 | MODULE_LICENSE("GPL v2"); |