hc
2023-02-17 557c24d082b6ecb9bfe5407b77ae43fa7650a5dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
/* 
 * Copyright (C) 2014 Rockchip Corporation.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/spi/spi.h>
#include <linux/platform_device.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/debugfs.h>
#include <linux/of_gpio.h>
#include <linux/gpio.h>
#include <linux/iio/consumer.h>
#include <linux/of.h>
#include "nkio.h"
 
/* Debug */
#if 1
#define DBG(x...) printk(x)
#else
#define DBG(x...) do { } while (0)
#endif
 
struct nk_io_pdata *NKpdata_info;
u32 op0_enable,op1_enable,op2_enable,op3_enable,op4_enable,op5_enable,mic_enable;
u32 ip0_enable,ip1_enable,ip2_enable,ip3_enable,ip4_enable,ip5_enable;
u32 module_enable;
//static struct class *nk_class;
 
 
 
void Audio_SET(int i);
 
  void Audio_SET(int i)
 {
    if(i==11){
        gpio_direction_output(NKpdata_info->audio_switch_gpio, 1);
        printk("Audio_SET ENABLE------andy\n");
    }else{
        gpio_direction_output(NKpdata_info->audio_switch_gpio, 0);
        printk("Audio_SET DISABLE------andy\n");
    }
 }
  EXPORT_SYMBOL_GPL(Audio_SET);
 
static int nk_io_control_probe(struct platform_device *pdev)
{
   struct device_node *node = pdev->dev.of_node;
   struct nk_io_pdata *pdata;    
   int ret;
 
 
   enum of_gpio_flags flags;
   
   printk(" #######nk_io_control_probe####### \n");
 
   pdata = kzalloc(sizeof(struct nk_io_pdata), GFP_KERNEL);
   if (pdata == NULL) {
       printk("%s failed to allocate driver data\n",__FUNCTION__);
       return -ENOMEM;
   }
   memset(pdata,0,sizeof(struct nk_io_pdata));
   
   //vcc_5v_io
   ret = of_get_named_gpio_flags(node, "vcc_5v_io", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property vcc_5v_io\n", __FUNCTION__);
       goto err;
   } else {
       pdata->vcc_5v_io = ret;
       ret = devm_gpio_request(&pdev->dev, pdata->vcc_5v_io, "vcc_5v_io");
       if(ret < 0){
           printk("%s() devm_gpio_request vcc_5v_io request ERROR\n", __FUNCTION__);
           goto err;
       }
 
       ret = gpio_direction_output(pdata->vcc_5v_io,1); 
       if(ret < 0){
           printk("%s() gpio_direction_input vcc_5v_io set ERROR\n", __FUNCTION__);
           goto err;
       }
   }
#if 0    
   //vcc3_io_en_gpio
   ret = of_get_named_gpio_flags(node, "vcc3_io_en_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property vcc3_io_en_gpio\n", __FUNCTION__);
       goto err;
   } else {
       pdata->vcc3_io_en_gpio = ret;
       ret = devm_gpio_request(&pdev->dev, pdata->vcc3_io_en_gpio, "vcc3_io_en_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request vcc3_io_en_gpio request ERROR\n", __FUNCTION__);
           goto err;
       }
 
       ret = gpio_direction_output(pdata->vcc3_io_en_gpio,1); 
       if(ret < 0){
           printk("%s() gpio_direction_output vcc3_io_en_gpio set ERROR\n", __FUNCTION__);
           goto err;
       }
   }
