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>
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>
16 static struct of_device_id five_v_en_of_match[] = {
17 { .compatible = "5v_en" },
21 MODULE_DEVICE_TABLE(of, five_v_en_of_match);
24 static int five_v_en_probe(struct platform_device *pdev)
26 struct device_node *node = pdev->dev.of_node;
27 enum of_gpio_flags flags;
32 //printk("func: %s\n", __func__);
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);
43 ret = devm_gpio_request(&pdev->dev, gpio, "otg_5v_gpio");
46 "failed to request GPIO%d for otg_drv\n",
50 gpio_direction_output(gpio, en_value);
52 //printk("func: %s\n", __func__);
56 static int five_v_en_remove(struct platform_device *pdev)
58 //printk("func: %s\n", __func__);
62 #ifdef CONFIG_PM_SLEEP
63 static int five_v_en_suspend(struct device *dev)
65 //printk("func: %s\n", __func__);
69 static int five_v_en_resume(struct device *dev)
71 //printk("func: %s\n", __func__);
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,
85 static struct platform_driver five_v_en_driver = {
89 .pm = &five_v_en_pm_ops,
90 .of_match_table = of_match_ptr(five_v_en_of_match),
92 .probe = five_v_en_probe,
93 .remove = five_v_en_remove,
96 module_platform_driver(five_v_en_driver);
98 MODULE_DESCRIPTION("5v power for otg and hdmi Driver");
99 MODULE_LICENSE("GPL");
100 MODULE_ALIAS("platform:five_v_en");