Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 303873
b: refs/heads/master
c: 62bb84e
h: refs/heads/master
i:
  303871: b70ed04
v: v3
  • Loading branch information
Alexander Shishkin authored and Greg Kroah-Hartman committed May 9, 2012
1 parent f3351a2 commit 4bebd6d
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 103 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: ed6c6f419f02a6da444e26374f3510ac57b6faf4
refs/heads/master: 62bb84ed0e4d14b0a5070f44b2387a42f7f535d9
18 changes: 15 additions & 3 deletions trunk/drivers/usb/gadget/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,28 @@ config USB_FSL_QE
Set CONFIG_USB_GADGET to "m" to build this driver as a
dynamically linked module called "fsl_qe_udc".

config USB_CHIPIDEA_UDC
tristate "ChipIdea UDC driver"
select USB_GADGET_DUALSPEED
help
This module contains the ChipIdea USB device controller driver;
you will also need platform driver like ci13xxx_pci or ci13xxx_msm
to use it.

Say "y" to link the driver statically, or "m" to build a
dynamically linked module called "ci13xxx_udc", which will serve
as a driver for ChipIdea udc on different platforms.

config USB_CI13XXX_PCI
tristate "MIPS USB CI13xxx PCI UDC"
depends on PCI
depends on PCI && USB_CHIPIDEA_UDC
select USB_GADGET_DUALSPEED
help
MIPS USB IP core family device controller
Currently it only supports IP part number CI13412

Say "y" to link the driver statically, or "m" to build a
dynamically linked module called "ci13xxx_udc" and force all
dynamically linked module called "ci13xxx_pci" and force all
gadget drivers to also be dynamically linked.

config USB_NET2272
Expand Down Expand Up @@ -484,7 +496,7 @@ config USB_EG20T

config USB_CI13XXX_MSM
tristate "MIPS USB CI13xxx for MSM"
depends on ARCH_MSM
depends on ARCH_MSM && USB_CHIPIDEA_UDC
select USB_GADGET_DUALSPEED
select USB_MSM_OTG
help
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/usb/gadget/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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_CHIPIDEA_UDC) += ci13xxx_udc.o
obj-$(CONFIG_USB_CI13XXX_PCI) += ci13xxx_pci.o
obj-$(CONFIG_USB_S3C_HSOTG) += s3c-hsotg.o
obj-$(CONFIG_USB_S3C_HSUDC) += s3c-hsudc.o
Expand Down
58 changes: 20 additions & 38 deletions trunk/drivers/usb/gadget/ci13xxx_msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
#include <linux/pm_runtime.h>
#include <linux/usb/msm_hsusb_hw.h>
#include <linux/usb/ulpi.h>
#include <linux/usb/gadget.h>

#include "ci13xxx_udc.c"
#include "ci13xxx_udc.h"

#define MSM_USB_BASE (udc->regs)

static irqreturn_t msm_udc_irq(int irq, void *data)
{
return udc_irq();
}

static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
{
struct device *dev = udc->gadget.dev.parent;
Expand Down Expand Up @@ -60,54 +56,40 @@ static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver = {

static int ci13xxx_msm_probe(struct platform_device *pdev)
{
struct resource *res;
void __iomem *regs;
int irq;
struct platform_device *plat_ci;
int ret;

dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "failed to get platform resource mem\n");
return -ENXIO;
}

regs = ioremap(res->start, resource_size(res));
if (!regs) {
dev_err(&pdev->dev, "ioremap failed\n");
plat_ci = platform_device_alloc("ci_udc", -1);
if (!plat_ci) {
dev_err(&pdev->dev, "can't allocate ci_udc platform device\n");
return -ENOMEM;
}

ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, regs,
DEF_CAPOFFSET);
if (ret < 0) {
dev_err(&pdev->dev, "udc_probe failed\n");
goto iounmap;
ret = platform_device_add_resources(plat_ci, pdev->resource,
pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "can't add resources to platform device\n");
goto put_platform;
}

irq = platform_get_irq(pdev, 0);
if (irq < 0) {
dev_err(&pdev->dev, "IRQ not found\n");
ret = -ENXIO;
goto udc_remove;
}
ret = platform_device_add_data(plat_ci, &ci13xxx_msm_udc_driver,
sizeof(ci13xxx_msm_udc_driver));
if (ret)
goto put_platform;

ret = request_irq(irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev);
if (ret < 0) {
dev_err(&pdev->dev, "request_irq failed\n");
goto udc_remove;
}
ret = platform_device_add(plat_ci);
if (ret)
goto put_platform;

pm_runtime_no_callbacks(&pdev->dev);
pm_runtime_enable(&pdev->dev);

return 0;

udc_remove:
udc_remove();
iounmap:
iounmap(regs);
put_platform:
platform_device_put(plat_ci);

return ret;
}
Expand Down
124 changes: 67 additions & 57 deletions trunk/drivers/usb/gadget/ci13xxx_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,28 @@
* published by the Free Software Foundation.
*/