#endif
        //vcc_12v_io
        ret = of_get_named_gpio_flags(node, "vcc_12v_io", 0, &flags);
        if (ret < 0) {
                printk("%s() Can not read property vcc_12v_io\n", __FUNCTION__);
                goto err;
        } else {
                pdata->vcc_12v_io = ret;
                ret = devm_gpio_request(&pdev->dev, pdata->vcc_12v_io, "vcc_12v_io");
                if(ret < 0){
                        printk("%s() devm_gpio_request vcc_12v_io request ERROR\n", __FUNCTION__);
                        goto err;
                }
 
                ret = gpio_direction_output(pdata->vcc_12v_io,1);
                if(ret < 0){
                        printk("%s() gpio_direction_input vcc_12v_io set ERROR\n", __FUNCTION__);
                        goto err;
                }
        }
 
 
   //hub_host2_5V_rest_gpio
   ret = of_get_named_gpio_flags(node, "hub_host2_5V_rest_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property hub_host2_5V_rest_gpio\n", __FUNCTION__);
       goto err;
   } else {
       pdata->hub_host2_5V_rest_gpio = ret;
       ret = devm_gpio_request(&pdev->dev, pdata->hub_host2_5V_rest_gpio, "hub_host2_5V_rest_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request hub_host2_5V_rest_gpio request ERROR\n", __FUNCTION__);
           goto err;
       }
 
       ret = gpio_direction_output(pdata->hub_host2_5V_rest_gpio,0); 
       if(ret < 0){
           printk("%s() gpio_direction_input hub_host2_5V_rest_gpio set ERROR\n", __FUNCTION__);
           goto err;
       }
       msleep(800);
       ret = gpio_direction_output(pdata->hub_host2_5V_rest_gpio,1); 
       if(ret < 0){
           printk("%s() gpio_direction_input hub_host2_5V_rest_gpio set ERROR\n", __FUNCTION__);
           goto err;
       }
   }
 
   //hub_host3_5v_gpio
   ret = of_get_named_gpio_flags(node, "hub_host3_5v_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property hub_host3_5v_gpio\n", __FUNCTION__);
       goto err;
   } else {
       pdata->hub_host3_5v_gpio = ret;
       gpio_free(ret);
       ret = devm_gpio_request(&pdev->dev, pdata->hub_host3_5v_gpio, "hub_host3_5v_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request hub_host3_5v_gpio request ERROR\n", __FUNCTION__);
           goto err;
       }
 
       ret = gpio_direction_output(pdata->hub_host3_5v_gpio,1); 
       if(ret < 0){
           printk("%s() gpio_direction_input hub_host3_5v_gpio set ERROR\n", __FUNCTION__);
           goto err;
       }
   }
#if 0
   //hub_host3_5V_rest_gpio
   ret = of_get_named_gpio_flags(node, "hub_host3_5V_rest_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property hub_host3_5V_rest_gpio\n", __FUNCTION__);
       goto err;
   } else {
       pdata->hub_host3_5V_rest_gpio = ret;
       ret = devm_gpio_request(&pdev->dev, pdata->hub_host3_5V_rest_gpio, "hub_host3_5V_rest_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request hub_host3_5V_rest_gpio request ERROR\n", __FUNCTION__);
           goto err;
       }
 
       ret = gpio_direction_output(pdata->hub_host3_5V_rest_gpio,0); 
       if(ret < 0){
           printk("%s() gpio_direction_input hub_host3_5V_rest_gpio set ERROR\n", __FUNCTION__);
           goto err;
       }
       msleep(800);
       ret = gpio_direction_output(pdata->hub_host3_5V_rest_gpio,1); 
       if(ret < 0){
           printk("%s() gpio_direction_input hub_host3_5V_rest_gpio set ERROR\n", __FUNCTION__);
           goto err;
       }
   }
