提交 0949e99b 编写于 作者: F Felipe Balbi

usb: dwc3: fetch mode of operation from HW

There's no need to add driver_data for something
we can fetch from HW.

This also makes our id_table unnecessary - at least
for now -, so we also remove it on the same patch.
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 9f622b2a
...@@ -325,15 +325,17 @@ static void dwc3_core_exit(struct dwc3 *dwc) ...@@ -325,15 +325,17 @@ static void dwc3_core_exit(struct dwc3 *dwc)
static int __devinit dwc3_probe(struct platform_device *pdev) static int __devinit dwc3_probe(struct platform_device *pdev)
{ {
const struct platform_device_id *id = platform_get_device_id(pdev);
struct resource *res; struct resource *res;
struct dwc3 *dwc; struct dwc3 *dwc;
void __iomem *regs;
unsigned int features = id->driver_data;
int ret = -ENOMEM; int ret = -ENOMEM;
int irq; int irq;
void __iomem *regs;
void *mem; void *mem;
u8 mode;
mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL);
if (!mem) { if (!mem) {
dev_err(&pdev->dev, "not enough memory\n"); dev_err(&pdev->dev, "not enough memory\n");
...@@ -396,13 +398,22 @@ static int __devinit dwc3_probe(struct platform_device *pdev) ...@@ -396,13 +398,22 @@ static int __devinit dwc3_probe(struct platform_device *pdev)
goto err3; goto err3;
} }
if (features & DWC3_HAS_PERIPHERAL) { mode = DWC3_MODE(dwc->hwparams.hwparams0);
switch (mode) {
case DWC3_MODE_DRD:
case DWC3_MODE_DEVICE:
ret = dwc3_gadget_init(dwc); ret = dwc3_gadget_init(dwc);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to initialized gadget\n"); dev_err(&pdev->dev, "failed to initialize gadget\n");
goto err4; goto err4;
} }
break;
default:
dev_err(&pdev->dev, "Unsupported mode of operation %d\n", mode);
goto err4;
} }
dwc->mode = mode;
ret = dwc3_debugfs_init(dwc); ret = dwc3_debugfs_init(dwc);
if (ret) { if (ret) {
...@@ -415,8 +426,15 @@ static int __devinit dwc3_probe(struct platform_device *pdev) ...@@ -415,8 +426,15 @@ static int __devinit dwc3_probe(struct platform_device *pdev)
return 0; return 0;
err5: err5:
if (features & DWC3_HAS_PERIPHERAL) switch (mode) {
case DWC3_MODE_DRD:
case DWC3_MODE_DEVICE:
dwc3_gadget_exit(dwc); dwc3_gadget_exit(dwc);
break;
default:
/* do nothing */
break;
}
err4: err4:
dwc3_core_exit(dwc); dwc3_core_exit(dwc);
...@@ -436,10 +454,8 @@ static int __devinit dwc3_probe(struct platform_device *pdev) ...@@ -436,10 +454,8 @@ static int __devinit dwc3_probe(struct platform_device *pdev)
static int __devexit dwc3_remove(struct platform_device *pdev) static int __devexit dwc3_remove(struct platform_device *pdev)
{ {
const struct platform_device_id *id = platform_get_device_id(pdev);
struct dwc3 *dwc = platform_get_drvdata(pdev); struct dwc3 *dwc = platform_get_drvdata(pdev);
struct resource *res; struct resource *res;
unsigned int features = id->driver_data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -448,8 +464,15 @@ static int __devexit dwc3_remove(struct platform_device *pdev) ...@@ -448,8 +464,15 @@ static int __devexit dwc3_remove(struct platform_device *pdev)
dwc3_debugfs_exit(dwc); dwc3_debugfs_exit(dwc);
if (features & DWC3_HAS_PERIPHERAL) switch (dwc->mode) {
case DWC3_MODE_DRD:
case DWC3_MODE_DEVICE:
dwc3_gadget_exit(dwc); dwc3_gadget_exit(dwc);
break;
default:
/* do nothing */
break;
}
dwc3_core_exit(dwc); dwc3_core_exit(dwc);
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
...@@ -459,28 +482,12 @@ static int __devexit dwc3_remove(struct platform_device *pdev) ...@@ -459,28 +482,12 @@ static int __devexit dwc3_remove(struct platform_device *pdev)
return 0; return 0;
} }
static const struct platform_device_id dwc3_id_table[] __devinitconst = {
{
.name = "dwc3-omap",
.driver_data = (DWC3_HAS_PERIPHERAL
| DWC3_HAS_XHCI
| DWC3_HAS_OTG),
},
{
.name = "dwc3-pci",
.driver_data = DWC3_HAS_PERIPHERAL,
},
{ }, /* Terminating Entry */
};
MODULE_DEVICE_TABLE(platform, dwc3_id_table);
static struct platform_driver dwc3_driver = { static struct platform_driver dwc3_driver = {
.probe = dwc3_probe, .probe = dwc3_probe,
.remove = __devexit_p(dwc3_remove), .remove = __devexit_p(dwc3_remove),
.driver = { .driver = {
.name = "dwc3", .name = "dwc3",
}, },
.id_table = dwc3_id_table,
}; };
MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
......
...@@ -536,6 +536,15 @@ struct dwc3_hwparams { ...@@ -536,6 +536,15 @@ struct dwc3_hwparams {
u32 hwparams8; u32 hwparams8;
}; };
/* HWPARAMS0 */
#define DWC3_MODE(n) ((n) & 0x7)
#define DWC3_MODE_DEVICE 0
#define DWC3_MODE_HOST 1
#define DWC3_MODE_DRD 2
#define DWC3_MODE_HUB 3
/* HWPARAMS1 */
#define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15)
/** /**
...@@ -560,6 +569,7 @@ struct dwc3_hwparams { ...@@ -560,6 +569,7 @@ struct dwc3_hwparams {
* @num_event_buffers: calculated number of event buffers * @num_event_buffers: calculated number of event buffers
* @maximum_speed: maximum speed requested (mainly for testing purposes) * @maximum_speed: maximum speed requested (mainly for testing purposes)
* @revision: revision register contents * @revision: revision register contents
* @mode: mode of operation
* @is_selfpowered: true when we are selfpowered * @is_selfpowered: true when we are selfpowered
* @three_stage_setup: set if we perform a three phase setup * @three_stage_setup: set if we perform a three phase setup
* @ep0_status_pending: ep0 status response without a req is pending * @ep0_status_pending: ep0 status response without a req is pending
...@@ -602,6 +612,7 @@ struct dwc3 { ...@@ -602,6 +612,7 @@ struct dwc3 {
u32 num_event_buffers; u32 num_event_buffers;
u32 maximum_speed; u32 maximum_speed;
u32 revision; u32 revision;
u32 mode;
#define DWC3_REVISION_173A 0x5533173a #define DWC3_REVISION_173A 0x5533173a
#define DWC3_REVISION_175A 0x5533175a #define DWC3_REVISION_175A 0x5533175a
......
...@@ -236,7 +236,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) ...@@ -236,7 +236,7 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev)
goto err1; goto err1;
} }
dwc3 = platform_device_alloc("dwc3-omap", -1); dwc3 = platform_device_alloc("dwc3", -1);
if (!dwc3) { if (!dwc3) {
dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); dev_err(&pdev->dev, "couldn't allocate dwc3 device\n");
goto err2; goto err2;
......
...@@ -118,7 +118,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, ...@@ -118,7 +118,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci,
if (devid < 0) if (devid < 0)
goto err2; goto err2;
dwc3 = platform_device_alloc("dwc3-pci", devid); dwc3 = platform_device_alloc("dwc3", devid);
if (!dwc3) { if (!dwc3) {
dev_err(&pci->dev, "couldn't allocate dwc3 device\n"); dev_err(&pci->dev, "couldn't allocate dwc3 device\n");
goto err3; goto err3;
...@@ -196,7 +196,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { ...@@ -196,7 +196,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = {
MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
static struct pci_driver dwc3_pci_driver = { static struct pci_driver dwc3_pci_driver = {
.name = "pci-dwc3", .name = "dwc3-pci",
.id_table = dwc3_pci_id_table, .id_table = dwc3_pci_id_table,
.probe = dwc3_pci_probe, .probe = dwc3_pci_probe,
.remove = __devexit_p(dwc3_pci_remove), .remove = __devexit_p(dwc3_pci_remove),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册