2 * drivers/usb/otg/nop-usb-xceiv.c
4 * NOP USB transceiver for all USB transceiver which are either built-in
5 * into USB IP or which are mostly autonomous.
7 * Copyright (C) 2009 Texas Instruments Inc
8 * Author: Ajay Kumar Gupta <ajay.gupta@ti.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * This provides a "nop" transceiver for PHYs which are
26 * autonomous such as isp1504, isp1707, etc.
29 #include <linux/module.h>
30 #include <linux/platform_device.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/usb/otg.h>
34 struct nop_usb_xceiv {
35 struct otg_transceiver otg;
39 static struct platform_device *pd;
41 void usb_nop_xceiv_register(void)
45 pd = platform_device_register_simple("nop_usb_xceiv", -1, NULL, 0);
47 printk(KERN_ERR "Unable to register usb nop transceiver\n");
51 EXPORT_SYMBOL(usb_nop_xceiv_register);
53 void usb_nop_xceiv_unregister(void)
55 platform_device_unregister(pd);
57 EXPORT_SYMBOL(usb_nop_xceiv_unregister);
59 static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x)
61 return container_of(x, struct nop_usb_xceiv, otg);
64 static int nop_set_suspend(struct otg_transceiver *x, int suspend)
69 static int nop_set_peripheral(struct otg_transceiver *x,
70 struct usb_gadget *gadget)
72 struct nop_usb_xceiv *nop;
77 nop = xceiv_to_nop(x);
80 nop->otg.gadget = NULL;
84 nop->otg.gadget = gadget;
85 nop->otg.state = OTG_STATE_B_IDLE;
89 static int nop_set_host(struct otg_transceiver *x, struct usb_bus *host)
91 struct nop_usb_xceiv *nop;
96 nop = xceiv_to_nop(x);
103 nop->otg.host = host;
107 static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
109 struct nop_usb_xceiv *nop;
112 nop = kzalloc(sizeof *nop, GFP_KERNEL);
116 nop->dev = &pdev->dev;
117 nop->otg.dev = nop->dev;
118 nop->otg.label = "nop-xceiv";
119 nop->otg.state = OTG_STATE_UNDEFINED;
120 nop->otg.set_host = nop_set_host;
121 nop->otg.set_peripheral = nop_set_peripheral;
122 nop->otg.set_suspend = nop_set_suspend;
124 err = otg_set_transceiver(&nop->otg);
126 dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
131 platform_set_drvdata(pdev, nop);
139 static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
141 struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
143 otg_set_transceiver(NULL);
145 platform_set_drvdata(pdev, NULL);
151 static struct platform_driver nop_usb_xceiv_driver = {
152 .probe = nop_usb_xceiv_probe,
153 .remove = __devexit_p(nop_usb_xceiv_remove),
155 .name = "nop_usb_xceiv",
156 .owner = THIS_MODULE,
160 static int __init nop_usb_xceiv_init(void)
162 return platform_driver_register(&nop_usb_xceiv_driver);
164 subsys_initcall(nop_usb_xceiv_init);
166 static void __exit nop_usb_xceiv_exit(void)
168 platform_driver_unregister(&nop_usb_xceiv_driver);
170 module_exit(nop_usb_xceiv_exit);
172 MODULE_ALIAS("platform:nop_usb_xceiv");
173 MODULE_AUTHOR("Texas Instruments Inc");
174 MODULE_DESCRIPTION("NOP USB Transceiver driver");
175 MODULE_LICENSE("GPL");