cwz update tps65910 irq
[firefly-linux-kernel-4.4.55.git] / drivers / mfd / tps65910-core.c
1 /*
2  * tps65910-core.c -- Multifunction core driver for  TPS65910x chips
3  *
4  * Copyright (C) 2010 Mistral solutions Pvt Ltd <www.mistralsolutions.com>
5  *
6  * Based on twl-core.c
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  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  */
22
23 #include <linux/init.h>
24 #include <linux/mutex.h>
25 #include <linux/platform_device.h>
26 #include <linux/clk.h>
27 #include <linux/err.h>
28
29 #include <linux/regulator/machine.h>
30
31 #include <linux/i2c.h>
32 #include <linux/i2c/tps65910.h>
33 #include <mach/board.h>
34 #include <mach/gpio.h>
35 #include <linux/irq.h>
36 #include <linux/interrupt.h>
37 #include <linux/delay.h>
38
39 #if 1
40 #define DBG(x...)       printk(KERN_INFO x)
41 #else
42 #define DBG(x...)
43 #endif
44 #define TPS65910_SPEED  400 * 1000
45
46
47 #define DRIVER_NAME                     "tps65910"
48
49 #if defined(CONFIG_GPIO_TPS65910)
50 #define tps65910_has_gpio()             true
51 #else
52 #define tps65910_has_gpio()             false
53 #endif
54
55 #if defined(CONFIG_REGULATOR_TPS65910)
56 #define tps65910_has_regulator()        true
57 #else
58 #define tps65910_has_regulator()        false
59 #endif
60
61 #if defined(CONFIG_RTC_DRV_TPS65910)
62 #define tps65910_has_rtc()              true
63 #else
64 #define tps65910_has_rtc()              false
65 #endif
66
67 #define TPS65910_GENERAL                        0
68 #define TPS65910_SMARTREFLEX            1
69
70
71 struct tps65910_platform_data *gtps65910_platform = NULL;
72
73 enum tps65910x_model {
74         TPS65910,       /* TI processors OMAP3 family */
75         TPS659101,      /* Samsung - S5PV210, S5PC1xx */
76         TPS659102,      /* Samsung - S3C64xx */
77         TPS659103,      /* Reserved */
78         TPS659104,      /* Reserved */
79         TPS659105,      /* TI processors - DM643x, DM644x */
80         TPS659106,      /* Reserved */
81         TPS659107,      /* Reserved */
82         TPS659108,      /* Reserved */
83         TPS659109,      /* Freescale - i.MX51 */
84
85 };
86
87 static bool inuse;
88 static struct work_struct core_work;
89 static struct mutex work_lock;
90
91 /* Structure for each TPS65910 Slave */
92 struct tps65910_client {
93         struct i2c_client *client;
94         u8 address;
95         /* max numb of i2c_msg required for read = 2 */
96         struct i2c_msg xfer_msg[2];
97         /* To lock access to xfer_msg */
98         struct mutex xfer_lock;
99 };
100 static struct tps65910_client tps65910_modules[TPS65910_NUM_SLAVES];
101
102 /* bbch = Back-up battery charger control register */
103 int tps65910_enable_bbch(u8 voltage)
104 {
105         u8 val = 0;
106         int err;
107
108         if (voltage == TPS65910_BBSEL_3P0 || voltage == TPS65910_BBSEL_2P52 ||
109                         voltage == TPS65910_BBSEL_3P15 ||
110                         voltage == TPS65910_BBSEL_VBAT) {
111                 val = (voltage | TPS65910_BBCHEN);
112                 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val,
113                                 TPS65910_REG_BBCH);
114                 if (err) {
115                         printk(KERN_ERR "Unable write TPS65910_REG_BBCH reg\n");
116                         return -EIO;
117                 }
118         } else {
119                 printk(KERN_ERR"Invalid argumnet for %s \n", __func__);
120                 return -EINVAL;
121         }
122
123         return 0;
124 }
125 EXPORT_SYMBOL(tps65910_enable_bbch);
126
127 int tps65910_disable_bbch(void)
128 {
129         u8 val = 0;
130         int err;
131
132         err = tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_BBCH);
133
134         if (!err) {
135                 val &= ~TPS65910_BBCHEN;
136
137                 err = tps65910_i2c_write_u8(TPS65910_I2C_ID0, val,
138                                 TPS65910_REG_BBCH);
139                 if (err) {
140                         printk(KERN_ERR "Unable write TPS65910_REG_BBCH \
141                                         reg\n");
142                         return -EIO;
143                 }
144         } else {
145                 printk(KERN_ERR "Unable to read TPS65910_REG_BBCH reg\n");
146                 return -EIO;
147         }
148         return 0;
149 }
150 EXPORT_SYMBOL(tps65910_disable_bbch);
151
152 int tps65910_i2c_read_u8(u8 mod_no, u8 *value, u8 reg)
153 {
154         struct tps65910_client *tps65910;
155         int ret;
156         
157         switch (mod_no) {
158         case TPS65910_I2C_ID0:
159                 tps65910 = &tps65910_modules[0];
160                 tps65910->address = TPS65910_I2C_ID0;
161                 break;
162         case TPS65910_I2C_ID1:
163                 tps65910 = &tps65910_modules[1];
164                 tps65910->address = TPS65910_I2C_ID1;
165                 break;
166         default:
167                 printk(KERN_ERR "Invalid Slave address for TPS65910\n");
168                 return -ENODEV;
169         }
170         
171         ret = i2c_master_reg8_recv(tps65910->client, reg, (char *)value, 1, TPS65910_SPEED);
172         DBG("%s: ret=%d, slave_addr=0x%x, reg=0x%x, value=0x%x\n", __FUNCTION__, (ret > 0 ? 0: -EINVAL), mod_no, reg, *value);
173
174         return (ret > 0 ? 0: -EINVAL);
175 }
176 EXPORT_SYMBOL(tps65910_i2c_read_u8);
177
178 int tps65910_i2c_write_u8(u8 slave_addr, u8 value, u8 reg)
179 {
180         struct tps65910_client *tps65910;
181         int ret;
182
183         switch (slave_addr) {
184         case TPS65910_I2C_ID0:
185                 tps65910 = &tps65910_modules[0];
186                 tps65910->address = TPS65910_I2C_ID0;
187                 break;
188         case TPS65910_I2C_ID1:
189                 tps65910 = &tps65910_modules[1];
190                 tps65910->address = TPS65910_I2C_ID1;
191                 break;
192         default:
193                 printk(KERN_ERR "Invalid Slave address for TPS65910\n");
194                 return -ENODEV;
195         }
196
197         ret = i2c_master_reg8_send(tps65910->client, reg, (char *)&value, 1, TPS65910_SPEED);
198         DBG("%s: ret=%d, slave_addr=0x%x, reg=0x%x, value=0x%x\n", __FUNCTION__, ret, slave_addr, reg, value);
199
200         if (ret < 0)
201                 return -EIO;
202         else
203                 return 0;
204 }
205 EXPORT_SYMBOL(tps65910_i2c_write_u8);
206
207
208 int tps65910_enable_irq(int irq)
209 {
210         u8  mask = 0x00;
211
212         if (irq > 7) {
213                 irq -= 8;
214                 tps65910_i2c_read_u8(TPS65910_I2C_ID0,
215                                 &mask, TPS65910_REG_INT_MSK2);
216                 mask &= ~(1 << irq);
217                 return tps65910_i2c_write_u8(TPS65910_I2C_ID0,
218                                 mask, TPS65910_REG_INT_MSK2);
219         } else {
220                 tps65910_i2c_read_u8(TPS65910_I2C_ID0,
221                                 &mask, TPS65910_REG_INT_MSK);
222                 mask &= ~(1 << irq);
223                 return tps65910_i2c_write_u8(TPS65910_I2C_ID0,
224                                 mask, TPS65910_REG_INT_MSK);
225         }
226 }
227 EXPORT_SYMBOL(tps65910_enable_irq);
228
229 int tps65910_disable_irq(int irq)
230 {
231         u8  mask = 0x00;
232
233         if (irq > 7) {
234                 irq -= 8;
235                 tps65910_i2c_read_u8(TPS65910_I2C_ID0,
236                                 &mask, TPS65910_REG_INT_MSK2);
237                 mask |= (1 << irq);
238                 return tps65910_i2c_write_u8(TPS65910_I2C_ID0,
239                                 mask, TPS65910_REG_INT_MSK2);
240         } else {
241                 tps65910_i2c_read_u8(TPS65910_I2C_ID0,
242                                 &mask, TPS65910_REG_INT_MSK);
243                 mask = (1 << irq);
244                 return tps65910_i2c_write_u8(TPS65910_I2C_ID0,
245                                 mask, TPS65910_REG_INT_MSK);
246         }
247 }
248 EXPORT_SYMBOL(tps65910_disable_irq);
249
250 int tps65910_add_irq_work(int irq,
251                 void (*handler)(void *data))
252 {
253         int ret = 0;
254         gtps65910_platform->handlers[irq] = handler;
255         ret = tps65910_enable_irq(irq);
256
257         return ret;
258 }
259 EXPORT_SYMBOL(tps65910_add_irq_work);
260
261 int tps65910_remove_irq_work(int irq)
262 {
263         int ret = 0;
264         ret = tps65910_disable_irq(irq);
265         gtps65910_platform->handlers[irq] = NULL;
266         return ret;
267 }
268 EXPORT_SYMBOL(tps65910_remove_irq_work);
269
270 static void tps65910_core_work(struct work_struct *work)
271 {
272         /* Read the status register and take action  */
273         u8      status = 0x00;
274         u8      status2 = 0x00;
275         u8      mask = 0x00;
276         u8      mask2 = 0x00;
277         u16 isr = 0x00;
278         u16 irq = 0;
279         void    (*handler)(void *data) = NULL;
280
281         DBG("Enter::%s %d\n",__FUNCTION__,__LINE__);
282         mutex_lock(&work_lock);
283         while (1) {
284                 tps65910_i2c_read_u8(TPS65910_I2C_ID0, &status2,
285                                 TPS65910_REG_INT_STS2);
286                 tps65910_i2c_read_u8(TPS65910_I2C_ID0, &mask2,
287                                 TPS65910_REG_INT_MSK2);
288                 status2 &= (~mask2);
289                 isr = (status2 << 8);
290                 tps65910_i2c_read_u8(TPS65910_I2C_ID0, &status,
291                                 TPS65910_REG_INT_STS);
292                 tps65910_i2c_read_u8(TPS65910_I2C_ID0, &mask,
293                                 TPS65910_REG_INT_MSK);
294                 status &= ~(mask);
295                 isr |= status;
296                 if (!isr)
297                         break;
298
299                 while (isr) {
300                         irq = fls(isr) - 1;
301                         isr &= ~(1 << irq);
302                         handler = gtps65910_platform->handlers[irq];
303                         if (handler)
304                                 handler(gtps65910_platform);
305                 }
306         }
307         enable_irq(gtps65910_platform->irq_num);
308         mutex_unlock(&work_lock);
309 }
310
311
312 static irqreturn_t tps65910_isr(int irq,  void *data)
313 {
314         disable_irq_nosync(irq);
315         (void) schedule_work(&core_work);
316         return IRQ_HANDLED;
317 }
318
319
320 static struct device *add_numbered_child(unsigned chip, const char *name,
321         int num, void *pdata, unsigned pdata_len, bool can_wakeup, int irq)
322 {
323
324         struct platform_device  *pdev;
325         struct tps65910_client  *tps65910 = &tps65910_modules[chip];
326         int  status;
327
328         pdev = platform_device_alloc(name, num);
329         if (!pdev) {
330                 dev_dbg(&tps65910->client->dev, "can't alloc dev\n");
331                 status = -ENOMEM;
332                 goto err;
333         }
334         device_init_wakeup(&pdev->dev, can_wakeup);
335         pdev->dev.parent = &tps65910->client->dev;
336
337         if (pdata) {
338                 status = platform_device_add_data(pdev, pdata, pdata_len);
339                 if (status < 0) {
340                         dev_dbg(&pdev->dev, "can't add platform_data\n");
341                         goto err;
342                 }
343         }
344         status = platform_device_add(pdev);
345
346 err:
347         if (status < 0) {
348                 platform_device_put(pdev);
349                 dev_err(&tps65910->client->dev, "can't add %s dev\n", name);
350                 return ERR_PTR(status);
351         }
352         return &pdev->dev;
353
354 }
355
356 static inline struct device *add_child(unsigned chip, const char *name,
357                 void *pdata, unsigned pdata_len,
358                 bool can_wakeup, int irq)
359 {
360         return add_numbered_child(chip, name, -1, pdata, pdata_len,
361                         can_wakeup, irq);
362 }
363
364 static
365 struct device *add_regulator_linked(int num, struct regulator_init_data *pdata,
366                 struct regulator_consumer_supply *consumers,
367                 unsigned num_consumers)
368 {
369         /* regulator framework demands init_data */
370         if (!pdata)
371                 return NULL;
372
373         if (consumers) {
374                 pdata->consumer_supplies = consumers;
375                 pdata->num_consumer_supplies = num_consumers;
376         }
377         return add_numbered_child(TPS65910_GENERAL, "tps65910_regulator", num,
378                         pdata, sizeof(*pdata), false, TPS65910_HOST_IRQ);
379 }
380
381         static struct device *
382 add_regulator(int num, struct regulator_init_data *pdata)
383 {
384         return add_regulator_linked(num, pdata, NULL, 0);
385 }
386
387 static int
388 add_children(struct tps65910_platform_data *pdata, unsigned long features)
389 {
390         int             status;
391         struct device   *child;
392
393         struct platform_device  *pdev = NULL;
394
395         if (tps65910_has_gpio() && (pdata->gpio != NULL)) {
396
397                 pdev = platform_device_alloc("tps65910_gpio", -1);
398                 if (!pdev) {
399                         status = -ENOMEM;
400                         goto err;
401                 }
402                 pdev->dev.parent = &tps65910_modules[0].client->dev;
403                 device_init_wakeup(&pdev->dev, 0);
404                 if (pdata) {
405                         status = platform_device_add_data(pdev, pdata,
406                                                         sizeof(*pdata));
407                         if (status < 0) {
408                                 dev_dbg(&pdev->dev,
409                                 "can't add platform_data\n");
410                                 goto err;
411                         }
412                 }
413         }
414         if (tps65910_has_rtc()) {
415                 child = add_child(TPS65910_GENERAL, "tps65910_rtc",
416                                 NULL, 0, true, pdata->irq_num);
417                 if (IS_ERR(child))
418                         return PTR_ERR(child);
419         }
420
421         if (tps65910_has_regulator()) {
422
423                 child = add_regulator(TPS65910_VIO, pdata->vio);
424                 if (IS_ERR(child))
425                         return PTR_ERR(child);
426
427                 child = add_regulator(TPS65910_VDD1, pdata->vdd1);
428                 if (IS_ERR(child))
429                         return PTR_ERR(child);
430
431                 child = add_regulator(TPS65910_VDD2, pdata->vdd2);
432                 if (IS_ERR(child))
433                         return PTR_ERR(child);
434
435                 child = add_regulator(TPS65910_VDD3, pdata->vdd3);
436                 if (IS_ERR(child))
437                         return PTR_ERR(child);
438
439                 child = add_regulator(TPS65910_VDIG1, pdata->vdig1);
440                 if (IS_ERR(child))
441                         return PTR_ERR(child);
442
443                 child = add_regulator(TPS65910_VDIG2, pdata->vdig2);
444                 if (IS_ERR(child))
445                         return PTR_ERR(child);
446
447                 child = add_regulator(TPS65910_VAUX33, pdata->vaux33);
448                 if (IS_ERR(child))
449                         return PTR_ERR(child);
450
451                 child = add_regulator(TPS65910_VMMC, pdata->vmmc);
452                 if (IS_ERR(child))
453                         return PTR_ERR(child);
454
455                 child = add_regulator(TPS65910_VAUX1, pdata->vaux1);
456                 if (IS_ERR(child))
457                         return PTR_ERR(child);
458
459                 child = add_regulator(TPS65910_VAUX2, pdata->vaux2);
460                 if (IS_ERR(child))
461                         return PTR_ERR(child);
462
463                 child = add_regulator(TPS65910_VDAC, pdata->vdac);
464                 if (IS_ERR(child))
465                         return PTR_ERR(child);
466
467                 child = add_regulator(TPS65910_VPLL, pdata->vpll);
468                 if (IS_ERR(child))
469                         return PTR_ERR(child);
470         }
471         return 0;
472
473 err:
474         return -1;
475
476 }
477
478 static int tps65910_remove(struct i2c_client *client)
479 {
480         unsigned i;
481
482         for (i = 0; i < TPS65910_NUM_SLAVES; i++) {
483
484                 struct tps65910_client *tps65910 = &tps65910_modules[i];
485
486                 if (tps65910->client && tps65910->client != client)
487                         i2c_unregister_device(tps65910->client);
488
489                 tps65910_modules[i].client = NULL;
490         }
491         inuse = false;
492         return 0;
493 }
494
495 static int __init
496 tps65910_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
497 {
498         int      status;
499         unsigned i;
500         struct tps65910_platform_data   *pdata;
501  
502         pdata = client->dev.platform_data;
503         gtps65910_platform = pdata;
504
505         DBG("cwz: tps65910_i2c_probe\n");
506         
507         if (!pdata) {
508                 dev_dbg(&client->dev, "no platform data?\n");
509                 return -EINVAL;
510         }
511
512         if (!i2c_check_functionality(client->adapter,I2C_FUNC_I2C)) {
513                 dev_dbg(&client->dev, "can't talk I2C?\n");
514                 return -EIO;
515         }
516
517         if (inuse) {
518                 dev_dbg(&client->dev, "driver is already in use\n");
519                 return -EBUSY;
520         } 
521         for (i = 0; i < TPS65910_NUM_SLAVES; i++) {
522
523                 struct tps65910_client  *tps65910 = &tps65910_modules[i];
524
525                 tps65910->address = client->addr;
526
527                 if (i == 0)
528                         tps65910->client = client;
529                 else {
530                         tps65910->client = i2c_new_dummy(client->adapter,
531                                         tps65910->address);
532
533                         if (!tps65910->client) {
534                                 dev_err(&client->dev,
535                                                 "can't attach client %d\n", i);
536                                 status = -ENOMEM;
537                                 goto fail;
538                         }
539                 }
540                 mutex_init(&tps65910->xfer_lock);
541         } 
542
543         inuse = true;
544
545         if (pdata->board_tps65910_config != NULL)
546                 pdata->board_tps65910_config(pdata);
547
548         if (pdata->irq_num) {
549                 /* TPS65910 power ON interrupt(s) would have already been
550                  * occurred, so immediately after request_irq the control will
551                  * be transferred to tps65910_isr, if we do core_work
552                  * initialization after requesting IRQ, the system crashes
553                  * and does not boot; to avoid this we do core_work
554                  * initialization before requesting IRQ
555                  */
556                 mutex_init(&work_lock);
557
558                 if(gpio_request(client->irq, "tps65910 irq"))
559                 {
560                         dev_err(&client->dev, "gpio request fail\n");
561                         gpio_free(client->irq);
562                         goto fail;
563                 }
564                 
565                 pdata->irq_num = gpio_to_irq(client->irq);
566                 gpio_pull_updown(client->irq,GPIOPullUp);
567
568                 status = request_irq(pdata->irq_num, tps65910_isr,
569                                         IRQF_TRIGGER_FALLING, client->dev.driver->name, pdata);
570                 if (status < 0) {
571                         pr_err("tps65910: could not claim irq%d: %d\n",
572                                         pdata->irq_num, status);
573                         goto fail;
574                 }
575                 enable_irq_wake(pdata->irq_num);
576                 INIT_WORK(&core_work, tps65910_core_work);
577         }
578
579         status = add_children(pdata, 0x00);
580         if (status < 0)
581                 goto fail;
582
583         return 0;
584
585 fail:
586         if (status < 0)
587                 tps65910_remove(client);
588
589         return status;
590 }
591
592
593 static int tps65910_i2c_remove(struct i2c_client *client)
594 {
595         unsigned i;
596
597         for (i = 0; i < TPS65910_NUM_SLAVES; i++) {
598
599                 struct tps65910_client  *tps65910 = &tps65910_modules[i];
600
601                 if (tps65910->client && tps65910->client != client)
602                         i2c_unregister_device(tps65910->client);
603
604                 tps65910_modules[i].client = NULL;
605         }
606         inuse = false;
607         return 0;
608 }
609
610 /* chip-specific feature flags, for i2c_device_id.driver_data */
611 static const struct i2c_device_id tps65910_i2c_ids[] = {
612         { "tps65910", TPS65910 },
613         { "tps659101", TPS659101 },
614         { "tps659102", TPS659102 },
615         { "tps659103", TPS659103 },
616         { "tps659104", TPS659104 },
617         { "tps659105", TPS659105 },
618         { "tps659106", TPS659106 },
619         { "tps659107", TPS659107 },
620         { "tps659108", TPS659108 },
621         { "tps659109", TPS659109 },
622         {/* end of list */ },
623 };
624 MODULE_DEVICE_TABLE(i2c, tps65910_i2c_ids);
625
626 /* One Client Driver ,3 Clients - Regulator, RTC , GPIO */
627 static struct i2c_driver tps65910_i2c_driver = {
628         .driver         = {
629                 .name   = DRIVER_NAME,
630                 .owner  = THIS_MODULE,
631         },
632         .id_table       = tps65910_i2c_ids,
633         .probe          = tps65910_i2c_probe,
634         .remove         = __devexit_p(tps65910_i2c_remove),
635 };
636
637 static int __init tps65910_init(void)
638 {
639         int res;
640
641         res = i2c_add_driver(&tps65910_i2c_driver);
642         if (res < 0) {
643                 pr_err(DRIVER_NAME ": driver registration failed\n");
644                 return res;
645         }
646
647         return 0;
648 }
649 subsys_initcall_sync(tps65910_init);
650
651 static void __exit tps65910_exit(void)
652 {
653         i2c_del_driver(&tps65910_i2c_driver);
654 }
655 module_exit(tps65910_exit);
656
657
658 #ifdef CONFIG_PROC_FS
659 #include <linux/proc_fs.h>
660 #include <linux/seq_file.h>
661
662 static int proc_tps65910_show(struct seq_file *s, void *v)
663 {
664     u8 val = 0;
665         
666         seq_printf(s, "\n\nTPS65910 Registers is:\n");
667
668         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_REF);
669         seq_printf(s, "REF_REG=0x%x, Value=0x%x\n", TPS65910_REG_REF, val);
670         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VRTC);
671         seq_printf(s, "VRTC_REG=0x%x, Value=0x%x\n", TPS65910_REG_VRTC, val);
672         
673         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD1);
674         seq_printf(s, "VDD1_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDD1, val);
675         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD1_OP);
676         seq_printf(s, "VDD1_OP_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDD1_OP, val);
677
678         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD2);
679         seq_printf(s, "VDD2_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDD2, val);
680         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDD2_OP);
681         seq_printf(s, "VDD2_OP_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDD2_OP, val);
682
683         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VIO);
684         seq_printf(s, "VIO_REG=0x%x, Value=0x%x\n", TPS65910_REG_VIO, val);
685
686         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDIG1);
687         seq_printf(s, "VDIG1_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDIG1, val);
688         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDIG2);
689         seq_printf(s, "VDIG2_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDIG2, val);
690         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VAUX1);
691         seq_printf(s, "VAUX1_REG=0x%x, Value=0x%x\n", TPS65910_REG_VAUX1, val);
692         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VAUX2);
693         seq_printf(s, "VAUX2_REG=0x%x, Value=0x%x\n", TPS65910_REG_VAUX2, val);
694         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VAUX33);
695         seq_printf(s, "VAUX33_REG=0x%x, Value=0x%x\n", TPS65910_REG_VAUX33, val);
696         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VMMC);
697         seq_printf(s, "VMMC_REG=0x%x, Value=0x%x\n", TPS65910_REG_VMMC, val);
698         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VPLL);
699         seq_printf(s, "VPLL_REG=0x%x, Value=0x%x\n", TPS65910_REG_VPLL, val);
700         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_VDAC);
701         seq_printf(s, "VDAC_REG=0x%x, Value=0x%x\n", TPS65910_REG_VDAC, val);
702
703         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_DEVCTRL);
704         seq_printf(s, "DEVCTRL_REG=0x%x, Value=0x%x\n", TPS65910_REG_DEVCTRL, val);
705         tps65910_i2c_read_u8(TPS65910_I2C_ID0, &val, TPS65910_REG_DEVCTRL2);
706         seq_printf(s, "DEVCTRL2_REG=0x%x, Value=0x%x\n", TPS65910_REG_DEVCTRL2, val);
707
708 #if 0   //      cwz 1 test vcore
709 {
710     struct regulator *vldo;
711         
712         vldo = regulator_get(NULL, "vcore");
713         if (vldo != NULL)
714         {
715                 int uV = 0;
716                 
717                 seq_printf(s, "Set VCORE.\n");
718                 regulator_set_voltage(vldo,1100000,1100000);
719
720                 uV = regulator_get_voltage(vldo);
721                 seq_printf(s, "Get VCORE=%d(uV).\n", uV);
722         }
723 }
724 #endif  
725         return 0;
726 }
727
728 static int proc_tps65910_open(struct inode *inode, struct file *file)
729 {
730         return single_open(file, proc_tps65910_show, NULL);
731 }
732
733 static const struct file_operations proc_tps65910_fops = {
734         .open           = proc_tps65910_open,
735         .read           = seq_read,
736         .llseek         = seq_lseek,
737         .release        = single_release,
738 };
739
740 static int __init proc_tps65910_init(void)
741 {
742         proc_create("tps65910", 0, NULL, &proc_tps65910_fops);
743         return 0;
744 }
745 late_initcall(proc_tps65910_init);
746 #endif /* CONFIG_PROC_FS */
747
748 MODULE_AUTHOR("cwz <cwz@rock-chips.com>");
749 MODULE_DESCRIPTION("I2C Core interface for TPS65910");
750 MODULE_LICENSE("GPL");