#endif
   //wake_4g_gpio
      ret = of_get_named_gpio_flags(node, "wake_4g_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property wake_4g_gpio\n", __FUNCTION__);
      } else {
              pdata->wake_4g_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->wake_4g_gpio, "wake_4g_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request wake_4g_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->wake_4g_gpio,0);
              if(ret < 0){
                      printk("%s() gpio_direction_input wake_4g_gpio set ERROR\n", __FUNCTION__);
              }
      }
 
 
      //reset_4g_gpio
      ret = of_get_named_gpio_flags(node, "reset_4g_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property reset_4g_gpio\n", __FUNCTION__);
      } else {
              pdata->reset_4g_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->reset_4g_gpio, "reset_4g_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request reset_4g_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->reset_4g_gpio,1);
              if(ret < 0){
                      printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);
                      goto err;
              }
                  msleep(800);
               ret = gpio_direction_output(pdata->reset_4g_gpio,0); 
               if(ret < 0){
                       printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);
                   
       }
      }
 
      //en_4g_gpio
      ret = of_get_named_gpio_flags(node, "en_4g_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property en_4g_gpio\n", __FUNCTION__);
      } else {
              pdata->en_4g_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->en_4g_gpio, "en_4g_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request en_4g_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->en_4g_gpio,1);
              if(ret < 0){
                      printk("%s() gpio_direction_output en_4g_gpio set ERROR\n", __FUNCTION__);
              }
      }
 
      //hp_en_gpio
      ret = of_get_named_gpio_flags(node, "hp_en_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property hp_en_gpio\n", __FUNCTION__);
      } else {
              pdata->hp_en_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->hp_en_gpio, "hp_en_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request hp_en_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->hp_en_gpio,1);
              if(ret < 0){
                      printk("%s() gpio_direction_output hp_en_gpio set ERROR\n", __FUNCTION__);
              }
      }
#if 0        
                 //pcie_power_en_gpio
      ret = of_get_named_gpio_flags(node, "pcie_power_en_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property pcie_power_en_gpio\n", __FUNCTION__);
      } else {
              pdata->pcie_power_en_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->pcie_power_en_gpio, "pcie_power_en_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request pcie_power_en_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->pcie_power_en_gpio,1);
              if(ret < 0){
                      printk("%s() gpio_direction_output pcie_power_en_gpio set ERROR\n", __FUNCTION__);
              }
      }
#endif       
         //wifi_power_en_gpio
      ret = of_get_named_gpio_flags(node, "wifi_power_en_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property wifi_power_en_gpio\n", __FUNCTION__);
      } else {
              pdata->wifi_power_en_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->wifi_power_en_gpio, "wifi_power_en_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request wifi_power_en_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->wifi_power_en_gpio,1);
              if(ret < 0){
                      printk("%s() gpio_direction_output wifi_power_en_gpio set ERROR\n", __FUNCTION__);
              }
      }
 
 
         //spk_out_gpio
      ret = of_get_named_gpio_flags(node, "spk_out_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property spk_out_gpio\n", __FUNCTION__);
      } else {
              pdata->spk_out_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->spk_out_gpio, "spk_out_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request spk_out_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->spk_out_gpio,0);
              if(ret < 0){
                      printk("%s() gpio_direction_output spk_out_gpio set ERROR\n", __FUNCTION__);
              }
      }
      //air_mode_4g_gpio
      ret = of_get_named_gpio_flags(node, "air_mode_4g_gpio", 0, &flags);
      if (ret < 0) {
              printk("%s() Can not read property air_mode_4g_gpio\n", __FUNCTION__);
      } else {
              pdata->air_mode_4g_gpio = ret;
 
              ret = devm_gpio_request(&pdev->dev, pdata->air_mode_4g_gpio, "air_mode_4g_gpio");
              if(ret < 0){
                      printk("%s() devm_gpio_request air_mode_4g_gpio request ERROR\n", __FUNCTION__);
              }
              ret = gpio_direction_output(pdata->air_mode_4g_gpio,0);
              if(ret < 0){
                      printk("%s() gpio_direction_input air_mode_4g_gpio set ERROR\n", __FUNCTION__);
              }
      }
 
     
