blob: 6599407b56247e1413fddf00f0f6deeaf9f53c4b [file] [log] [blame]
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01001/*
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +02002 * max14577.c - mfd core driver for the Maxim 14577/77836
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01003 *
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +02004 * Copyright (C) 2014 Samsung Electrnoics
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01005 * Chanwoo Choi <cw00.choi@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * This driver is based on max8997.c
19 */
20
Sachin Kamatc8016d42014-02-12 14:40:11 +053021#include <linux/err.h>
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010022#include <linux/module.h>
23#include <linux/interrupt.h>
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +020024#include <linux/of_device.h>
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010025#include <linux/mfd/core.h>
26#include <linux/mfd/max14577.h>
27#include <linux/mfd/max14577-private.h>
28
Krzysztof Kozlowski92725492014-05-13 12:58:38 +020029static const struct mfd_cell max14577_devs[] = {
Krzysztof Kozlowskia0b0ea42014-01-28 13:18:28 +010030 {
31 .name = "max14577-muic",
32 .of_compatible = "maxim,max14577-muic",
33 },
Krzysztof Kozlowski41096802013-11-27 15:16:17 +010034 {
35 .name = "max14577-regulator",
36 .of_compatible = "maxim,max14577-regulator",
37 },
Krzysztof Kozlowski44767672014-09-12 08:53:54 +020038 {
39 .name = "max14577-charger",
40 .of_compatible = "maxim,max14577-charger",
41 },
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010042};
43
Krzysztof Kozlowski92725492014-05-13 12:58:38 +020044static const struct mfd_cell max77836_devs[] = {
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +020045 {
46 .name = "max77836-muic",
47 .of_compatible = "maxim,max77836-muic",
48 },
49 {
50 .name = "max77836-regulator",
51 .of_compatible = "maxim,max77836-regulator",
52 },
53 {
54 .name = "max77836-charger",
55 .of_compatible = "maxim,max77836-charger",
56 },
57 {
58 .name = "max77836-battery",
59 .of_compatible = "maxim,max77836-battery",
60 },
61};
62
Krzysztof Kozlowski8f7f6272014-05-13 12:58:39 +020063static const struct of_device_id max14577_dt_match[] = {
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +020064 {
65 .compatible = "maxim,max14577",
66 .data = (void *)MAXIM_DEVICE_TYPE_MAX14577,
67 },
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +020068 {
69 .compatible = "maxim,max77836",
70 .data = (void *)MAXIM_DEVICE_TYPE_MAX77836,
71 },
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +020072 {},
73};
74
Krzysztof Kozlowski575343d2014-04-14 11:17:13 +020075static bool max14577_muic_volatile_reg(struct device *dev, unsigned int reg)
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010076{
77 switch (reg) {
78 case MAX14577_REG_INT1 ... MAX14577_REG_STATUS3:
79 return true;
80 default:
81 break;
82 }
83 return false;
84}
85
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +020086static bool max77836_muic_volatile_reg(struct device *dev, unsigned int reg)
87{
88 /* Any max14577 volatile registers are also max77836 volatile. */
89 if (max14577_muic_volatile_reg(dev, reg))
90 return true;
91
92 switch (reg) {
93 case MAX77836_FG_REG_VCELL_MSB ... MAX77836_FG_REG_SOC_LSB:
94 case MAX77836_FG_REG_CRATE_MSB ... MAX77836_FG_REG_CRATE_LSB:
95 case MAX77836_FG_REG_STATUS_H ... MAX77836_FG_REG_STATUS_L:
96 case MAX77836_PMIC_REG_INTSRC:
97 case MAX77836_PMIC_REG_TOPSYS_INT:
98 case MAX77836_PMIC_REG_TOPSYS_STAT:
99 return true;
100 default:
101 break;
102 }
103 return false;
104}
105
Krzysztof Kozlowski575343d2014-04-14 11:17:13 +0200106static const struct regmap_config max14577_muic_regmap_config = {
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100107 .reg_bits = 8,
108 .val_bits = 8,
Krzysztof Kozlowski575343d2014-04-14 11:17:13 +0200109 .volatile_reg = max14577_muic_volatile_reg,
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100110 .max_register = MAX14577_REG_END,
111};
112
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200113static const struct regmap_config max77836_pmic_regmap_config = {
114 .reg_bits = 8,
115 .val_bits = 8,
116 .volatile_reg = max77836_muic_volatile_reg,
117 .max_register = MAX77836_PMIC_REG_END,
118};
119
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100120static const struct regmap_irq max14577_irqs[] = {
121 /* INT1 interrupts */
Krzysztof Kozlowskic7846852014-04-14 11:17:17 +0200122 { .reg_offset = 0, .mask = MAX14577_INT1_ADC_MASK, },
123 { .reg_offset = 0, .mask = MAX14577_INT1_ADCLOW_MASK, },
124 { .reg_offset = 0, .mask = MAX14577_INT1_ADCERR_MASK, },
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100125 /* INT2 interrupts */
Krzysztof Kozlowskic7846852014-04-14 11:17:17 +0200126 { .reg_offset = 1, .mask = MAX14577_INT2_CHGTYP_MASK, },
127 { .reg_offset = 1, .mask = MAX14577_INT2_CHGDETRUN_MASK, },
128 { .reg_offset = 1, .mask = MAX14577_INT2_DCDTMR_MASK, },
129 { .reg_offset = 1, .mask = MAX14577_INT2_DBCHG_MASK, },
130 { .reg_offset = 1, .mask = MAX14577_INT2_VBVOLT_MASK, },
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100131 /* INT3 interrupts */
Krzysztof Kozlowskic7846852014-04-14 11:17:17 +0200132 { .reg_offset = 2, .mask = MAX14577_INT3_EOC_MASK, },
133 { .reg_offset = 2, .mask = MAX14577_INT3_CGMBC_MASK, },
134 { .reg_offset = 2, .mask = MAX14577_INT3_OVP_MASK, },
135 { .reg_offset = 2, .mask = MAX14577_INT3_MBCCHGERR_MASK, },
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100136};
137
138static const struct regmap_irq_chip max14577_irq_chip = {
139 .name = "max14577",
140 .status_base = MAX14577_REG_INT1,
141 .mask_base = MAX14577_REG_INTMASK1,
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200142 .mask_invert = true,
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100143 .num_regs = 3,
144 .irqs = max14577_irqs,
145 .num_irqs = ARRAY_SIZE(max14577_irqs),
146};
147
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200148static const struct regmap_irq max77836_muic_irqs[] = {
149 /* INT1 interrupts */
150 { .reg_offset = 0, .mask = MAX14577_INT1_ADC_MASK, },
151 { .reg_offset = 0, .mask = MAX14577_INT1_ADCLOW_MASK, },
152 { .reg_offset = 0, .mask = MAX14577_INT1_ADCERR_MASK, },
Krzysztof Kozlowski4706a522014-04-14 11:17:19 +0200153 { .reg_offset = 0, .mask = MAX77836_INT1_ADC1K_MASK, },
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200154 /* INT2 interrupts */
155 { .reg_offset = 1, .mask = MAX14577_INT2_CHGTYP_MASK, },
156 { .reg_offset = 1, .mask = MAX14577_INT2_CHGDETRUN_MASK, },
157 { .reg_offset = 1, .mask = MAX14577_INT2_DCDTMR_MASK, },
158 { .reg_offset = 1, .mask = MAX14577_INT2_DBCHG_MASK, },
159 { .reg_offset = 1, .mask = MAX14577_INT2_VBVOLT_MASK, },
160 { .reg_offset = 1, .mask = MAX77836_INT2_VIDRM_MASK, },
161 /* INT3 interrupts */
162 { .reg_offset = 2, .mask = MAX14577_INT3_EOC_MASK, },
163 { .reg_offset = 2, .mask = MAX14577_INT3_CGMBC_MASK, },
164 { .reg_offset = 2, .mask = MAX14577_INT3_OVP_MASK, },
165 { .reg_offset = 2, .mask = MAX14577_INT3_MBCCHGERR_MASK, },
166};
167
168static const struct regmap_irq_chip max77836_muic_irq_chip = {
169 .name = "max77836-muic",
170 .status_base = MAX14577_REG_INT1,
171 .mask_base = MAX14577_REG_INTMASK1,
172 .mask_invert = true,
173 .num_regs = 3,
174 .irqs = max77836_muic_irqs,
175 .num_irqs = ARRAY_SIZE(max77836_muic_irqs),
176};
177
178static const struct regmap_irq max77836_pmic_irqs[] = {
179 { .reg_offset = 0, .mask = MAX77836_TOPSYS_INT_T120C_MASK, },
180 { .reg_offset = 0, .mask = MAX77836_TOPSYS_INT_T140C_MASK, },
181};
182
183static const struct regmap_irq_chip max77836_pmic_irq_chip = {
184 .name = "max77836-pmic",
185 .status_base = MAX77836_PMIC_REG_TOPSYS_INT,
186 .mask_base = MAX77836_PMIC_REG_TOPSYS_INT_MASK,
187 .mask_invert = false,
188 .num_regs = 1,
189 .irqs = max77836_pmic_irqs,
190 .num_irqs = ARRAY_SIZE(max77836_pmic_irqs),
191};
192
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +0200193static void max14577_print_dev_type(struct max14577 *max14577)
194{
195 u8 reg_data, vendor_id, device_id;
196 int ret;
197
198 ret = max14577_read_reg(max14577->regmap, MAX14577_REG_DEVICEID,
199 &reg_data);
200 if (ret) {
201 dev_err(max14577->dev,
202 "Failed to read DEVICEID register: %d\n", ret);
203 return;
204 }
205
206 vendor_id = ((reg_data & DEVID_VENDORID_MASK) >>
207 DEVID_VENDORID_SHIFT);
208 device_id = ((reg_data & DEVID_DEVICEID_MASK) >>
209 DEVID_DEVICEID_SHIFT);
210
211 dev_info(max14577->dev, "Device type: %u (ID: 0x%x, vendor: 0x%x)\n",
212 max14577->dev_type, device_id, vendor_id);
213}
214
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200215/*
216 * Max77836 specific initialization code for driver probe.
217 * Adds new I2C dummy device, regmap and regmap IRQ chip.
218 * Unmasks Interrupt Source register.
219 *
220 * On success returns 0.
221 * On failure returns errno and reverts any changes done so far (e.g. remove
222 * I2C dummy device), except masking the INT SRC register.
223 */
224static int max77836_init(struct max14577 *max14577)
225{
226 int ret;
227 u8 intsrc_mask;
228
229 max14577->i2c_pmic = i2c_new_dummy(max14577->i2c->adapter,
230 I2C_ADDR_PMIC);
231 if (!max14577->i2c_pmic) {
232 dev_err(max14577->dev, "Failed to register PMIC I2C device\n");
233 return -ENODEV;
234 }
235 i2c_set_clientdata(max14577->i2c_pmic, max14577);
236
237 max14577->regmap_pmic = devm_regmap_init_i2c(max14577->i2c_pmic,
238 &max77836_pmic_regmap_config);
239 if (IS_ERR(max14577->regmap_pmic)) {
240 ret = PTR_ERR(max14577->regmap_pmic);
241 dev_err(max14577->dev, "Failed to allocate PMIC register map: %d\n",
242 ret);
243 goto err;
244 }
245
246 /* Un-mask MAX77836 Interrupt Source register */
247 ret = max14577_read_reg(max14577->regmap_pmic,
248 MAX77836_PMIC_REG_INTSRC_MASK, &intsrc_mask);
249 if (ret < 0) {
250 dev_err(max14577->dev, "Failed to read PMIC register\n");
251 goto err;
252 }
253
254 intsrc_mask &= ~(MAX77836_INTSRC_MASK_TOP_INT_MASK);
255 intsrc_mask &= ~(MAX77836_INTSRC_MASK_MUIC_CHG_INT_MASK);
256 ret = max14577_write_reg(max14577->regmap_pmic,
257 MAX77836_PMIC_REG_INTSRC_MASK, intsrc_mask);
258 if (ret < 0) {
259 dev_err(max14577->dev, "Failed to write PMIC register\n");
260 goto err;
261 }
262
263 ret = regmap_add_irq_chip(max14577->regmap_pmic, max14577->irq,
264 IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED,
265 0, &max77836_pmic_irq_chip,
266 &max14577->irq_data_pmic);
267 if (ret != 0) {
268 dev_err(max14577->dev, "Failed to request PMIC IRQ %d: %d\n",
269 max14577->irq, ret);
270 goto err;
271 }
272
273 return 0;
274
275err:
276 i2c_unregister_device(max14577->i2c_pmic);
277
278 return ret;
279}
280
281/*
282 * Max77836 specific de-initialization code for driver remove.
283 */
284static void max77836_remove(struct max14577 *max14577)
285{
286 regmap_del_irq_chip(max14577->irq, max14577->irq_data_pmic);
287 i2c_unregister_device(max14577->i2c_pmic);
288}
289
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100290static int max14577_i2c_probe(struct i2c_client *i2c,
291 const struct i2c_device_id *id)
292{
293 struct max14577 *max14577;
294 struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
295 struct device_node *np = i2c->dev.of_node;
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100296 int ret = 0;
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200297 const struct regmap_irq_chip *irq_chip;
Krzysztof Kozlowski92725492014-05-13 12:58:38 +0200298 const struct mfd_cell *mfd_devs;
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200299 unsigned int mfd_devs_size;
300 int irq_flags;
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100301
302 if (np) {
303 pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL);
304 if (!pdata)
305 return -ENOMEM;
306 i2c->dev.platform_data = pdata;
307 }
308
309 if (!pdata) {
Dan Carpenteraab5dc62013-12-04 17:07:12 +0300310 dev_err(&i2c->dev, "No platform data found.\n");
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100311 return -EINVAL;
312 }
313
314 max14577 = devm_kzalloc(&i2c->dev, sizeof(*max14577), GFP_KERNEL);
315 if (!max14577)
316 return -ENOMEM;
317
318 i2c_set_clientdata(i2c, max14577);
319 max14577->dev = &i2c->dev;
320 max14577->i2c = i2c;
321 max14577->irq = i2c->irq;
322
Krzysztof Kozlowski575343d2014-04-14 11:17:13 +0200323 max14577->regmap = devm_regmap_init_i2c(i2c,
324 &max14577_muic_regmap_config);
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100325 if (IS_ERR(max14577->regmap)) {
326 ret = PTR_ERR(max14577->regmap);
327 dev_err(max14577->dev, "Failed to allocate register map: %d\n",
328 ret);
329 return ret;
330 }
331
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +0200332 if (np) {
333 const struct of_device_id *of_id;
334
335 of_id = of_match_device(max14577_dt_match, &i2c->dev);
336 if (of_id)
Lee Jonesfab84452014-05-20 15:37:41 +0100337 max14577->dev_type =
338 (enum maxim_device_type)of_id->data;
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +0200339 } else {
340 max14577->dev_type = id->driver_data;
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100341 }
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +0200342
343 max14577_print_dev_type(max14577);
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100344
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200345 switch (max14577->dev_type) {
346 case MAXIM_DEVICE_TYPE_MAX77836:
347 irq_chip = &max77836_muic_irq_chip;
348 mfd_devs = max77836_devs;
349 mfd_devs_size = ARRAY_SIZE(max77836_devs);
350 irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED;
351 break;
352 case MAXIM_DEVICE_TYPE_MAX14577:
353 default:
354 irq_chip = &max14577_irq_chip;
355 mfd_devs = max14577_devs;
356 mfd_devs_size = ARRAY_SIZE(max14577_devs);
357 irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
358 break;
359 }
360
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100361 ret = regmap_add_irq_chip(max14577->regmap, max14577->irq,
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200362 irq_flags, 0, irq_chip,
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100363 &max14577->irq_data);
364 if (ret != 0) {
365 dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
366 max14577->irq, ret);
367 return ret;
368 }
369
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200370 /* Max77836 specific initialization code (additional regmap) */
371 if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836) {
372 ret = max77836_init(max14577);
373 if (ret < 0)
374 goto err_max77836;
375 }
376
377 ret = mfd_add_devices(max14577->dev, -1, mfd_devs,
378 mfd_devs_size, NULL, 0,
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100379 regmap_irq_get_domain(max14577->irq_data));
380 if (ret < 0)
381 goto err_mfd;
382
383 device_init_wakeup(max14577->dev, 1);
384
385 return 0;
386
387err_mfd:
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200388 if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836)
389 max77836_remove(max14577);
390err_max77836:
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100391 regmap_del_irq_chip(max14577->irq, max14577->irq_data);
392
393 return ret;
394}
395
396static int max14577_i2c_remove(struct i2c_client *i2c)
397{
398 struct max14577 *max14577 = i2c_get_clientdata(i2c);
399
400 mfd_remove_devices(max14577->dev);
401 regmap_del_irq_chip(max14577->irq, max14577->irq_data);
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200402 if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836)
403 max77836_remove(max14577);
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100404
405 return 0;
406}
407
408static const struct i2c_device_id max14577_i2c_id[] = {
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +0200409 { "max14577", MAXIM_DEVICE_TYPE_MAX14577, },
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200410 { "max77836", MAXIM_DEVICE_TYPE_MAX77836, },
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100411 { }
412};
413MODULE_DEVICE_TABLE(i2c, max14577_i2c_id);
414
Geert Uytterhoeven3edeb1e2014-01-26 11:38:42 +0100415#ifdef CONFIG_PM_SLEEP
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100416static int max14577_suspend(struct device *dev)
417{
418 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
419 struct max14577 *max14577 = i2c_get_clientdata(i2c);
420
Krzysztof Kozlowskic4f725b2014-04-22 15:59:22 +0200421 if (device_may_wakeup(dev))
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100422 enable_irq_wake(max14577->irq);
Krzysztof Kozlowskic4f725b2014-04-22 15:59:22 +0200423 /*
424 * MUIC IRQ must be disabled during suspend because if it happens
425 * while suspended it will be handled before resuming I2C.
426 *
427 * When device is woken up from suspend (e.g. by ADC change),
428 * an interrupt occurs before resuming I2C bus controller.
429 * Interrupt handler tries to read registers but this read
430 * will fail because I2C is still suspended.
431 */
432 disable_irq(max14577->irq);
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100433
434 return 0;
435}
436
437static int max14577_resume(struct device *dev)
438{
439 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
440 struct max14577 *max14577 = i2c_get_clientdata(i2c);
441
Krzysztof Kozlowskic4f725b2014-04-22 15:59:22 +0200442 if (device_may_wakeup(dev))
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100443 disable_irq_wake(max14577->irq);
Krzysztof Kozlowskic4f725b2014-04-22 15:59:22 +0200444 enable_irq(max14577->irq);
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100445
446 return 0;
447}
Geert Uytterhoeven3edeb1e2014-01-26 11:38:42 +0100448#endif /* CONFIG_PM_SLEEP */
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100449
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100450static SIMPLE_DEV_PM_OPS(max14577_pm, max14577_suspend, max14577_resume);
451
452static struct i2c_driver max14577_i2c_driver = {
453 .driver = {
454 .name = "max14577",
455 .owner = THIS_MODULE,
456 .pm = &max14577_pm,
Sachin Kamatae679c12013-12-21 15:50:16 +0530457 .of_match_table = max14577_dt_match,
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100458 },
459 .probe = max14577_i2c_probe,
460 .remove = max14577_i2c_remove,
461 .id_table = max14577_i2c_id,
462};
463
464static int __init max14577_i2c_init(void)
465{
Krzysztof Kozlowskieccb80c2014-04-14 11:17:14 +0200466 BUILD_BUG_ON(ARRAY_SIZE(max14577_i2c_id) != MAXIM_DEVICE_TYPE_NUM);
467 BUILD_BUG_ON(ARRAY_SIZE(max14577_dt_match) != MAXIM_DEVICE_TYPE_NUM);
468
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100469 return i2c_add_driver(&max14577_i2c_driver);
470}
471subsys_initcall(max14577_i2c_init);
472
473static void __exit max14577_i2c_exit(void)
474{
475 i2c_del_driver(&max14577_i2c_driver);
476}
477module_exit(max14577_i2c_exit);
478
479MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>, Krzysztof Kozlowski <k.kozlowski@samsung.com>");
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +0200480MODULE_DESCRIPTION("Maxim 14577/77836 multi-function core driver");
Chanwoo Choi3008ddb2013-11-22 16:51:05 +0100481MODULE_LICENSE("GPL");