From: George Cherian <george.cherian-l0cyMroinI0@public.gmane.org>
To: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
rdunlap-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
pawel.moll-5wv7dgnIgG8@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] extcon: extcon-dra7xx: Add Extcon driver for DRA7xx
Date: Mon, 16 Jun 2014 11:11:45 +0530 [thread overview]
Message-ID: <539E8399.80902@ti.com> (raw)
In-Reply-To: <539E79A1.50208-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
On 6/16/2014 10:29 AM, Guenter Roeck wrote:
> On 06/15/2014 07:42 PM, George Cherian wrote:
>> This is the driver for the USB ID pin detection. This driver
>> handles only the USB ID pin changes generated by cable
>> insertion/removal.
>>
>> Signed-off-by: George Cherian <george.cherian-l0cyMroinI0@public.gmane.org>
>
> Hi George,
>
> Curious: Why can't you use extcon-gpio ?
Main reason being missing dt support.
>
> Also, I thought that Linux specific bindings would be unacceptable.
> "ti,dra7xx-extcon" looks very linux specific to me. Did the rules
> change ?
>
Then how about "ti,extcon-usbid" ?
> Thanks,
> Guenter
>
>> ---
>> .../devicetree/bindings/extcon/extcon-dra7xx.txt | 15 ++
>> drivers/extcon/Kconfig | 5 +
>> drivers/extcon/Makefile | 1 +
>> drivers/extcon/extcon-dra7xx.c | 164
>> +++++++++++++++++++++
>> 4 files changed, 185 insertions(+)
>> create mode 100644
>> Documentation/devicetree/bindings/extcon/extcon-dra7xx.txt
>> create mode 100644 drivers/extcon/extcon-dra7xx.c
>>
>> diff --git
>> a/Documentation/devicetree/bindings/extcon/extcon-dra7xx.txt
>> b/Documentation/devicetree/bindings/extcon/extcon-dra7xx.txt
>> new file mode 100644
>> index 0000000..69c3804
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/extcon/extcon-dra7xx.txt
>> @@ -0,0 +1,15 @@
>> +EXTCON FOR DRA7xx USB
>> +
>> +Required Properties:
>> + - compatible : Should be "ti,dra7xx-extcon"
>> + - gpios : specifies the gpio pin used for ID pin detection.
>> +
>> +
>> +Please refer to ../gpio/gpio.txt for details of the common GPIO
>> bindings
>> +
>> +Example:
>> +
>> + dra7xx_extcon {
>> + compatible = "ti,dra7xx-extcon";
>> + gpios = <&gpio21 1 0>;
>> + };
>> diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
>> index aebde48..1481b7f 100644
>> --- a/drivers/extcon/Kconfig
>> +++ b/drivers/extcon/Kconfig
>> @@ -70,4 +70,9 @@ config EXTCON_PALMAS
>> Say Y here to enable support for USB peripheral and USB host
>> detection by palmas usb.
>>
>> +config EXTCON_DRA7XX
>> + tristate "DRA7xx USB ID detection EXTCON support"
>> + help
>> + Say Y here to enable support for USB ID detection for DRA7xx.
>> +
>> endif # MULTISTATE_SWITCH
>> diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
>> index bf7861e..b5f7cac 100644
>> --- a/drivers/extcon/Makefile
>> +++ b/drivers/extcon/Makefile
>> @@ -10,3 +10,4 @@ obj-$(CONFIG_EXTCON_MAX77693) += extcon-max77693.o
>> obj-$(CONFIG_EXTCON_MAX8997) += extcon-max8997.o
>> obj-$(CONFIG_EXTCON_ARIZONA) += extcon-arizona.o
>> obj-$(CONFIG_EXTCON_PALMAS) += extcon-palmas.o
>> +obj-$(CONFIG_EXTCON_DRA7XX) += extcon-dra7xx.o
>> diff --git a/drivers/extcon/extcon-dra7xx.c
>> b/drivers/extcon/extcon-dra7xx.c
>> new file mode 100644
>> index 0000000..2f80509
>> --- /dev/null
>> +++ b/drivers/extcon/extcon-dra7xx.c
>> @@ -0,0 +1,164 @@
>> +/*
>> + * DRA7xx-Extcon USB ID pin detection driver
>> + *
>> + * Copyright (C) 2014 Texas Instruments Incorporated -
>> http://www.ti.com
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * Author: George Cherian <george.cherian-l0cyMroinI0@public.gmane.org>
>> + *
>> + * 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/err.h>
>> +#include <linux/extcon.h>
>> +#include <linux/gpio.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_gpio.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/platform_device.h>
>> +
>> +struct dra7xx_extcon {
>> + struct device *dev;
>> + struct extcon_dev edev;
>> +
>> + int id_gpio;
>> + int id_irq;
>> +};
>> +
>> +static const char *dra7xx_extcon_cable[] = {
>> + [1] = "USB-HOST",
>> + NULL,
>> +};
>> +
>> +#define ID_GND 0
>> +
>> +static irqreturn_t id_irq_handler(int irq, void *data)
>> +{
>> + struct dra7xx_extcon *dra7xx_extcon = (struct dra7xx_extcon *)data;
>> + int id_current;
>> +
>> + id_current = gpio_get_value_cansleep(dra7xx_extcon->id_gpio);
>> + if (id_current == ID_GND)
>> + extcon_set_cable_state(&dra7xx_extcon->edev, "USB-HOST", true);
>> + else
>> + extcon_set_cable_state(&dra7xx_extcon->edev, "USB-HOST",
>> false);
>> +
>> + return IRQ_HANDLED;
>> +}
>> +
>> +static void dra7xx_extcon_set_initial_state(struct dra7xx_extcon
>> *dra7xx_extcon)
>> +{
>> + int id_current;
>> +
>> + id_current = gpio_get_value_cansleep(dra7xx_extcon->id_gpio);
>> + if (id_current == ID_GND)
>> + extcon_set_cable_state(&dra7xx_extcon->edev,
>> + "USB-HOST", true);
>> + else
>> + extcon_set_cable_state(&dra7xx_extcon->edev,
>> + "USB-HOST", false);
>> +}
>> +
>> +static int dra7xx_extcon_request_irq(struct dra7xx_extcon
>> *dra7xx_extcon)
>> +{
>> + int ret;
>> +
>> + ret = devm_request_threaded_irq(dra7xx_extcon->dev,
>> + dra7xx_extcon->id_irq,
>> + NULL, id_irq_handler,
>> + IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
>> + dev_name(dra7xx_extcon->dev),
>> + (void *)dra7xx_extcon);
>> + if (ret) {
>> + dev_err(dra7xx_extcon->dev, "failed to request id irq #%d\n",
>> + dra7xx_extcon->id_irq);
>> + return ret;
>> + }
>> + return ret;
>> +}
>> +
>> +static int dra7xx_extcon_probe(struct platform_device *pdev)
>> +{
>> + struct device_node *node = pdev->dev.of_node;
>> + struct dra7xx_extcon *dra7xx_extcon;
>> + int ret, gpio;
>> +
>> + dra7xx_extcon = devm_kzalloc(&pdev->dev, sizeof(*dra7xx_extcon),
>> + GFP_KERNEL);
>> + if (!dra7xx_extcon)
>> + return -ENOMEM;
>> +
>> + dra7xx_extcon->dev = &pdev->dev;
>> +
>> + platform_set_drvdata(pdev, dra7xx_extcon);
>> +
>> + dra7xx_extcon->edev.supported_cable = dra7xx_extcon_cable;
>> +
>> + gpio = of_get_gpio(node, 0);
>> + if (gpio_is_valid(gpio)) {
>> + dra7xx_extcon->id_gpio = gpio;
>> + ret = devm_gpio_request(&pdev->dev, dra7xx_extcon->id_gpio,
>> + "id_gpio");
>> + if (ret)
>> + return ret;
>> +
>> + dra7xx_extcon->id_irq = gpio_to_irq(dra7xx_extcon->id_gpio);
>> + } else {
>> + dev_err(&pdev->dev, "failed to get id gpio\n");
>> + return -EPROBE_DEFER;
>> + }
>> +
>> + ret = dra7xx_extcon_request_irq(dra7xx_extcon);
>> + if (ret)
>> + return ret;
>> +
>> + ret = extcon_dev_register(&dra7xx_extcon->edev);
>> + if (ret) {
>> + dev_err(&pdev->dev, "failed to register extcon device\n");
>> + return ret;
>> + }
>> +
>> + dra7xx_extcon_set_initial_state(dra7xx_extcon);
>> +
>> + return 0;
>> +}
>> +
>> +static int dra7xx_extcon_remove(struct platform_device *pdev)
>> +{
>> + struct dra7xx_extcon *dra7xx_extcon = platform_get_drvdata(pdev);
>> +
>> + extcon_dev_unregister(&dra7xx_extcon->edev);
>> + return 0;
>> +}
>> +
>> +static struct of_device_id of_dra7xx_extcon_match_tbl[] = {
>> + { .compatible = "ti,dra7xx-extcon", },
>> + { /* end */ }
>> +};
>> +
>> +static struct platform_driver dra7xx_extcon_driver = {
>> + .probe = dra7xx_extcon_probe,
>> + .remove = dra7xx_extcon_remove,
>> + .driver = {
>> + .name = "dra7xx-extcon",
>> + .of_match_table = of_dra7xx_extcon_match_tbl,
>> + .owner = THIS_MODULE,
>> + },
>> +};
>> +
>> +module_platform_driver(dra7xx_extcon_driver);
>> +
>> +MODULE_ALIAS("platform:extcon-dra7xx");
>> +MODULE_AUTHOR("George Cherian <george.cherian-l0cyMroinI0@public.gmane.org>");
>> +MODULE_DESCRIPTION("USB ID pin detection driver for DRA7xx");
>> +MODULE_LICENSE("GPL");
>> +MODULE_DEVICE_TABLE(of, of_dra7xx_extcon_match_tbl);
>>
>
--
-George
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-06-16 5:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-16 2:42 [PATCH] extcon: extcon-dra7xx: Add Extcon driver for DRA7xx George Cherian
2014-06-16 4:59 ` Guenter Roeck
[not found] ` <539E79A1.50208-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2014-06-16 5:41 ` George Cherian [this message]
2014-06-16 5:48 ` Chanwoo Choi
2014-06-17 12:26 ` George Cherian
2014-06-16 14:15 ` Guenter Roeck
2014-06-17 12:28 ` George Cherian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=539E8399.80902@ti.com \
--to=george.cherian-l0cymroini0@public.gmane.org \
--cc=cw00.choi-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=myungjoo.ham-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=rdunlap-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).