aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-02-10 23:45:00 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-03-18 11:19:11 -0400
commitba1aff67f99a219b0c56bf7f10cea2c41cbd0583 (patch)
treea7a036fecc4f95331bfa144fad833ac170adb94e
parent78f0357ec8baa1ffe9c14b81f88cb0f3a5e1c15a (diff)
chipidea: pci: register nop PHY
Since PHY for ChipIdea is optional (not all SoCs having PHY for ChipIdea should be programmed), we register 'nop' PHY for platforms that do not have programmable PHY. Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/chipidea/ci_hdrc_pci.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c
index 4df669437211..773d150512fa 100644
--- a/drivers/usb/chipidea/ci_hdrc_pci.c
+++ b/drivers/usb/chipidea/ci_hdrc_pci.c
@@ -16,10 +16,16 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/usb/gadget.h> 17#include <linux/usb/gadget.h>
18#include <linux/usb/chipidea.h> 18#include <linux/usb/chipidea.h>
19#include <linux/usb/usb_phy_generic.h>
19 20
20/* driver name */ 21/* driver name */
21#define UDC_DRIVER_NAME "ci_hdrc_pci" 22#define UDC_DRIVER_NAME "ci_hdrc_pci"
22 23
24struct ci_hdrc_pci {
25 struct platform_device *ci;
26 struct platform_device *phy;
27};
28
23/****************************************************************************** 29/******************************************************************************
24 * PCI block 30 * PCI block
25 *****************************************************************************/ 31 *****************************************************************************/
@@ -52,7 +58,7 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
52 const struct pci_device_id *id) 58 const struct pci_device_id *id)
53{ 59{
54 struct ci_hdrc_platform_data *platdata = (void *)id->driver_data; 60 struct ci_hdrc_platform_data *platdata = (void *)id->driver_data;
55 struct platform_device *plat_ci; 61 struct ci_hdrc_pci *ci;
56 struct resource res[3]; 62 struct resource res[3];
57 int retval = 0, nres = 2; 63 int retval = 0, nres = 2;
58 64
@@ -61,6 +67,10 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
61 return -ENODEV; 67 return -ENODEV;
62 } 68 }
63 69
70 ci = devm_kzalloc(&pdev->dev, sizeof(*ci), GFP_KERNEL);
71 if (!ci)
72 return -ENOMEM;
73
64 retval = pcim_enable_device(pdev); 74 retval = pcim_enable_device(pdev);
65 if (retval) 75 if (retval)
66 return retval; 76 return retval;
@@ -73,6 +83,11 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
73 pci_set_master(pdev); 83 pci_set_master(pdev);
74 pci_try_set_mwi(pdev); 84 pci_try_set_mwi(pdev);
75 85
86 /* register a nop PHY */
87 ci->phy = usb_phy_generic_register();
88 if (!ci->phy)
89 return -ENOMEM;
90
76 memset(res, 0, sizeof(res)); 91 memset(res, 0, sizeof(res));
77 res[0].start = pci_resource_start(pdev, 0); 92 res[0].start = pci_resource_start(pdev, 0);
78 res[0].end = pci_resource_end(pdev, 0); 93 res[0].end = pci_resource_end(pdev, 0);
@@ -80,13 +95,14 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
80 res[1].start = pdev->irq; 95 res[1].start = pdev->irq;
81 res[1].flags = IORESOURCE_IRQ; 96 res[1].flags = IORESOURCE_IRQ;
82 97
83 plat_ci = ci_hdrc_add_device(&pdev->dev, res, nres, platdata); 98 ci->ci = ci_hdrc_add_device(&pdev->dev, res, nres, platdata);
84 if (IS_ERR(plat_ci)) { 99 if (IS_ERR(ci->ci)) {
85 dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n"); 100 dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n");
86 return PTR_ERR(plat_ci); 101 usb_phy_generic_unregister(ci->phy);
102 return PTR_ERR(ci->ci);
87 } 103 }
88 104
89 pci_set_drvdata(pdev, plat_ci); 105 pci_set_drvdata(pdev, ci);
90 106
91 return 0; 107 return 0;
92} 108}
@@ -101,9 +117,10 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
101 */ 117 */
102static void ci_hdrc_pci_remove(struct pci_dev *pdev) 118static void ci_hdrc_pci_remove(struct pci_dev *pdev)
103{ 119{
104 struct platform_device *plat_ci = pci_get_drvdata(pdev); 120 struct ci_hdrc_pci *ci = pci_get_drvdata(pdev);
105 121
106 ci_hdrc_remove_device(plat_ci); 122 ci_hdrc_remove_device(ci->ci);
123 usb_phy_generic_unregister(ci->phy);
107} 124}
108 125
109/** 126/**