Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 226970
b: refs/heads/master
c: 409a15d
h: refs/heads/master
v: v3
  • Loading branch information
Pavankumar Kondeti authored and Greg Kroah-Hartman committed Dec 10, 2010
1 parent c84cda7 commit cb75a1d
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 169 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 87c0104af742af2acfcbd685f2b9a40f33770dc0
refs/heads/master: 409a15da9851b6e6a5e1c5787be31a987184b7cf
8 changes: 4 additions & 4 deletions trunk/drivers/usb/gadget/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ config USB_FSL_QE
default USB_GADGET
select USB_GADGET_SELECTED

config USB_GADGET_CI13XXX
boolean "MIPS USB CI13xxx"
config USB_GADGET_CI13XXX_PCI
boolean "MIPS USB CI13xxx PCI UDC"
depends on PCI
select USB_GADGET_DUALSPEED
help
Expand All @@ -439,9 +439,9 @@ config USB_GADGET_CI13XXX
dynamically linked module called "ci13xxx_udc" and force all
gadget drivers to also be dynamically linked.

config USB_CI13XXX
config USB_CI13XXX_PCI
tristate
depends on USB_GADGET_CI13XXX
depends on USB_GADGET_CI13XXX_PCI
default USB_GADGET
select USB_GADGET_SELECTED

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/gadget/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o
obj-$(CONFIG_USB_M66592) += m66592-udc.o
obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o
obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o
obj-$(CONFIG_USB_CI13XXX) += ci13xxx_udc.o
obj-$(CONFIG_USB_CI13XXX_PCI) += ci13xxx_pci.o
obj-$(CONFIG_USB_S3C_HSOTG) += s3c-hsotg.o
obj-$(CONFIG_USB_LANGWELL) += langwell_udc.o
obj-$(CONFIG_USB_EG20T) += pch_udc.o
Expand Down
172 changes: 172 additions & 0 deletions trunk/drivers/usb/gadget/ci13xxx_pci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/*
* ci13xxx_pci.c - MIPS USB IP core family device controller
*
* Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
*
* Author: David Lopo
*
* 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/module.h>
#include <linux/pci.h>

#include "ci13xxx_udc.c"

/* driver name */
#define UDC_DRIVER_NAME "ci13xxx_pci"

/******************************************************************************
* PCI block
*****************************************************************************/
/**
* ci13xxx_pci_irq: interrut handler
* @irq: irq number
* @pdev: USB Device Controller interrupt source
*
* This function returns IRQ_HANDLED if the IRQ has been handled
* This is an ISR don't trace, use attribute interface instead
*/
static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
{
if (irq == 0) {
dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
return IRQ_HANDLED;
}
return udc_irq();
}

/**
* ci13xxx_pci_probe: PCI probe
* @pdev: USB device controller being probed
* @id: PCI hotplug ID connecting controller to UDC framework
*
* This function returns an error code
* Allocates basic PCI resources for this USB device controller, and then
* invokes the udc_probe() method to start the UDC associated with it
*/
static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
void __iomem *regs = NULL;
int retval = 0;

if (id == NULL)
return -EINVAL;

retval = pci_enable_device(pdev);
if (retval)
goto done;

if (!pdev->irq) {
dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
retval = -ENODEV;
goto disable_device;
}

retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
if (retval)
goto disable_device;

/* BAR 0 holds all the registers */
regs = pci_iomap(pdev, 0, 0);
if (!regs) {
dev_err(&pdev->dev, "Error mapping memory!");
retval = -EFAULT;
goto release_regions;
}
pci_set_drvdata(pdev, (__force void *)regs);

pci_set_master(pdev);
pci_try_set_mwi(pdev);

retval = udc_probe(&pdev->dev, regs, UDC_DRIVER_NAME);
if (retval)
goto iounmap;

/* our device does not have MSI capability */

retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
UDC_DRIVER_NAME, pdev);
if (retval)
goto gadget_remove;

return 0;

gadget_remove:
udc_remove();
iounmap:
pci_iounmap(pdev, regs);
release_regions:
pci_release_regions(pdev);
disable_device:
pci_disable_device(pdev);
done:
return retval;
}

/**
* ci13xxx_pci_remove: PCI remove
* @pdev: USB Device Controller being removed
*
* Reverses the effect of ci13xxx_pci_probe(),
* first invoking the udc_remove() and then releases
* all PCI resources allocated for this USB device controller
*/
static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
{
free_irq(pdev->irq, pdev);
udc_remove();
pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
pci_release_regions(pdev);
pci_disable_device(pdev);
}

/**
* PCI device table
* PCI device structure
*
* Check "pci.h" for details
*/
static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
{ PCI_DEVICE(0x153F, 0x1004) },
{ PCI_DEVICE(0x153F, 0x1006) },
{ 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
};
MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);

static struct pci_driver ci13xxx_pci_driver = {
.name = UDC_DRIVER_NAME,
.id_table = ci13xxx_pci_id_table,
.probe = ci13xxx_pci_probe,
.remove = __devexit_p(ci13xxx_pci_remove),
};

