upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / media / video / s5p-tv / mhl_v1 / sii9234.c
1
2 /***************************************************************************
3
4
5
6 *   SiI9244 - MHL Transmitter Driver
7
8 *
9
10 * Copyright (C) (2011, Silicon Image Inc)
11
12 *
13
14 * This program is free software; you can redistribute it and/or modify
15
16 * it under the terms of the GNU General Public License as published by
17
18 * the Free Software Foundation version 2.
19
20 *
21
22 * This program is distributed ¡°as is¡± WITHOUT ANY WARRANTY of any
23
24 * kind, whether express or implied; without even the implied warranty
25
26 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
28 * GNU General Public License for more details.
29
30 *
31
32 *****************************************************************************/
33
34 #include <linux/interrupt.h>
35 #include <linux/irq.h>
36 #include <linux/i2c.h>
37 #include <linux/gpio.h>
38 #include <plat/pm.h>
39 #include <asm/irq.h>
40 #include <linux/delay.h>
41 #include <plat/gpio-cfg.h>
42 #include <plat/gpio-core.h>
43 #include <mach/regs-gpio.h>
44 #include <mach/regs-clock.h>
45 #include <linux/miscdevice.h>
46 #include <linux/slab.h>
47 #include <linux/syscalls.h> 
48 #include <linux/fcntl.h> 
49 #include <asm/uaccess.h> 
50 #include <linux/regulator/consumer.h>
51 #include <linux/mfd/max8998.h>
52 #include <linux/mfd/max8997.h>
53
54
55 #include "sii9234_driver.h"
56 #include "Common_Def.h"
57 #include "u1hd_gpio.h"
58
59 #define SUBJECT "MHL_DRIVER"
60
61 #define SII_DEV_DBG(format,...)\
62         printk ("[ "SUBJECT " (%s,%d) ] " format "\n", __func__, __LINE__, ## __VA_ARGS__);
63
64 struct work_struct sii9234_int_work;
65 struct workqueue_struct *sii9234_wq = NULL;
66
67 struct i2c_driver sii9234_i2c_driver;
68 struct i2c_client *sii9234_i2c_client = NULL;
69
70 struct i2c_driver sii9234a_i2c_driver;
71 struct i2c_client *sii9234a_i2c_client = NULL;
72
73 struct i2c_driver sii9234b_i2c_driver;
74 struct i2c_client *sii9234b_i2c_client = NULL;
75
76 struct i2c_driver sii9234c_i2c_driver;
77 struct i2c_client *sii9234c_i2c_client = NULL;
78
79 extern bool sii9234_init(void);
80
81 static struct i2c_device_id sii9234_id[] = {
82         {"SII9234", 0},
83         {}
84 };
85
86 static struct i2c_device_id sii9234a_id[] = {
87         {"SII9234A", 0},
88         {}
89 };
90
91 static struct i2c_device_id sii9234b_id[] = {
92         {"SII9234B", 0},
93         {}
94 };
95
96 static struct i2c_device_id sii9234c_id[] = {
97         {"SII9234C", 0},
98         {}
99 };
100
101 int MHL_i2c_init = 0;
102
103
104 struct sii9234_state {
105         struct i2c_client *client;
106 };
107
108 void sii9234_cfg_power(bool on);
109
110 static void sii9234_cfg_gpio(void);
111
112 irqreturn_t mhl_int_irq_handler(int irq, void *dev_id);
113
114 irqreturn_t mhl_wake_up_irq_handler(int irq, void *dev_id);
115
116 void sii9234_interrupt_event_work(struct work_struct *p);
117
118 #define MHL_SWITCH_TEST 1
119
120 #ifdef MHL_SWITCH_TEST
121 struct class *sec_mhl;
122 EXPORT_SYMBOL(sec_mhl);
123
124 struct device *mhl_switch;
125 EXPORT_SYMBOL(mhl_switch);
126
127 static ssize_t check_MHL_command(struct device *dev, struct device_attribute *attr, char *buf)
128 {
129         int count;
130         int res;
131
132         printk(KERN_ERR "[MHL]: check_MHL_command\n");
133         sii9234_cfg_power(1);
134         res = SiI9234_startTPI();
135         count = sprintf(buf,"%d\n", res );
136         sii9234_cfg_power(0);
137         return count;
138
139 }
140
141 static ssize_t change_switch_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
142 {
143         char *after;
144         unsigned long value = simple_strtoul(buf, &after, 10);
145         int i;
146         printk(KERN_ERR "[MHL_SWITCH] Change the switch: %ld\n", value);
147
148         if (value == 0) {
149                 for (i = 0; i <20; i++) {
150                         printk(KERN_ERR "[MHL] try %d\n", i+1);
151                         msleep(500);
152                 }
153                 s3c_gpio_cfgpin(GPIO_MHL_INT, GPIO_MHL_INT_AF);
154                 s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_UP);
155                 gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_HIGH);
156                 sii9234_cfg_power(1);
157                 sii9234_init();
158         } else {
159                 sii9234_cfg_power(0);
160                 s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_NONE);
161                 gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_LOW);
162         }
163         return size;
164 }
165
166 static BLOCKING_NOTIFIER_HEAD(mhl_notifier_client_list);
167
168 int mhl_register_client(struct notifier_block *nb)
169 {
170         return blocking_notifier_chain_register(
171                         &mhl_notifier_client_list, nb);
172 }
173 EXPORT_SYMBOL(mhl_register_client);
174
175 int mhl_unregister_client(struct notifier_block *nb)
176 {
177         return blocking_notifier_chain_unregister(
178                         &mhl_notifier_client_list, nb);
179 }
180 EXPORT_SYMBOL(mhl_unregister_client);
181
182 static int mhl_send_event(unsigned long val, void *v)
183 {
184         return blocking_notifier_call_chain(
185                         &mhl_notifier_client_list, val, v);
186 }
187
188 void MHL_On(bool on)
189 {
190         printk("[MHL] USB path change : %d\n", on);
191         if (on == 1) {
192                 mhl_send_event(1, NULL);
193                 if(gpio_get_value(GPIO_MHL_SEL))
194                         printk("[MHL] GPIO_MHL_SEL : already 1\n");
195                 else {
196                         gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_HIGH);
197                         sii9234_cfg_power(1);
198                         sii9234_init();
199                 }       
200         } else {
201                 if(!gpio_get_value(GPIO_MHL_SEL))
202                         printk("[MHL] GPIO_MHL_SEL : already 0\n");
203                 else {  
204                         sii9234_cfg_power(0);
205                         gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_LOW);
206                 }
207         }
208
209 }
210 EXPORT_SYMBOL(MHL_On);
211
212
213 static DEVICE_ATTR(mhl_sel, S_IRUGO | S_IWUSR | S_IXOTH, check_MHL_command, change_switch_store);
214 #endif
215
216 static ssize_t MHD_check_read(struct device *dev, struct device_attribute *attr, char *buf)
217 {
218         int count;
219         int res = 0;
220         #if 0
221
222         s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_UP);       //MHL_SEL
223
224         gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_HIGH);
225         
226
227         //TVout_LDO_ctrl(true);
228         
229         if(!MHD_HW_IsOn())
230         {
231                 sii9234_tpi_init();
232                 res = MHD_Read_deviceID();
233                 MHD_HW_Off();           
234         }
235         else
236         {
237                 sii9234_tpi_init();
238                 res = MHD_Read_deviceID();
239         }
240
241         I2C_WriteByte(0x72, 0xA5, 0xE1);
242         res = 0;
243         res = I2C_ReadByte(0x72, 0xA5);
244
245         printk(KERN_ERR "A5 res %x",res);
246
247         res = 0;
248         res = I2C_ReadByte(0x72, 0x1B);
249
250         printk(KERN_ERR "Device ID res %x",res);
251
252         res = 0;
253         res = I2C_ReadByte(0x72, 0x1C);
254
255         printk(KERN_ERR "Device Rev ID res %x",res);
256
257         res = 0;
258         res = I2C_ReadByte(0x72, 0x1D);
259
260         printk(KERN_ERR "Device Reserved ID res %x",res);
261
262         printk(KERN_ERR "\n####HDMI_EN1 %x MHL_RST %x GPIO_MHL_SEL %x\n",gpio_get_value(GPIO_HDMI_EN),gpio_get_value(GPIO_MHL_RST),gpio_get_value(GPIO_MHL_SEL));
263
264         res = I2C_ReadByte(0x7A, 0x3D);
265
266         res = I2C_ReadByte(0x7A, 0xFF);
267                 
268         s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_NONE);     //MHL_SEL
269
270         gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_LOW);
271 #endif
272         count = sprintf(buf,"%d\n", res );
273         //TVout_LDO_ctrl(false);
274         return count;
275 }
276
277 static ssize_t MHD_check_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
278 {
279         printk(KERN_ERR "input data --> %s\n", buf);
280
281         return size;
282 }
283
284 static DEVICE_ATTR(MHD_file, S_IRUGO , MHD_check_read, MHD_check_write);
285
286
287 struct i2c_client* get_sii9234_client(u8 device_id)
288 {
289
290         struct i2c_client* client_ptr;
291
292         if(device_id == 0x72)
293                 client_ptr = sii9234_i2c_client;
294         else if(device_id == 0x7A)
295                 client_ptr = sii9234a_i2c_client;
296         else if(device_id == 0x92)
297                 client_ptr = sii9234b_i2c_client;
298         else if(device_id == 0xC8)
299                 client_ptr = sii9234c_i2c_client;
300         else
301                 client_ptr = NULL;
302
303         return client_ptr;
304 }
305 EXPORT_SYMBOL(get_sii9234_client);
306
307 u8 sii9234_i2c_read(struct i2c_client *client, u8 reg)
308 {
309         u8 ret;
310         
311         if(!MHL_i2c_init)
312         {
313                 SII_DEV_DBG("I2C not ready");
314                 return 0;
315         }
316         
317         i2c_smbus_write_byte(client, reg);
318         
319
320         ret = i2c_smbus_read_byte(client);
321
322         //printk(KERN_ERR "#######Read reg %x data %x\n", reg, ret);
323
324         if (ret < 0)
325         {
326                 SII_DEV_DBG("i2c read fail");
327                 return -EIO;
328         }
329         return ret;
330
331 }
332 EXPORT_SYMBOL(sii9234_i2c_read);
333
334
335 int sii9234_i2c_write(struct i2c_client *client, u8 reg, u8 data)
336 {
337         if(!MHL_i2c_init)
338         {
339                 SII_DEV_DBG("I2C not ready");
340                 return 0;
341         }
342
343         //printk(KERN_ERR "#######Write reg %x data %x\n", reg, data);
344         return i2c_smbus_write_byte_data(client, reg, data);
345 }
346 EXPORT_SYMBOL(sii9234_i2c_write);
347
348
349 void sii9234_interrupt_event_work(struct work_struct *p)
350 {
351
352         printk(KERN_ERR "[MHL]sii9234_interrupt_event_work() is called\n");
353         sii9234_interrupt_event();
354 }
355
356
357 void mhl_int_irq_handler_sched(void)
358 {
359         //printk(KERN_ERR "mhl_int_irq_handler_sched() is called\n");
360         queue_work(sii9234_wq, &sii9234_int_work);              
361 }
362
363
364 irqreturn_t mhl_int_irq_handler(int irq, void *dev_id)
365 {
366         printk(KERN_ERR "[MHL]mhl_int_irq_handler() is called\n");
367
368         if (gpio_get_value(GPIO_MHL_SEL))       
369                 mhl_int_irq_handler_sched();
370
371         return IRQ_HANDLED;
372 }
373
374  
375 irqreturn_t mhl_wake_up_irq_handler(int irq, void *dev_id)
376 {
377
378         printk(KERN_ERR "mhl_wake_up_irq_handler() is called\n");
379
380         if (gpio_get_value(GPIO_MHL_SEL))       
381                 mhl_int_irq_handler_sched();
382         
383         return IRQ_HANDLED;
384 }
385
386 static int sii9234_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
387 {
388         /* int retval; */
389
390         struct sii9234_state *state;
391
392         struct class *mhl_class;
393         struct device *mhl_dev;
394
395         state = kzalloc(sizeof(struct sii9234_state), GFP_KERNEL);
396         if (state == NULL) {            
397                 printk(KERN_ERR "failed to allocate memory \n");
398                 return -ENOMEM;
399         }
400         
401         state->client = client;
402         i2c_set_clientdata(client, state);
403
404
405         
406         /* rest of the initialisation goes here. */
407         
408         printk(KERN_ERR "SII9234 attach success!!!\n");
409
410         sii9234_i2c_client = client;
411
412         MHL_i2c_init = 1;
413
414         mhl_class = class_create(THIS_MODULE, "mhl");
415         if (IS_ERR(mhl_class))
416         {
417                 pr_err("Failed to create class(mhl)!\n");
418         }
419
420         mhl_dev = device_create(mhl_class, NULL, 0, NULL, "mhl_dev");
421         if (IS_ERR(mhl_dev))
422         {
423                 pr_err("Failed to create device(mhl_dev)!\n");
424         }
425
426         if (device_create_file(mhl_dev, &dev_attr_MHD_file) < 0)
427                 printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_MHD_file.attr.name);
428
429         return 0;
430
431 }
432
433
434
435 static int __devexit sii9234_remove(struct i2c_client *client)
436 {
437         struct sii9234_state *state = i2c_get_clientdata(client);
438         kfree(state);
439
440         return 0;
441 }
442
443 static int sii9234a_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
444 {
445         struct sii9234_state *state;
446
447         state = kzalloc(sizeof(struct sii9234_state), GFP_KERNEL);
448         if (state == NULL) {            
449                 printk(KERN_ERR "failed to allocate memory \n");
450                 return -ENOMEM;
451         }
452         
453         state->client = client;
454         i2c_set_clientdata(client, state);
455         
456         /* rest of the initialisation goes here. */
457         
458         printk(KERN_ERR "SII9234A attach success!!!\n");
459
460         sii9234a_i2c_client = client;
461
462         return 0;
463
464 }
465
466
467
468 static int __devexit sii9234a_remove(struct i2c_client *client)
469 {
470         struct sii9234_state *state = i2c_get_clientdata(client);
471         kfree(state);
472         return 0;
473 }
474
475 static int sii9234b_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
476 {
477         struct sii9234_state *state;
478
479         state = kzalloc(sizeof(struct sii9234_state), GFP_KERNEL);
480         if (state == NULL) {            
481                 printk(KERN_ERR "failed to allocate memory \n");
482                 return -ENOMEM;
483         }
484         
485         state->client = client;
486         i2c_set_clientdata(client, state);
487         
488         /* rest of the initialisation goes here. */
489         
490         printk(KERN_ERR "SII9234B attach success!!!\n");
491
492         sii9234b_i2c_client = client;
493
494         
495         return 0;
496
497 }
498
499
500
501 static int __devexit sii9234b_remove(struct i2c_client *client)
502 {
503         struct sii9234_state *state = i2c_get_clientdata(client);
504         kfree(state);
505         return 0;
506 }
507
508
509 static int sii9234c_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
510 {
511         struct sii9234_state *state;
512         int ret;
513
514         state = kzalloc(sizeof(struct sii9234_state), GFP_KERNEL);
515         if (state == NULL) {            
516                 printk(KERN_ERR "failed to allocate memory \n");
517                 return -ENOMEM;
518         }
519         
520         state->client = client;
521         i2c_set_clientdata(client, state);
522         
523         /* rest of the initialisation goes here. */
524         
525         printk(KERN_ERR "SII9234C attach success!!!\n");
526
527         sii9234c_i2c_client = client;
528
529         msleep(100);    
530
531         sii9234_wq = create_singlethread_workqueue("sii9234_wq");
532         INIT_WORK(&sii9234_int_work, sii9234_interrupt_event_work);
533
534         ret = request_threaded_irq(MHL_INT_IRQ, NULL, mhl_int_irq_handler,
535                                 IRQF_SHARED , "mhl_int", (void *) state); 
536         if (ret) {
537                 printk(KERN_ERR "unable to request irq mhl_int"
538                                         " err:: %d\n", ret);
539                 return ret;
540         }               
541         printk(KERN_ERR "MHL int reques successful %d\n", ret);
542         
543         ret = request_threaded_irq(MHL_WAKEUP_IRQ, NULL,
544                 mhl_wake_up_irq_handler, IRQF_SHARED,
545                 "mhl_wake_up", (void *) state);
546         if (ret) {
547                 printk(KERN_ERR "unable to request irq mhl_wake_up"
548                                         " err:: %d\n", ret);
549                 return ret;
550         }               
551         
552         return 0;
553
554 }
555
556
557
558 static int __devexit sii9234c_remove(struct i2c_client *client)
559 {
560         struct sii9234_state *state = i2c_get_clientdata(client);
561         kfree(state);
562         return 0;
563 }
564
565 struct i2c_driver sii9234_i2c_driver = {
566         .driver = {
567                 .owner  = THIS_MODULE,
568                 .name   = "SII9234",
569         },
570         .id_table       = sii9234_id,
571         .probe  = sii9234_i2c_probe,
572         .remove = __devexit_p(sii9234_remove),
573         .command = NULL,
574 };
575
576 struct i2c_driver sii9234a_i2c_driver = {
577         .driver = {
578                 .owner  = THIS_MODULE,
579                 .name   = "SII9234A",
580         },
581         .id_table       = sii9234a_id,
582         .probe  = sii9234a_i2c_probe,
583         .remove = __devexit_p(sii9234a_remove),
584         .command = NULL,
585 };
586
587 struct i2c_driver sii9234b_i2c_driver = {
588         .driver = {
589                 .owner  = THIS_MODULE,
590                 .name   = "SII9234B",
591         },
592         .id_table       = sii9234b_id,
593         .probe  = sii9234b_i2c_probe,
594         .remove = __devexit_p(sii9234b_remove),
595         .command = NULL,
596 };
597
598 struct i2c_driver sii9234c_i2c_driver = {
599         .driver = {
600                 .owner  = THIS_MODULE,
601                 .name   = "SII9234C",
602         },
603         .id_table       = sii9234c_id,
604         .probe  = sii9234c_i2c_probe,
605         .remove = __devexit_p(sii9234c_remove),
606         .command = NULL,
607 };
608
609
610 extern struct device * fimc_get_active_device(void);
611
612
613 void sii9234_cfg_power(bool on)
614 {
615
616         if(on)
617         {
618 //              s3c_gpio_cfgpin(GPIO_HDMI_EN,S3C_GPIO_OUTPUT);  //HDMI_EN
619 #ifdef CONFIG_TARGET_LOCALE_KOR
620                 gpio_set_value(GPIO_HDMI_EN,GPIO_LEVEL_HIGH);
621 #else
622                 gpio_set_value(GPIO_HDMI_EN,GPIO_LEVEL_HIGH);
623 #endif
624                 
625                 s3c_gpio_cfgpin(GPIO_MHL_RST,S3C_GPIO_OUTPUT);  //MHL_RST
626                 s3c_gpio_setpull(GPIO_MHL_RST, S3C_GPIO_PULL_NONE);
627         
628
629                 s3c_gpio_setpull(GPIO_AP_SCL_18V, S3C_GPIO_PULL_DOWN);
630                 gpio_set_value(GPIO_MHL_RST, GPIO_LEVEL_LOW);
631                 msleep(10);
632                 gpio_set_value(GPIO_MHL_RST, GPIO_LEVEL_HIGH);
633                 s3c_gpio_setpull(GPIO_AP_SCL_18V, S3C_GPIO_PULL_NONE);
634
635                 sii9234_unmaks_interrupt();
636         }
637         else
638         {
639                 gpio_set_value(GPIO_MHL_RST, GPIO_LEVEL_LOW);
640                 msleep(10);
641                 gpio_set_value(GPIO_MHL_RST, GPIO_LEVEL_HIGH);
642 #ifdef CONFIG_TARGET_LOCALE_KOR
643                 gpio_set_value(GPIO_HDMI_EN,GPIO_LEVEL_HIGH);
644 #else
645                 gpio_set_value(GPIO_HDMI_EN,GPIO_LEVEL_LOW);
646 #endif
647                 gpio_set_value(GPIO_MHL_RST, GPIO_LEVEL_LOW);
648         }
649         printk(KERN_ERR "[MHL]%s : %d \n",__func__,on);
650
651 out:
652         return;
653 }
654
655
656 static void sii9234_cfg_gpio()
657 {
658         s3c_gpio_cfgpin(GPIO_AP_SDA_18V, S3C_GPIO_SFN(0x0));    //AP_MHL_SDA
659         s3c_gpio_setpull(GPIO_AP_SDA_18V, S3C_GPIO_PULL_NONE);
660
661         s3c_gpio_cfgpin(GPIO_AP_SCL_18V,S3C_GPIO_SFN(0x1));     //AP_MHL_SCL
662         s3c_gpio_setpull(GPIO_AP_SCL_18V, S3C_GPIO_PULL_NONE);
663
664         s3c_gpio_cfgpin(GPIO_MHL_WAKE_UP,S3C_GPIO_INPUT);//GPH1(6) XEINT 14
665         set_irq_type(MHL_WAKEUP_IRQ, IRQ_TYPE_EDGE_RISING);
666         s3c_gpio_setpull(GPIO_MHL_WAKE_UP, S3C_GPIO_PULL_DOWN);
667
668         s3c_gpio_setpull(GPIO_MHL_INT, S3C_GPIO_PULL_DOWN);
669         set_irq_type(MHL_INT_IRQ, IRQ_TYPE_EDGE_RISING);
670         s3c_gpio_cfgpin(GPIO_MHL_INT, GPIO_MHL_INT_AF); 
671
672 #ifdef CONFIG_TARGET_LOCALE_KOR
673         s3c_gpio_cfgpin(GPIO_HDMI_EN,S3C_GPIO_OUTPUT);  //HDMI_EN
674         gpio_set_value(GPIO_HDMI_EN,GPIO_LEVEL_LOW);
675         s3c_gpio_setpull(GPIO_HDMI_EN, S3C_GPIO_PULL_NONE);
676 #else
677         s3c_gpio_cfgpin(GPIO_HDMI_EN,S3C_GPIO_OUTPUT);  //HDMI_EN
678         gpio_set_value(GPIO_HDMI_EN,GPIO_LEVEL_LOW);
679         s3c_gpio_setpull(GPIO_HDMI_EN, S3C_GPIO_PULL_NONE);
680 #endif
681
682         s3c_gpio_cfgpin(GPIO_MHL_RST,S3C_GPIO_OUTPUT);
683         s3c_gpio_setpull(GPIO_MHL_RST, S3C_GPIO_PULL_NONE);
684         gpio_set_value(GPIO_MHL_RST, GPIO_LEVEL_LOW);
685
686         s3c_gpio_cfgpin(GPIO_MHL_SEL,S3C_GPIO_OUTPUT);
687         s3c_gpio_setpull(GPIO_MHL_SEL, S3C_GPIO_PULL_NONE);
688         gpio_set_value(GPIO_MHL_SEL, GPIO_LEVEL_LOW);
689
690 }
691
692 static int mhl_open(struct inode *ip, struct file *fp)
693 {
694         printk(KERN_ERR "[%s] \n",__func__);
695         return 0;
696
697 }
698
699 static int mhl_release(struct inode *ip, struct file *fp)
700 {
701         
702         printk(KERN_ERR "[%s] \n",__func__);
703         return 0;
704 }
705
706
707 static int mhl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
708 {
709         printk(KERN_ERR "[%s] \n",__func__);
710
711 #if 0
712         byte data;
713
714         switch(cmd)
715         {
716                 case MHL_READ_RCP_DATA:
717                         data = GetCbusRcpData();
718                         ResetCbusRcpData();
719                         put_user(data,(byte *)arg);
720                         printk(KERN_ERR "MHL_READ_RCP_DATA read");
721                         break;
722                 
723                 default:
724                 break;
725         }
726 #endif          
727         return 0;
728 }
729
730 static struct file_operations mhl_fops = {
731         .owner  = THIS_MODULE,
732         .open   = mhl_open,
733         .release = mhl_release,
734 };
735                  
736 static struct miscdevice mhl_device = {
737     .minor  = MISC_DYNAMIC_MINOR,
738     .name   = "mhl",
739     .fops   = &mhl_fops,
740 };
741
742 static int __init sii9234_module_init(void)
743 {
744         int ret;
745
746         sii9234_cfg_gpio();
747
748         /* sii9234_cfg_power(1);        //Turn On power to sii9234 
749         */
750
751 #ifdef MHL_SWITCH_TEST
752         sec_mhl = class_create(THIS_MODULE, "sec_mhl");
753         if (IS_ERR(sec_mhl))
754                 printk(KERN_ERR "[MHL] Failed to create class (sec_mhl)\n");
755
756         mhl_switch = device_create(sec_mhl, NULL, 0, NULL, "switch");
757         if (IS_ERR(mhl_switch))
758                 printk(KERN_ERR "[MHL] Failed to create device (mhl_switch)\n");
759         if (device_create_file(mhl_switch, &dev_attr_mhl_sel) < 0)
760                 printk(KERN_ERR "[MHL] Failed to create file (mhl_sel)");
761 #endif
762
763         ret = misc_register(&mhl_device);
764         if(ret) {
765                 pr_err(KERN_ERR "misc_register failed - mhl \n");
766         }
767
768         ret = i2c_add_driver(&sii9234_i2c_driver);
769         if (ret != 0)
770                 printk(KERN_ERR "[MHL SII9234] can't add i2c driver\n");        
771         else
772                 printk(KERN_ERR "[MHL SII9234] add i2c driver\n");
773         ret = i2c_add_driver(&sii9234a_i2c_driver);
774         if (ret != 0)
775                 printk(KERN_ERR "[MHL SII9234A] can't add i2c driver\n");       
776         else
777                 printk(KERN_ERR "[MHL SII9234A] add i2c driver\n");
778         ret = i2c_add_driver(&sii9234b_i2c_driver);
779         if (ret != 0)
780                 printk(KERN_ERR "[MHL SII9234B] can't add i2c driver\n");       
781         else
782                 printk(KERN_ERR "[MHL SII9234B] add i2c driver\n");
783
784         ret = i2c_add_driver(&sii9234c_i2c_driver);
785         if (ret != 0)
786                 printk(KERN_ERR "[MHL SII9234C] can't add i2c driver\n");       
787         else
788                 printk(KERN_ERR "[MHL SII9234C] add i2c driver\n");
789
790         return ret;     
791 }
792 module_init(sii9234_module_init);
793 static void __exit sii9234_exit(void)
794 {
795         i2c_del_driver(&sii9234_i2c_driver);
796         i2c_del_driver(&sii9234a_i2c_driver);
797         i2c_del_driver(&sii9234b_i2c_driver);   
798         i2c_del_driver(&sii9234c_i2c_driver);
799         
800 };
801 module_exit(sii9234_exit);
802
803 MODULE_DESCRIPTION("Sii9234 MHL driver");
804 MODULE_AUTHOR("Aakash Manik");
805 MODULE_LICENSE("GPL");