* [PATCH v2 0/3] ARM/usb: add PHY for Lubbock platform
@ 2014-11-29 22:02 Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 1/3] ARM: pxa: lubbock: add declaration of vbus tranceiver Dmitry Eremin-Solenikov
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Dmitry Eremin-Solenikov @ 2014-11-29 22:02 UTC (permalink / raw)
To: linux-arm-kernel
This is the second iteration of a compile-tested-only PHY for the Lubbock
platform. Could you please take a look and test.
Changes since V1:
- Switched to using threaded IRQs in a phy
- This allowed me to drop workqueue scheduling
- Dropped mach/lubbock.h from pxa25x_udc.h header.
The following changes since commit f114040e3ea6e07372334ade75d1ee0775c355e1:
Linux 3.18-rc1 (2014-10-19 18:08:38 -0700)
are available in the git repository at:
git.infradead.org:public_git/zaurus.git lubbock
for you to fetch changes up to 3ef110afa33e9e5c2ab77a4ababd279f8bd4e95c:
usb: gadget: drop lubbock-specific code from pxa25x_udc (2014-11-30 00:51:31 +0300)
----------------------------------------------------------------
Dmitry Eremin-Solenikov (3):
ARM: pxa: lubbock: add declaration of vbus tranceiver
usb: phy: add lubbock phy driver
usb: gadget: drop lubbock-specific code from pxa25x_udc
arch/arm/mach-pxa/lubbock.c | 6 +
drivers/usb/gadget/udc/pxa25x_udc.c | 61 ----------
drivers/usb/gadget/udc/pxa25x_udc.h | 5 -
drivers/usb/phy/Kconfig | 10 ++
drivers/usb/phy/Makefile | 1 +
drivers/usb/phy/phy-lubbock.c | 220 ++++++++++++++++++++++++++++++++++++
6 files changed, 237 insertions(+), 66 deletions(-)
create mode 100644 drivers/usb/phy/phy-lubbock.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/3] ARM: pxa: lubbock: add declaration of vbus tranceiver
2014-11-29 22:02 [PATCH v2 0/3] ARM/usb: add PHY for Lubbock platform Dmitry Eremin-Solenikov
@ 2014-11-29 22:02 ` Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 2/3] usb: phy: add lubbock phy driver Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 3/3] usb: gadget: drop lubbock-specific code from pxa25x_udc Dmitry Eremin-Solenikov
2 siblings, 0 replies; 11+ messages in thread
From: Dmitry Eremin-Solenikov @ 2014-11-29 22:02 UTC (permalink / raw)
To: linux-arm-kernel
Add a declaration of lubbock-vbus device, used as UDC transceiver on
Lubbock platform.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
arch/arm/mach-pxa/lubbock.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index d8a1be6..5e2dcf7 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -383,11 +383,17 @@ static struct platform_device lubbock_flash_device[2] = {
},
};
+static struct platform_device lubbock_vbus = {
+ .name = "lubbock-vbus",
+ .id = -1,
+};
+
static struct platform_device *devices[] __initdata = {
&sa1111_device,
&smc91x_device,
&lubbock_flash_device[0],
&lubbock_flash_device[1],
+ &lubbock_vbus,
};
static struct pxafb_mode_info sharp_lm8v31_mode = {
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2014-11-29 22:02 [PATCH v2 0/3] ARM/usb: add PHY for Lubbock platform Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 1/3] ARM: pxa: lubbock: add declaration of vbus tranceiver Dmitry Eremin-Solenikov
@ 2014-11-29 22:02 ` Dmitry Eremin-Solenikov
2014-11-29 22:44 ` Jeremiah Mahler
` (2 more replies)
2014-11-29 22:02 ` [PATCH v2 3/3] usb: gadget: drop lubbock-specific code from pxa25x_udc Dmitry Eremin-Solenikov
2 siblings, 3 replies; 11+ messages in thread
From: Dmitry Eremin-Solenikov @ 2014-11-29 22:02 UTC (permalink / raw)
To: linux-arm-kernel
Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
driver determines connector/VBUS status by reading CPLD register. Also
it uses a work to call into udc stack, instead of pinging vbus session
right from irq handler.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/usb/phy/Kconfig | 10 ++
drivers/usb/phy/Makefile | 1 +
drivers/usb/phy/phy-lubbock.c | 220 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 231 insertions(+)
create mode 100644 drivers/usb/phy/phy-lubbock.c
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 0cd1f44..98b1682 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -137,6 +137,16 @@ config USB_ISP1301
To compile this driver as a module, choose M here: the
module will be called phy-isp1301.
+config USB_LUBBOCK
+ tristate "USB VBUS PHY Driver for DBPXA250 Lubbock platform"
+ depends on ARCH_LUBBOCK
+ help
+ Say Y here to add support for the USB Gadget VBUS tranceiver driver
+ for DBPXA250 (Lubbock) platform.
+
+ To compile this driver as a module, choose M here: the
+ module will be called phy-lubbock.
+
config USB_MSM_OTG
tristate "Qualcomm on-chip USB OTG controller support"
depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM || COMPILE_TEST)
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 75f2bba..0fe461c 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o
obj-$(CONFIG_USB_EHCI_TEGRA) += phy-tegra-usb.o
obj-$(CONFIG_USB_GPIO_VBUS) += phy-gpio-vbus-usb.o
obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o
+obj-$(CONFIG_USB_LUBBOCK) += phy-lubbock.o
obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o
obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o
obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o
diff --git a/drivers/usb/phy/phy-lubbock.c b/drivers/usb/phy/phy-lubbock.c
new file mode 100644
index 0000000..f73c1a6
--- /dev/null
+++ b/drivers/usb/phy/phy-lubbock.c
@@ -0,0 +1,220 @@
+/*
+ * gpio-lubbock.c - VBUS handling code for DBPXA250 platform (lubbock)
+ *
+ * Based on lubbock-vbus.c:
+ * Copyright (c) 2008 Philipp Zabel <philipp.zabel@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/usb.h>
+
+#include <linux/usb/gadget.h>
+#include <linux/usb/otg.h>
+
+#include <mach/hardware.h>
+#include <mach/lubbock.h>
+
+struct lubbock_vbus_data {
+ struct usb_phy phy;
+ struct device *dev;
+ int vbus;
+};
+
+static int is_vbus_powered(void)
+{
+ return !(LUB_MISC_RD && BIT(9));
+}
+
+static void lubbock_vbus_handle(struct lubbock_vbus_data *lubbock_vbus)
+{
+ int status, vbus;
+
+ if (!lubbock_vbus->phy.otg->gadget)
+ return;
+
+ vbus = is_vbus_powered();
+ if ((vbus ^ lubbock_vbus->vbus) == 0)
+ return;
+ lubbock_vbus->vbus = vbus;
+
+ if (vbus) {
+ status = USB_EVENT_VBUS;
+ lubbock_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
+ lubbock_vbus->phy.last_event = status;
+ usb_gadget_vbus_connect(lubbock_vbus->phy.otg->gadget);
+
+ atomic_notifier_call_chain(&lubbock_vbus->phy.notifier,
+ status, lubbock_vbus->phy.otg->gadget);
+ } else {
+ usb_gadget_vbus_disconnect(lubbock_vbus->phy.otg->gadget);
+ status = USB_EVENT_NONE;
+ lubbock_vbus->phy.state = OTG_STATE_B_IDLE;
+ lubbock_vbus->phy.last_event = status;
+
+ atomic_notifier_call_chain(&lubbock_vbus->phy.notifier,
+ status, lubbock_vbus->phy.otg->gadget);
+ }
+}
+
+/* VBUS change IRQ handler */
+static irqreturn_t lubbock_vbus_irq(int irq, void *data)
+{
+ struct platform_device *pdev = data;
+ struct lubbock_vbus_data *lubbock_vbus = platform_get_drvdata(pdev);
+ struct usb_otg *otg = lubbock_vbus->phy.otg;
+
+ dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n",
+ is_vbus_powered() ? "supplied" : "inactive",
+ otg->gadget ? otg->gadget->name : "none");
+
+ switch (irq) {
+ case LUBBOCK_USB_IRQ:
+ disable_irq(LUBBOCK_USB_IRQ);
+ enable_irq(LUBBOCK_USB_DISC_IRQ);
+ break;
+ case LUBBOCK_USB_DISC_IRQ:
+ disable_irq(LUBBOCK_USB_DISC_IRQ);
+ enable_irq(LUBBOCK_USB_IRQ);
+ break;
+ default:
+ return IRQ_NONE;
+ }
+
+ /*
+ * No need to use workqueue here - we are in a threded handler,
+ * so we can sleep.
+ */
+ if (otg->gadget)
+ lubbock_vbus_handle(lubbock_vbus);
+
+ return IRQ_HANDLED;
+}
+
+/* OTG transceiver interface */
+
+/* bind/unbind the peripheral controller */
+static int lubbock_vbus_set_peripheral(struct usb_otg *otg,
+ struct usb_gadget *gadget)
+{
+ struct lubbock_vbus_data *lubbock_vbus;
+ struct platform_device *pdev;
+
+ lubbock_vbus = container_of(otg->phy, struct lubbock_vbus_data, phy);
+ pdev = to_platform_device(lubbock_vbus->dev);
+
+ if (!gadget) {
+ dev_dbg(&pdev->dev, "unregistering gadget '%s'\n",
+ otg->gadget->name);
+
+ usb_gadget_vbus_disconnect(otg->gadget);
+ otg->phy->state = OTG_STATE_UNDEFINED;
+
+ otg->gadget = NULL;
+ return 0;
+ }
+
+ otg->gadget = gadget;
+ dev_dbg(&pdev->dev, "registered gadget '%s'\n", gadget->name);
+
+ /* initialize connection state */
+ lubbock_vbus->vbus = 0; /* start with disconnected */
+ lubbock_vbus_irq(LUBBOCK_USB_DISC_IRQ, pdev);
+
+ return 0;
+}
+
+/* for non-OTG B devices: set/clear transceiver suspend mode */
+static int lubbock_vbus_set_suspend(struct usb_phy *phy, int suspend)
+{
+ return 0;
+}
+
+/* platform driver interface */
+
+static int lubbock_vbus_probe(struct platform_device *pdev)
+{
+ struct lubbock_vbus_data *lubbock_vbus;
+ int err;
+
+ lubbock_vbus = devm_kzalloc(&pdev->dev,
+ sizeof(struct lubbock_vbus_data),
+ GFP_KERNEL);
+ if (!lubbock_vbus)
+ return -ENOMEM;
+
+ lubbock_vbus->phy.otg = devm_kzalloc(&pdev->dev,
+ sizeof(struct usb_otg),
+ GFP_KERNEL);
+ if (!lubbock_vbus->phy.otg)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, lubbock_vbus);
+ lubbock_vbus->dev = &pdev->dev;
+ lubbock_vbus->phy.label = "lubbock-vbus";
+ lubbock_vbus->phy.dev = lubbock_vbus->dev;
+ lubbock_vbus->phy.set_suspend = lubbock_vbus_set_suspend;
+ lubbock_vbus->phy.state = OTG_STATE_UNDEFINED;
+
+ lubbock_vbus->phy.otg->phy = &lubbock_vbus->phy;
+ lubbock_vbus->phy.otg->set_peripheral = lubbock_vbus_set_peripheral;
+
+ err = devm_request_threaded_irq(&pdev->dev, LUBBOCK_USB_DISC_IRQ,
+ NULL, lubbock_vbus_irq, 0, "vbus disconnect", pdev);
+ if (err) {
+ dev_err(&pdev->dev, "can't request irq %i, err: %d\n",
+ LUBBOCK_USB_DISC_IRQ, err);
+ return err;
+ }
+
+ err = devm_request_threaded_irq(&pdev->dev, LUBBOCK_USB_IRQ,
+ NULL, lubbock_vbus_irq, 0, "vbus connect", pdev);
+ if (err) {
+ dev_err(&pdev->dev, "can't request irq %i, err: %d\n",
+ LUBBOCK_USB_IRQ, err);
+ return err;
+ }
+
+ /* only active when a gadget is registered */
+ err = usb_add_phy(&lubbock_vbus->phy, USB_PHY_TYPE_USB2);
+ if (err) {
+ dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
+ err);
+ return err;
+ }
+
+ return 0;
+}
+
+static int lubbock_vbus_remove(struct platform_device *pdev)
+{
+ struct lubbock_vbus_data *lubbock_vbus = platform_get_drvdata(pdev);
+
+ usb_remove_phy(&lubbock_vbus->phy);
+
+ return 0;
+}
+
+MODULE_ALIAS("platform:lubbock-vbus");
+
+static struct platform_driver lubbock_vbus_driver = {
+ .driver = {
+ .name = "lubbock-vbus",
+ .owner = THIS_MODULE,
+ },
+ .probe = lubbock_vbus_probe,
+ .remove = lubbock_vbus_remove,
+};
+
+module_platform_driver(lubbock_vbus_driver);
+
+MODULE_DESCRIPTION("OTG transceiver driver for DBPXA250 Lubbock platform");
+MODULE_AUTHOR("Dmitry Eremin-Solenikov");
+MODULE_LICENSE("GPL v2");
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] usb: gadget: drop lubbock-specific code from pxa25x_udc
2014-11-29 22:02 [PATCH v2 0/3] ARM/usb: add PHY for Lubbock platform Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 1/3] ARM: pxa: lubbock: add declaration of vbus tranceiver Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 2/3] usb: phy: add lubbock phy driver Dmitry Eremin-Solenikov
@ 2014-11-29 22:02 ` Dmitry Eremin-Solenikov
2 siblings, 0 replies; 11+ messages in thread
From: Dmitry Eremin-Solenikov @ 2014-11-29 22:02 UTC (permalink / raw)
To: linux-arm-kernel
Now, as there is a special phy for lubbock platforms, drop all
lubbock-specific code from pxa25x udc driver. It should use phy instead.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/usb/gadget/udc/pxa25x_udc.c | 61 -------------------------------------
drivers/usb/gadget/udc/pxa25x_udc.h | 5 ---
2 files changed, 66 deletions(-)
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c
index 42f7eeb..e3d0715 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -56,10 +56,6 @@
#include <mach/hardware.h>
#endif
-#ifdef CONFIG_ARCH_LUBBOCK
-#include <mach/lubbock.h>
-#endif
-
/*
* This driver handles the USB Device Controller (UDC) in Intel's PXA 25x
* series processors. The UDC for the IXP 4xx series is very similar.
@@ -1334,43 +1330,6 @@ static int pxa25x_udc_stop(struct usb_gadget*g,
/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_ARCH_LUBBOCK
-
-/* Lubbock has separate connect and disconnect irqs. More typical designs
- * use one GPIO as the VBUS IRQ, and another to control the D+ pullup.
- */
-
-static irqreturn_t
-lubbock_vbus_irq(int irq, void *_dev)
-{
- struct pxa25x_udc *dev = _dev;
- int vbus;
-
- dev->stats.irqs++;
- switch (irq) {
- case LUBBOCK_USB_IRQ:
- vbus = 1;
- disable_irq(LUBBOCK_USB_IRQ);
- enable_irq(LUBBOCK_USB_DISC_IRQ);
- break;
- case LUBBOCK_USB_DISC_IRQ:
- vbus = 0;
- disable_irq(LUBBOCK_USB_DISC_IRQ);
- enable_irq(LUBBOCK_USB_IRQ);
- break;
- default:
- return IRQ_NONE;
- }
-
- pxa25x_udc_vbus_session(&dev->gadget, vbus);
- return IRQ_HANDLED;
-}
-
-#endif
-
-
-/*-------------------------------------------------------------------------*/
-
static inline void clear_ep_state (struct pxa25x_udc *dev)
{
unsigned i;
@@ -2154,26 +2113,6 @@ static int pxa25x_udc_probe(struct platform_device *pdev)
}
dev->got_irq = 1;
-#ifdef CONFIG_ARCH_LUBBOCK
- if (machine_is_lubbock()) {
- retval = devm_request_irq(&pdev->dev, LUBBOCK_USB_DISC_IRQ,
- lubbock_vbus_irq, 0, driver_name,
- dev);
- if (retval != 0) {
- pr_err("%s: can't get irq %i, err %d\n",
- driver_name, LUBBOCK_USB_DISC_IRQ, retval);
- goto err;
- }
- retval = devm_request_irq(&pdev->dev, LUBBOCK_USB_IRQ,
- lubbock_vbus_irq, 0, driver_name,
- dev);
- if (retval != 0) {
- pr_err("%s: can't get irq %i, err %d\n",
- driver_name, LUBBOCK_USB_IRQ, retval);
- goto err;
- }
- } else
-#endif
create_debug_files(dev);
retval = usb_add_gadget_udc(&pdev->dev, &dev->gadget);
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.h b/drivers/usb/gadget/udc/pxa25x_udc.h
index 3fe5931..59c6bbc 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.h
+++ b/drivers/usb/gadget/udc/pxa25x_udc.h
@@ -130,11 +130,6 @@ struct pxa25x_udc {
/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_ARCH_LUBBOCK
-#include <mach/lubbock.h>
-/* lubbock can also report usb connect/disconnect irqs */
-#endif
-
static struct pxa25x_udc *the_controller;
/*-------------------------------------------------------------------------*/
--
2.1.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2014-11-29 22:02 ` [PATCH v2 2/3] usb: phy: add lubbock phy driver Dmitry Eremin-Solenikov
@ 2014-11-29 22:44 ` Jeremiah Mahler
2014-11-30 21:07 ` Robert Jarzmik
2015-01-08 16:58 ` Felipe Balbi
2 siblings, 0 replies; 11+ messages in thread
From: Jeremiah Mahler @ 2014-11-29 22:44 UTC (permalink / raw)
To: linux-arm-kernel
Dmitry,
On Sun, Nov 30, 2014 at 01:02:04AM +0300, Dmitry Eremin-Solenikov wrote:
> Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
>
[]
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 0cd1f44..98b1682 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -137,6 +137,16 @@ config USB_ISP1301
> To compile this driver as a module, choose M here: the
> module will be called phy-isp1301.
>
> +config USB_LUBBOCK
> + tristate "USB VBUS PHY Driver for DBPXA250 Lubbock platform"
> + depends on ARCH_LUBBOCK
> + help
> + Say Y here to add support for the USB Gadget VBUS tranceiver driver
^^^^^^^^^^
transceiver
> + for DBPXA250 (Lubbock) platform.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called phy-lubbock.
> +
> config USB_MSM_OTG
> tristate "Qualcomm on-chip USB OTG controller support"
> depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM || COMPILE_TEST)
> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> +};
[]
> +module_platform_driver(lubbock_vbus_driver);
> +
> +MODULE_DESCRIPTION("OTG transceiver driver for DBPXA250 Lubbock platform");
> +MODULE_AUTHOR("Dmitry Eremin-Solenikov");
> +MODULE_LICENSE("GPL v2");
> --
> 2.1.3
>
> --
[]
--
- Jeremiah Mahler
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2014-11-29 22:02 ` [PATCH v2 2/3] usb: phy: add lubbock phy driver Dmitry Eremin-Solenikov
2014-11-29 22:44 ` Jeremiah Mahler
@ 2014-11-30 21:07 ` Robert Jarzmik
2015-01-08 16:58 ` Felipe Balbi
2 siblings, 0 replies; 11+ messages in thread
From: Robert Jarzmik @ 2014-11-30 21:07 UTC (permalink / raw)
To: linux-arm-kernel
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> writes:
> Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
> driver determines connector/VBUS status by reading CPLD register. Also
> it uses a work to call into udc stack, instead of pinging vbus session
> right from irq handler.
This comment is not accurate anymore, right ? The work call, etc ...
Moreover, I have this compile error:
drivers/built-in.o: In function `lubbock_vbus_remove':
/home/rj/mio_linux/kernel/drivers/usb/phy/phy-lubbock.c:200: undefined reference to `usb_remove_phy'
drivers/built-in.o: In function `lubbock_vbus_probe':
/home/rj/mio_linux/kernel/drivers/usb/phy/phy-lubbock.c:186: undefined reference to `usb_add_phy'
Makefile:922: recipe for target 'vmlinux' failed
A select in Kconfig is missing, right ?
And then :
genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq 294
lubbock-vbus lubbock-vbus: can't request irq 294, err: -22
lubbock-vbus: probe of lubbock-vbus failed with error -22
> +static int is_vbus_powered(void)
> +{
> + return !(LUB_MISC_RD && BIT(9));
That BIT(9) is a bit ugly. Moreover the "&&" is certainly wrong.
A define somewhere would be fine.
> +}
> +
> +static void lubbock_vbus_handle(struct lubbock_vbus_data *lubbock_vbus)
I have not reviewed that one thoroughly ...
> +
> +/* VBUS change IRQ handler */
> +static irqreturn_t lubbock_vbus_irq(int irq, void *data)
> +{
> + struct platform_device *pdev = data;
> + struct lubbock_vbus_data *lubbock_vbus = platform_get_drvdata(pdev);
> + struct usb_otg *otg = lubbock_vbus->phy.otg;
> +
> + dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n",
> + is_vbus_powered() ? "supplied" : "inactive",
> + otg->gadget ? otg->gadget->name : "none");
> +
> + switch (irq) {
> + case LUBBOCK_USB_IRQ:
> + disable_irq(LUBBOCK_USB_IRQ);
> + enable_irq(LUBBOCK_USB_DISC_IRQ);
> + break;
> + case LUBBOCK_USB_DISC_IRQ:
> + disable_irq(LUBBOCK_USB_DISC_IRQ);
> + enable_irq(LUBBOCK_USB_IRQ);
> + break;
> + default:
> + return IRQ_NONE;
> + }
> +
> + /*
> + * No need to use workqueue here - we are in a threded handler,
> + * so we can sleep.
> + */
What if a new interrupt occurs in here, and preempts this thread.
> + if (otg->gadget)
> + lubbock_vbus_handle(lubbock_vbus);
I think the enable_irq() call should be here. I can't have an ordering problem
at this point, right ?
> + err = devm_request_threaded_irq(&pdev->dev, LUBBOCK_USB_DISC_IRQ,
> + NULL, lubbock_vbus_irq, 0, "vbus disconnect", pdev);
> + if (err) {
> + dev_err(&pdev->dev, "can't request irq %i, err: %d\n",
> + LUBBOCK_USB_DISC_IRQ, err);
> + return err;
> + }
> +
> + err = devm_request_threaded_irq(&pdev->dev, LUBBOCK_USB_IRQ,
> + NULL, lubbock_vbus_irq, 0, "vbus connect", pdev);
> + if (err) {
> + dev_err(&pdev->dev, "can't request irq %i, err: %d\n",
> + LUBBOCK_USB_IRQ, err);
> + return err;
> + }
Here you have both interrupts enabled, this will mean one interrupt at least
will fire. And of course the other one will be enabled a second time, hence
imbalance.
If you want to have an initial status of disconnected gadget, just enable ti
connect interrupt at probing.
Cheers.
--
Robert
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2014-11-29 22:02 ` [PATCH v2 2/3] usb: phy: add lubbock phy driver Dmitry Eremin-Solenikov
2014-11-29 22:44 ` Jeremiah Mahler
2014-11-30 21:07 ` Robert Jarzmik
@ 2015-01-08 16:58 ` Felipe Balbi
2015-01-11 18:44 ` Dmitry Eremin-Solenikov
2 siblings, 1 reply; 11+ messages in thread
From: Felipe Balbi @ 2015-01-08 16:58 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Nov 30, 2014 at 01:02:04AM +0300, Dmitry Eremin-Solenikov wrote:
> Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
> driver determines connector/VBUS status by reading CPLD register. Also
> it uses a work to call into udc stack, instead of pinging vbus session
> right from irq handler.
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> drivers/usb/phy/Kconfig | 10 ++
> drivers/usb/phy/Makefile | 1 +
new phy drivers under drivers/phy only, sorry.
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150108/1b0d65ee/attachment.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2015-01-08 16:58 ` Felipe Balbi
@ 2015-01-11 18:44 ` Dmitry Eremin-Solenikov
2015-01-12 21:51 ` Felipe Balbi
0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Eremin-Solenikov @ 2015-01-11 18:44 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
2015-01-08 19:58 GMT+03:00 Felipe Balbi <balbi@ti.com>:
> On Sun, Nov 30, 2014 at 01:02:04AM +0300, Dmitry Eremin-Solenikov wrote:
>> Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
>> driver determines connector/VBUS status by reading CPLD register. Also
>> it uses a work to call into udc stack, instead of pinging vbus session
>> right from irq handler.
>>
>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>> ---
>> drivers/usb/phy/Kconfig | 10 ++
>> drivers/usb/phy/Makefile | 1 +
>
> new phy drivers under drivers/phy only, sorry.
Hmm. How do drivers/phy drivers coordinate with usb gadget subsystem?
I see none of them calling usb_gadget_vbus_connect/disconnect().
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2015-01-11 18:44 ` Dmitry Eremin-Solenikov
@ 2015-01-12 21:51 ` Felipe Balbi
2015-01-13 6:10 ` Kishon Vijay Abraham I
0 siblings, 1 reply; 11+ messages in thread
From: Felipe Balbi @ 2015-01-12 21:51 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jan 11, 2015 at 10:44:59PM +0400, Dmitry Eremin-Solenikov wrote:
> Hello,
>
> 2015-01-08 19:58 GMT+03:00 Felipe Balbi <balbi@ti.com>:
> > On Sun, Nov 30, 2014 at 01:02:04AM +0300, Dmitry Eremin-Solenikov wrote:
> >> Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
> >> driver determines connector/VBUS status by reading CPLD register. Also
> >> it uses a work to call into udc stack, instead of pinging vbus session
> >> right from irq handler.
> >>
> >> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> >> ---
> >> drivers/usb/phy/Kconfig | 10 ++
> >> drivers/usb/phy/Makefile | 1 +
> >
> > new phy drivers under drivers/phy only, sorry.
>
> Hmm. How do drivers/phy drivers coordinate with usb gadget subsystem?
> I see none of them calling usb_gadget_vbus_connect/disconnect().
I'll leave that to Kishon, since he wrote drivers/phy. Kishon, any
hints?
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150112/3d24ea70/attachment-0001.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2015-01-12 21:51 ` Felipe Balbi
@ 2015-01-13 6:10 ` Kishon Vijay Abraham I
2015-01-15 1:45 ` Dmitry Eremin-Solenikov
0 siblings, 1 reply; 11+ messages in thread
From: Kishon Vijay Abraham I @ 2015-01-13 6:10 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Tuesday 13 January 2015 03:21 AM, Felipe Balbi wrote:
> On Sun, Jan 11, 2015 at 10:44:59PM +0400, Dmitry Eremin-Solenikov wrote:
>> Hello,
>>
>> 2015-01-08 19:58 GMT+03:00 Felipe Balbi <balbi@ti.com>:
>>> On Sun, Nov 30, 2014 at 01:02:04AM +0300, Dmitry Eremin-Solenikov wrote:
>>>> Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
>>>> driver determines connector/VBUS status by reading CPLD register. Also
>>>> it uses a work to call into udc stack, instead of pinging vbus session
>>>> right from irq handler.
>>>>
>>>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>>>> ---
>>>> drivers/usb/phy/Kconfig | 10 ++
>>>> drivers/usb/phy/Makefile | 1 +
>>>
>>> new phy drivers under drivers/phy only, sorry.
>>
>> Hmm. How do drivers/phy drivers coordinate with usb gadget subsystem?
>> I see none of them calling usb_gadget_vbus_connect/disconnect().
>
> I'll leave that to Kishon, since he wrote drivers/phy. Kishon, any
> hints?
Extcon framework can be used to detect the connector status. So the PHY driver
should register with the extcon framework if it has the capability to determine
the connector status and the gadget driver should register with the extcon
framework if it has to receive the connector status.
I'm not sure if we should be adding these extcon APIs inside the PHY framework
itself as all PHYs might not have the capability to detect the connector status.
Thanks
Kishon
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] usb: phy: add lubbock phy driver
2015-01-13 6:10 ` Kishon Vijay Abraham I
@ 2015-01-15 1:45 ` Dmitry Eremin-Solenikov
0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Eremin-Solenikov @ 2015-01-15 1:45 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
2015-01-13 9:10 GMT+03:00 Kishon Vijay Abraham I <kishon@ti.com>:
> Hi,
>
> On Tuesday 13 January 2015 03:21 AM, Felipe Balbi wrote:
>> On Sun, Jan 11, 2015 at 10:44:59PM +0400, Dmitry Eremin-Solenikov wrote:
>>> Hello,
>>>
>>> 2015-01-08 19:58 GMT+03:00 Felipe Balbi <balbi@ti.com>:
>>>> On Sun, Nov 30, 2014 at 01:02:04AM +0300, Dmitry Eremin-Solenikov wrote:
>>>>> Extract lubbock-specific code from pxa25x_udc driver. As a bonus, phy
>>>>> driver determines connector/VBUS status by reading CPLD register. Also
>>>>> it uses a work to call into udc stack, instead of pinging vbus session
>>>>> right from irq handler.
>>>>>
>>>>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
>>>>> ---
>>>>> drivers/usb/phy/Kconfig | 10 ++
>>>>> drivers/usb/phy/Makefile | 1 +
>>>>
>>>> new phy drivers under drivers/phy only, sorry.
>>>
>>> Hmm. How do drivers/phy drivers coordinate with usb gadget subsystem?
>>> I see none of them calling usb_gadget_vbus_connect/disconnect().
>>
>> I'll leave that to Kishon, since he wrote drivers/phy. Kishon, any
>> hints?
>
> Extcon framework can be used to detect the connector status. So the PHY driver
> should register with the extcon framework if it has the capability to determine
> the connector status and the gadget driver should register with the extcon
> framework if it has to receive the connector status.
If I understand correctly, this means the whole usb gadget/otg subsystem needs
to be redesigned/refactored to support extconn drivers. Is it planned already?
Can we still submit drivers to an old usb-phy subsystem as 'new phy' subsystem
does not provide us necessary integration with usb-gadget subsystem?
>
> I'm not sure if we should be adding these extcon APIs inside the PHY framework
> itself as all PHYs might not have the capability to detect the connector status.
In fact I have several devices for which I had to implement a simple usb-phy
that is able to control D+ pullup, but isn't able to detect VBUS presense
and thus has to assume that the device is always connected.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-01-15 1:45 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-29 22:02 [PATCH v2 0/3] ARM/usb: add PHY for Lubbock platform Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 1/3] ARM: pxa: lubbock: add declaration of vbus tranceiver Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 2/3] usb: phy: add lubbock phy driver Dmitry Eremin-Solenikov
2014-11-29 22:44 ` Jeremiah Mahler
2014-11-30 21:07 ` Robert Jarzmik
2015-01-08 16:58 ` Felipe Balbi
2015-01-11 18:44 ` Dmitry Eremin-Solenikov
2015-01-12 21:51 ` Felipe Balbi
2015-01-13 6:10 ` Kishon Vijay Abraham I
2015-01-15 1:45 ` Dmitry Eremin-Solenikov
2014-11-29 22:02 ` [PATCH v2 3/3] usb: gadget: drop lubbock-specific code from pxa25x_udc Dmitry Eremin-Solenikov
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).