hc
2023-03-15 f8c23d1415aad662de5acfa33671b5d14d2c1300
kernel/drivers/misc/nkio/nk_io_core.c
....@@ -42,29 +42,6 @@
4242 //static struct class *nk_class;
4343
4444
45
-void MODULE_SET(int i)
46
-{
47
- if(i==11){
48
- gpio_direction_output(NKpdata_info->en_4g_gpio, 1);
49
- }else{
50
- gpio_direction_output(NKpdata_info->en_4g_gpio, 0);
51
- }
52
-}
53
-
54
-EXPORT_SYMBOL_GPL(MODULE_SET);
55
-
56
-
57
-void LED_SET(int i)
58
-{
59
- if(i==11){
60
- gpio_direction_output(NKpdata_info->led_gpio, 1);
61
- }else{
62
- gpio_direction_output(NKpdata_info->led_gpio, 0);
63
- }
64
-}
65
-
66
-EXPORT_SYMBOL_GPL(LED_SET);
67
-
6845
6946 void Audio_SET(int i);
7047
....@@ -84,11 +61,8 @@
8461 {
8562 struct device_node *node = pdev->dev.of_node;
8663 struct nk_io_pdata *pdata;
87
- int gpio0, gpio1, gpio2, gpio3, reset_pin, ch342_reset;
8864 int ret;
89
- int lvds_index;
90
- int i=0;
91
- static int lvds_gpio[4] ;
65
+
9266
9367 enum of_gpio_flags flags;
9468
....@@ -120,11 +94,11 @@
12094 goto err;
12195 }
12296 }
123
-
97
+#if 0
12498 //vcc3_io_en_gpio
12599 ret = of_get_named_gpio_flags(node, "vcc3_io_en_gpio", 0, &flags);
126100 if (ret < 0) {
127
- printk("%s() Can not read property tp_enable\n", __FUNCTION__);
101
+ printk("%s() Can not read property vcc3_io_en_gpio\n", __FUNCTION__);
128102 goto err;
129103 } else {
130104 pdata->vcc3_io_en_gpio = ret;
....@@ -140,7 +114,7 @@
140114 goto err;
141115 }
142116 }
143
-
117
+#endif
144118 //vcc_12v_io
145119 ret = of_get_named_gpio_flags(node, "vcc_12v_io", 0, &flags);
146120 if (ret < 0) {
....@@ -161,49 +135,6 @@
161135 }
162136 }
163137
164
-
165
-
166
- //hub_host2_5v_gpio
167
- ret = of_get_named_gpio_flags(node, "hub_host2_5v_gpio", 0, &flags);
168
- if (ret < 0) {
169
- printk("%s() Can not read property hub_host2_5v_gpio\n", __FUNCTION__);
170
- goto err;
171
- } else {
172
- pdata->hub_host2_5v_gpio = ret;
173
- gpio_free(ret);
174
- ret = devm_gpio_request(&pdev->dev, pdata->hub_host2_5v_gpio, "hub_host2_5v_gpio");
175
- if (ret < 0){
176
- printk("%s() devm_gpio_request hub_host2_5v_gpio request ERROR\n", __FUNCTION__);
177
- goto err;
178
- }
179
-
180
- ret = gpio_direction_output(pdata->hub_host2_5v_gpio,1);
181
- if(ret < 0){
182
- printk("%s() gpio_direction_input hub_host2_5v_gpio set ERROR\n", __FUNCTION__);
183
- goto err;
184
- }
185
- }
186
-
187
- //usb_en_oc_gpio
188
- ret = of_get_named_gpio_flags(node, "usb_en_oc_gpio", 0, &flags);
189
- if (ret < 0) {
190
- printk("%s() Can not read property usb_en_oc_gpio\n", __FUNCTION__);
191
- goto err;
192
- } else {
193
- pdata->usb_en_oc_gpio = ret;
194
- gpio_free(ret);
195
- ret = devm_gpio_request(&pdev->dev, pdata->usb_en_oc_gpio, "usb_en_oc_gpio");
196
- if (ret < 0){
197
- printk("%s() devm_gpio_request usb_en_oc_gpio request ERROR\n", __FUNCTION__);
198
- goto err;
199
- }
200
-
201
- ret = gpio_direction_output(pdata->usb_en_oc_gpio,1);
202
- if(ret < 0){
203
- printk("%s() gpio_direction_input usb_en_oc_gpio set ERROR\n", __FUNCTION__);
204
- goto err;
205
- }
206
- }
207138
208139 //hub_host2_5V_rest_gpio
209140 ret = of_get_named_gpio_flags(node, "hub_host2_5V_rest_gpio", 0, &flags);
....@@ -307,10 +238,17 @@
307238 if(ret < 0){
308239 printk("%s() devm_gpio_request reset_4g_gpio request ERROR\n", __FUNCTION__);
309240 }
310
- ret = gpio_direction_output(pdata->reset_4g_gpio,0);
241
+ ret = gpio_direction_output(pdata->reset_4g_gpio,1);
311242 if(ret < 0){
312243 printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);
244
+ goto err;
313245 }
246
+ msleep(800);
247
+ ret = gpio_direction_output(pdata->reset_4g_gpio,0);
248
+ if(ret < 0){
249
+ printk("%s() gpio_direction_input reset_4g_gpio set ERROR\n", __FUNCTION__);
250
+
251
+ }
314252 }
315253
316254 //en_4g_gpio
....@@ -326,11 +264,79 @@
326264 }
327265 ret = gpio_direction_output(pdata->en_4g_gpio,1);
328266 if(ret < 0){
329
- printk("%s() gpio_direction_input en_4g_gpio set ERROR\n", __FUNCTION__);
267
+ printk("%s() gpio_direction_output en_4g_gpio set ERROR\n", __FUNCTION__);
330268 }
331269 }
332270
271
+ //hp_en_gpio
272
+ ret = of_get_named_gpio_flags(node, "hp_en_gpio", 0, &flags);
273
+ if (ret < 0) {
274
+ printk("%s() Can not read property hp_en_gpio\n", __FUNCTION__);
275
+ } else {
276
+ pdata->hp_en_gpio = ret;
333277
278
+ ret = devm_gpio_request(&pdev->dev, pdata->hp_en_gpio, "hp_en_gpio");
279
+ if(ret < 0){
280
+ printk("%s() devm_gpio_request hp_en_gpio request ERROR\n", __FUNCTION__);
281
+ }
282
+ ret = gpio_direction_output(pdata->hp_en_gpio,1);
283
+ if(ret < 0){
284
+ printk("%s() gpio_direction_output hp_en_gpio set ERROR\n", __FUNCTION__);
285
+ }
286
+ }
287
+#if 0
288
+ //pcie_power_en_gpio
289
+ ret = of_get_named_gpio_flags(node, "pcie_power_en_gpio", 0, &flags);
290
+ if (ret < 0) {
291
+ printk("%s() Can not read property pcie_power_en_gpio\n", __FUNCTION__);
292
+ } else {
293
+ pdata->pcie_power_en_gpio = ret;
294
+
295
+ ret = devm_gpio_request(&pdev->dev, pdata->pcie_power_en_gpio, "pcie_power_en_gpio");
296
+ if(ret < 0){
297
+ printk("%s() devm_gpio_request pcie_power_en_gpio request ERROR\n", __FUNCTION__);
298
+ }
299
+ ret = gpio_direction_output(pdata->pcie_power_en_gpio,1);
300
+ if(ret < 0){
301
+ printk("%s() gpio_direction_output pcie_power_en_gpio set ERROR\n", __FUNCTION__);
302
+ }
303
+ }
304
+#endif
305
+ //wifi_power_en_gpio
306
+ ret = of_get_named_gpio_flags(node, "wifi_power_en_gpio", 0, &flags);
307
+ if (ret < 0) {
308
+ printk("%s() Can not read property wifi_power_en_gpio\n", __FUNCTION__);
309
+ } else {
310
+ pdata->wifi_power_en_gpio = ret;
311
+
312
+ ret = devm_gpio_request(&pdev->dev, pdata->wifi_power_en_gpio, "wifi_power_en_gpio");
313
+ if(ret < 0){
314
+ printk("%s() devm_gpio_request wifi_power_en_gpio request ERROR\n", __FUNCTION__);
315
+ }
316
+ ret = gpio_direction_output(pdata->wifi_power_en_gpio,1);
317
+ if(ret < 0){
318
+ printk("%s() gpio_direction_output wifi_power_en_gpio set ERROR\n", __FUNCTION__);
319
+ }
320
+ }
321
+
322
+/*
323
+ //spk_out_gpio
324
+ ret = of_get_named_gpio_flags(node, "spk_out_gpio", 0, &flags);
325
+ if (ret < 0) {
326
+ printk("%s() Can not read property spk_out_gpio\n", __FUNCTION__);
327
+ } else {
328
+ pdata->spk_out_gpio = ret;
329
+
330
+ ret = devm_gpio_request(&pdev->dev, pdata->spk_out_gpio, "spk_out_gpio");
331
+ if(ret < 0){
332
+ printk("%s() devm_gpio_request spk_out_gpio request ERROR\n", __FUNCTION__);
333
+ }
334
+ ret = gpio_direction_output(pdata->spk_out_gpio,0);
335
+ if(ret < 0){
336
+ printk("%s() gpio_direction_output spk_out_gpio set ERROR\n", __FUNCTION__);
337
+ }
338
+ }
339
+*/
334340 //air_mode_4g_gpio
335341 ret = of_get_named_gpio_flags(node, "air_mode_4g_gpio", 0, &flags);
336342 if (ret < 0) {
....@@ -386,24 +392,42 @@
386392 }
387393 }
388394
389
- //ch342_enable-gpio;
390
- ret = of_get_named_gpio_flags(node, "ch342_power", 0, &flags);
395
+ //lcd_bk_en_gpio;
396
+ ret = of_get_named_gpio_flags(node, "lcd_bk_en_gpio", 0, &flags);
391397 if (ret < 0) {
392
- printk("%s() Can not read property ch342_gpio\n", __FUNCTION__);
398
+ printk("%s() Can not read property lcd_bk_en_gpio\n", __FUNCTION__);
393399 } else {
394
- pdata->ch342_power = ret;
400
+ pdata->lcd_bk_en_gpio = ret;
395401
396
- ret = devm_gpio_request(&pdev->dev, pdata->ch342_power, "ch342_power");
402
+ ret = devm_gpio_request(&pdev->dev, pdata->lcd_bk_en_gpio, "lcd_bk_en_gpio");
397403 if(ret < 0){
398
- printk("%s() devm_gpio_request ch342_power request ERROR\n", __FUNCTION__);
404
+ printk("%s() devm_gpio_request lcd_bk_en_gpio request ERROR\n", __FUNCTION__);
399405 }
400406
401
- ret = gpio_direction_output(pdata->ch342_power,1);
407
+ ret = gpio_direction_output(pdata->lcd_bk_en_gpio,1);
402408 if(ret < 0){
403
- printk("%s() gpio_direction_input ch342_power set ERROR\n", __FUNCTION__);
409
+ printk("%s() gpio_direction_output lcd_bk_en_gpio set ERROR\n", __FUNCTION__);
404410 }
405411 }
406
-*/
412
+
413
+ //lcd_pwblk_gpio;
414
+ ret = of_get_named_gpio_flags(node, "lcd_pwblk_gpio", 0, &flags);
415
+ if (ret < 0) {
416
+ printk("%s() Can not read property lcd_pwblk_gpio\n", __FUNCTION__);
417
+ } else {
418
+ pdata->lcd_pwblk_gpio = ret;
419
+
420
+ ret = devm_gpio_request(&pdev->dev, pdata->lcd_pwblk_gpio, "lcd_pwblk_gpio");
421
+ if(ret < 0){
422
+ printk("%s() devm_gpio_request lcd_pwblk_gpio request ERROR\n", __FUNCTION__);
423
+ }
424
+
425
+ ret = gpio_direction_output(pdata->lcd_pwblk_gpio,1);
426
+ if(ret < 0){
427
+ printk("%s() gpio_direction_output lcd_pwblk_gpio set ERROR\n", __FUNCTION__);
428
+ }
429
+ }
430
+
407431
408432 //edp_set_pixel-s
409433 ret = of_get_named_gpio_flags(node, "edp_reset", 0, &flags);
....@@ -507,6 +531,12 @@
507531 gpio_direction_output(gpio2, lvds_gpio[2]);
508532 gpio_direction_output(gpio3, lvds_gpio[3]);
509533
534
+
535
+ gpio_direction_output(reset_pin, 0);
536
+ usleep_range(80000, 100000);
537
+ gpio_direction_output(reset_pin, 1);
538
+ usleep_range(80000, 100000);
539
+*/
510540 printk(" #######nk_io_control_probe end####### \n");
511541 return 0;
512542
....@@ -551,38 +581,6 @@
551581
552582 static int nk_io_control_resume(struct platform_device *pdev)
553583 {
554
- int ret,reset_pin;
555
- printk("nk_io resume !!!!\n");
556
- ret = gpio_get_value(120);
557
-
558
-#if 0
559
- gpio_set_value(8,1);
560
- ret = gpio_get_value(8);
561
- printk("vcc12v gpio value : %d\n",ret);
562
-#endif
563
-#if 0
564
- gpio_set_value(15,1);
565
- ret = gpio_get_value(15);
566
- printk("edp_en gpio value : %d\n",ret);
567
- gpio_set_value(21,1);
568
- ret = gpio_get_value(21);
569
- printk("hub_host3_5v_gpio value : %d\n",ret);
570
-#endif
571
-#if 0
572
- usleep_range(80000, 100000);
573
- gpio_set_value(120,0);
574
-// gpio_direction_output(120, 0);
575
- usleep_range(80000, 100000);
576
- ret = gpio_get_value(120);
577
- printk("edp_reset gpio value : %d\n",ret);
578
-// gpio_direction_output(120, 1);
579
- gpio_set_value(120,1);
580
- usleep_range(80000, 100000);
581
- ret = gpio_get_value(120);
582
- printk("edp_reset gpio value : %d\n",ret);
583
-#endif
584
- //enable = 1;
585
- //LED_SET(11);
586584 return 0;
587585 }
588586