summaryrefslogtreecommitdiff
path: root/drivers/usb/host/isp1763-otg.c
blob: a951c3381245512c196d9e1561ee0803d267d261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* 
* Copyright (C) ST-Ericsson AP Pte Ltd 2010 
*
* ISP1763 Linux OTG Controller driver : host
* 
* This program is free software; you can redistribute it and/or modify it under the terms of 
* the GNU General Public License as published by the Free Software Foundation; version 
* 2 of the License. 
* 
* This program is distributed in the hope that it will be useful, but WITHOUT ANY  
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  
* FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more  
* details. 
* 
* You should have received a copy of the GNU General Public License 
* along with this program; if not, write to the Free Software 
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
* 
* This is a host controller driver file. OTG related events are handled here.
* 
* Author : wired support <wired.support@stericsson.com>
*
*/


/*hub device which connected with root port*/
struct usb_device *hubdev = 0;
/* hub interrupt urb*/
struct urb *huburb;

/*return otghub from here*/
struct usb_device *
phci_register_otg_device(struct isp1763_dev *dev)
{
	printk("OTG dev %x %d\n",(u32) hubdev, hubdev->devnum);
	if (hubdev && hubdev->devnum >= 0x2) {
		return hubdev;
	}

	return NULL;
}
EXPORT_SYMBOL(phci_register_otg_device);

/*suspend the otg port(0)
 * needed when port is switching
 * from host to device
 * */
int
phci_suspend_otg_port(struct isp1763_dev *dev, u32 command)
{
	int status = 0;
	hubdev->otgstate = USB_OTG_SUSPEND;
	if (huburb->status == -EINPROGRESS) {
		huburb->status = 0;
	}

	huburb->status = 0;
	huburb->complete(huburb);
	return status;
}
EXPORT_SYMBOL(phci_suspend_otg_port);

/*set the flag to enumerate the device*/
int
phci_enumerate_otg_port(struct isp1763_dev *dev, u32 command)
{
	/*set the flag to enumerate */
	/*connect change interrupt will happen from
	 * phci_intl_worker only
	 * */
	hubdev->otgstate = USB_OTG_ENUMERATE;
	if (huburb->status == -EINPROGRESS) {
		huburb->status = 0;
	}
	/*complete the urb */

	huburb->complete(huburb);

	/*reset the otghub urb status */
	huburb->status = -EINPROGRESS;
	return 0;
}
EXPORT_SYMBOL(phci_enumerate_otg_port);

/*host controller resume sequence at otg port*/
int
phci_resume_otg_port(struct isp1763_dev *dev, u32 command)
{
	printk("Resume is called\n");
	hubdev->otgstate = USB_OTG_RESUME;
	if (huburb->status == -EINPROGRESS) {
		huburb->status = 0;
	}
	/*complete the urb */

	huburb->complete(huburb);

	/*reset the otghub urb status */
	huburb->status = -EINPROGRESS;
	return 0;
}
EXPORT_SYMBOL(phci_resume_otg_port);
/*host controller remote wakeup sequence at otg port*/
int
phci_remotewakeup(struct isp1763_dev *dev)
{
    printk("phci_remotewakeup_otg_port is called\n");
    hubdev->otgstate = USB_OTG_REMOTEWAKEUP;
    if(huburb->status == -EINPROGRESS)
        huburb->status = 0;
    /*complete the urb*/
#if ((defined LINUX_269) || defined (LINUX_2611))
    huburb->complete(huburb,NULL);      
#else
	 huburb->complete(huburb);
#endif
    /*reset the otghub urb status*/
    huburb->status = -EINPROGRESS;
    return 0;
}
EXPORT_SYMBOL(phci_remotewakeup);

/*host controller wakeup sequence at otg port*/
int
phci_resume_wakeup(struct isp1763_dev *dev)
{
    printk("phci_wakeup_otg_port is called\n");
#if 0
    hubdev->otgstate = USB_OTG_WAKEUP_ALL;
    if(huburb->status == -EINPROGRESS)
#endif
        huburb->status = 0;
    /*complete the urb*/
#if ((defined LINUX_269) || defined (LINUX_2611))
    huburb->complete(huburb,NULL);      
#else
	 huburb->complete(huburb);
#endif
    /*reset the otghub urb status*/
    huburb->status = -EINPROGRESS;
    return 0;
}
EXPORT_SYMBOL(phci_resume_wakeup);

struct isp1763_driver *host_driver;
struct isp1763_driver *device_driver;

void
pehci_delrhtimer(struct isp1763_dev *dev)
{

	struct usb_hcd *usb_hcd =
		container_of(huburb->dev->parent->bus, struct usb_hcd, self);
	del_timer_sync(&usb_hcd->rh_timer);
	del_timer(&usb_hcd->rh_timer);

}
EXPORT_SYMBOL(pehci_delrhtimer);

int
pehci_Deinitialize(struct isp1763_dev *dev)
{
	dev -= 2;
	if (dev->index == 0) {
		if (dev->driver) {
			if (dev->driver->powerdown) {
				dev->driver->powerdown(dev);
			}
		}
	}
return 0;
}
EXPORT_SYMBOL(pehci_Deinitialize);

int
pehci_Reinitialize(struct isp1763_dev *dev)
{

	dev -= 2;
	if (dev->index == 0) {
		if(dev->driver->powerup){
			dev->driver->powerup(dev);
		}
	}
return 0;
}
EXPORT_SYMBOL(pehci_Reinitialize);