Re: [PATCH 4/7] pxa25x: separate lubbock handling to lubbock-usb transceiver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David,

Let me know if you're OK I take this patch, as several others following
have dependency on this one.

On Mon, Apr 4, 2011 at 3:01 PM, Eric Miao <eric.y.miao@xxxxxxxxx> wrote:
> On Fri, Apr 1, 2011 at 9:56 PM, Dmitry Eremin-Solenikov
> <dbaryshkov@xxxxxxxxx> wrote:
>> Move all handling of lubbock board to separate lubbock-usb transceiver,
>> removing cruft from pxa25x_udc.
>>
>> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@xxxxxxxxx>
>
> I like this change very much. It would be perfect if someone can actually
> test this, but provided Lubbock is no way popular these days, it would
> just be fine.
>
> Acked-by: Eric Miao <eric.y.miao@xxxxxxxxx>
>
>> ---
>> Âdrivers/usb/gadget/pxa25x_udc.c | Â 74 ----------------
>> Âdrivers/usb/otg/Kconfig     |  Â8 ++
>> Âdrivers/usb/otg/Makefile    Â|  Â1 +
>> Âdrivers/usb/otg/lubbock-usb.c  | Â178 +++++++++++++++++++++++++++++++++++++++
>> Â4 files changed, 187 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 444b60a..6cb32b8 100644
>> --- a/drivers/usb/gadget/pxa25x_udc.c
>> +++ b/drivers/usb/gadget/pxa25x_udc.c
>> @@ -65,10 +65,6 @@
>> Â#include <mach/pxa25x-udc.h>
>> Â#endif
>>
>> -#ifdef CONFIG_ARCH_LUBBOCK
>> -#include <mach/lubbock.h>
>> -#endif
>> -
>> Â#include <asm/mach/udc_pxa2xx.h>
>>
>>
>> @@ -1383,42 +1379,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)
>> Â{
>> @@ -2206,38 +2166,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);
>> -lubbock_fail0:
>> - Â Â Â Â Â Â Â Â Â Â Â 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);
>> - Â Â Â Â Â Â Â Â Â Â Â free_irq(LUBBOCK_USB_DISC_IRQ, dev);
>> - Â Â Â Â Â Â Â Â Â Â Â goto lubbock_fail0;
>> - Â Â Â Â Â Â Â }
>> - Â Â Â } else
>> -#endif
>> Â Â Â Âcreate_debug_files(dev);
>>
>> Â Â Â Âreturn 0;
>>
>> -#ifdef CONFIG_ARCH_LUBBOCK
>> - Â Â Â free_irq(LUBBOCK_USB_DISC_IRQ, dev);
>> - err_irq_lub:
>> -#endif
>> Â Â Â Âfree_irq(irq, dev);
>> Âerr_irq1:
>> Â Â Â Âif (gpio_is_valid(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 daf3e5f..7ddfc54 100644
>> --- a/drivers/usb/otg/Kconfig
>> +++ b/drivers/usb/otg/Kconfig
>> @@ -122,4 +122,12 @@ 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).
>> +
>> Âendif # USB || OTG
>> diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
>> index e22d917..5ed42cd 100644
>> --- a/drivers/usb/otg/Makefile
>> +++ b/drivers/usb/otg/Makefile
>> @@ -19,3 +19,4 @@ 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
>> diff --git a/drivers/usb/otg/lubbock-usb.c b/drivers/usb/otg/lubbock-usb.c
>> new file mode 100644
>> index 0000000..d18c101
>> --- /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 <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/dma-mapping.h>
>> +#include <linux/usb.h>
>> +#include <linux/usb/gadget.h>
>> +#include <linux/usb/otg.h>
>> +#include <linux/slab.h>
>> +#include <linux/interrupt.h>
>> +
>> +#include <mach/lubbock.h>
>> +
>> +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 | IRQF_SAMPLE_RANDOM,
>> + Â Â Â Â Â Â Â Â Â Â Â 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 | IRQF_SAMPLE_RANDOM,
>> + Â Â Â Â Â Â Â Â Â Â Â 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);
>> +
>> + Â Â Â BLOCKING_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");
>> +
>> --
>> 1.7.4.1
>>
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux