usb: xceiv: nop: let it work as USB2 and USB3 phy
authorFelipe Balbi <balbi@ti.com>
Thu, 19 Jul 2012 10:38:06 +0000 (13:38 +0300)
committerFelipe Balbi <balbi@ti.com>
Fri, 3 Aug 2012 06:36:19 +0000 (09:36 +0300)
We add a platform_data to pass the desired mode
for the nop-xceiv so it can work on USB2 and USB3
modes.

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/otg/nop-usb-xceiv.c
include/linux/usb/nop-usb-xceiv.h

index 3c3ad6bb307c0eb6b1974940b2d230b5f8741f5e..e52e35e7adaf9bea0b85a3b6ca3b1790a1c4bda1 100644 (file)
@@ -95,7 +95,9 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
 
 static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
 {
+       struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data;
        struct nop_usb_xceiv    *nop;
+       enum usb_phy_type       type = USB_PHY_TYPE_USB2;
        int err;
 
        nop = kzalloc(sizeof *nop, GFP_KERNEL);
@@ -108,6 +110,9 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
+       if (pdata)
+               type = pdata->type;
+
        nop->dev                = &pdev->dev;
        nop->phy.dev            = nop->dev;
        nop->phy.label          = "nop-xceiv";
@@ -118,7 +123,7 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
        nop->phy.otg->set_host          = nop_set_host;
        nop->phy.otg->set_peripheral    = nop_set_peripheral;
 
-       err = usb_add_phy(&nop->phy, USB_PHY_TYPE_USB2);
+       err = usb_add_phy(&nop->phy, type);
        if (err) {
                dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
                        err);
index ecc7562a38cc469675b1280ece9ebf22e8ff70fe..28884c7174112d7ede78d0283d9cba35802eddaa 100644 (file)
@@ -1,6 +1,12 @@
 #ifndef __LINUX_USB_NOP_XCEIV_H
 #define __LINUX_USB_NOP_XCEIV_H
 
+#include <linux/usb/otg.h>
+
+struct nop_usb_xceiv_platform_data {
+       enum usb_phy_type type;
+};
+
 #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE))
 /* sometimes transceivers are accessed only through e.g. ULPI */
 extern void usb_nop_xceiv_register(void);