#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/usb/gadget.h>

#include "ci13xxx_udc.c"
#include "ci13xxx_udc.h"

/* 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();
}
struct ci13xxx_udc_driver pci_driver = {
.name = UDC_DRIVER_NAME,
.capoffset = DEF_CAPOFFSET,
};

static struct ci13xxx_udc_driver ci13xxx_pci_udc_driver = {
struct ci13xxx_udc_driver langwell_pci_driver = {
.name = UDC_DRIVER_NAME,
.capoffset = 0,
};

/**
Expand All @@ -54,9 +46,10 @@ static struct ci13xxx_udc_driver ci13xxx_pci_udc_driver = {
static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
void __iomem *regs = NULL;
uintptr_t capoffset = DEF_CAPOFFSET;
int retval = 0;
struct ci13xxx_udc_driver *driver = (void *)id->driver_data;
struct platform_device *plat_ci;
struct resource res[3];
int retval = 0, nres = 2;

if (id == NULL)
return -EINVAL;
Expand All @@ -71,45 +64,50 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
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_power_state(pdev, PCI_D0);
pci_set_master(pdev);
pci_try_set_mwi(pdev);

if (pdev->vendor == PCI_VENDOR_ID_INTEL)
capoffset = 0;
plat_ci = platform_device_alloc("ci_udc", -1);
if (!plat_ci) {
dev_err(&pdev->dev, "can't allocate ci_udc platform device\n");
retval = -ENOMEM;
goto disable_device;
}

retval = udc_probe(&ci13xxx_pci_udc_driver, &pdev->dev, regs,
capoffset);
memset(res, 0, sizeof(res));
res[0].start = pci_resource_start(pdev, 0);
res[0].end = pci_resource_end(pdev, 0);
res[0].flags = IORESOURCE_MEM;
res[1].start = pdev->irq;
res[1].flags = IORESOURCE_IRQ;

retval = platform_device_add_resources(plat_ci, res, nres);
if (retval) {
dev_err(&pdev->dev, "can't add resources to platform device\n");
goto put_platform;
}

retval = platform_device_add_data(plat_ci, driver, sizeof(*driver));
if (retval)
goto iounmap;
goto put_platform;

/* our device does not have MSI capability */
dma_set_coherent_mask(&plat_ci->dev, pdev->dev.coherent_dma_mask);
plat_ci->dev.dma_mask = pdev->dev.dma_mask;
plat_ci->dev.dma_parms = pdev->dev.dma_parms;
plat_ci->dev.parent = &pdev->dev;

retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
UDC_DRIVER_NAME, pdev);
pci_set_drvdata(pdev, plat_ci);

retval = platform_device_add(plat_ci);
if (retval)
goto gadget_remove;
goto put_platform;

return 0;

gadget_remove:
udc_remove();
iounmap:
pci_iounmap(pdev, regs);
release_regions:
pci_release_regions(pdev);
put_platform:
pci_set_drvdata(pdev, NULL);
platform_device_put(plat_ci);
disable_device:
pci_disable_device(pdev);
done:
Expand All @@ -126,10 +124,10 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
*/
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);
struct platform_device *plat_ci = pci_get_drvdata(pdev);

platform_device_unregister(plat_ci);
pci_set_drvdata(pdev, NULL);
pci_disable_device(pdev);
}

Expand All @@ -140,10 +138,22 @@ static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
* Check "pci.h" for details
*/
static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
{ PCI_DEVICE(0x153F, 0x1004) },
{ PCI_DEVICE(0x153F, 0x1006) },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811) },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829) },
{
PCI_DEVICE(0x153F, 0x1004),
.driver_data = (kernel_ulong_t)&pci_driver,
},
{
PCI_DEVICE(0x153F, 0x1006),
.driver_data = (kernel_ulong_t)&pci_driver,
},
{
PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811),
.driver_data = (kernel_ulong_t)&langwell_pci_driver,
},
{
PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829),
.driver_data = (kernel_ulong_t)&langwell_pci_driver,
},
{ 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
};
MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);
Expand Down
Loading

0 comments on commit 4bebd6d

Please sign in to comment.