From patchwork Tue Jul 5 13:08:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 944922 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p65D9t7I014057 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 5 Jul 2011 13:10:16 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qe5Nb-0007T7-8c; Tue, 05 Jul 2011 13:09:32 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qe5Na-0007bj-NG; Tue, 05 Jul 2011 13:09:30 +0000 Received: from mail-fx0-f43.google.com ([209.85.161.43]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qe5NF-0007X5-Jm for linux-arm-kernel@lists.infradead.org; Tue, 05 Jul 2011 13:09:11 +0000 Received: by mail-fx0-f43.google.com with SMTP id 17so5321658fxg.16 for ; Tue, 05 Jul 2011 06:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=YKXq2NquTNLHKlCAqPH8lp8oFJdN8Aq7ZGfMz1gS40Q=; b=mxtf+UmuzcPQz2/ncmW0oJ4UFi+BFf/QEvBl4HxBw/MpweixZwzueCYhARoxAqZdN/ +WKSiiiujeuGwgdMHx8WU4t90fYzeqxX1iIVaHV/rDa84vQakK6+d64Am3ZVLCL20JgC ja/AiusgVVQxzgPEp+1HdCvYxn5t9se3mWYog= Received: by 10.223.161.6 with SMTP id p6mr11512076fax.83.1309871349216; Tue, 05 Jul 2011 06:09:09 -0700 (PDT) Received: from doriath.ww600.siemens.net ([91.213.169.4]) by mx.google.com with ESMTPS id n20sm1952263fad.16.2011.07.05.06.09.05 (version=SSLv3 cipher=OTHER); Tue, 05 Jul 2011 06:09:08 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH 04/15] ARM: pxa25x_udc: separate lubbock handling to lubbock-usb transceiver Date: Tue, 5 Jul 2011 17:08:30 +0400 Message-Id: <1309871321-11305-5-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1309871321-11305-1-git-send-email-dbaryshkov@gmail.com> References: <1309871321-11305-1-git-send-email-dbaryshkov@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110705_090909_926630_053BDA3A X-CRM114-Status: GOOD ( 22.42 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.161.43 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dbaryshkov[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 T_TO_NO_BRKTS_FREEMAIL To: misformatted and free email service Cc: Greg Kroah-Hartman , Eric Miao , Felipe Balbi X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 05 Jul 2011 13:10:16 +0000 (UTC) Move all handling of lubbock board to separate lubbock-usb transceiver, removing cruft from pxa25x_udc. Signed-off-by: Dmitry Eremin-Solenikov Signed-off-by: Eric Miao Signed-off-by: Dmitry Eremin-Solenikov Acked-by: Felipe Balbi --- drivers/usb/gadget/pxa25x_udc.c | 74 ---------------- drivers/usb/otg/Kconfig | 10 ++ drivers/usb/otg/Makefile | 1 + drivers/usb/otg/lubbock-usb.c | 178 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 189 insertions(+), 74 deletions(-) create mode 100644 drivers/usb/otg/lubbock-usb.c diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 7745454..6f543c7 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c @@ -66,10 +66,6 @@ #include #endif -#ifdef CONFIG_ARCH_LUBBOCK -#include -#endif - #include @@ -1384,42 +1380,6 @@ EXPORT_SYMBOL(usb_gadget_unregister_driver); /*-------------------------------------------------------------------------*/ -#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) { @@ -2207,38 +2167,10 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) } dev->got_irq = 1; -#ifdef CONFIG_ARCH_LUBBOCK - if (machine_is_lubbock()) { - retval = request_irq(LUBBOCK_USB_DISC_IRQ, - lubbock_vbus_irq, - IRQF_DISABLED | IRQF_SAMPLE_RANDOM, - 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_irq_lub; - } - retval = request_irq(LUBBOCK_USB_IRQ, - lubbock_vbus_irq, - IRQF_DISABLED | IRQF_SAMPLE_RANDOM, - driver_name, dev); - if (retval != 0) { - pr_err("%s: can't get irq %i, err %d\n", - driver_name, LUBBOCK_USB_IRQ, retval); - goto lubbock_fail0; - } - } else -#endif create_debug_files(dev); return 0; -#ifdef CONFIG_ARCH_LUBBOCK -lubbock_fail0: - free_irq(LUBBOCK_USB_DISC_IRQ, dev); - err_irq_lub: - free_irq(irq, dev); -#endif err_irq1: if (gpio_is_valid(dev->mach->gpio_pullup)) gpio_free(dev->mach->gpio_pullup); @@ -2273,12 +2205,6 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev) free_irq(platform_get_irq(pdev, 0), dev); dev->got_irq = 0; } -#ifdef CONFIG_ARCH_LUBBOCK - if (machine_is_lubbock()) { - free_irq(LUBBOCK_USB_DISC_IRQ, dev); - free_irq(LUBBOCK_USB_IRQ, dev); - } -#endif if (gpio_is_valid(dev->mach->gpio_pullup)) gpio_free(dev->mach->gpio_pullup); diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index c66481a..cf3a245 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig @@ -122,6 +122,16 @@ config AB8500_USB This transceiver supports high and full speed devices plus, in host mode, low speed. +config LUBBOCK_USB + tristate "Intel DBPXA250 (Lubbock) Tranceiver Driver" + depends on ARCH_LUBBOCK + select USB_OTG_UTILS + help + Enable this to support the USB UDC connectivity on Intel DBPXA250 + development platform (so-called Lubbock). + This driver is of no use for all other platforms, so if you are + using other board, you can safely say N here. + config FSL_USB2_OTG bool "Freescale USB OTG Transceiver Driver" depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile index 566655c..24d4e63 100644 --- a/drivers/usb/otg/Makefile +++ b/drivers/usb/otg/Makefile @@ -19,5 +19,6 @@ obj-$(CONFIG_USB_ULPI) += ulpi.o obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o obj-$(CONFIG_USB_MSM_OTG) += msm_otg.o obj-$(CONFIG_AB8500_USB) += ab8500-usb.o +obj-$(CONFIG_LUBBOCK_USB) += lubbock-usb.o fsl_usb2_otg-objs := fsl_otg.o otg_fsm.o obj-$(CONFIG_FSL_USB2_OTG) += fsl_usb2_otg.o diff --git a/drivers/usb/otg/lubbock-usb.c b/drivers/usb/otg/lubbock-usb.c new file mode 100644 index 0000000..3ff8297 --- /dev/null +++ b/drivers/usb/otg/lubbock-usb.c @@ -0,0 +1,178 @@ +/* + * Intel DBPXA250 Development Platform USB UDC support + * + * Copyright (C) 2011 Dmitry Eremin-Solenikov + * + * Based on pxa25x_udc driver: + * Copyright (C) 2002 Intrinsyc, Inc. (Frank Becker) + * Copyright (C) 2003 Robert Schwebel, Pengutronix + * Copyright (C) 2003 Benedikt Spranger, Pengutronix + * Copyright (C) 2003 David Brownell + * Copyright (C) 2003 Joshua Wise + * + * Largely based on lubbock-usb-xceiv: + * Copyright (C) 2009 Texas Instruments Inc + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static int lubbock_udc_is_connected(void) +{ + return (LUB_MISC_RD & (1 << 9)) == 0; +} + +static int lubbock_set_peripheral(struct otg_transceiver *lubbock, + struct usb_gadget *gadget) +{ + if (!lubbock) + return -ENODEV; + + if (!gadget) { + lubbock->gadget = NULL; + return 0; + } + + lubbock->gadget = gadget; + lubbock->state = OTG_STATE_B_IDLE; + if (lubbock_udc_is_connected()) { + lubbock->state = OTG_STATE_B_PERIPHERAL; + usb_gadget_vbus_connect(lubbock->gadget); + } + + return 0; +} + +/* 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 otg_transceiver *lubbock = _dev; + switch (irq) { + case LUBBOCK_USB_IRQ: + lubbock->state = OTG_STATE_B_PERIPHERAL; + usb_gadget_vbus_connect(lubbock->gadget); + + disable_irq(LUBBOCK_USB_IRQ); + enable_irq(LUBBOCK_USB_DISC_IRQ); + break; + case LUBBOCK_USB_DISC_IRQ: + usb_gadget_vbus_disconnect(lubbock->gadget); + lubbock->state = OTG_STATE_B_IDLE; + + disable_irq(LUBBOCK_USB_DISC_IRQ); + enable_irq(LUBBOCK_USB_IRQ); + break; + default: + return IRQ_NONE; + } + + return IRQ_HANDLED; +} + + +static int __devinit lubbock_usb_xceiv_probe(struct platform_device *pdev) +{ + struct otg_transceiver *lubbock; + int err; + + lubbock = kzalloc(sizeof *lubbock, GFP_KERNEL); + if (!lubbock) + return -ENOMEM; + + lubbock->dev = &pdev->dev; + lubbock->label = "lubbock-xceiv"; + lubbock->state = OTG_STATE_UNDEFINED; + lubbock->set_peripheral = lubbock_set_peripheral; + + err = request_irq(LUBBOCK_USB_DISC_IRQ, + lubbock_vbus_irq, + IRQF_DISABLED, + lubbock->label, lubbock); + if (err != 0) { + pr_err("%s: can't get irq %i, err %d\n", + lubbock->label, LUBBOCK_USB_DISC_IRQ, err); + goto err_irq_lub; + } + err = request_irq(LUBBOCK_USB_IRQ, + lubbock_vbus_irq, + IRQF_DISABLED, + lubbock->label, lubbock); + if (err != 0) { + pr_err("%s: can't get irq %i, err %d\n", + lubbock->label, LUBBOCK_USB_IRQ, err); + goto err_irq_lub2; + } + + err = otg_set_transceiver(lubbock); + if (err) { + dev_err(&pdev->dev, "can't register transceiver, err: %d\n", + err); + goto exit; + } + + platform_set_drvdata(pdev, lubbock); + + ATOMIC_INIT_NOTIFIER_HEAD(&lubbock->notifier); + + return 0; +exit: + free_irq(LUBBOCK_USB_IRQ, lubbock); +err_irq_lub2: + free_irq(LUBBOCK_USB_DISC_IRQ, lubbock); +err_irq_lub: + kfree(lubbock); + return err; +} + +static int __devexit lubbock_usb_xceiv_remove(struct platform_device *pdev) +{ + struct otg_transceiver *lubbock = platform_get_drvdata(pdev); + + otg_set_transceiver(NULL); + + platform_set_drvdata(pdev, NULL); + + free_irq(LUBBOCK_USB_IRQ, lubbock); + free_irq(LUBBOCK_USB_DISC_IRQ, lubbock); + + kfree(lubbock); + + return 0; +} + +static struct platform_driver lubbock_usb_xceiv_driver = { + .probe = lubbock_usb_xceiv_probe, + .remove = __devexit_p(lubbock_usb_xceiv_remove), + .driver = { + .name = "lubbock_usb_xceiv", + .owner = THIS_MODULE, + }, +}; + +static int __init lubbock_usb_xceiv_init(void) +{ + return platform_driver_register(&lubbock_usb_xceiv_driver); +} +subsys_initcall(lubbock_usb_xceiv_init); + +static void __exit lubbock_usb_xceiv_exit(void) +{ + platform_driver_unregister(&lubbock_usb_xceiv_driver); +} +module_exit(lubbock_usb_xceiv_exit); + +MODULE_ALIAS("platform:lubbock_usb_xceiv"); +MODULE_DESCRIPTION("lubbock USB Transceiver driver"); +MODULE_LICENSE("GPL"); +