/**
* ci13xxx_pci_init: module init
*
* Driver load
*/
static int __init ci13xxx_pci_init(void)
{
return pci_register_driver(&ci13xxx_pci_driver);
}
module_init(ci13xxx_pci_init);

/**
* ci13xxx_pci_exit: module exit
*
* Driver unload
*/
static void __exit ci13xxx_pci_exit(void)
{
pci_unregister_driver(&ci13xxx_pci_driver);
}
module_exit(ci13xxx_pci_exit);

MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
MODULE_LICENSE("GPL");
MODULE_VERSION("June 2008");
159 changes: 0 additions & 159 deletions trunk/drivers/usb/gadget/ci13xxx_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* - ENDPT: endpoint operations (Gadget API)
* - GADGET: gadget operations (Gadget API)
* - BUS: bus glue code, bus abstraction layer
* - PCI: PCI core interface and PCI resources (interrupts, memory...)
*
* Compile Options
* - CONFIG_USB_GADGET_DEBUG_FILES: enable debug facilities
Expand Down Expand Up @@ -60,8 +59,6 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
Expand All @@ -75,9 +72,6 @@
/* ctrl register bank access */
static DEFINE_SPINLOCK(udc_lock);

/* driver name */
#define UDC_DRIVER_NAME "ci13xxx_udc"

/* control endpoint description */
static const struct usb_endpoint_descriptor
ctrl_endpt_desc = {
Expand Down Expand Up @@ -2680,156 +2674,3 @@ static void udc_remove(void)
kfree(udc);
_udc = NULL;
}

/******************************************************************************
* PCI block
*****************************************************************************/
/**
* ci13xxx_pci_irq: interrut handler
* @irq: irq number
* @pdev: USB Device Controller interrupt source
*
* This function returns IRQ_HANDLED if the IRQ has been handled
* This is an ISR don't trace, use attribute interface instead
*/
static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
{
if (irq == 0) {
dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
return IRQ_HANDLED;
}
return udc_irq();
}

/**
* ci13xxx_pci_probe: PCI probe
* @pdev: USB device controller being probed
* @id: PCI hotplug ID connecting controller to UDC framework
*
* This function returns an error code
* Allocates basic PCI resources for this USB device controller, and then
* invokes the udc_probe() method to start the UDC associated with it
*/
static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
void __iomem *regs = NULL;
int retval = 0;

if (id == NULL)
return -EINVAL;

retval = pci_enable_device(pdev);
if (retval)
goto done;

if (!pdev->irq) {
dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
retval = -ENODEV;
goto disable_device;
}

retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
if (retval)
goto disable_device;

/* BAR 0 holds all the registers */
regs = pci_iomap(pdev, 0, 0);
if (!regs) {
dev_err(&pdev->dev, "Error mapping memory!");
retval = -EFAULT;
goto release_regions;
}
pci_set_drvdata(pdev, (__force void *)regs);

pci_set_master(pdev);
pci_try_set_mwi(pdev);

retval = udc_probe(&pdev->dev, regs, UDC_DRIVER_NAME);
if (retval)
goto iounmap;

/* our device does not have MSI capability */

retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
UDC_DRIVER_NAME, pdev);
if (retval)
goto gadget_remove;

return 0;

gadget_remove:
udc_remove();
iounmap:
pci_iounmap(pdev, regs);
release_regions:
pci_release_regions(pdev);
disable_device:
pci_disable_device(pdev);
done:
return retval;
}

/**
* ci13xxx_pci_remove: PCI remove
* @pdev: USB Device Controller being removed
*
* Reverses the effect of ci13xxx_pci_probe(),
* first invoking the udc_remove() and then releases
* all PCI resources allocated for this USB device controller
*/
static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
{
free_irq(pdev->irq, pdev);
udc_remove();
pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
pci_release_regions(pdev);
pci_disable_device(pdev);
}

/**
* PCI device table
* PCI device structure
*
* Check "pci.h" for details
*/
static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
{ PCI_DEVICE(0x153F, 0x1004) },
{ PCI_DEVICE(0x153F, 0x1006) },
{ 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
};
MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);

static struct pci_driver ci13xxx_pci_driver = {
.name = UDC_DRIVER_NAME,
.id_table = ci13xxx_pci_id_table,
.probe = ci13xxx_pci_probe,
.remove = __devexit_p(ci13xxx_pci_remove),
};

/**
* ci13xxx_pci_init: module init
*
* Driver load
*/
static int __init ci13xxx_pci_init(void)
{
return pci_register_driver(&ci13xxx_pci_driver);
}
module_init(ci13xxx_pci_init);

/**
* ci13xxx_pci_exit: module exit
*
* Driver unload
*/
static void __exit ci13xxx_pci_exit(void)
{
pci_unregister_driver(&ci13xxx_pci_driver);
}
module_exit(ci13xxx_pci_exit);

MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
MODULE_LICENSE("GPL");
MODULE_VERSION("June 2008");
Loading

0 comments on commit cb75a1d

Please sign in to comment.