Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 1 | /* |
| 2 | * max77693.c - mfd core driver for the MAX 77693 |
| 3 | * |
| 4 | * Copyright (C) 2012 Samsung Electronics |
| 5 | * SangYoung Son <hello.son@smasung.com> |
| 6 | * |
| 7 | * This program is not provided / owned by Maxim Integrated Products. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | * This driver is based on max8997.c |
| 24 | */ |
| 25 | |
| 26 | #include <linux/module.h> |
| 27 | #include <linux/slab.h> |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/err.h> |
| 30 | #include <linux/interrupt.h> |
Sachin Kamat | 71c7f93 | 2013-10-18 16:11:57 +0530 | [diff] [blame] | 31 | #include <linux/of.h> |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 32 | #include <linux/pm_runtime.h> |
| 33 | #include <linux/mutex.h> |
| 34 | #include <linux/mfd/core.h> |
| 35 | #include <linux/mfd/max77693.h> |
| 36 | #include <linux/mfd/max77693-private.h> |
| 37 | #include <linux/regulator/machine.h> |
| 38 | #include <linux/regmap.h> |
| 39 | |
| 40 | #define I2C_ADDR_PMIC (0xCC >> 1) /* Charger, Flash LED */ |
| 41 | #define I2C_ADDR_MUIC (0x4A >> 1) |
| 42 | #define I2C_ADDR_HAPTIC (0x90 >> 1) |
| 43 | |
Geert Uytterhoeven | 7c0517b | 2013-11-18 14:33:00 +0100 | [diff] [blame] | 44 | static const struct mfd_cell max77693_devs[] = { |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 45 | { .name = "max77693-pmic", }, |
Krzysztof Kozlowski | efa3ca4 | 2014-10-20 14:34:46 +0200 | [diff] [blame] | 46 | { |
| 47 | .name = "max77693-charger", |
| 48 | .of_compatible = "maxim,max77693-charger", |
| 49 | }, |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 50 | { .name = "max77693-muic", }, |
Jaewon Kim | d1bafd7 | 2014-09-18 01:40:25 +0900 | [diff] [blame] | 51 | { |
| 52 | .name = "max77693-haptic", |
| 53 | .of_compatible = "maxim,max77693-haptic", |
| 54 | }, |
Jacek Anaszewski | a0bc6072 | 2014-08-22 11:06:18 +0200 | [diff] [blame] | 55 | { |
| 56 | .name = "max77693-flash", |
| 57 | .of_compatible = "maxim,max77693-flash", |
| 58 | }, |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 59 | }; |
| 60 | |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 61 | static const struct regmap_config max77693_regmap_config = { |
| 62 | .reg_bits = 8, |
| 63 | .val_bits = 8, |
| 64 | .max_register = MAX77693_PMIC_REG_END, |
| 65 | }; |
| 66 | |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 67 | static const struct regmap_irq max77693_led_irqs[] = { |
| 68 | { .mask = LED_IRQ_FLED2_OPEN, }, |
| 69 | { .mask = LED_IRQ_FLED2_SHORT, }, |
| 70 | { .mask = LED_IRQ_FLED1_OPEN, }, |
| 71 | { .mask = LED_IRQ_FLED1_SHORT, }, |
| 72 | { .mask = LED_IRQ_MAX_FLASH, }, |
| 73 | }; |
| 74 | |
| 75 | static const struct regmap_irq_chip max77693_led_irq_chip = { |
| 76 | .name = "max77693-led", |
| 77 | .status_base = MAX77693_LED_REG_FLASH_INT, |
| 78 | .mask_base = MAX77693_LED_REG_FLASH_INT_MASK, |
| 79 | .mask_invert = false, |
| 80 | .num_regs = 1, |
| 81 | .irqs = max77693_led_irqs, |
| 82 | .num_irqs = ARRAY_SIZE(max77693_led_irqs), |
| 83 | }; |
| 84 | |
| 85 | static const struct regmap_irq max77693_topsys_irqs[] = { |
| 86 | { .mask = TOPSYS_IRQ_T120C_INT, }, |
| 87 | { .mask = TOPSYS_IRQ_T140C_INT, }, |
| 88 | { .mask = TOPSYS_IRQ_LOWSYS_INT, }, |
| 89 | }; |
| 90 | |
| 91 | static const struct regmap_irq_chip max77693_topsys_irq_chip = { |
| 92 | .name = "max77693-topsys", |
| 93 | .status_base = MAX77693_PMIC_REG_TOPSYS_INT, |
| 94 | .mask_base = MAX77693_PMIC_REG_TOPSYS_INT_MASK, |
| 95 | .mask_invert = false, |
| 96 | .num_regs = 1, |
| 97 | .irqs = max77693_topsys_irqs, |
| 98 | .num_irqs = ARRAY_SIZE(max77693_topsys_irqs), |
| 99 | }; |
| 100 | |
| 101 | static const struct regmap_irq max77693_charger_irqs[] = { |
| 102 | { .mask = CHG_IRQ_BYP_I, }, |
| 103 | { .mask = CHG_IRQ_THM_I, }, |
| 104 | { .mask = CHG_IRQ_BAT_I, }, |
| 105 | { .mask = CHG_IRQ_CHG_I, }, |
| 106 | { .mask = CHG_IRQ_CHGIN_I, }, |
| 107 | }; |
| 108 | |
| 109 | static const struct regmap_irq_chip max77693_charger_irq_chip = { |
| 110 | .name = "max77693-charger", |
| 111 | .status_base = MAX77693_CHG_REG_CHG_INT, |
| 112 | .mask_base = MAX77693_CHG_REG_CHG_INT_MASK, |
| 113 | .mask_invert = false, |
| 114 | .num_regs = 1, |
| 115 | .irqs = max77693_charger_irqs, |
| 116 | .num_irqs = ARRAY_SIZE(max77693_charger_irqs), |
| 117 | }; |
| 118 | |
Krzysztof Kozlowski | 75ad132 | 2013-12-20 10:35:08 +0100 | [diff] [blame] | 119 | static const struct regmap_config max77693_regmap_muic_config = { |
| 120 | .reg_bits = 8, |
| 121 | .val_bits = 8, |
| 122 | .max_register = MAX77693_MUIC_REG_END, |
| 123 | }; |
| 124 | |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 125 | static const struct regmap_irq max77693_muic_irqs[] = { |
| 126 | { .reg_offset = 0, .mask = MUIC_IRQ_INT1_ADC, }, |
| 127 | { .reg_offset = 0, .mask = MUIC_IRQ_INT1_ADC_LOW, }, |
| 128 | { .reg_offset = 0, .mask = MUIC_IRQ_INT1_ADC_ERR, }, |
| 129 | { .reg_offset = 0, .mask = MUIC_IRQ_INT1_ADC1K, }, |
| 130 | |
| 131 | { .reg_offset = 1, .mask = MUIC_IRQ_INT2_CHGTYP, }, |
| 132 | { .reg_offset = 1, .mask = MUIC_IRQ_INT2_CHGDETREUN, }, |
| 133 | { .reg_offset = 1, .mask = MUIC_IRQ_INT2_DCDTMR, }, |
| 134 | { .reg_offset = 1, .mask = MUIC_IRQ_INT2_DXOVP, }, |
| 135 | { .reg_offset = 1, .mask = MUIC_IRQ_INT2_VBVOLT, }, |
| 136 | { .reg_offset = 1, .mask = MUIC_IRQ_INT2_VIDRM, }, |
| 137 | |
| 138 | { .reg_offset = 2, .mask = MUIC_IRQ_INT3_EOC, }, |
| 139 | { .reg_offset = 2, .mask = MUIC_IRQ_INT3_CGMBC, }, |
| 140 | { .reg_offset = 2, .mask = MUIC_IRQ_INT3_OVP, }, |
| 141 | { .reg_offset = 2, .mask = MUIC_IRQ_INT3_MBCCHG_ERR, }, |
| 142 | { .reg_offset = 2, .mask = MUIC_IRQ_INT3_CHG_ENABLED, }, |
| 143 | { .reg_offset = 2, .mask = MUIC_IRQ_INT3_BAT_DET, }, |
| 144 | }; |
| 145 | |
| 146 | static const struct regmap_irq_chip max77693_muic_irq_chip = { |
| 147 | .name = "max77693-muic", |
| 148 | .status_base = MAX77693_MUIC_REG_INT1, |
| 149 | .mask_base = MAX77693_MUIC_REG_INTMASK1, |
| 150 | .mask_invert = true, |
| 151 | .num_regs = 3, |
| 152 | .irqs = max77693_muic_irqs, |
| 153 | .num_irqs = ARRAY_SIZE(max77693_muic_irqs), |
| 154 | }; |
| 155 | |
Jaewon Kim | efbf492 | 2014-09-18 01:40:24 +0900 | [diff] [blame] | 156 | static const struct regmap_config max77693_regmap_haptic_config = { |
| 157 | .reg_bits = 8, |
| 158 | .val_bits = 8, |
| 159 | .max_register = MAX77693_HAPTIC_REG_END, |
| 160 | }; |
| 161 | |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 162 | static int max77693_i2c_probe(struct i2c_client *i2c, |
| 163 | const struct i2c_device_id *id) |
| 164 | { |
| 165 | struct max77693_dev *max77693; |
Robert Baldyga | d0540f9 | 2014-05-21 08:52:47 +0200 | [diff] [blame] | 166 | unsigned int reg_data; |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 167 | int ret = 0; |
| 168 | |
| 169 | max77693 = devm_kzalloc(&i2c->dev, |
| 170 | sizeof(struct max77693_dev), GFP_KERNEL); |
| 171 | if (max77693 == NULL) |
| 172 | return -ENOMEM; |
| 173 | |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 174 | i2c_set_clientdata(i2c, max77693); |
| 175 | max77693->dev = &i2c->dev; |
| 176 | max77693->i2c = i2c; |
| 177 | max77693->irq = i2c->irq; |
| 178 | max77693->type = id->driver_data; |
| 179 | |
Axel Lin | 2429d86 | 2012-12-25 00:28:36 +0800 | [diff] [blame] | 180 | max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config); |
| 181 | if (IS_ERR(max77693->regmap)) { |
| 182 | ret = PTR_ERR(max77693->regmap); |
| 183 | dev_err(max77693->dev, "failed to allocate register map: %d\n", |
| 184 | ret); |
| 185 | return ret; |
| 186 | } |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 187 | |
Robert Baldyga | d0540f9 | 2014-05-21 08:52:47 +0200 | [diff] [blame] | 188 | ret = regmap_read(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2, |
Axel Lin | 2429d86 | 2012-12-25 00:28:36 +0800 | [diff] [blame] | 189 | ®_data); |
| 190 | if (ret < 0) { |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 191 | dev_err(max77693->dev, "device not found on this channel\n"); |
Axel Lin | 2429d86 | 2012-12-25 00:28:36 +0800 | [diff] [blame] | 192 | return ret; |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 193 | } else |
| 194 | dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); |
| 195 | |
| 196 | max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); |
Krzysztof Kozlowski | ad09dd6 | 2014-02-11 11:03:32 +0100 | [diff] [blame] | 197 | if (!max77693->muic) { |
| 198 | dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n"); |
| 199 | return -ENODEV; |
| 200 | } |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 201 | i2c_set_clientdata(max77693->muic, max77693); |
| 202 | |
| 203 | max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); |
Krzysztof Kozlowski | ad09dd6 | 2014-02-11 11:03:32 +0100 | [diff] [blame] | 204 | if (!max77693->haptic) { |
| 205 | dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n"); |
| 206 | ret = -ENODEV; |
| 207 | goto err_i2c_haptic; |
| 208 | } |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 209 | i2c_set_clientdata(max77693->haptic, max77693); |
| 210 | |
Jaewon Kim | efbf492 | 2014-09-18 01:40:24 +0900 | [diff] [blame] | 211 | max77693->regmap_haptic = devm_regmap_init_i2c(max77693->haptic, |
| 212 | &max77693_regmap_haptic_config); |
| 213 | if (IS_ERR(max77693->regmap_haptic)) { |
| 214 | ret = PTR_ERR(max77693->regmap_haptic); |
| 215 | dev_err(max77693->dev, |
| 216 | "failed to initialize haptic register map: %d\n", ret); |
| 217 | goto err_regmap; |
| 218 | } |
| 219 | |
Chanwoo Choi | b186b12 | 2012-08-21 15:16:23 +0900 | [diff] [blame] | 220 | /* |
| 221 | * Initialize register map for MUIC device because use regmap-muic |
| 222 | * instance of MUIC device when irq of max77693 is initialized |
| 223 | * before call max77693-muic probe() function. |
| 224 | */ |
| 225 | max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic, |
Krzysztof Kozlowski | 75ad132 | 2013-12-20 10:35:08 +0100 | [diff] [blame] | 226 | &max77693_regmap_muic_config); |
Chanwoo Choi | b186b12 | 2012-08-21 15:16:23 +0900 | [diff] [blame] | 227 | if (IS_ERR(max77693->regmap_muic)) { |
| 228 | ret = PTR_ERR(max77693->regmap_muic); |
| 229 | dev_err(max77693->dev, |
| 230 | "failed to allocate register map: %d\n", ret); |
Jaewon Kim | efbf492 | 2014-09-18 01:40:24 +0900 | [diff] [blame] | 231 | goto err_regmap; |
Chanwoo Choi | b186b12 | 2012-08-21 15:16:23 +0900 | [diff] [blame] | 232 | } |
| 233 | |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 234 | ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, |
| 235 | IRQF_ONESHOT | IRQF_SHARED | |
| 236 | IRQF_TRIGGER_FALLING, 0, |
| 237 | &max77693_led_irq_chip, |
| 238 | &max77693->irq_data_led); |
| 239 | if (ret) { |
| 240 | dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); |
Jaewon Kim | efbf492 | 2014-09-18 01:40:24 +0900 | [diff] [blame] | 241 | goto err_regmap; |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, |
| 245 | IRQF_ONESHOT | IRQF_SHARED | |
| 246 | IRQF_TRIGGER_FALLING, 0, |
| 247 | &max77693_topsys_irq_chip, |
| 248 | &max77693->irq_data_topsys); |
| 249 | if (ret) { |
| 250 | dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); |
| 251 | goto err_irq_topsys; |
| 252 | } |
| 253 | |
| 254 | ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, |
| 255 | IRQF_ONESHOT | IRQF_SHARED | |
| 256 | IRQF_TRIGGER_FALLING, 0, |
| 257 | &max77693_charger_irq_chip, |
| 258 | &max77693->irq_data_charger); |
| 259 | if (ret) { |
| 260 | dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); |
| 261 | goto err_irq_charger; |
| 262 | } |
| 263 | |
Krzysztof Kozlowski | 43fc939 | 2014-10-10 10:22:01 +0200 | [diff] [blame] | 264 | ret = regmap_add_irq_chip(max77693->regmap_muic, max77693->irq, |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 265 | IRQF_ONESHOT | IRQF_SHARED | |
| 266 | IRQF_TRIGGER_FALLING, 0, |
| 267 | &max77693_muic_irq_chip, |
| 268 | &max77693->irq_data_muic); |
| 269 | if (ret) { |
| 270 | dev_err(max77693->dev, "failed to add irq chip: %d\n", ret); |
| 271 | goto err_irq_muic; |
| 272 | } |
Chanwoo Choi | 6592ebb | 2012-05-14 22:54:20 +0200 | [diff] [blame] | 273 | |
Krzysztof Kozlowski | c0acb81 | 2014-10-10 12:48:35 +0200 | [diff] [blame] | 274 | /* Unmask interrupts from all blocks in interrupt source register */ |
| 275 | ret = regmap_update_bits(max77693->regmap, |
| 276 | MAX77693_PMIC_REG_INTSRC_MASK, |
| 277 | SRC_IRQ_ALL, (unsigned int)~SRC_IRQ_ALL); |
| 278 | if (ret < 0) { |
| 279 | dev_err(max77693->dev, |
| 280 | "Could not unmask interrupts in INTSRC: %d\n", |
| 281 | ret); |
| 282 | goto err_intsrc; |
| 283 | } |
| 284 | |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 285 | pm_runtime_set_active(max77693->dev); |
| 286 | |
| 287 | ret = mfd_add_devices(max77693->dev, -1, max77693_devs, |
Mark Brown | 0848c94 | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 288 | ARRAY_SIZE(max77693_devs), NULL, 0, NULL); |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 289 | if (ret < 0) |
| 290 | goto err_mfd; |
| 291 | |
| 292 | return ret; |
| 293 | |
| 294 | err_mfd: |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 295 | mfd_remove_devices(max77693->dev); |
Krzysztof Kozlowski | c0acb81 | 2014-10-10 12:48:35 +0200 | [diff] [blame] | 296 | err_intsrc: |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 297 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); |
| 298 | err_irq_muic: |
| 299 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); |
| 300 | err_irq_charger: |
| 301 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); |
| 302 | err_irq_topsys: |
| 303 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); |
Jaewon Kim | efbf492 | 2014-09-18 01:40:24 +0900 | [diff] [blame] | 304 | err_regmap: |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 305 | i2c_unregister_device(max77693->haptic); |
Krzysztof Kozlowski | ad09dd6 | 2014-02-11 11:03:32 +0100 | [diff] [blame] | 306 | err_i2c_haptic: |
| 307 | i2c_unregister_device(max77693->muic); |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 308 | return ret; |
| 309 | } |
| 310 | |
| 311 | static int max77693_i2c_remove(struct i2c_client *i2c) |
| 312 | { |
| 313 | struct max77693_dev *max77693 = i2c_get_clientdata(i2c); |
| 314 | |
| 315 | mfd_remove_devices(max77693->dev); |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 316 | |
| 317 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); |
| 318 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); |
| 319 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_topsys); |
| 320 | regmap_del_irq_chip(max77693->irq, max77693->irq_data_led); |
| 321 | |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 322 | i2c_unregister_device(max77693->muic); |
| 323 | i2c_unregister_device(max77693->haptic); |
| 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | static const struct i2c_device_id max77693_i2c_id[] = { |
| 329 | { "max77693", TYPE_MAX77693 }, |
| 330 | { } |
| 331 | }; |
| 332 | MODULE_DEVICE_TABLE(i2c, max77693_i2c_id); |
| 333 | |
Chanwoo Choi | 6592ebb | 2012-05-14 22:54:20 +0200 | [diff] [blame] | 334 | static int max77693_suspend(struct device *dev) |
| 335 | { |
| 336 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); |
| 337 | struct max77693_dev *max77693 = i2c_get_clientdata(i2c); |
| 338 | |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 339 | if (device_may_wakeup(dev)) { |
| 340 | enable_irq_wake(max77693->irq); |
| 341 | disable_irq(max77693->irq); |
| 342 | } |
| 343 | |
Chanwoo Choi | 6592ebb | 2012-05-14 22:54:20 +0200 | [diff] [blame] | 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | static int max77693_resume(struct device *dev) |
| 348 | { |
| 349 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); |
| 350 | struct max77693_dev *max77693 = i2c_get_clientdata(i2c); |
| 351 | |
Robert Baldyga | 342d669 | 2014-05-21 08:52:48 +0200 | [diff] [blame] | 352 | if (device_may_wakeup(dev)) { |
| 353 | disable_irq_wake(max77693->irq); |
| 354 | enable_irq(max77693->irq); |
| 355 | } |
| 356 | |
| 357 | return 0; |
Chanwoo Choi | 6592ebb | 2012-05-14 22:54:20 +0200 | [diff] [blame] | 358 | } |
| 359 | |
Mark Brown | 12477a3 | 2012-06-05 16:15:59 +0100 | [diff] [blame] | 360 | static const struct dev_pm_ops max77693_pm = { |
Chanwoo Choi | 6592ebb | 2012-05-14 22:54:20 +0200 | [diff] [blame] | 361 | .suspend = max77693_suspend, |
| 362 | .resume = max77693_resume, |
| 363 | }; |
| 364 | |
Andrzej Hajda | 4657185 | 2013-09-27 09:27:46 +0200 | [diff] [blame] | 365 | #ifdef CONFIG_OF |
Krzysztof Kozlowski | 5ce9a55 | 2014-05-13 12:58:52 +0200 | [diff] [blame] | 366 | static const struct of_device_id max77693_dt_match[] = { |
Andrzej Hajda | 4657185 | 2013-09-27 09:27:46 +0200 | [diff] [blame] | 367 | { .compatible = "maxim,max77693" }, |
| 368 | {}, |
| 369 | }; |
| 370 | #endif |
| 371 | |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 372 | static struct i2c_driver max77693_i2c_driver = { |
| 373 | .driver = { |
| 374 | .name = "max77693", |
| 375 | .owner = THIS_MODULE, |
Chanwoo Choi | 6592ebb | 2012-05-14 22:54:20 +0200 | [diff] [blame] | 376 | .pm = &max77693_pm, |
Andrzej Hajda | 4657185 | 2013-09-27 09:27:46 +0200 | [diff] [blame] | 377 | .of_match_table = of_match_ptr(max77693_dt_match), |
Chanwoo Choi | 83871c0 | 2012-05-14 22:50:39 +0200 | [diff] [blame] | 378 | }, |
| 379 | .probe = max77693_i2c_probe, |
| 380 | .remove = max77693_i2c_remove, |
| 381 | .id_table = max77693_i2c_id, |
| 382 | }; |
| 383 | |
| 384 | static int __init max77693_i2c_init(void) |
| 385 | { |
| 386 | return i2c_add_driver(&max77693_i2c_driver); |
| 387 | } |
| 388 | /* init early so consumer devices can complete system boot */ |
| 389 | subsys_initcall(max77693_i2c_init); |
| 390 | |
| 391 | static void __exit max77693_i2c_exit(void) |
| 392 | { |
| 393 | i2c_del_driver(&max77693_i2c_driver); |
| 394 | } |
| 395 | module_exit(max77693_i2c_exit); |
| 396 | |
| 397 | MODULE_DESCRIPTION("MAXIM 77693 multi-function core driver"); |
| 398 | MODULE_AUTHOR("SangYoung, Son <hello.son@samsung.com>"); |
| 399 | MODULE_LICENSE("GPL"); |