From a143dc52d84a59a6654cc34026c2364e8f8b24a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=83=AD=E6=AF=85?= Date: Mon, 21 Apr 2014 09:49:06 +0800 Subject: [PATCH] p977 : add 5v_en driver --- drivers/misc/5v_en.c | 100 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 drivers/misc/5v_en.c diff --git a/drivers/misc/5v_en.c b/drivers/misc/5v_en.c new file mode 100644 index 000000000000..b8d282eeafd7 --- /dev/null +++ b/drivers/misc/5v_en.c @@ -0,0 +1,100 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static struct of_device_id five_v_en_of_match[] = { + { .compatible = "5v_en" }, + { } +}; + +MODULE_DEVICE_TABLE(of, five_v_en_of_match); + + +static int five_v_en_probe(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + enum of_gpio_flags flags; + int gpio; + int ret; + int en_value; + + printk("func: %s\n", __func__); + if (!node) + return -ENODEV; + + gpio = of_get_named_gpio_flags(node, "5ven,pin", 0, &flags); + en_value = (flags == GPIO_ACTIVE_HIGH)? 1:0; + //gpio = of_get_named_gpio(node, "gpios", 0); + if(!gpio_is_valid(gpio)){ + dev_err(&pdev->dev, "invalid 5v gpio%d\n", gpio); + } + + ret = devm_gpio_request(&pdev->dev, gpio, "otg_5v_gpio"); + if (ret) { + dev_err(&pdev->dev, + "failed to request GPIO%d for otg_drv\n", + gpio); + return -EINVAL; + } + gpio_direction_output(gpio, en_value); + + printk("func: %s\n", __func__); + return 0; +} + +static int five_v_en_remove(struct platform_device *pdev) +{ + printk("func: %s\n", __func__); + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int five_v_en_suspend(struct device *dev) +{ + printk("func: %s\n", __func__); + return 0; +} + +static int five_v_en_resume(struct device *dev) +{ + printk("func: %s\n", __func__); + return 0; +} +#endif + +static const struct dev_pm_ops five_v_en_pm_ops = { +#ifdef CONFIG_PM_SLEEP + .suspend = five_v_en_suspend, + .resume = five_v_en_resume, + .poweroff = five_v_en_suspend, + .restore = five_v_en_resume, +#endif +}; + +static struct platform_driver five_v_en_driver = { + .driver = { + .name = "five_v_en", + .owner = THIS_MODULE, + .pm = &five_v_en_pm_ops, + .of_match_table = of_match_ptr(five_v_en_of_match), + }, + .probe = five_v_en_probe, + .remove = five_v_en_remove, +}; + +module_platform_driver(five_v_en_driver); + +MODULE_DESCRIPTION("5v power for otg and hdmi Driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:five_v_en"); -- 2.34.1