usb: dwc3: add functions to set force mode
[firefly-linux-kernel-4.4.55.git] / drivers / misc / 5v_en.c
1 #include <dt-bindings/gpio/gpio.h>
2 #include <linux/gpio.h>
3 #include <linux/of_gpio.h>
4 #include <linux/module.h>
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <linux/platform_device.h>
8 #include <linux/fb.h>
9 #include <linux/backlight.h>
10 #include <linux/err.h>
11 #include <linux/pwm.h>
12 #include <linux/pwm_backlight.h>
13 #include <linux/slab.h>
14
15
16 static struct of_device_id five_v_en_of_match[] = {
17         { .compatible = "5v_en" },
18         { }
19 };
20
21 MODULE_DEVICE_TABLE(of, five_v_en_of_match);
22
23
24 static int five_v_en_probe(struct platform_device *pdev)
25 {
26         struct device_node *node = pdev->dev.of_node;
27         enum of_gpio_flags flags;
28         int gpio;
29         int ret;
30         int en_value;
31
32         //printk("func: %s\n", __func__); 
33         if (!node)
34                 return -ENODEV;
35
36         gpio = of_get_named_gpio_flags(node, "5ven,pin", 0, &flags);
37         en_value = (flags == GPIO_ACTIVE_HIGH)? 1:0;
38         //gpio =  of_get_named_gpio(node, "gpios", 0);
39         if(!gpio_is_valid(gpio)){
40                 dev_err(&pdev->dev, "invalid 5v gpio%d\n", gpio);
41         }
42
43         ret = devm_gpio_request(&pdev->dev, gpio, "otg_5v_gpio");
44         if (ret) {
45                 dev_err(&pdev->dev,
46                         "failed to request GPIO%d for otg_drv\n",
47                         gpio);
48                 return -EINVAL;
49         }
50         gpio_direction_output(gpio, en_value);
51
52         //printk("func: %s\n", __func__); 
53         return 0;
54 }
55
56 static int five_v_en_remove(struct platform_device *pdev)
57 {
58         //printk("func: %s\n", __func__); 
59         return 0;
60 }
61
62 #ifdef CONFIG_PM_SLEEP
63 static int five_v_en_suspend(struct device *dev)
64 {
65         //printk("func: %s\n", __func__); 
66         return 0;
67 }
68
69 static int five_v_en_resume(struct device *dev)
70 {
71         //printk("func: %s\n", __func__); 
72         return 0;
73 }
74 #endif
75
76 static const struct dev_pm_ops five_v_en_pm_ops = {
77 #ifdef CONFIG_PM_SLEEP
78         .suspend = five_v_en_suspend,
79         .resume = five_v_en_resume,
80         .poweroff = five_v_en_suspend,
81         .restore = five_v_en_resume,
82 #endif
83 };
84
85 static struct platform_driver five_v_en_driver = {
86         .driver         = {
87                 .name           = "five_v_en",
88                 .owner          = THIS_MODULE,
89                 .pm             = &five_v_en_pm_ops,
90                 .of_match_table = of_match_ptr(five_v_en_of_match),
91         },
92         .probe          = five_v_en_probe,
93         .remove         = five_v_en_remove,
94 };
95
96 module_platform_driver(five_v_en_driver);
97
98 MODULE_DESCRIPTION("5v power for otg and hdmi Driver");
99 MODULE_LICENSE("GPL");
100 MODULE_ALIAS("platform:five_v_en");