/*
   //edp_power_supply_gpio;
   ret = of_get_named_gpio_flags(node, "edp_power_supply_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property edp_power_supply_gpio\n", __FUNCTION__);
   } else {
       pdata->edp_power_supply_gpio = ret;
 
       ret = devm_gpio_request(&pdev->dev, pdata->edp_power_supply_gpio, "edp_power_supply_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request edp_power_supply_gpio request ERROR\n", __FUNCTION__);
       }
       
       ret = gpio_direction_output(pdata->edp_power_supply_gpio,1);
       if(ret < 0){
           printk("%s() gpio_direction_input edp_power_supply_gpio set ERROR\n", __FUNCTION__);
       }
   }
   
   //edp_enable-gpio;
   ret = of_get_named_gpio_flags(node, "edp_enable_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property edp_enable_gpio\n", __FUNCTION__);
   } else {
       pdata->edp_enable_gpio = ret;
 
       ret = devm_gpio_request(&pdev->dev, pdata->edp_enable_gpio, "edp_enable_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request edp_enable_gpio request ERROR\n", __FUNCTION__);
       }
       
       ret = gpio_direction_output(pdata->edp_enable_gpio,1);
       if(ret < 0){
           printk("%s() gpio_direction_input edp_enable_gpio set ERROR\n", __FUNCTION__);
       }
   } 
  
   //lcd_bk_en_gpio;
   ret = of_get_named_gpio_flags(node, "lcd_bk_en_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property lcd_bk_en_gpio\n", __FUNCTION__);
   } else {
       pdata->lcd_bk_en_gpio = ret;
 
       ret = devm_gpio_request(&pdev->dev, pdata->lcd_bk_en_gpio, "lcd_bk_en_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request lcd_bk_en_gpio request ERROR\n", __FUNCTION__);
       }
       
       ret = gpio_direction_output(pdata->lcd_bk_en_gpio,1);
       if(ret < 0){
           printk("%s() gpio_direction_output lcd_bk_en_gpio set ERROR\n", __FUNCTION__);
       }
   }   
   
      //lcd_pwblk_gpio;
   ret = of_get_named_gpio_flags(node, "lcd_pwblk_gpio", 0, &flags);
   if (ret < 0) {
       printk("%s() Can not read property lcd_pwblk_gpio\n", __FUNCTION__);
   } else {
       pdata->lcd_pwblk_gpio = ret;
 
       ret = devm_gpio_request(&pdev->dev, pdata->lcd_pwblk_gpio, "lcd_pwblk_gpio");
       if(ret < 0){
           printk("%s() devm_gpio_request lcd_pwblk_gpio request ERROR\n", __FUNCTION__);
       }
       
       ret = gpio_direction_output(pdata->lcd_pwblk_gpio,1);
       if(ret < 0){
           printk("%s() gpio_direction_output lcd_pwblk_gpio set ERROR\n", __FUNCTION__);
       }
   } 
 
 
        //edp_set_pixel-s
         ret = of_get_named_gpio_flags(node, "edp_reset", 0, &flags);
    if (ret < 0) {
        printk("%s() Can not read property edp_reset\n", __FUNCTION__);
        goto err;
    }
 
    reset_pin = ret;
 
// enable lvds
     ret = of_get_named_gpio_flags(node, "edp_gpio0", 0, &flags);
    if (ret < 0) {
        printk("%s() Can not read property edp_gpio0\n", __FUNCTION__);
        goto err;
    }
    gpio0 = ret;
 
 
 
    ret = of_get_named_gpio_flags(node, "edp_gpio1", 0, &flags);
    if (ret < 0) {
        printk("%s() Can not read property edp_gpio1\n", __FUNCTION__);
        goto err;
    }
 
        gpio1 = ret;
 
    ret = of_get_named_gpio_flags(node, "edp_gpio2", 0, &flags);
    if (ret < 0) {
        printk("%s() Can not read property edp_gpio2\n", __FUNCTION__);
        goto err;
    }
 
    gpio2 = ret;
 
    ret = of_get_named_gpio_flags(node, "edp_gpio3", 0, &flags);
    if (ret < 0) {
        printk("%s() Can not read property edp_gpio3\n", __FUNCTION__);
        goto err;
    }
 
    gpio3 = ret;
 
 
    ret = devm_gpio_request(&pdev->dev, reset_pin, "edp_reset");
    if(ret < 0){
        printk("%s() devm_gpio_request edp_reset request ERROR\n", __FUNCTION__);
        goto err;
    }
 
 
    ret = devm_gpio_request(&pdev->dev, gpio0, "edp_gpio0");
    if(ret < 0){
        printk("%s() devm_gpio_request edp_gpio0 request ERROR\n", __FUNCTION__);
        goto err;
    }
 
    ret = devm_gpio_request(&pdev->dev, gpio1, "edp_gpio1");
    if(ret < 0){
        printk("%s() devm_gpio_request edp_gpio1 request ERROR\n", __FUNCTION__);
        goto err;
    }
 
    ret = devm_gpio_request(&pdev->dev, gpio2, "edp_gpio2");
    if(ret < 0){
        printk("%s() devm_gpio_request edp_gpio2 request ERROR\n", __FUNCTION__);
        goto err;
    }
 
    ret = devm_gpio_request(&pdev->dev, gpio3, "edp_gpio3");
    if(ret < 0){
        printk("%s() devm_gpio_request edp_gpio3 request ERROR\n", __FUNCTION__);
        goto err;
    }
   
      ret = of_property_read_u32(node, "nodka_lvds", &lvds_index);
        if (ret < 0){
                printk("%s() Can not read property nodka_lvds\n", __FUNCTION__);
        }
 
        printk("nodka_lvds_index = %d\n",lvds_index);
 
        while ( i < 4 ){
                if ( lvds_index > 0)
                        lvds_gpio[i] = lvds_index%2;
                else
                        lvds_gpio[i] = 0;
                printk("lvds_gpio[%d]=%d\n",i,lvds_gpio[i]);
                lvds_index = lvds_index/2;
                i++;
        }
 
    gpio_direction_output(reset_pin, 0);
    usleep_range(80000, 100000);
    gpio_direction_output(reset_pin, 1);
    usleep_range(80000, 100000);
 
   gpio_direction_output(gpio0, lvds_gpio[0]);
   gpio_direction_output(gpio1, lvds_gpio[1]);
   gpio_direction_output(gpio2, lvds_gpio[2]);
   gpio_direction_output(gpio3, lvds_gpio[3]);
   
 
   gpio_direction_output(reset_pin, 0);
    usleep_range(80000, 100000);
    gpio_direction_output(reset_pin, 1);
    usleep_range(80000, 100000);
*/
   printk(" #######nk_io_control_probe end####### \n");
   return 0;
   
