xref: /openbmc/linux/drivers/mfd/tps6586x.c (revision 0cac60c7)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Core driver for TI TPS6586x PMIC family
4  *
5  * Copyright (c) 2010 CompuLab Ltd.
6  * Mike Rapoport <mike@compulab.co.il>
7  *
8  * Based on da903x.c.
9  * Copyright (C) 2008 Compulab, Ltd.
10  * Mike Rapoport <mike@compulab.co.il>
11  * Copyright (C) 2006-2008 Marvell International Ltd.
12  * Eric Miao <eric.miao@marvell.com>
13  */
14 
15 #include <linux/interrupt.h>
16 #include <linux/irq.h>
17 #include <linux/irqdomain.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/mutex.h>
21 #include <linux/slab.h>
22 #include <linux/err.h>
23 #include <linux/i2c.h>
24 #include <linux/platform_device.h>
25 #include <linux/regmap.h>
26 #include <linux/of.h>
27 
28 #include <linux/mfd/core.h>
29 #include <linux/mfd/tps6586x.h>
30 
31 #define TPS6586X_SUPPLYENE	0x14
32 #define EXITSLREQ_BIT		BIT(1)
33 #define SLEEP_MODE_BIT		BIT(3)
34 
35 /* interrupt control registers */
36 #define TPS6586X_INT_ACK1	0xb5
37 #define TPS6586X_INT_ACK2	0xb6
38 #define TPS6586X_INT_ACK3	0xb7
39 #define TPS6586X_INT_ACK4	0xb8
40 
41 /* interrupt mask registers */
42 #define TPS6586X_INT_MASK1	0xb0
43 #define TPS6586X_INT_MASK2	0xb1
44 #define TPS6586X_INT_MASK3	0xb2
45 #define TPS6586X_INT_MASK4	0xb3
46 #define TPS6586X_INT_MASK5	0xb4
47 
48 /* device id */
49 #define TPS6586X_VERSIONCRC	0xcd
50 
51 /* Maximum register */
52 #define TPS6586X_MAX_REGISTER	TPS6586X_VERSIONCRC
53 
54 struct tps6586x_irq_data {
55 	u8	mask_reg;
56 	u8	mask_mask;
57 };
58 
59 #define TPS6586X_IRQ(_reg, _mask)				\
60 	{							\
61 		.mask_reg = (_reg) - TPS6586X_INT_MASK1,	\
62 		.mask_mask = (_mask),				\
63 	}
64 
65 static const struct tps6586x_irq_data tps6586x_irqs[] = {
66 	[TPS6586X_INT_PLDO_0]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 0),
67 	[TPS6586X_INT_PLDO_1]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 1),
68 	[TPS6586X_INT_PLDO_2]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 2),
69 	[TPS6586X_INT_PLDO_3]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 3),
70 	[TPS6586X_INT_PLDO_4]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 4),
71 	[TPS6586X_INT_PLDO_5]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 5),
72 	[TPS6586X_INT_PLDO_6]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 6),
73 	[TPS6586X_INT_PLDO_7]	= TPS6586X_IRQ(TPS6586X_INT_MASK1, 1 << 7),
74 	[TPS6586X_INT_COMP_DET]	= TPS6586X_IRQ(TPS6586X_INT_MASK4, 1 << 0),
75 	[TPS6586X_INT_ADC]	= TPS6586X_IRQ(TPS6586X_INT_MASK2, 1 << 1),
76 	[TPS6586X_INT_PLDO_8]	= TPS6586X_IRQ(TPS6586X_INT_MASK2, 1 << 2),
77 	[TPS6586X_INT_PLDO_9]	= TPS6586X_IRQ(TPS6586X_INT_MASK2, 1 << 3),
78 	[TPS6586X_INT_PSM_0]	= TPS6586X_IRQ(TPS6586X_INT_MASK2, 1 << 4),
79 	[TPS6586X_INT_PSM_1]	= TPS6586X_IRQ(TPS6586X_INT_MASK2, 1 << 5),
80 	[TPS6586X_INT_PSM_2]	= TPS6586X_IRQ(TPS6586X_INT_MASK2, 1 << 6),
81 	[TPS6586X_INT_PSM_3]	= TPS6586X_IRQ(TPS6586X_INT_MASK2, 1 << 7),
82 	[TPS6586X_INT_RTC_ALM1]	= TPS6586X_IRQ(TPS6586X_INT_MASK5, 1 << 4),
83 	[TPS6586X_INT_ACUSB_OVP] = TPS6586X_IRQ(TPS6586X_INT_MASK5, 0x03),
84 	[TPS6586X_INT_USB_DET]	= TPS6586X_IRQ(TPS6586X_INT_MASK5, 1 << 2),
85 	[TPS6586X_INT_AC_DET]	= TPS6586X_IRQ(TPS6586X_INT_MASK5, 1 << 3),
86 	[TPS6586X_INT_BAT_DET]	= TPS6586X_IRQ(TPS6586X_INT_MASK3, 1 << 0),
87 	[TPS6586X_INT_CHG_STAT]	= TPS6586X_IRQ(TPS6586X_INT_MASK4, 0xfc),
88 	[TPS6586X_INT_CHG_TEMP]	= TPS6586X_IRQ(TPS6586X_INT_MASK3, 0x06),
89 	[TPS6586X_INT_PP]	= TPS6586X_IRQ(TPS6586X_INT_MASK3, 0xf0),
90 	[TPS6586X_INT_RESUME]	= TPS6586X_IRQ(TPS6586X_INT_MASK5, 1 << 5),
91 	[TPS6586X_INT_LOW_SYS]	= TPS6586X_IRQ(TPS6586X_INT_MASK5, 1 << 6),
92 	[TPS6586X_INT_RTC_ALM2] = TPS6586X_IRQ(TPS6586X_INT_MASK4, 1 << 1),
93 };
94 
95 static const struct resource tps6586x_rtc_resources[] = {
96 	{
97 		.start  = TPS6586X_INT_RTC_ALM1,
98 		.end	= TPS6586X_INT_RTC_ALM1,
99 		.flags	= IORESOURCE_IRQ,
100 	},
101 };
102 
103 static const struct mfd_cell tps6586x_cell[] = {
104 	{
105 		.name = "tps6586x-gpio",
106 	},
107 	{
108 		.name = "tps6586x-regulator",
109 	},
110 	{
111 		.name = "tps6586x-rtc",
112 		.num_resources = ARRAY_SIZE(tps6586x_rtc_resources),
113 		.resources = &tps6586x_rtc_resources[0],
114 	},
115 	{
116 		.name = "tps6586x-onkey",
117 	},
118 };
119 
120 struct tps6586x {
121 	struct device		*dev;
122 	struct i2c_client	*client;
123 	struct regmap		*regmap;
124 	int			version;
125 
126 	int			irq;
127 	struct irq_chip		irq_chip;
128 	struct mutex		irq_lock;
129 	int			irq_base;
130 	u32			irq_en;
131 	u8			mask_reg[5];
132 	struct irq_domain	*irq_domain;
133 };
134 
135 static inline struct tps6586x *dev_to_tps6586x(struct device *dev)
136 {
137 	return i2c_get_clientdata(to_i2c_client(dev));
138 }
139 
140 int tps6586x_write(struct device *dev, int reg, uint8_t val)
141 {
142 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
143 
144 	return regmap_write(tps6586x->regmap, reg, val);
145 }
146 EXPORT_SYMBOL_GPL(tps6586x_write);
147 
148 int tps6586x_writes(struct device *dev, int reg, int len, uint8_t *val)
149 {
150 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
151 
152 	return regmap_bulk_write(tps6586x->regmap, reg, val, len);
153 }
154 EXPORT_SYMBOL_GPL(tps6586x_writes);
155 
156 int tps6586x_read(struct device *dev, int reg, uint8_t *val)
157 {
158 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
159 	unsigned int rval;
160 	int ret;
161 
162 	ret = regmap_read(tps6586x->regmap, reg, &rval);
163 	if (!ret)
164 		*val = rval;
165 	return ret;
166 }
167 EXPORT_SYMBOL_GPL(tps6586x_read);
168 
169 int tps6586x_reads(struct device *dev, int reg, int len, uint8_t *val)
170 {
171 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
172 
173 	return regmap_bulk_read(tps6586x->regmap, reg, val, len);
174 }
175 EXPORT_SYMBOL_GPL(tps6586x_reads);
176 
177 int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask)
178 {
179 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
180 
181 	return regmap_update_bits(tps6586x->regmap, reg, bit_mask, bit_mask);
182 }
183 EXPORT_SYMBOL_GPL(tps6586x_set_bits);
184 
185 int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask)
186 {
187 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
188 
189 	return regmap_update_bits(tps6586x->regmap, reg, bit_mask, 0);
190 }
191 EXPORT_SYMBOL_GPL(tps6586x_clr_bits);
192 
193 int tps6586x_update(struct device *dev, int reg, uint8_t val, uint8_t mask)
194 {
195 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
196 
197 	return regmap_update_bits(tps6586x->regmap, reg, mask, val);
198 }
199 EXPORT_SYMBOL_GPL(tps6586x_update);
200 
201 int tps6586x_irq_get_virq(struct device *dev, int irq)
202 {
203 	struct tps6586x *tps6586x = dev_to_tps6586x(dev);
204 
205 	return irq_create_mapping(tps6586x->irq_domain, irq);
206 }
207 EXPORT_SYMBOL_GPL(tps6586x_irq_get_virq);
208 
209 int tps6586x_get_version(struct device *dev)
210 {
211 	struct tps6586x *tps6586x = dev_get_drvdata(dev);
212 
213 	return tps6586x->version;
214 }
215 EXPORT_SYMBOL_GPL(tps6586x_get_version);
216 
217 static int __remove_subdev(struct device *dev, void *unused)
218 {
219 	platform_device_unregister(to_platform_device(dev));
220 	return 0;
221 }
222 
223 static int tps6586x_remove_subdevs(struct tps6586x *tps6586x)
224 {
225 	return device_for_each_child(tps6586x->dev, NULL, __remove_subdev);
226 }
227 
228 static void tps6586x_irq_lock(struct irq_data *data)
229 {
230 	struct tps6586x *tps6586x = irq_data_get_irq_chip_data(data);
231 
232 	mutex_lock(&tps6586x->irq_lock);
233 }
234 
235 static void tps6586x_irq_enable(struct irq_data *irq_data)
236 {
237 	struct tps6586x *tps6586x = irq_data_get_irq_chip_data(irq_data);
238 	unsigned int __irq = irq_data->hwirq;
239 	const struct tps6586x_irq_data *data = &tps6586x_irqs[__irq];
240 
241 	tps6586x->mask_reg[data->mask_reg] &= ~data->mask_mask;
242 	tps6586x->irq_en |= (1 << __irq);
243 }
244 
245 static void tps6586x_irq_disable(struct irq_data *irq_data)
246 {
247 	struct tps6586x *tps6586x = irq_data_get_irq_chip_data(irq_data);
248 
249 	unsigned int __irq = irq_data->hwirq;
250 	const struct tps6586x_irq_data *data = &tps6586x_irqs[__irq];
251 
252 	tps6586x->mask_reg[data->mask_reg] |= data->mask_mask;
253 	tps6586x->irq_en &= ~(1 << __irq);
254 }
255 
256 static void tps6586x_irq_sync_unlock(struct irq_data *data)
257 {
258 	struct tps6586x *tps6586x = irq_data_get_irq_chip_data(data);
259 	int i;
260 
261 	for (i = 0; i < ARRAY_SIZE(tps6586x->mask_reg); i++) {
262 		int ret;
263 		ret = tps6586x_write(tps6586x->dev,
264 					    TPS6586X_INT_MASK1 + i,
265 					    tps6586x->mask_reg[i]);
266 		WARN_ON(ret);
267 	}
268 
269 	mutex_unlock(&tps6586x->irq_lock);
270 }
271 
272 static int tps6586x_irq_set_wake(struct irq_data *irq_data, unsigned int on)
273 {
274 	struct tps6586x *tps6586x = irq_data_get_irq_chip_data(irq_data);
275 	return irq_set_irq_wake(tps6586x->irq, on);
276 }
277 
278 static struct irq_chip tps6586x_irq_chip = {
279 	.name = "tps6586x",
280 	.irq_bus_lock = tps6586x_irq_lock,
281 	.irq_bus_sync_unlock = tps6586x_irq_sync_unlock,
282 	.irq_disable = tps6586x_irq_disable,
283 	.irq_enable = tps6586x_irq_enable,
284 	.irq_set_wake = pm_sleep_ptr(tps6586x_irq_set_wake),
285 };
286 
287 static int tps6586x_irq_map(struct irq_domain *h, unsigned int virq,
288 				irq_hw_number_t hw)
289 {
290 	struct tps6586x *tps6586x = h->host_data;
291 
292 	irq_set_chip_data(virq, tps6586x);
293 	irq_set_chip_and_handler(virq, &tps6586x_irq_chip, handle_simple_irq);
294 	irq_set_nested_thread(virq, 1);
295 	irq_set_noprobe(virq);
296 
297 	return 0;
298 }
299 
300 static const struct irq_domain_ops tps6586x_domain_ops = {
301 	.map    = tps6586x_irq_map,
302 	.xlate  = irq_domain_xlate_twocell,
303 };
304 
305 static irqreturn_t tps6586x_irq(int irq, void *data)
306 {
307 	struct tps6586x *tps6586x = data;
308 	uint32_t acks;
309 	__le32 val;
310 	int ret = 0;
311 
312 	ret = tps6586x_reads(tps6586x->dev, TPS6586X_INT_ACK1,
313 			     sizeof(acks), (uint8_t *)&val);
314 
315 	if (ret < 0) {
316 		dev_err(tps6586x->dev, "failed to read interrupt status\n");
317 		return IRQ_NONE;
318 	}
319 
320 	acks = le32_to_cpu(val);
321 
322 	while (acks) {
323 		int i = __ffs(acks);
324 
325 		if (tps6586x->irq_en & (1 << i))
326 			handle_nested_irq(
327 				irq_find_mapping(tps6586x->irq_domain, i));
328 
329 		acks &= ~(1 << i);
330 	}
331 
332 	return IRQ_HANDLED;
333 }
334 
335 static int tps6586x_irq_init(struct tps6586x *tps6586x, int irq,
336 				       int irq_base)
337 {
338 	int i, ret;
339 	u8 tmp[4];
340 	int new_irq_base;
341 	int irq_num = ARRAY_SIZE(tps6586x_irqs);
342 
343 	tps6586x->irq = irq;
344 
345 	mutex_init(&tps6586x->irq_lock);
346 	for (i = 0; i < 5; i++) {
347 		tps6586x->mask_reg[i] = 0xff;
348 		tps6586x_write(tps6586x->dev, TPS6586X_INT_MASK1 + i, 0xff);
349 	}
350 
351 	tps6586x_reads(tps6586x->dev, TPS6586X_INT_ACK1, sizeof(tmp), tmp);
352 
353 	if  (irq_base > 0) {
354 		new_irq_base = irq_alloc_descs(irq_base, 0, irq_num, -1);
355 		if (new_irq_base < 0) {
356 			dev_err(tps6586x->dev,
357 				"Failed to alloc IRQs: %d\n", new_irq_base);
358 			return new_irq_base;
359 		}
360 	} else {
361 		new_irq_base = 0;
362 	}
363 
364 	tps6586x->irq_domain = irq_domain_add_simple(tps6586x->dev->of_node,
365 				irq_num, new_irq_base, &tps6586x_domain_ops,
366 				tps6586x);
367 	if (!tps6586x->irq_domain) {
368 		dev_err(tps6586x->dev, "Failed to create IRQ domain\n");
369 		return -ENOMEM;
370 	}
371 	ret = request_threaded_irq(irq, NULL, tps6586x_irq, IRQF_ONESHOT,
372 				   "tps6586x", tps6586x);
373 
374 	if (!ret)
375 		device_init_wakeup(tps6586x->dev, 1);
376 
377 	return ret;
378 }
379 
380 static int tps6586x_add_subdevs(struct tps6586x *tps6586x,
381 					  struct tps6586x_platform_data *pdata)
382 {
383 	struct tps6586x_subdev_info *subdev;
384 	struct platform_device *pdev;
385 	int i, ret = 0;
386 
387 	for (i = 0; i < pdata->num_subdevs; i++) {
388 		subdev = &pdata->subdevs[i];
389 
390 		pdev = platform_device_alloc(subdev->name, subdev->id);
391 		if (!pdev) {
392 			ret = -ENOMEM;
393 			goto failed;
394 		}
395 
396 		pdev->dev.parent = tps6586x->dev;
397 		pdev->dev.platform_data = subdev->platform_data;
398 		pdev->dev.of_node = subdev->of_node;
399 
400 		ret = platform_device_add(pdev);
401 		if (ret) {
402 			platform_device_put(pdev);
403 			goto failed;
404 		}
405 	}
406 	return 0;
407 
408 failed:
409 	tps6586x_remove_subdevs(tps6586x);
410 	return ret;
411 }
412 
413 #ifdef CONFIG_OF
414 static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client)
415 {
416 	struct device_node *np = client->dev.of_node;
417 	struct tps6586x_platform_data *pdata;
418 
419 	pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
420 	if (!pdata)
421 		return NULL;
422 
423 	pdata->num_subdevs = 0;
424 	pdata->subdevs = NULL;
425 	pdata->gpio_base = -1;
426 	pdata->irq_base = -1;
427 	pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller");
428 
429 	return pdata;
430 }
431 
432 static const struct of_device_id tps6586x_of_match[] = {
433 	{ .compatible = "ti,tps6586x", },
434 	{ },
435 };
436 #else
437 static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client)
438 {
439 	return NULL;
440 }
441 #endif
442 
443 static bool is_volatile_reg(struct device *dev, unsigned int reg)
444 {
445 	/* Cache all interrupt mask register */
446 	if ((reg >= TPS6586X_INT_MASK1) && (reg <= TPS6586X_INT_MASK5))
447 		return false;
448 
449 	return true;
450 }
451 
452 static const struct regmap_config tps6586x_regmap_config = {
453 	.reg_bits = 8,
454 	.val_bits = 8,
455 	.max_register = TPS6586X_MAX_REGISTER,
456 	.volatile_reg = is_volatile_reg,
457 	.cache_type = REGCACHE_RBTREE,
458 };
459 
460 static struct device *tps6586x_dev;
461 static void tps6586x_power_off(void)
462 {
463 	if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT))
464 		return;
465 
466 	tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
467 }
468 
469 static void tps6586x_print_version(struct i2c_client *client, int version)
470 {
471 	const char *name;
472 
473 	switch (version) {
474 	case TPS658621A:
475 		name = "TPS658621A";
476 		break;
477 	case TPS658621CD:
478 		name = "TPS658621C/D";
479 		break;
480 	case TPS658623:
481 		name = "TPS658623";
482 		break;
483 	case TPS658640:
484 	case TPS658640v2:
485 		name = "TPS658640";
486 		break;
487 	case TPS658643:
488 		name = "TPS658643";
489 		break;
490 	default:
491 		name = "TPS6586X";
492 		break;
493 	}
494 
495 	dev_info(&client->dev, "Found %s, VERSIONCRC is %02x\n", name, version);
496 }
497 
498 static int tps6586x_i2c_probe(struct i2c_client *client)
499 {
500 	struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev);
501 	struct tps6586x *tps6586x;
502 	int ret;
503 	int version;
504 
505 	if (!pdata && client->dev.of_node)
506 		pdata = tps6586x_parse_dt(client);
507 
508 	if (!pdata) {
509 		dev_err(&client->dev, "tps6586x requires platform data\n");
510 		return -ENOTSUPP;
511 	}
512 
513 	version = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC);
514 	if (version < 0) {
515 		dev_err(&client->dev, "Chip ID read failed: %d\n", version);
516 		return -EIO;
517 	}
518 
519 	tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL);
520 	if (!tps6586x)
521 		return -ENOMEM;
522 
523 	tps6586x->version = version;
524 	tps6586x_print_version(client, tps6586x->version);
525 
526 	tps6586x->client = client;
527 	tps6586x->dev = &client->dev;
528 	i2c_set_clientdata(client, tps6586x);
529 
530 	tps6586x->regmap = devm_regmap_init_i2c(client,
531 					&tps6586x_regmap_config);
532 	if (IS_ERR(tps6586x->regmap)) {
533 		ret = PTR_ERR(tps6586x->regmap);
534 		dev_err(&client->dev, "regmap init failed: %d\n", ret);
535 		return ret;
536 	}
537 
538 
539 	if (client->irq) {
540 		ret = tps6586x_irq_init(tps6586x, client->irq,
541 					pdata->irq_base);
542 		if (ret) {
543 			dev_err(&client->dev, "IRQ init failed: %d\n", ret);
544 			return ret;
545 		}
546 	}
547 
548 	ret = mfd_add_devices(tps6586x->dev, -1,
549 			      tps6586x_cell, ARRAY_SIZE(tps6586x_cell),
550 			      NULL, 0, tps6586x->irq_domain);
551 	if (ret < 0) {
552 		dev_err(&client->dev, "mfd_add_devices failed: %d\n", ret);
553 		goto err_mfd_add;
554 	}
555 
556 	ret = tps6586x_add_subdevs(tps6586x, pdata);
557 	if (ret) {
558 		dev_err(&client->dev, "add devices failed: %d\n", ret);
559 		goto err_add_devs;
560 	}
561 
562 	if (pdata->pm_off && !pm_power_off) {
563 		tps6586x_dev = &client->dev;
564 		pm_power_off = tps6586x_power_off;
565 	}
566 
567 	return 0;
568 
569 err_add_devs:
570 	mfd_remove_devices(tps6586x->dev);
571 err_mfd_add:
572 	if (client->irq)
573 		free_irq(client->irq, tps6586x);
574 	return ret;
575 }
576 
577 static void tps6586x_i2c_remove(struct i2c_client *client)
578 {
579 	struct tps6586x *tps6586x = i2c_get_clientdata(client);
580 
581 	tps6586x_remove_subdevs(tps6586x);
582 	mfd_remove_devices(tps6586x->dev);
583 	if (client->irq)
584 		free_irq(client->irq, tps6586x);
585 }
586 
587 static int __maybe_unused tps6586x_i2c_suspend(struct device *dev)
588 {
589 	struct tps6586x *tps6586x = dev_get_drvdata(dev);
590 
591 	if (tps6586x->client->irq)
592 		disable_irq(tps6586x->client->irq);
593 
594 	return 0;
595 }
596 
597 static int __maybe_unused tps6586x_i2c_resume(struct device *dev)
598 {
599 	struct tps6586x *tps6586x = dev_get_drvdata(dev);
600 
601 	if (tps6586x->client->irq)
602 		enable_irq(tps6586x->client->irq);
603 
604 	return 0;
605 }
606 
607 static SIMPLE_DEV_PM_OPS(tps6586x_pm_ops, tps6586x_i2c_suspend,
608 			 tps6586x_i2c_resume);
609 
610 static const struct i2c_device_id tps6586x_id_table[] = {
611 	{ "tps6586x", 0 },
612 	{ },
613 };
614 MODULE_DEVICE_TABLE(i2c, tps6586x_id_table);
615 
616 static struct i2c_driver tps6586x_driver = {
617 	.driver	= {
618 		.name	= "tps6586x",
619 		.of_match_table = of_match_ptr(tps6586x_of_match),
620 		.pm	= &tps6586x_pm_ops,
621 	},
622 	.probe_new	= tps6586x_i2c_probe,
623 	.remove		= tps6586x_i2c_remove,
624 	.id_table	= tps6586x_id_table,
625 };
626 
627 static int __init tps6586x_init(void)
628 {
629 	return i2c_add_driver(&tps6586x_driver);
630 }
631 subsys_initcall(tps6586x_init);
632 
633 static void __exit tps6586x_exit(void)
634 {
635 	i2c_del_driver(&tps6586x_driver);
636 }
637 module_exit(tps6586x_exit);
638 
639 MODULE_DESCRIPTION("TPS6586X core driver");
640 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
641 MODULE_LICENSE("GPL");
642