2 * otg.c -- USB OTG utility code
4 * Copyright (C) 2004 Texas Instruments
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/kernel.h>
13 #include <linux/export.h>
14 #include <linux/device.h>
16 #include <linux/usb/otg.h>
18 static struct otg_transceiver
*xceiv
;
21 * otg_get_transceiver - find the (single) OTG transceiver
23 * Returns the transceiver driver, after getting a refcount to it; or
24 * null if there is no such transceiver. The caller is responsible for
25 * calling otg_put_transceiver() to release that count.
27 * For use by USB host and peripheral drivers.
29 struct otg_transceiver
*otg_get_transceiver(void)
32 get_device(xceiv
->dev
);
35 EXPORT_SYMBOL(otg_get_transceiver
);
38 * otg_put_transceiver - release the (single) OTG transceiver
39 * @x: the transceiver returned by otg_get_transceiver()
41 * Releases a refcount the caller received from otg_get_transceiver().
43 * For use by USB host and peripheral drivers.
45 void otg_put_transceiver(struct otg_transceiver
*x
)
50 EXPORT_SYMBOL(otg_put_transceiver
);
53 * otg_set_transceiver - declare the (single) OTG transceiver
54 * @x: the USB OTG transceiver to be used; or NULL
56 * This call is exclusively for use by transceiver drivers, which
57 * coordinate the activities of drivers for host and peripheral
58 * controllers, and in some cases for VBUS current regulation.
60 int otg_set_transceiver(struct otg_transceiver
*x
)
67 EXPORT_SYMBOL(otg_set_transceiver
);
69 const char *otg_state_string(enum usb_otg_state state
)
72 case OTG_STATE_A_IDLE
:
74 case OTG_STATE_A_WAIT_VRISE
:
75 return "a_wait_vrise";
76 case OTG_STATE_A_WAIT_BCON
:
78 case OTG_STATE_A_HOST
:
80 case OTG_STATE_A_SUSPEND
:
82 case OTG_STATE_A_PERIPHERAL
:
83 return "a_peripheral";
84 case OTG_STATE_A_WAIT_VFALL
:
85 return "a_wait_vfall";
86 case OTG_STATE_A_VBUS_ERR
:
88 case OTG_STATE_B_IDLE
:
90 case OTG_STATE_B_SRP_INIT
:
92 case OTG_STATE_B_PERIPHERAL
:
93 return "b_peripheral";
94 case OTG_STATE_B_WAIT_ACON
:
96 case OTG_STATE_B_HOST
:
102 EXPORT_SYMBOL(otg_state_string
);