2 * driver/mfd/ricoh619.c
4 * Core driver implementation to access RICOH RC5T619 power management chip.
6 * Copyright (C) 2012-2013 RICOH COMPANY,LTD
9 * Copyright (C) 2011 NVIDIA Corporation
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 /*#define VERBOSE_DEBUG 1*/
27 #include <linux/interrupt.h>
28 #include <linux/irq.h>
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/init.h>
32 #include <linux/slab.h>
33 #include <linux/gpio.h>
34 #include <linux/i2c.h>
35 #include <linux/mfd/core.h>
36 #include <linux/mfd/ricoh619.h>
37 #include <linux/power/ricoh619_battery.h>
40 struct ricoh619 *g_ricoh619;
41 struct sleep_control_data {
45 #define SLEEP_INIT(_id, _reg) \
46 [RICOH619_DS_##_id] = {.reg_add = _reg}
48 static struct sleep_control_data sleep_data[] = {
49 SLEEP_INIT(DC1, 0x16),
50 SLEEP_INIT(DC2, 0x17),
51 SLEEP_INIT(DC3, 0x18),
52 SLEEP_INIT(DC4, 0x19),
53 SLEEP_INIT(DC5, 0x1A),
54 SLEEP_INIT(LDO1, 0x1B),
55 SLEEP_INIT(LDO2, 0x1C),
56 SLEEP_INIT(LDO3, 0x1D),
57 SLEEP_INIT(LDO4, 0x1E),
58 SLEEP_INIT(LDO5, 0x1F),
59 SLEEP_INIT(LDO6, 0x20),
60 SLEEP_INIT(LDO7, 0x21),
61 SLEEP_INIT(LDO8, 0x22),
62 SLEEP_INIT(LDO9, 0x23),
63 SLEEP_INIT(LDO10, 0x24),
64 SLEEP_INIT(PSO0, 0x25),
65 SLEEP_INIT(PSO1, 0x26),
66 SLEEP_INIT(PSO2, 0x27),
67 SLEEP_INIT(PSO3, 0x28),
68 SLEEP_INIT(PSO4, 0x29),
69 SLEEP_INIT(LDORTC1, 0x2A),
72 static inline int __ricoh619_read(struct i2c_client *client,
77 ret = i2c_smbus_read_byte_data(client, reg);
79 dev_err(&client->dev, "failed reading at 0x%02x\n", reg);
84 dev_dbg(&client->dev, "ricoh619: reg read reg=%x, val=%x\n",
89 static inline int __ricoh619_bulk_reads(struct i2c_client *client, u8 reg,
90 int len, uint8_t *val)
95 ret = i2c_smbus_read_i2c_block_data(client, reg, len, val);
97 dev_err(&client->dev, "failed reading from 0x%02x\n", reg);
100 for (i = 0; i < len; ++i) {
101 dev_dbg(&client->dev, "ricoh619: reg read reg=%x, val=%x\n",
102 reg + i, *(val + i));
107 static inline int __ricoh619_write(struct i2c_client *client,
112 dev_dbg(&client->dev, "ricoh619: reg write reg=%x, val=%x\n",
114 ret = i2c_smbus_write_byte_data(client, reg, val);
116 dev_err(&client->dev, "failed writing 0x%02x to 0x%02x\n",
124 static inline int __ricoh619_bulk_writes(struct i2c_client *client, u8 reg,
125 int len, uint8_t *val)
130 for (i = 0; i < len; ++i) {
131 dev_dbg(&client->dev, "ricoh619: reg write reg=%x, val=%x\n",
132 reg + i, *(val + i));
135 ret = i2c_smbus_write_i2c_block_data(client, reg, len, val);
137 dev_err(&client->dev, "failed writings to 0x%02x\n", reg);
144 static inline int set_bank_ricoh619(struct device *dev, int bank)
146 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
149 if (bank != (bank & 1))
151 if (bank == ricoh619->bank_num)
153 ret = __ricoh619_write(to_i2c_client(dev), RICOH619_REG_BANKSEL, bank);
155 ricoh619->bank_num = bank;
160 int ricoh619_write(struct device *dev, u8 reg, uint8_t val)
162 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
165 mutex_lock(&ricoh619->io_lock);
166 ret = set_bank_ricoh619(dev, 0);
168 ret = __ricoh619_write(to_i2c_client(dev), reg, val);
169 mutex_unlock(&ricoh619->io_lock);
173 EXPORT_SYMBOL_GPL(ricoh619_write);
175 int ricoh619_write_bank1(struct device *dev, u8 reg, uint8_t val)
177 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
180 mutex_lock(&ricoh619->io_lock);
181 ret = set_bank_ricoh619(dev, 1);
183 ret = __ricoh619_write(to_i2c_client(dev), reg, val);
184 mutex_unlock(&ricoh619->io_lock);
188 EXPORT_SYMBOL_GPL(ricoh619_write_bank1);
190 int ricoh619_bulk_writes(struct device *dev, u8 reg, u8 len, uint8_t *val)
192 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
195 mutex_lock(&ricoh619->io_lock);
196 ret = set_bank_ricoh619(dev, 0);
198 ret = __ricoh619_bulk_writes(to_i2c_client(dev), reg, len, val);
199 mutex_unlock(&ricoh619->io_lock);
203 EXPORT_SYMBOL_GPL(ricoh619_bulk_writes);
205 int ricoh619_bulk_writes_bank1(struct device *dev, u8 reg, u8 len, uint8_t *val)
207 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
210 mutex_lock(&ricoh619->io_lock);
211 ret = set_bank_ricoh619(dev, 1);
213 ret = __ricoh619_bulk_writes(to_i2c_client(dev), reg, len, val);
214 mutex_unlock(&ricoh619->io_lock);
218 EXPORT_SYMBOL_GPL(ricoh619_bulk_writes_bank1);
220 int ricoh619_read(struct device *dev, u8 reg, uint8_t *val)
222 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
225 mutex_lock(&ricoh619->io_lock);
226 ret = set_bank_ricoh619(dev, 0);
228 ret = __ricoh619_read(to_i2c_client(dev), reg, val);
229 mutex_unlock(&ricoh619->io_lock);
233 EXPORT_SYMBOL_GPL(ricoh619_read);
235 int ricoh619_read_bank1(struct device *dev, u8 reg, uint8_t *val)
237 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
240 mutex_lock(&ricoh619->io_lock);
241 ret = set_bank_ricoh619(dev, 1);
243 ret = __ricoh619_read(to_i2c_client(dev), reg, val);
244 mutex_unlock(&ricoh619->io_lock);
249 EXPORT_SYMBOL_GPL(ricoh619_read_bank1);
251 int ricoh619_bulk_reads(struct device *dev, u8 reg, u8 len, uint8_t *val)
253 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
256 mutex_lock(&ricoh619->io_lock);
257 ret = set_bank_ricoh619(dev, 0);
259 ret = __ricoh619_bulk_reads(to_i2c_client(dev), reg, len, val);
260 mutex_unlock(&ricoh619->io_lock);
264 EXPORT_SYMBOL_GPL(ricoh619_bulk_reads);
266 int ricoh619_bulk_reads_bank1(struct device *dev, u8 reg, u8 len, uint8_t *val)
268 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
271 mutex_lock(&ricoh619->io_lock);
272 ret = set_bank_ricoh619(dev, 1);
274 ret = __ricoh619_bulk_reads(to_i2c_client(dev), reg, len, val);
275 mutex_unlock(&ricoh619->io_lock);
279 EXPORT_SYMBOL_GPL(ricoh619_bulk_reads_bank1);
281 int ricoh619_set_bits(struct device *dev, u8 reg, uint8_t bit_mask)
283 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
287 mutex_lock(&ricoh619->io_lock);
288 ret = set_bank_ricoh619(dev, 0);
290 ret = __ricoh619_read(to_i2c_client(dev), reg, ®_val);
294 if ((reg_val & bit_mask) != bit_mask) {
296 ret = __ricoh619_write(to_i2c_client(dev), reg,
301 mutex_unlock(&ricoh619->io_lock);
304 EXPORT_SYMBOL_GPL(ricoh619_set_bits);
306 int ricoh619_clr_bits(struct device *dev, u8 reg, uint8_t bit_mask)
308 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
312 mutex_lock(&ricoh619->io_lock);
313 ret = set_bank_ricoh619(dev, 0);
315 ret = __ricoh619_read(to_i2c_client(dev), reg, ®_val);
319 if (reg_val & bit_mask) {
320 reg_val &= ~bit_mask;
321 ret = __ricoh619_write(to_i2c_client(dev), reg,
326 mutex_unlock(&ricoh619->io_lock);
329 EXPORT_SYMBOL_GPL(ricoh619_clr_bits);
331 int ricoh619_update(struct device *dev, u8 reg, uint8_t val, uint8_t mask)
333 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
337 mutex_lock(&ricoh619->io_lock);
338 ret = set_bank_ricoh619(dev, 0);
340 ret = __ricoh619_read(ricoh619->client, reg, ®_val);
344 if ((reg_val & mask) != val) {
345 reg_val = (reg_val & ~mask) | (val & mask);
346 ret = __ricoh619_write(ricoh619->client, reg, reg_val);
350 mutex_unlock(&ricoh619->io_lock);
353 EXPORT_SYMBOL_GPL(ricoh619_update);
355 int ricoh619_update_bank1(struct device *dev, u8 reg, uint8_t val, uint8_t mask)
357 struct ricoh619 *ricoh619 = dev_get_drvdata(dev);
361 mutex_lock(&ricoh619->io_lock);
362 ret = set_bank_ricoh619(dev, 1);
364 ret = __ricoh619_read(ricoh619->client, reg, ®_val);
368 if ((reg_val & mask) != val) {
369 reg_val = (reg_val & ~mask) | (val & mask);
370 ret = __ricoh619_write(ricoh619->client, reg, reg_val);
374 mutex_unlock(&ricoh619->io_lock);
378 static struct i2c_client *ricoh619_i2c_client;
379 int ricoh619_power_off(void)
384 int status, charge_state;
385 struct ricoh619 *ricoh619 = g_ricoh619;
389 ricoh619_read(ricoh619->dev, 0xBD, &status);
390 charge_state = (status & 0x1F);
391 // supply_state = ((status & 0xC0) >> 6);
393 ret = ricoh619_write(ricoh619->dev, RICOH619_PSWR, val);
395 dev_err(ricoh619->dev, "Error in writing PSWR_REG\n");
397 if (g_fg_on_mode == 0) {
398 ret = ricoh619_clr_bits(ricoh619->dev,
399 RICOH619_FG_CTRL, 0x01);
401 dev_err(ricoh619->dev, "Error in writing FG_CTRL\n");
404 /* set rapid timer 300 min */
405 err = ricoh619_set_bits(ricoh619->dev, TIMSET_REG, 0x03);
407 dev_err(ricoh619->dev, "Error in writing the TIMSET_Reg\n");
409 ret = ricoh619_write(ricoh619->dev, RICOH619_INTC_INTEN, 0);
411 if (!ricoh619_i2c_client)
413 //__ricoh618_write(ricoh618_i2c_client, RICOH618_PWR_REP_CNT, 0x0); //Not repeat power ON after power off(Power Off/N_OE)
414 // __ricoh618_write(ricoh618_i2c_client, RICOH618_PWR_SLP_CNT, 0x1); //Power OFF
415 ret = ricoh619_clr_bits(ricoh619->dev,RICOH619_PWR_REP_CNT,(0x1<<0));//Not repeat power ON after power off(Power Off/N_OE)
417 if(( charge_state == CHG_STATE_CHG_TRICKLE)||( charge_state == CHG_STATE_CHG_RAPID))
418 ricoh619_set_bits(ricoh619->dev, RICOH619_PWR_REP_CNT,(0x1<<0));//Power OFF
419 ret = ricoh619_set_bits(ricoh619->dev, RICOH619_PWR_SLP_CNT,(0x1<<0));//Power OFF
421 printk("ricoh619 power off error!\n");
426 EXPORT_SYMBOL_GPL(ricoh619_power_off);
428 static int ricoh619_gpio_get(struct gpio_chip *gc, unsigned offset)
430 struct ricoh619 *ricoh619 = container_of(gc, struct ricoh619, gpio_chip);
434 ret = ricoh619_read(ricoh619->dev, RICOH619_GPIO_MON_IOIN, &val);
438 return ((val & (0x1 << offset)) != 0);
441 static void ricoh619_gpio_set(struct gpio_chip *gc, unsigned offset,
444 struct ricoh619 *ricoh619 = container_of(gc, struct ricoh619, gpio_chip);
446 ricoh619_set_bits(ricoh619->dev, RICOH619_GPIO_IOOUT,
449 ricoh619_clr_bits(ricoh619->dev, RICOH619_GPIO_IOOUT,
453 static int ricoh619_gpio_input(struct gpio_chip *gc, unsigned offset)
455 struct ricoh619 *ricoh619 = container_of(gc, struct ricoh619, gpio_chip);
457 return ricoh619_clr_bits(ricoh619->dev, RICOH619_GPIO_IOSEL,
461 static int ricoh619_gpio_output(struct gpio_chip *gc, unsigned offset,
464 struct ricoh619 *ricoh619 = container_of(gc, struct ricoh619, gpio_chip);
466 ricoh619_gpio_set(gc, offset, value);
467 return ricoh619_set_bits(ricoh619->dev, RICOH619_GPIO_IOSEL,
471 static int ricoh619_gpio_to_irq(struct gpio_chip *gc, unsigned off)
473 struct ricoh619 *ricoh619 = container_of(gc, struct ricoh619, gpio_chip);
475 if ((off >= 0) && (off < 8))
476 return ricoh619->irq_base + RICOH619_IRQ_GPIO0 + off;
482 static void __devinit ricoh619_gpio_init(struct ricoh619 *ricoh619,
483 struct ricoh619_platform_data *pdata)
487 struct ricoh619_gpio_init_data *ginit;
489 if (pdata->gpio_base <= 0)
492 for (i = 0; i < pdata->num_gpioinit_data; ++i) {
493 ginit = &pdata->gpio_init_data[i];
495 if (!ginit->init_apply)
498 if (ginit->output_mode_en) {
499 /* GPIO output mode */
500 if (ginit->output_val)
502 ret = ricoh619_set_bits(ricoh619->dev,
503 RICOH619_GPIO_IOOUT, 1 << i);
506 ret = ricoh619_clr_bits(ricoh619->dev,
507 RICOH619_GPIO_IOOUT, 1 << i);
509 ret = ricoh619_set_bits(ricoh619->dev,
510 RICOH619_GPIO_IOSEL, 1 << i);
512 /* GPIO input mode */
513 ret = ricoh619_clr_bits(ricoh619->dev,
514 RICOH619_GPIO_IOSEL, 1 << i);
516 /* if LED function enabled in OTP */
517 if (ginit->led_mode) {
519 if (i == 0) /* GP0 */
520 ret = ricoh619_set_bits(ricoh619->dev,
521 RICOH619_GPIO_LED_FUNC,
522 0x04 | (ginit->led_func & 0x03));
523 if (i == 1) /* GP1 */
524 ret = ricoh619_set_bits(ricoh619->dev,
525 RICOH619_GPIO_LED_FUNC,
526 0x40 | (ginit->led_func & 0x03) << 4);
532 dev_err(ricoh619->dev, "Gpio %d init "
533 "dir configuration failed: %d\n", i, ret);
537 ricoh619->gpio_chip.owner = THIS_MODULE;
538 ricoh619->gpio_chip.label = ricoh619->client->name;
539 ricoh619->gpio_chip.dev = ricoh619->dev;
540 ricoh619->gpio_chip.base = pdata->gpio_base;
541 ricoh619->gpio_chip.ngpio = RICOH619_NR_GPIO;
542 ricoh619->gpio_chip.can_sleep = 1;
544 ricoh619->gpio_chip.direction_input = ricoh619_gpio_input;
545 ricoh619->gpio_chip.direction_output = ricoh619_gpio_output;
546 ricoh619->gpio_chip.set = ricoh619_gpio_set;
547 ricoh619->gpio_chip.get = ricoh619_gpio_get;
548 ricoh619->gpio_chip.to_irq = ricoh619_gpio_to_irq;
550 ret = gpiochip_add(&ricoh619->gpio_chip);
552 dev_warn(ricoh619->dev, "GPIO registration failed: %d\n", ret);
555 static int ricoh619_remove_subdev(struct device *dev, void *unused)
557 platform_device_unregister(to_platform_device(dev));
561 static int ricoh619_remove_subdevs(struct ricoh619 *ricoh619)
563 return device_for_each_child(ricoh619->dev, NULL,
564 ricoh619_remove_subdev);
567 static int __devinit ricoh619_add_subdevs(struct ricoh619 *ricoh619,
568 struct ricoh619_platform_data *pdata)
570 struct ricoh619_subdev_info *subdev;
571 struct platform_device *pdev;
574 for (i = 0; i < pdata->num_subdevs; i++) {
575 subdev = &pdata->subdevs[i];
577 pdev = platform_device_alloc(subdev->name, subdev->id);
579 pdev->dev.parent = ricoh619->dev;
580 pdev->dev.platform_data = subdev->platform_data;
582 ret = platform_device_add(pdev);
589 ricoh619_remove_subdevs(ricoh619);
593 #ifdef CONFIG_DEBUG_FS
594 #include <linux/debugfs.h>
595 #include <linux/seq_file.h>
596 static void print_regs(const char *header, struct seq_file *s,
597 struct i2c_client *client, int start_offset,
604 seq_printf(s, "%s\n", header);
605 for (i = start_offset; i <= end_offset; ++i) {
606 ret = __ricoh619_read(client, i, ®_val);
608 seq_printf(s, "Reg 0x%02x Value 0x%02x\n", i, reg_val);
610 seq_printf(s, "------------------\n");
613 static int dbg_ricoh_show(struct seq_file *s, void *unused)
615 struct ricoh619 *ricoh = s->private;
616 struct i2c_client *client = ricoh->client;
618 seq_printf(s, "RICOH619 Registers\n");
619 seq_printf(s, "------------------\n");
621 print_regs("System Regs", s, client, 0x0, 0x05);
622 print_regs("Power Control Regs", s, client, 0x07, 0x2B);
623 print_regs("DCDC Regs", s, client, 0x2C, 0x43);
624 print_regs("LDO Regs", s, client, 0x44, 0x61);
625 print_regs("ADC Regs", s, client, 0x64, 0x8F);
626 print_regs("GPIO Regs", s, client, 0x90, 0x98);
627 print_regs("INTC Regs", s, client, 0x9C, 0x9E);
628 print_regs("RTC Regs", s, client, 0xA0, 0xAF);
629 print_regs("OPT Regs", s, client, 0xB0, 0xB1);
630 print_regs("CHG Regs", s, client, 0xB2, 0xDF);
631 print_regs("FUEL Regs", s, client, 0xE0, 0xFC);
635 static int dbg_ricoh_open(struct inode *inode, struct file *file)
637 return single_open(file, dbg_ricoh_show, inode->i_private);
640 static const struct file_operations debug_fops = {
641 .open = dbg_ricoh_open,
644 .release = single_release,
646 static void __init ricoh619_debuginit(struct ricoh619 *ricoh)
648 (void)debugfs_create_file("ricoh619", S_IRUGO, NULL,
652 static void print_regs(const char *header, struct i2c_client *client,
653 int start_offset, int end_offset)
659 printk(KERN_INFO "%s\n", header);
660 for (i = start_offset; i <= end_offset; ++i) {
661 ret = __ricoh619_read(client, i, ®_val);
663 printk(KERN_INFO "Reg 0x%02x Value 0x%02x\n",
666 printk(KERN_INFO "------------------\n");
668 static void __init ricoh619_debuginit(struct ricoh619 *ricoh)
670 struct i2c_client *client = ricoh->client;
672 printk(KERN_INFO "RICOH619 Registers\n");
673 printk(KERN_INFO "------------------\n");
675 print_regs("System Regs", client, 0x0, 0x05);
676 print_regs("Power Control Regs", client, 0x07, 0x2B);
677 print_regs("DCDC Regs", client, 0x2C, 0x43);
678 print_regs("LDO Regs", client, 0x44, 0x5C);
679 print_regs("ADC Regs", client, 0x64, 0x8F);
680 print_regs("GPIO Regs", client, 0x90, 0x9B);
681 print_regs("INTC Regs", client, 0x9C, 0x9E);
682 print_regs("OPT Regs", client, 0xB0, 0xB1);
683 print_regs("CHG Regs", client, 0xB2, 0xDF);
684 print_regs("FUEL Regs", client, 0xE0, 0xFC);
690 static void __devinit ricoh619_noe_init(struct ricoh619 *ricoh)
692 struct i2c_client *client = ricoh->client;
694 __ricoh619_write(client, RICOH619_PWR_NOE_TIMSET, 0x0); //N_OE timer setting to 128mS
695 __ricoh619_write(client, RICOH619_PWR_REP_CNT, 0x1); //Repeat power ON after reset (Power Off/N_OE)
698 static int ricoh619_i2c_probe(struct i2c_client *client,
699 const struct i2c_device_id *id)
701 struct ricoh619 *ricoh619;
702 struct ricoh619_platform_data *pdata = client->dev.platform_data;
705 printk(KERN_INFO "PMU: %s:\n", __func__);
707 ricoh619 = kzalloc(sizeof(struct ricoh619), GFP_KERNEL);
708 if (ricoh619 == NULL)
711 ricoh619->client = client;
712 ricoh619->dev = &client->dev;
713 i2c_set_clientdata(client, ricoh619);
715 mutex_init(&ricoh619->io_lock);
717 ret = ricoh619_read(ricoh619->dev, 0x36, &control);
718 if ((control < 0) || (control == 0xff)) {
719 printk(KERN_INFO "The device is not ricoh619\n");
722 /***************set noe time 128ms**************/
723 ret = ricoh619_set_bits(ricoh619->dev,0x11,(0x1 <<3));
724 ret = ricoh619_clr_bits(ricoh619->dev,0x11,(0x7 <<0));
725 ret = ricoh619_clr_bits(ricoh619->dev,0x11,(0x1 <<3));
726 /**********************************************/
728 /***************set PKEY long press time 0sec*******/
729 ret = ricoh619_set_bits(ricoh619->dev,0x10,(0x1 <<7));
730 ret = ricoh619_clr_bits(ricoh619->dev,0x10,(0x1 <<3));
731 ret = ricoh619_clr_bits(ricoh619->dev,0x10,(0x1 <<7));
732 /**********************************************/
734 ricoh619->bank_num = 0;
736 // ret = pdata->init_port(client->irq); // For init PMIC_IRQ port
738 ret = ricoh619_irq_init(ricoh619, client->irq, pdata->irq_base);
740 dev_err(&client->dev, "IRQ init failed: %d\n", ret);
745 ret = ricoh619_add_subdevs(ricoh619, pdata);
747 dev_err(&client->dev, "add devices failed: %d\n", ret);
750 ricoh619_noe_init(ricoh619);
752 g_ricoh619 = ricoh619;
753 if (pdata && pdata->pre_init) {
754 ret = pdata->pre_init(ricoh619);
756 dev_err(ricoh619->dev, "pre_init() failed: %d\n", ret);
761 //ricoh619_gpio_init(ricoh619, pdata);
763 ricoh619_debuginit(ricoh619);
765 if (pdata && pdata->post_init) {
766 ret = pdata->post_init(ricoh619);
768 dev_err(ricoh619->dev, "post_init() failed: %d\n", ret);
773 ricoh619_i2c_client = client;
776 mfd_remove_devices(ricoh619->dev);
780 ricoh619_irq_exit(ricoh619);
786 static int __devexit ricoh619_i2c_remove(struct i2c_client *client)
788 struct ricoh619 *ricoh619 = i2c_get_clientdata(client);
791 ricoh619_irq_exit(ricoh619);
793 ricoh619_remove_subdevs(ricoh619);
799 static int ricoh619_i2c_suspend(struct i2c_client *client, pm_message_t state)
802 disable_irq(client->irq);
807 static int ricoh619_i2c_resume(struct i2c_client *client)
812 ret = __ricoh619_read(client, RICOH619_INT_IR_SYS, ®_val);
813 if(reg_val & 0x01) { //If PWR_KEY wakeup
814 // printk("PMU: %s: PWR_KEY Wakeup\n",__func__);
816 __ricoh619_write(client, RICOH619_INT_IR_SYS, 0x0); //Clear PWR_KEY IRQ
819 enable_irq(client->irq);
825 static const struct i2c_device_id ricoh619_i2c_id[] = {
830 MODULE_DEVICE_TABLE(i2c, ricoh619_i2c_id);
832 static struct i2c_driver ricoh619_i2c_driver = {
835 .owner = THIS_MODULE,
837 .probe = ricoh619_i2c_probe,
838 .remove = __devexit_p(ricoh619_i2c_remove),
840 .suspend = ricoh619_i2c_suspend,
841 .resume = ricoh619_i2c_resume,
843 .id_table = ricoh619_i2c_id,
847 static int __init ricoh619_i2c_init(void)
850 ret = i2c_add_driver(&ricoh619_i2c_driver);
852 pr_err("Failed to register I2C driver: %d\n", ret);
857 subsys_initcall_sync(ricoh619_i2c_init);
859 static void __exit ricoh619_i2c_exit(void)
861 i2c_del_driver(&ricoh619_i2c_driver);
864 module_exit(ricoh619_i2c_exit);
866 MODULE_DESCRIPTION("RICOH RC5T619 PMU multi-function core driver");
867 MODULE_AUTHOR("zhangqing <zhangqing@rock-chips.com>");
868 MODULE_LICENSE("GPL");