aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2008-11-24 15:02:21 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 13:00:03 -0500
commit3cb22d658668234edbe6dcb165501e9ef0c0a059 (patch)
treef242d930ce9fce671ee71132e2a7a5f461d93514
parent68144e0cc92125f41157ede7b060f83367bc4fe7 (diff)
USB: otg: sharable otg transceiver ops
Move otg_get/set/put_transceiver() from omap specific code to common otg.c so other upcoming drivers can share them. [ dbrownell@users.sourceforge.net: move to drivers/usb/otg, dox ] Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Felipe Balbi <me@felipebalbi.com> Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--arch/arm/plat-omap/usb.c38
-rw-r--r--drivers/usb/otg/Makefile11
-rw-r--r--drivers/usb/otg/otg.c65
3 files changed, 71 insertions, 43 deletions
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
index 2f88ca8b8f38..add0485703b5 100644
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -77,44 +77,6 @@
77 77
78/*-------------------------------------------------------------------------*/ 78/*-------------------------------------------------------------------------*/
79 79
80#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_USB_MUSB_OTG)
81
82static struct otg_transceiver *xceiv;
83
84/**
85 * otg_get_transceiver - find the (single) OTG transceiver driver
86 *
87 * Returns the transceiver driver, after getting a refcount to it; or
88 * null if there is no such transceiver. The caller is responsible for
89 * releasing that count.
90 */
91struct otg_transceiver *otg_get_transceiver(void)
92{
93 if (xceiv)
94 get_device(xceiv->dev);
95 return xceiv;
96}
97EXPORT_SYMBOL(otg_get_transceiver);
98
99void otg_put_transceiver(struct otg_transceiver *x)
100{
101 put_device(x->dev);
102}
103EXPORT_SYMBOL(otg_put_transceiver);
104
105int otg_set_transceiver(struct otg_transceiver *x)
106{
107 if (xceiv && x)
108 return -EBUSY;
109 xceiv = x;
110 return 0;
111}
112EXPORT_SYMBOL(otg_set_transceiver);
113
114#endif
115
116/*-------------------------------------------------------------------------*/
117
118#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP15XX) 80#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP15XX)
119 81
120static void omap2_usb_devconf_clear(u8 port, u32 mask) 82static void omap2_usb_devconf_clear(u8 port, u32 mask)
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
index 6c58b36ca7cf..7c80fc379e6a 100644
--- a/drivers/usb/otg/Makefile
+++ b/drivers/usb/otg/Makefile
@@ -2,12 +2,13 @@
2# OTG infrastructure and transceiver drivers 2# OTG infrastructure and transceiver drivers
3# 3#
4 4
5# infrastructure
6obj-$(CONFIG_USB_OTG_UTILS) += otg.o
7
8# transceiver drivers
5obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o 9obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
6obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 10obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
7 11
8ifeq ($(CONFIG_USB_DEBUG),y) 12ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG
9EXTRA_CFLAGS += -DDEBUG 13ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
10else ifeq ($(CONFIG_USB_GADGET_DEBUG),y)
11EXTRA_CFLAGS += -DDEBUG
12endif
13 14
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
new file mode 100644
index 000000000000..ff318fae7d4d
--- /dev/null
+++ b/drivers/usb/otg/otg.c
@@ -0,0 +1,65 @@
1/*
2 * otg.c -- USB OTG utility code
3 *
4 * Copyright (C) 2004 Texas Instruments
5 *
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.
10 */
11
12#include <linux/kernel.h>
13#include <linux/device.h>
14
15#include <linux/usb/otg.h>
16
17static struct otg_transceiver *xceiv;
18
19/**
20 * otg_get_transceiver - find the (single) OTG transceiver
21 *
22 * Returns the transceiver driver, after getting a refcount to it; or
23 * null if there is no such transceiver. The caller is responsible for
24 * calling otg_put_transceiver() to release that count.
25 *
26 * For use by USB host and peripheral drivers.
27 */
28struct otg_transceiver *otg_get_transceiver(void)
29{
30 if (xceiv)
31 get_device(xceiv->dev);
32 return xceiv;
33}
34EXPORT_SYMBOL(otg_get_transceiver);
35
36/**
37 * otg_put_transceiver - release the (single) OTG transceiver
38 * @x: the transceiver returned by otg_get_transceiver()
39 *
40 * Releases a refcount the caller received from otg_get_transceiver().
41 *
42 * For use by USB host and peripheral drivers.
43 */
44void otg_put_transceiver(struct otg_transceiver *x)
45{
46 put_device(x->dev);
47}
48EXPORT_SYMBOL(otg_put_transceiver);
49
50/**
51 * otg_set_transceiver - declare the (single) OTG transceiver
52 * @x: the USB OTG transceiver to be used; or NULL
53 *
54 * This call is exclusively for use by transceiver drivers, which
55 * coordinate the activities of drivers for host and peripheral
56 * controllers, and in some cases for VBUS current regulation.
57 */
58int otg_set_transceiver(struct otg_transceiver *x)
59{
60 if (xceiv && x)
61 return -EBUSY;
62 xceiv = x;
63 return 0;
64}
65EXPORT_SYMBOL(otg_set_transceiver);