0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/kernel.h>
0011 #include <linux/module.h>
0012 #include <linux/err.h>
0013 #include <linux/i2c.h>
0014 #include <linux/irq.h>
0015 #include <linux/interrupt.h>
0016 #include <linux/irqdomain.h>
0017 #include <linux/of.h>
0018 #include <linux/of_platform.h>
0019 #include <linux/platform_device.h>
0020 #include <linux/regmap.h>
0021 #include <linux/slab.h>
0022 #include <linux/mfd/core.h>
0023 #include <linux/mfd/88pm860x.h>
0024 #include <linux/regulator/machine.h>
0025 #include <linux/power/charger-manager.h>
0026
0027 #define INT_STATUS_NUM 3
0028
0029 static const struct resource bk0_resources[] = {
0030 {2, 2, "duty cycle", IORESOURCE_REG, },
0031 {3, 3, "always on", IORESOURCE_REG, },
0032 {3, 3, "current", IORESOURCE_REG, },
0033 };
0034 static const struct resource bk1_resources[] = {
0035 {4, 4, "duty cycle", IORESOURCE_REG, },
0036 {5, 5, "always on", IORESOURCE_REG, },
0037 {5, 5, "current", IORESOURCE_REG, },
0038 };
0039 static const struct resource bk2_resources[] = {
0040 {6, 6, "duty cycle", IORESOURCE_REG, },
0041 {7, 7, "always on", IORESOURCE_REG, },
0042 {5, 5, "current", IORESOURCE_REG, },
0043 };
0044
0045 static const struct resource led0_resources[] = {
0046
0047 {0xd, 0xd, "control", IORESOURCE_REG, },
0048 {0xc, 0xc, "blink", IORESOURCE_REG, },
0049 };
0050 static const struct resource led1_resources[] = {
0051
0052 {0xe, 0xe, "control", IORESOURCE_REG, },
0053 {0xc, 0xc, "blink", IORESOURCE_REG, },
0054 };
0055 static const struct resource led2_resources[] = {
0056
0057 {0xf, 0xf, "control", IORESOURCE_REG, },
0058 {0xc, 0xc, "blink", IORESOURCE_REG, },
0059 };
0060 static const struct resource led3_resources[] = {
0061
0062 {0x9, 0x9, "control", IORESOURCE_REG, },
0063 {0x8, 0x8, "blink", IORESOURCE_REG, },
0064 };
0065 static const struct resource led4_resources[] = {
0066
0067 {0xa, 0xa, "control", IORESOURCE_REG, },
0068 {0x8, 0x8, "blink", IORESOURCE_REG, },
0069 };
0070 static const struct resource led5_resources[] = {
0071
0072 {0xb, 0xb, "control", IORESOURCE_REG, },
0073 {0x8, 0x8, "blink", IORESOURCE_REG, },
0074 };
0075
0076 static const struct resource buck1_resources[] = {
0077 {0x24, 0x24, "buck set", IORESOURCE_REG, },
0078 };
0079 static const struct resource buck2_resources[] = {
0080 {0x25, 0x25, "buck set", IORESOURCE_REG, },
0081 };
0082 static const struct resource buck3_resources[] = {
0083 {0x26, 0x26, "buck set", IORESOURCE_REG, },
0084 };
0085 static const struct resource ldo1_resources[] = {
0086 {0x10, 0x10, "ldo set", IORESOURCE_REG, },
0087 };
0088 static const struct resource ldo2_resources[] = {
0089 {0x11, 0x11, "ldo set", IORESOURCE_REG, },
0090 };
0091 static const struct resource ldo3_resources[] = {
0092 {0x12, 0x12, "ldo set", IORESOURCE_REG, },
0093 };
0094 static const struct resource ldo4_resources[] = {
0095 {0x13, 0x13, "ldo set", IORESOURCE_REG, },
0096 };
0097 static const struct resource ldo5_resources[] = {
0098 {0x14, 0x14, "ldo set", IORESOURCE_REG, },
0099 };
0100 static const struct resource ldo6_resources[] = {
0101 {0x15, 0x15, "ldo set", IORESOURCE_REG, },
0102 };
0103 static const struct resource ldo7_resources[] = {
0104 {0x16, 0x16, "ldo set", IORESOURCE_REG, },
0105 };
0106 static const struct resource ldo8_resources[] = {
0107 {0x17, 0x17, "ldo set", IORESOURCE_REG, },
0108 };
0109 static const struct resource ldo9_resources[] = {
0110 {0x18, 0x18, "ldo set", IORESOURCE_REG, },
0111 };
0112 static const struct resource ldo10_resources[] = {
0113 {0x19, 0x19, "ldo set", IORESOURCE_REG, },
0114 };
0115 static const struct resource ldo12_resources[] = {
0116 {0x1a, 0x1a, "ldo set", IORESOURCE_REG, },
0117 };
0118 static const struct resource ldo_vibrator_resources[] = {
0119 {0x28, 0x28, "ldo set", IORESOURCE_REG, },
0120 };
0121 static const struct resource ldo14_resources[] = {
0122 {0x1b, 0x1b, "ldo set", IORESOURCE_REG, },
0123 };
0124
0125 static struct resource touch_resources[] = {
0126 {PM8607_IRQ_PEN, PM8607_IRQ_PEN, "touch", IORESOURCE_IRQ,},
0127 };
0128
0129 static struct resource onkey_resources[] = {
0130 {PM8607_IRQ_ONKEY, PM8607_IRQ_ONKEY, "onkey", IORESOURCE_IRQ,},
0131 };
0132
0133 static struct resource codec_resources[] = {
0134
0135 {PM8607_IRQ_MICIN, PM8607_IRQ_MICIN, "micin", IORESOURCE_IRQ,},
0136
0137 {PM8607_IRQ_HOOK, PM8607_IRQ_HOOK, "hook", IORESOURCE_IRQ,},
0138
0139 {PM8607_IRQ_HEADSET, PM8607_IRQ_HEADSET, "headset", IORESOURCE_IRQ,},
0140
0141 {PM8607_IRQ_AUDIO_SHORT, PM8607_IRQ_AUDIO_SHORT, "audio-short",
0142 IORESOURCE_IRQ,},
0143 };
0144
0145 static struct resource battery_resources[] = {
0146 {PM8607_IRQ_CC, PM8607_IRQ_CC, "columb counter", IORESOURCE_IRQ,},
0147 {PM8607_IRQ_BAT, PM8607_IRQ_BAT, "battery", IORESOURCE_IRQ,},
0148 };
0149
0150 static struct resource charger_resources[] = {
0151 {PM8607_IRQ_CHG, PM8607_IRQ_CHG, "charger detect", IORESOURCE_IRQ,},
0152 {PM8607_IRQ_CHG_DONE, PM8607_IRQ_CHG_DONE, "charging done",
0153 IORESOURCE_IRQ,},
0154 {PM8607_IRQ_CHG_FAIL, PM8607_IRQ_CHG_FAIL, "charging timeout",
0155 IORESOURCE_IRQ,},
0156 {PM8607_IRQ_CHG_FAULT, PM8607_IRQ_CHG_FAULT, "charging fault",
0157 IORESOURCE_IRQ,},
0158 {PM8607_IRQ_GPADC1, PM8607_IRQ_GPADC1, "battery temperature",
0159 IORESOURCE_IRQ,},
0160 {PM8607_IRQ_VBAT, PM8607_IRQ_VBAT, "battery voltage", IORESOURCE_IRQ,},
0161 {PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,},
0162 };
0163
0164 static struct resource rtc_resources[] = {
0165 {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,},
0166 };
0167
0168 static struct mfd_cell bk_devs[] = {
0169 {
0170 .name = "88pm860x-backlight",
0171 .id = 0,
0172 .num_resources = ARRAY_SIZE(bk0_resources),
0173 .resources = bk0_resources,
0174 }, {
0175 .name = "88pm860x-backlight",
0176 .id = 1,
0177 .num_resources = ARRAY_SIZE(bk1_resources),
0178 .resources = bk1_resources,
0179 }, {
0180 .name = "88pm860x-backlight",
0181 .id = 2,
0182 .num_resources = ARRAY_SIZE(bk2_resources),
0183 .resources = bk2_resources,
0184 },
0185 };
0186
0187 static struct mfd_cell led_devs[] = {
0188 {
0189 .name = "88pm860x-led",
0190 .id = 0,
0191 .num_resources = ARRAY_SIZE(led0_resources),
0192 .resources = led0_resources,
0193 }, {
0194 .name = "88pm860x-led",
0195 .id = 1,
0196 .num_resources = ARRAY_SIZE(led1_resources),
0197 .resources = led1_resources,
0198 }, {
0199 .name = "88pm860x-led",
0200 .id = 2,
0201 .num_resources = ARRAY_SIZE(led2_resources),
0202 .resources = led2_resources,
0203 }, {
0204 .name = "88pm860x-led",
0205 .id = 3,
0206 .num_resources = ARRAY_SIZE(led3_resources),
0207 .resources = led3_resources,
0208 }, {
0209 .name = "88pm860x-led",
0210 .id = 4,
0211 .num_resources = ARRAY_SIZE(led4_resources),
0212 .resources = led4_resources,
0213 }, {
0214 .name = "88pm860x-led",
0215 .id = 5,
0216 .num_resources = ARRAY_SIZE(led5_resources),
0217 .resources = led5_resources,
0218 },
0219 };
0220
0221 static struct mfd_cell reg_devs[] = {
0222 {
0223 .name = "88pm860x-regulator",
0224 .id = 0,
0225 .num_resources = ARRAY_SIZE(buck1_resources),
0226 .resources = buck1_resources,
0227 }, {
0228 .name = "88pm860x-regulator",
0229 .id = 1,
0230 .num_resources = ARRAY_SIZE(buck2_resources),
0231 .resources = buck2_resources,
0232 }, {
0233 .name = "88pm860x-regulator",
0234 .id = 2,
0235 .num_resources = ARRAY_SIZE(buck3_resources),
0236 .resources = buck3_resources,
0237 }, {
0238 .name = "88pm860x-regulator",
0239 .id = 3,
0240 .num_resources = ARRAY_SIZE(ldo1_resources),
0241 .resources = ldo1_resources,
0242 }, {
0243 .name = "88pm860x-regulator",
0244 .id = 4,
0245 .num_resources = ARRAY_SIZE(ldo2_resources),
0246 .resources = ldo2_resources,
0247 }, {
0248 .name = "88pm860x-regulator",
0249 .id = 5,
0250 .num_resources = ARRAY_SIZE(ldo3_resources),
0251 .resources = ldo3_resources,
0252 }, {
0253 .name = "88pm860x-regulator",
0254 .id = 6,
0255 .num_resources = ARRAY_SIZE(ldo4_resources),
0256 .resources = ldo4_resources,
0257 }, {
0258 .name = "88pm860x-regulator",
0259 .id = 7,
0260 .num_resources = ARRAY_SIZE(ldo5_resources),
0261 .resources = ldo5_resources,
0262 }, {
0263 .name = "88pm860x-regulator",
0264 .id = 8,
0265 .num_resources = ARRAY_SIZE(ldo6_resources),
0266 .resources = ldo6_resources,
0267 }, {
0268 .name = "88pm860x-regulator",
0269 .id = 9,
0270 .num_resources = ARRAY_SIZE(ldo7_resources),
0271 .resources = ldo7_resources,
0272 }, {
0273 .name = "88pm860x-regulator",
0274 .id = 10,
0275 .num_resources = ARRAY_SIZE(ldo8_resources),
0276 .resources = ldo8_resources,
0277 }, {
0278 .name = "88pm860x-regulator",
0279 .id = 11,
0280 .num_resources = ARRAY_SIZE(ldo9_resources),
0281 .resources = ldo9_resources,
0282 }, {
0283 .name = "88pm860x-regulator",
0284 .id = 12,
0285 .num_resources = ARRAY_SIZE(ldo10_resources),
0286 .resources = ldo10_resources,
0287 }, {
0288 .name = "88pm860x-regulator",
0289 .id = 13,
0290 .num_resources = ARRAY_SIZE(ldo12_resources),
0291 .resources = ldo12_resources,
0292 }, {
0293 .name = "88pm860x-regulator",
0294 .id = 14,
0295 .num_resources = ARRAY_SIZE(ldo_vibrator_resources),
0296 .resources = ldo_vibrator_resources,
0297 }, {
0298 .name = "88pm860x-regulator",
0299 .id = 15,
0300 .num_resources = ARRAY_SIZE(ldo14_resources),
0301 .resources = ldo14_resources,
0302 },
0303 };
0304
0305 static struct mfd_cell touch_devs[] = {
0306 {"88pm860x-touch", -1,},
0307 };
0308
0309 static struct mfd_cell onkey_devs[] = {
0310 {"88pm860x-onkey", -1,},
0311 };
0312
0313 static struct mfd_cell codec_devs[] = {
0314 {"88pm860x-codec", -1,},
0315 };
0316
0317 static struct regulator_consumer_supply preg_supply[] = {
0318 REGULATOR_SUPPLY("preg", "charger-manager"),
0319 };
0320
0321 static struct regulator_init_data preg_init_data = {
0322 .num_consumer_supplies = ARRAY_SIZE(preg_supply),
0323 .consumer_supplies = &preg_supply[0],
0324 };
0325
0326 static struct charger_regulator chg_desc_regulator_data[] = {
0327 { .regulator_name = "preg", },
0328 };
0329
0330 static struct mfd_cell power_devs[] = {
0331 {"88pm860x-battery", -1,},
0332 {"88pm860x-charger", -1,},
0333 {"88pm860x-preg", -1,},
0334 {"charger-manager", -1,},
0335 };
0336
0337 static struct mfd_cell rtc_devs[] = {
0338 {"88pm860x-rtc", -1,},
0339 };
0340
0341
0342 struct pm860x_irq_data {
0343 int reg;
0344 int mask_reg;
0345 int enable;
0346 int offs;
0347 };
0348
0349 static struct pm860x_irq_data pm860x_irqs[] = {
0350 [PM8607_IRQ_ONKEY] = {
0351 .reg = PM8607_INT_STATUS1,
0352 .mask_reg = PM8607_INT_MASK_1,
0353 .offs = 1 << 0,
0354 },
0355 [PM8607_IRQ_EXTON] = {
0356 .reg = PM8607_INT_STATUS1,
0357 .mask_reg = PM8607_INT_MASK_1,
0358 .offs = 1 << 1,
0359 },
0360 [PM8607_IRQ_CHG] = {
0361 .reg = PM8607_INT_STATUS1,
0362 .mask_reg = PM8607_INT_MASK_1,
0363 .offs = 1 << 2,
0364 },
0365 [PM8607_IRQ_BAT] = {
0366 .reg = PM8607_INT_STATUS1,
0367 .mask_reg = PM8607_INT_MASK_1,
0368 .offs = 1 << 3,
0369 },
0370 [PM8607_IRQ_RTC] = {
0371 .reg = PM8607_INT_STATUS1,
0372 .mask_reg = PM8607_INT_MASK_1,
0373 .offs = 1 << 4,
0374 },
0375 [PM8607_IRQ_CC] = {
0376 .reg = PM8607_INT_STATUS1,
0377 .mask_reg = PM8607_INT_MASK_1,
0378 .offs = 1 << 5,
0379 },
0380 [PM8607_IRQ_VBAT] = {
0381 .reg = PM8607_INT_STATUS2,
0382 .mask_reg = PM8607_INT_MASK_2,
0383 .offs = 1 << 0,
0384 },
0385 [PM8607_IRQ_VCHG] = {
0386 .reg = PM8607_INT_STATUS2,
0387 .mask_reg = PM8607_INT_MASK_2,
0388 .offs = 1 << 1,
0389 },
0390 [PM8607_IRQ_VSYS] = {
0391 .reg = PM8607_INT_STATUS2,
0392 .mask_reg = PM8607_INT_MASK_2,
0393 .offs = 1 << 2,
0394 },
0395 [PM8607_IRQ_TINT] = {
0396 .reg = PM8607_INT_STATUS2,
0397 .mask_reg = PM8607_INT_MASK_2,
0398 .offs = 1 << 3,
0399 },
0400 [PM8607_IRQ_GPADC0] = {
0401 .reg = PM8607_INT_STATUS2,
0402 .mask_reg = PM8607_INT_MASK_2,
0403 .offs = 1 << 4,
0404 },
0405 [PM8607_IRQ_GPADC1] = {
0406 .reg = PM8607_INT_STATUS2,
0407 .mask_reg = PM8607_INT_MASK_2,
0408 .offs = 1 << 5,
0409 },
0410 [PM8607_IRQ_GPADC2] = {
0411 .reg = PM8607_INT_STATUS2,
0412 .mask_reg = PM8607_INT_MASK_2,
0413 .offs = 1 << 6,
0414 },
0415 [PM8607_IRQ_GPADC3] = {
0416 .reg = PM8607_INT_STATUS2,
0417 .mask_reg = PM8607_INT_MASK_2,
0418 .offs = 1 << 7,
0419 },
0420 [PM8607_IRQ_AUDIO_SHORT] = {
0421 .reg = PM8607_INT_STATUS3,
0422 .mask_reg = PM8607_INT_MASK_3,
0423 .offs = 1 << 0,
0424 },
0425 [PM8607_IRQ_PEN] = {
0426 .reg = PM8607_INT_STATUS3,
0427 .mask_reg = PM8607_INT_MASK_3,
0428 .offs = 1 << 1,
0429 },
0430 [PM8607_IRQ_HEADSET] = {
0431 .reg = PM8607_INT_STATUS3,
0432 .mask_reg = PM8607_INT_MASK_3,
0433 .offs = 1 << 2,
0434 },
0435 [PM8607_IRQ_HOOK] = {
0436 .reg = PM8607_INT_STATUS3,
0437 .mask_reg = PM8607_INT_MASK_3,
0438 .offs = 1 << 3,
0439 },
0440 [PM8607_IRQ_MICIN] = {
0441 .reg = PM8607_INT_STATUS3,
0442 .mask_reg = PM8607_INT_MASK_3,
0443 .offs = 1 << 4,
0444 },
0445 [PM8607_IRQ_CHG_FAIL] = {
0446 .reg = PM8607_INT_STATUS3,
0447 .mask_reg = PM8607_INT_MASK_3,
0448 .offs = 1 << 5,
0449 },
0450 [PM8607_IRQ_CHG_DONE] = {
0451 .reg = PM8607_INT_STATUS3,
0452 .mask_reg = PM8607_INT_MASK_3,
0453 .offs = 1 << 6,
0454 },
0455 [PM8607_IRQ_CHG_FAULT] = {
0456 .reg = PM8607_INT_STATUS3,
0457 .mask_reg = PM8607_INT_MASK_3,
0458 .offs = 1 << 7,
0459 },
0460 };
0461
0462 static irqreturn_t pm860x_irq(int irq, void *data)
0463 {
0464 struct pm860x_chip *chip = data;
0465 struct pm860x_irq_data *irq_data;
0466 struct i2c_client *i2c;
0467 int read_reg = -1, value = 0;
0468 int i;
0469
0470 i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
0471 for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) {
0472 irq_data = &pm860x_irqs[i];
0473 if (read_reg != irq_data->reg) {
0474 read_reg = irq_data->reg;
0475 value = pm860x_reg_read(i2c, irq_data->reg);
0476 }
0477 if (value & irq_data->enable)
0478 handle_nested_irq(chip->irq_base + i);
0479 }
0480 return IRQ_HANDLED;
0481 }
0482
0483 static void pm860x_irq_lock(struct irq_data *data)
0484 {
0485 struct pm860x_chip *chip = irq_data_get_irq_chip_data(data);
0486
0487 mutex_lock(&chip->irq_lock);
0488 }
0489
0490 static void pm860x_irq_sync_unlock(struct irq_data *data)
0491 {
0492 struct pm860x_chip *chip = irq_data_get_irq_chip_data(data);
0493 struct pm860x_irq_data *irq_data;
0494 struct i2c_client *i2c;
0495 static unsigned char cached[3] = {0x0, 0x0, 0x0};
0496 unsigned char mask[3];
0497 int i;
0498
0499 i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
0500
0501 for (i = 0; i < 3; i++)
0502 mask[i] = cached[i];
0503 for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) {
0504 irq_data = &pm860x_irqs[i];
0505 switch (irq_data->mask_reg) {
0506 case PM8607_INT_MASK_1:
0507 mask[0] &= ~irq_data->offs;
0508 mask[0] |= irq_data->enable;
0509 break;
0510 case PM8607_INT_MASK_2:
0511 mask[1] &= ~irq_data->offs;
0512 mask[1] |= irq_data->enable;
0513 break;
0514 case PM8607_INT_MASK_3:
0515 mask[2] &= ~irq_data->offs;
0516 mask[2] |= irq_data->enable;
0517 break;
0518 default:
0519 dev_err(chip->dev, "wrong IRQ\n");
0520 break;
0521 }
0522 }
0523
0524 for (i = 0; i < 3; i++) {
0525 if (mask[i] != cached[i]) {
0526 cached[i] = mask[i];
0527 pm860x_reg_write(i2c, PM8607_INT_MASK_1 + i, mask[i]);
0528 }
0529 }
0530
0531 mutex_unlock(&chip->irq_lock);
0532 }
0533
0534 static void pm860x_irq_enable(struct irq_data *data)
0535 {
0536 pm860x_irqs[data->hwirq].enable = pm860x_irqs[data->hwirq].offs;
0537 }
0538
0539 static void pm860x_irq_disable(struct irq_data *data)
0540 {
0541 pm860x_irqs[data->hwirq].enable = 0;
0542 }
0543
0544 static struct irq_chip pm860x_irq_chip = {
0545 .name = "88pm860x",
0546 .irq_bus_lock = pm860x_irq_lock,
0547 .irq_bus_sync_unlock = pm860x_irq_sync_unlock,
0548 .irq_enable = pm860x_irq_enable,
0549 .irq_disable = pm860x_irq_disable,
0550 };
0551
0552 static int pm860x_irq_domain_map(struct irq_domain *d, unsigned int virq,
0553 irq_hw_number_t hw)
0554 {
0555 irq_set_chip_data(virq, d->host_data);
0556 irq_set_chip_and_handler(virq, &pm860x_irq_chip, handle_edge_irq);
0557 irq_set_nested_thread(virq, 1);
0558 irq_set_noprobe(virq);
0559 return 0;
0560 }
0561
0562 static const struct irq_domain_ops pm860x_irq_domain_ops = {
0563 .map = pm860x_irq_domain_map,
0564 .xlate = irq_domain_xlate_onetwocell,
0565 };
0566
0567 static int device_irq_init(struct pm860x_chip *chip,
0568 struct pm860x_platform_data *pdata)
0569 {
0570 struct i2c_client *i2c = (chip->id == CHIP_PM8607) ?
0571 chip->client : chip->companion;
0572 unsigned char status_buf[INT_STATUS_NUM];
0573 unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
0574 int data, mask, ret = -EINVAL;
0575 int nr_irqs, irq_base = -1;
0576 struct device_node *node = i2c->dev.of_node;
0577
0578 mask = PM8607_B0_MISC1_INV_INT | PM8607_B0_MISC1_INT_CLEAR
0579 | PM8607_B0_MISC1_INT_MASK;
0580 data = 0;
0581 chip->irq_mode = 0;
0582 if (pdata && pdata->irq_mode) {
0583
0584
0585
0586
0587
0588 data |= PM8607_B0_MISC1_INT_CLEAR;
0589 chip->irq_mode = 1;
0590 }
0591 ret = pm860x_set_bits(i2c, PM8607_B0_MISC1, mask, data);
0592 if (ret < 0)
0593 goto out;
0594
0595
0596 memset(status_buf, 0, INT_STATUS_NUM);
0597 ret = pm860x_bulk_write(i2c, PM8607_INT_MASK_1,
0598 INT_STATUS_NUM, status_buf);
0599 if (ret < 0)
0600 goto out;
0601
0602 if (chip->irq_mode) {
0603
0604 memset(status_buf, 0xFF, INT_STATUS_NUM);
0605 ret = pm860x_bulk_write(i2c, PM8607_INT_STATUS1,
0606 INT_STATUS_NUM, status_buf);
0607 } else {
0608
0609 ret = pm860x_bulk_read(i2c, PM8607_INT_STATUS1,
0610 INT_STATUS_NUM, status_buf);
0611 }
0612 if (ret < 0)
0613 goto out;
0614
0615 mutex_init(&chip->irq_lock);
0616
0617 if (pdata && pdata->irq_base)
0618 irq_base = pdata->irq_base;
0619 nr_irqs = ARRAY_SIZE(pm860x_irqs);
0620 chip->irq_base = irq_alloc_descs(irq_base, 0, nr_irqs, 0);
0621 if (chip->irq_base < 0) {
0622 dev_err(&i2c->dev, "Failed to allocate interrupts, ret:%d\n",
0623 chip->irq_base);
0624 ret = -EBUSY;
0625 goto out;
0626 }
0627 irq_domain_add_legacy(node, nr_irqs, chip->irq_base, 0,
0628 &pm860x_irq_domain_ops, chip);
0629 chip->core_irq = i2c->irq;
0630 if (!chip->core_irq)
0631 goto out;
0632
0633 ret = request_threaded_irq(chip->core_irq, NULL, pm860x_irq,
0634 flags | IRQF_ONESHOT, "88pm860x", chip);
0635 if (ret) {
0636 dev_err(chip->dev, "Failed to request IRQ: %d\n", ret);
0637 chip->core_irq = 0;
0638 }
0639
0640 return 0;
0641 out:
0642 chip->core_irq = 0;
0643 return ret;
0644 }
0645
0646 static void device_irq_exit(struct pm860x_chip *chip)
0647 {
0648 if (chip->core_irq)
0649 free_irq(chip->core_irq, chip);
0650 }
0651
0652 int pm8606_osc_enable(struct pm860x_chip *chip, unsigned short client)
0653 {
0654 int ret = -EIO;
0655 struct i2c_client *i2c = (chip->id == CHIP_PM8606) ?
0656 chip->client : chip->companion;
0657
0658 dev_dbg(chip->dev, "%s(B): client=0x%x\n", __func__, client);
0659 dev_dbg(chip->dev, "%s(B): vote=0x%x status=%d\n",
0660 __func__, chip->osc_vote,
0661 chip->osc_status);
0662
0663 mutex_lock(&chip->osc_lock);
0664
0665 chip->osc_vote |= client;
0666
0667 if (chip->osc_status != PM8606_REF_GP_OSC_ON) {
0668 chip->osc_status = PM8606_REF_GP_OSC_UNKNOWN;
0669
0670 if (pm860x_set_bits(i2c, PM8606_VSYS,
0671 PM8606_VSYS_EN, PM8606_VSYS_EN))
0672 goto out;
0673
0674
0675 if (pm860x_set_bits(i2c, PM8606_MISC,
0676 PM8606_MISC_OSC_EN, PM8606_MISC_OSC_EN))
0677 goto out;
0678
0679 chip->osc_status = PM8606_REF_GP_OSC_ON;
0680 }
0681 mutex_unlock(&chip->osc_lock);
0682
0683 dev_dbg(chip->dev, "%s(A): vote=0x%x status=%d ret=%d\n",
0684 __func__, chip->osc_vote,
0685 chip->osc_status, ret);
0686 return 0;
0687 out:
0688 mutex_unlock(&chip->osc_lock);
0689 return ret;
0690 }
0691 EXPORT_SYMBOL(pm8606_osc_enable);
0692
0693 int pm8606_osc_disable(struct pm860x_chip *chip, unsigned short client)
0694 {
0695 int ret = -EIO;
0696 struct i2c_client *i2c = (chip->id == CHIP_PM8606) ?
0697 chip->client : chip->companion;
0698
0699 dev_dbg(chip->dev, "%s(B): client=0x%x\n", __func__, client);
0700 dev_dbg(chip->dev, "%s(B): vote=0x%x status=%d\n",
0701 __func__, chip->osc_vote,
0702 chip->osc_status);
0703
0704 mutex_lock(&chip->osc_lock);
0705
0706 chip->osc_vote &= ~(client);
0707
0708
0709
0710
0711 if ((chip->osc_status != PM8606_REF_GP_OSC_OFF) &&
0712 (chip->osc_vote == REF_GP_NO_CLIENTS)) {
0713 chip->osc_status = PM8606_REF_GP_OSC_UNKNOWN;
0714
0715 if (pm860x_set_bits(i2c, PM8606_VSYS, PM8606_VSYS_EN, 0))
0716 goto out;
0717
0718 if (pm860x_set_bits(i2c, PM8606_MISC, PM8606_MISC_OSC_EN, 0))
0719 goto out;
0720 chip->osc_status = PM8606_REF_GP_OSC_OFF;
0721 }
0722 mutex_unlock(&chip->osc_lock);
0723
0724 dev_dbg(chip->dev, "%s(A): vote=0x%x status=%d ret=%d\n",
0725 __func__, chip->osc_vote,
0726 chip->osc_status, ret);
0727 return 0;
0728 out:
0729 mutex_unlock(&chip->osc_lock);
0730 return ret;
0731 }
0732 EXPORT_SYMBOL(pm8606_osc_disable);
0733
0734 static void device_osc_init(struct i2c_client *i2c)
0735 {
0736 struct pm860x_chip *chip = i2c_get_clientdata(i2c);
0737
0738 mutex_init(&chip->osc_lock);
0739
0740
0741 pm860x_set_bits(i2c, PM8606_VSYS, PM8606_VSYS_EN, 0);
0742
0743 pm860x_set_bits(i2c, PM8606_MISC, PM8606_MISC_OSC_EN, 0);
0744
0745 chip->osc_vote = REF_GP_NO_CLIENTS;
0746 chip->osc_status = PM8606_REF_GP_OSC_OFF;
0747 }
0748
0749 static void device_bk_init(struct pm860x_chip *chip,
0750 struct pm860x_platform_data *pdata)
0751 {
0752 int ret, i;
0753
0754 if (pdata && pdata->backlight) {
0755 if (pdata->num_backlights > ARRAY_SIZE(bk_devs))
0756 pdata->num_backlights = ARRAY_SIZE(bk_devs);
0757 for (i = 0; i < pdata->num_backlights; i++) {
0758 bk_devs[i].platform_data = &pdata->backlight[i];
0759 bk_devs[i].pdata_size =
0760 sizeof(struct pm860x_backlight_pdata);
0761 }
0762 }
0763 ret = mfd_add_devices(chip->dev, 0, bk_devs,
0764 ARRAY_SIZE(bk_devs), NULL, 0, NULL);
0765 if (ret < 0)
0766 dev_err(chip->dev, "Failed to add backlight subdev\n");
0767 }
0768
0769 static void device_led_init(struct pm860x_chip *chip,
0770 struct pm860x_platform_data *pdata)
0771 {
0772 int ret, i;
0773
0774 if (pdata && pdata->led) {
0775 if (pdata->num_leds > ARRAY_SIZE(led_devs))
0776 pdata->num_leds = ARRAY_SIZE(led_devs);
0777 for (i = 0; i < pdata->num_leds; i++) {
0778 led_devs[i].platform_data = &pdata->led[i];
0779 led_devs[i].pdata_size =
0780 sizeof(struct pm860x_led_pdata);
0781 }
0782 }
0783 ret = mfd_add_devices(chip->dev, 0, led_devs,
0784 ARRAY_SIZE(led_devs), NULL, 0, NULL);
0785 if (ret < 0) {
0786 dev_err(chip->dev, "Failed to add led subdev\n");
0787 return;
0788 }
0789 }
0790
0791 static void device_regulator_init(struct pm860x_chip *chip,
0792 struct pm860x_platform_data *pdata)
0793 {
0794 int ret;
0795
0796 if (pdata == NULL)
0797 return;
0798 if (pdata->buck1) {
0799 reg_devs[0].platform_data = pdata->buck1;
0800 reg_devs[0].pdata_size = sizeof(struct regulator_init_data);
0801 }
0802 if (pdata->buck2) {
0803 reg_devs[1].platform_data = pdata->buck2;
0804 reg_devs[1].pdata_size = sizeof(struct regulator_init_data);
0805 }
0806 if (pdata->buck3) {
0807 reg_devs[2].platform_data = pdata->buck3;
0808 reg_devs[2].pdata_size = sizeof(struct regulator_init_data);
0809 }
0810 if (pdata->ldo1) {
0811 reg_devs[3].platform_data = pdata->ldo1;
0812 reg_devs[3].pdata_size = sizeof(struct regulator_init_data);
0813 }
0814 if (pdata->ldo2) {
0815 reg_devs[4].platform_data = pdata->ldo2;
0816 reg_devs[4].pdata_size = sizeof(struct regulator_init_data);
0817 }
0818 if (pdata->ldo3) {
0819 reg_devs[5].platform_data = pdata->ldo3;
0820 reg_devs[5].pdata_size = sizeof(struct regulator_init_data);
0821 }
0822 if (pdata->ldo4) {
0823 reg_devs[6].platform_data = pdata->ldo4;
0824 reg_devs[6].pdata_size = sizeof(struct regulator_init_data);
0825 }
0826 if (pdata->ldo5) {
0827 reg_devs[7].platform_data = pdata->ldo5;
0828 reg_devs[7].pdata_size = sizeof(struct regulator_init_data);
0829 }
0830 if (pdata->ldo6) {
0831 reg_devs[8].platform_data = pdata->ldo6;
0832 reg_devs[8].pdata_size = sizeof(struct regulator_init_data);
0833 }
0834 if (pdata->ldo7) {
0835 reg_devs[9].platform_data = pdata->ldo7;
0836 reg_devs[9].pdata_size = sizeof(struct regulator_init_data);
0837 }
0838 if (pdata->ldo8) {
0839 reg_devs[10].platform_data = pdata->ldo8;
0840 reg_devs[10].pdata_size = sizeof(struct regulator_init_data);
0841 }
0842 if (pdata->ldo9) {
0843 reg_devs[11].platform_data = pdata->ldo9;
0844 reg_devs[11].pdata_size = sizeof(struct regulator_init_data);
0845 }
0846 if (pdata->ldo10) {
0847 reg_devs[12].platform_data = pdata->ldo10;
0848 reg_devs[12].pdata_size = sizeof(struct regulator_init_data);
0849 }
0850 if (pdata->ldo12) {
0851 reg_devs[13].platform_data = pdata->ldo12;
0852 reg_devs[13].pdata_size = sizeof(struct regulator_init_data);
0853 }
0854 if (pdata->ldo_vibrator) {
0855 reg_devs[14].platform_data = pdata->ldo_vibrator;
0856 reg_devs[14].pdata_size = sizeof(struct regulator_init_data);
0857 }
0858 if (pdata->ldo14) {
0859 reg_devs[15].platform_data = pdata->ldo14;
0860 reg_devs[15].pdata_size = sizeof(struct regulator_init_data);
0861 }
0862 ret = mfd_add_devices(chip->dev, 0, reg_devs,
0863 ARRAY_SIZE(reg_devs), NULL, 0, NULL);
0864 if (ret < 0) {
0865 dev_err(chip->dev, "Failed to add regulator subdev\n");
0866 return;
0867 }
0868 }
0869
0870 static void device_rtc_init(struct pm860x_chip *chip,
0871 struct pm860x_platform_data *pdata)
0872 {
0873 int ret;
0874
0875 if (!pdata)
0876 return;
0877
0878 rtc_devs[0].platform_data = pdata->rtc;
0879 rtc_devs[0].pdata_size = sizeof(struct pm860x_rtc_pdata);
0880 rtc_devs[0].num_resources = ARRAY_SIZE(rtc_resources);
0881 rtc_devs[0].resources = &rtc_resources[0];
0882 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
0883 ARRAY_SIZE(rtc_devs), &rtc_resources[0],
0884 chip->irq_base, NULL);
0885 if (ret < 0)
0886 dev_err(chip->dev, "Failed to add rtc subdev\n");
0887 }
0888
0889 static void device_touch_init(struct pm860x_chip *chip,
0890 struct pm860x_platform_data *pdata)
0891 {
0892 int ret;
0893
0894 if (pdata == NULL)
0895 return;
0896
0897 touch_devs[0].platform_data = pdata->touch;
0898 touch_devs[0].pdata_size = sizeof(struct pm860x_touch_pdata);
0899 touch_devs[0].num_resources = ARRAY_SIZE(touch_resources);
0900 touch_devs[0].resources = &touch_resources[0];
0901 ret = mfd_add_devices(chip->dev, 0, &touch_devs[0],
0902 ARRAY_SIZE(touch_devs), &touch_resources[0],
0903 chip->irq_base, NULL);
0904 if (ret < 0)
0905 dev_err(chip->dev, "Failed to add touch subdev\n");
0906 }
0907
0908 static void device_power_init(struct pm860x_chip *chip,
0909 struct pm860x_platform_data *pdata)
0910 {
0911 int ret;
0912
0913 if (pdata == NULL)
0914 return;
0915
0916 power_devs[0].platform_data = pdata->power;
0917 power_devs[0].pdata_size = sizeof(struct pm860x_power_pdata);
0918 power_devs[0].num_resources = ARRAY_SIZE(battery_resources);
0919 power_devs[0].resources = &battery_resources[0],
0920 ret = mfd_add_devices(chip->dev, 0, &power_devs[0], 1,
0921 &battery_resources[0], chip->irq_base, NULL);
0922 if (ret < 0)
0923 dev_err(chip->dev, "Failed to add battery subdev\n");
0924
0925 power_devs[1].platform_data = pdata->power;
0926 power_devs[1].pdata_size = sizeof(struct pm860x_power_pdata);
0927 power_devs[1].num_resources = ARRAY_SIZE(charger_resources);
0928 power_devs[1].resources = &charger_resources[0],
0929 ret = mfd_add_devices(chip->dev, 0, &power_devs[1], 1,
0930 &charger_resources[0], chip->irq_base, NULL);
0931 if (ret < 0)
0932 dev_err(chip->dev, "Failed to add charger subdev\n");
0933
0934 power_devs[2].platform_data = &preg_init_data;
0935 power_devs[2].pdata_size = sizeof(struct regulator_init_data);
0936 ret = mfd_add_devices(chip->dev, 0, &power_devs[2], 1,
0937 NULL, chip->irq_base, NULL);
0938 if (ret < 0)
0939 dev_err(chip->dev, "Failed to add preg subdev\n");
0940
0941 if (pdata->chg_desc) {
0942 pdata->chg_desc->charger_regulators =
0943 &chg_desc_regulator_data[0];
0944 pdata->chg_desc->num_charger_regulators =
0945 ARRAY_SIZE(chg_desc_regulator_data),
0946 power_devs[3].platform_data = pdata->chg_desc;
0947 power_devs[3].pdata_size = sizeof(*pdata->chg_desc);
0948 ret = mfd_add_devices(chip->dev, 0, &power_devs[3], 1,
0949 NULL, chip->irq_base, NULL);
0950 if (ret < 0)
0951 dev_err(chip->dev, "Failed to add chg-manager subdev\n");
0952 }
0953 }
0954
0955 static void device_onkey_init(struct pm860x_chip *chip,
0956 struct pm860x_platform_data *pdata)
0957 {
0958 int ret;
0959
0960 onkey_devs[0].num_resources = ARRAY_SIZE(onkey_resources);
0961 onkey_devs[0].resources = &onkey_resources[0],
0962 ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
0963 ARRAY_SIZE(onkey_devs), &onkey_resources[0],
0964 chip->irq_base, NULL);
0965 if (ret < 0)
0966 dev_err(chip->dev, "Failed to add onkey subdev\n");
0967 }
0968
0969 static void device_codec_init(struct pm860x_chip *chip,
0970 struct pm860x_platform_data *pdata)
0971 {
0972 int ret;
0973
0974 codec_devs[0].num_resources = ARRAY_SIZE(codec_resources);
0975 codec_devs[0].resources = &codec_resources[0],
0976 ret = mfd_add_devices(chip->dev, 0, &codec_devs[0],
0977 ARRAY_SIZE(codec_devs), &codec_resources[0], 0,
0978 NULL);
0979 if (ret < 0)
0980 dev_err(chip->dev, "Failed to add codec subdev\n");
0981 }
0982
0983 static void device_8607_init(struct pm860x_chip *chip,
0984 struct i2c_client *i2c,
0985 struct pm860x_platform_data *pdata)
0986 {
0987 int data, ret;
0988
0989 ret = pm860x_reg_read(i2c, PM8607_CHIP_ID);
0990 if (ret < 0) {
0991 dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
0992 goto out;
0993 }
0994 switch (ret & PM8607_VERSION_MASK) {
0995 case 0x40:
0996 case 0x50:
0997 dev_info(chip->dev, "Marvell 88PM8607 (ID: %02x) detected\n",
0998 ret);
0999 break;
1000 default:
1001 dev_err(chip->dev,
1002 "Failed to detect Marvell 88PM8607. Chip ID: %02x\n",
1003 ret);
1004 goto out;
1005 }
1006
1007 ret = pm860x_reg_read(i2c, PM8607_BUCK3);
1008 if (ret < 0) {
1009 dev_err(chip->dev, "Failed to read BUCK3 register: %d\n", ret);
1010 goto out;
1011 }
1012 if (ret & PM8607_BUCK3_DOUBLE)
1013 chip->buck3_double = 1;
1014
1015 ret = pm860x_reg_read(i2c, PM8607_B0_MISC1);
1016 if (ret < 0) {
1017 dev_err(chip->dev, "Failed to read MISC1 register: %d\n", ret);
1018 goto out;
1019 }
1020
1021 if (pdata && (pdata->i2c_port == PI2C_PORT))
1022 data = PM8607_B0_MISC1_PI2C;
1023 else
1024 data = 0;
1025 ret = pm860x_set_bits(i2c, PM8607_B0_MISC1, PM8607_B0_MISC1_PI2C, data);
1026 if (ret < 0) {
1027 dev_err(chip->dev, "Failed to access MISC1:%d\n", ret);
1028 goto out;
1029 }
1030
1031 ret = device_irq_init(chip, pdata);
1032 if (ret < 0)
1033 goto out;
1034
1035 device_regulator_init(chip, pdata);
1036 device_rtc_init(chip, pdata);
1037 device_onkey_init(chip, pdata);
1038 device_touch_init(chip, pdata);
1039 device_power_init(chip, pdata);
1040 device_codec_init(chip, pdata);
1041 out:
1042 return;
1043 }
1044
1045 static void device_8606_init(struct pm860x_chip *chip,
1046 struct i2c_client *i2c,
1047 struct pm860x_platform_data *pdata)
1048 {
1049 device_osc_init(i2c);
1050 device_bk_init(chip, pdata);
1051 device_led_init(chip, pdata);
1052 }
1053
1054 static int pm860x_device_init(struct pm860x_chip *chip,
1055 struct pm860x_platform_data *pdata)
1056 {
1057 chip->core_irq = 0;
1058
1059 switch (chip->id) {
1060 case CHIP_PM8606:
1061 device_8606_init(chip, chip->client, pdata);
1062 break;
1063 case CHIP_PM8607:
1064 device_8607_init(chip, chip->client, pdata);
1065 break;
1066 }
1067
1068 if (chip->companion) {
1069 switch (chip->id) {
1070 case CHIP_PM8607:
1071 device_8606_init(chip, chip->companion, pdata);
1072 break;
1073 case CHIP_PM8606:
1074 device_8607_init(chip, chip->companion, pdata);
1075 break;
1076 }
1077 }
1078
1079 return 0;
1080 }
1081
1082 static void pm860x_device_exit(struct pm860x_chip *chip)
1083 {
1084 device_irq_exit(chip);
1085 mfd_remove_devices(chip->dev);
1086 }
1087
1088 static int verify_addr(struct i2c_client *i2c)
1089 {
1090 unsigned short addr_8607[] = {0x30, 0x34};
1091 unsigned short addr_8606[] = {0x10, 0x11};
1092 int size, i;
1093
1094 if (i2c == NULL)
1095 return 0;
1096 size = ARRAY_SIZE(addr_8606);
1097 for (i = 0; i < size; i++) {
1098 if (i2c->addr == *(addr_8606 + i))
1099 return CHIP_PM8606;
1100 }
1101 size = ARRAY_SIZE(addr_8607);
1102 for (i = 0; i < size; i++) {
1103 if (i2c->addr == *(addr_8607 + i))
1104 return CHIP_PM8607;
1105 }
1106 return 0;
1107 }
1108
1109 static const struct regmap_config pm860x_regmap_config = {
1110 .reg_bits = 8,
1111 .val_bits = 8,
1112 };
1113
1114 static int pm860x_dt_init(struct device_node *np,
1115 struct device *dev,
1116 struct pm860x_platform_data *pdata)
1117 {
1118 int ret;
1119
1120 if (of_get_property(np, "marvell,88pm860x-irq-read-clr", NULL))
1121 pdata->irq_mode = 1;
1122 ret = of_property_read_u32(np, "marvell,88pm860x-slave-addr",
1123 &pdata->companion_addr);
1124 if (ret) {
1125 dev_err(dev,
1126 "Not found \"marvell,88pm860x-slave-addr\" property\n");
1127 pdata->companion_addr = 0;
1128 }
1129 return 0;
1130 }
1131
1132 static int pm860x_probe(struct i2c_client *client)
1133 {
1134 struct pm860x_platform_data *pdata = dev_get_platdata(&client->dev);
1135 struct device_node *node = client->dev.of_node;
1136 struct pm860x_chip *chip;
1137 int ret;
1138
1139 if (node && !pdata) {
1140
1141 pdata = devm_kzalloc(&client->dev,
1142 sizeof(struct pm860x_platform_data),
1143 GFP_KERNEL);
1144 if (!pdata)
1145 return -ENOMEM;
1146 ret = pm860x_dt_init(node, &client->dev, pdata);
1147 if (ret)
1148 return ret;
1149 } else if (!pdata) {
1150 pr_info("No platform data in %s!\n", __func__);
1151 return -EINVAL;
1152 }
1153
1154 chip = devm_kzalloc(&client->dev,
1155 sizeof(struct pm860x_chip), GFP_KERNEL);
1156 if (chip == NULL)
1157 return -ENOMEM;
1158
1159 chip->id = verify_addr(client);
1160 chip->regmap = devm_regmap_init_i2c(client, &pm860x_regmap_config);
1161 if (IS_ERR(chip->regmap)) {
1162 ret = PTR_ERR(chip->regmap);
1163 dev_err(&client->dev, "Failed to allocate register map: %d\n",
1164 ret);
1165 return ret;
1166 }
1167 chip->client = client;
1168 i2c_set_clientdata(client, chip);
1169 chip->dev = &client->dev;
1170 dev_set_drvdata(chip->dev, chip);
1171
1172
1173
1174
1175
1176
1177
1178
1179 if (pdata->companion_addr && (pdata->companion_addr != client->addr)) {
1180 chip->companion_addr = pdata->companion_addr;
1181 chip->companion = i2c_new_dummy_device(chip->client->adapter,
1182 chip->companion_addr);
1183 if (IS_ERR(chip->companion)) {
1184 dev_err(&client->dev,
1185 "Failed to allocate I2C companion device\n");
1186 return PTR_ERR(chip->companion);
1187 }
1188 chip->regmap_companion = regmap_init_i2c(chip->companion,
1189 &pm860x_regmap_config);
1190 if (IS_ERR(chip->regmap_companion)) {
1191 ret = PTR_ERR(chip->regmap_companion);
1192 dev_err(&chip->companion->dev,
1193 "Failed to allocate register map: %d\n", ret);
1194 i2c_unregister_device(chip->companion);
1195 return ret;
1196 }
1197 i2c_set_clientdata(chip->companion, chip);
1198 }
1199
1200 pm860x_device_init(chip, pdata);
1201 return 0;
1202 }
1203
1204 static int pm860x_remove(struct i2c_client *client)
1205 {
1206 struct pm860x_chip *chip = i2c_get_clientdata(client);
1207
1208 pm860x_device_exit(chip);
1209 if (chip->companion) {
1210 regmap_exit(chip->regmap_companion);
1211 i2c_unregister_device(chip->companion);
1212 }
1213 return 0;
1214 }
1215
1216 #ifdef CONFIG_PM_SLEEP
1217 static int pm860x_suspend(struct device *dev)
1218 {
1219 struct i2c_client *client = to_i2c_client(dev);
1220 struct pm860x_chip *chip = i2c_get_clientdata(client);
1221
1222 if (device_may_wakeup(dev) && chip->wakeup_flag)
1223 enable_irq_wake(chip->core_irq);
1224 return 0;
1225 }
1226
1227 static int pm860x_resume(struct device *dev)
1228 {
1229 struct i2c_client *client = to_i2c_client(dev);
1230 struct pm860x_chip *chip = i2c_get_clientdata(client);
1231
1232 if (device_may_wakeup(dev) && chip->wakeup_flag)
1233 disable_irq_wake(chip->core_irq);
1234 return 0;
1235 }
1236 #endif
1237
1238 static SIMPLE_DEV_PM_OPS(pm860x_pm_ops, pm860x_suspend, pm860x_resume);
1239
1240 static const struct i2c_device_id pm860x_id_table[] = {
1241 { "88PM860x", 0 },
1242 {}
1243 };
1244 MODULE_DEVICE_TABLE(i2c, pm860x_id_table);
1245
1246 static const struct of_device_id pm860x_dt_ids[] = {
1247 { .compatible = "marvell,88pm860x", },
1248 {},
1249 };
1250 MODULE_DEVICE_TABLE(of, pm860x_dt_ids);
1251
1252 static struct i2c_driver pm860x_driver = {
1253 .driver = {
1254 .name = "88PM860x",
1255 .pm = &pm860x_pm_ops,
1256 .of_match_table = pm860x_dt_ids,
1257 },
1258 .probe_new = pm860x_probe,
1259 .remove = pm860x_remove,
1260 .id_table = pm860x_id_table,
1261 };
1262
1263 static int __init pm860x_i2c_init(void)
1264 {
1265 int ret;
1266
1267 ret = i2c_add_driver(&pm860x_driver);
1268 if (ret != 0)
1269 pr_err("Failed to register 88PM860x I2C driver: %d\n", ret);
1270 return ret;
1271 }
1272 subsys_initcall(pm860x_i2c_init);
1273
1274 static void __exit pm860x_i2c_exit(void)
1275 {
1276 i2c_del_driver(&pm860x_driver);
1277 }
1278 module_exit(pm860x_i2c_exit);
1279
1280 MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM860x");
1281 MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
1282 MODULE_LICENSE("GPL");