err:
   kfree(pdata);
   return ret;    
}    
 
 
static int nk_io_control_remove(struct platform_device *pdev)
{
   if(NKpdata_info)
       kfree(NKpdata_info);
   return 0;
}
 
static int nk_io_control_suspend(struct platform_device *pdev, pm_message_t state)
{
   int ret;
   struct nk_io_pdata *pdata;
   printk("nk_suspend  !!!!\n");
#if 0
   ret = gpio_get_value(8);
   printk("vcc12v gpio value : %d\n",ret);
        usleep_range(80000, 100000);
        gpio_set_value(8,0);
   ret = gpio_get_value(8);
   printk("vcc12v gpio value : %d\n",ret);
#endif
#if 0
   ret = gpio_get_value(21);
   printk("hub_host3_5v_gpio value : %d\n",ret);
        usleep_range(80000, 100000);
        gpio_set_value(21,0);
   ret = gpio_get_value(21);
   printk("hub_host3_5v_gpio value : %d\n",ret);
   //enable = 0;
   //LED_SET(0);
#endif
   return 0;
}
 
static int nk_io_control_resume(struct platform_device *pdev)
{
        return 0;
}
 
static const struct of_device_id nk_io_control_of_match[] = {
        { .compatible = "nk_io_control", },
        {},
};
MODULE_DEVICE_TABLE(of, nk_io_control_of_match);
 
static struct platform_driver nk_io_control_driver = {
   .probe    = nk_io_control_probe,
   .remove = nk_io_control_remove,
   .resume =     nk_io_control_resume,    
   .suspend =     nk_io_control_suspend,    
   .driver    = {
       .name    = "nk_io_control",
       .owner    = THIS_MODULE,
       .of_match_table = of_match_ptr(nk_io_control_of_match),        
   },
};
 
static int __init nk_io_control_init(void)
{
   platform_driver_register(&nk_io_control_driver);
   return 0;
}
 
static void __exit nk_io_control_exit(void)
{
   platform_driver_unregister(&nk_io_control_driver);
}
 
subsys_initcall(nk_io_control_init);
 
//late_initcall(nk_io_control_init);
MODULE_DESCRIPTION("nk io Core Driver");
MODULE_LICENSE("GPL");