Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753718AbaFPFmh (ORCPT ); Mon, 16 Jun 2014 01:42:37 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:52123 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751103AbaFPFmf (ORCPT ); Mon, 16 Jun 2014 01:42:35 -0400 Message-ID: <539E8399.80902@ti.com> Date: Mon, 16 Jun 2014 11:11:45 +0530 From: George Cherian User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Guenter Roeck , , , , , , , , , CC: , , Subject: Re: [PATCH] extcon: extcon-dra7xx: Add Extcon driver for DRA7xx References: <1402886548-22765-1-git-send-email-george.cherian@ti.com> <539E79A1.50208@roeck-us.net> In-Reply-To: <539E79A1.50208@roeck-us.net> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > > 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 >> + * >> + * 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 >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +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 "); >> +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 linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/