Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
arch
tile
gxio
usb_host.c
Go to the documentation of this file.
1
/*
2
* Copyright 2012 Tilera Corporation. All Rights Reserved.
3
*
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation, version 2.
7
*
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11
* NON INFRINGEMENT. See the GNU General Public License for
12
* more details.
13
*/
14
15
/*
16
*
17
* Implementation of USB gxio calls.
18
*/
19
20
#include <
linux/io.h
>
21
#include <linux/errno.h>
22
#include <linux/module.h>
23
24
#include <
gxio/iorpc_globals.h
>
25
#include <
gxio/iorpc_usb_host.h
>
26
#include <
gxio/kiorpc.h
>
27
#include <
gxio/usb_host.h
>
28
29
int
gxio_usb_host_init
(
gxio_usb_host_context_t
*
context
,
int
usb_index,
30
int
is_ehci)
31
{
32
char
file
[32];
33
int
fd
;
34
35
if
(is_ehci)
36
snprintf
(file,
sizeof
(file),
"usb_host/%d/iorpc/ehci"
,
37
usb_index);
38
else
39
snprintf
(file,
sizeof
(file),
"usb_host/%d/iorpc/ohci"
,
40
usb_index);
41
42
fd =
hv_dev_open
((
HV_VirtAddr
) file, 0);
43
if
(fd < 0) {
44
if
(fd >=
GXIO_ERR_MIN
&& fd <=
GXIO_ERR_MAX
)
45
return
fd
;
46
else
47
return
-
ENODEV
;
48
}
49
50
context->
fd
=
fd
;
51
52
// Map in the MMIO space.
53
context->
mmio_base
=
54
(
void
__force
*)
iorpc_ioremap
(fd, 0,
HV_USB_HOST_MMIO_SIZE
);
55
56
if
(context->
mmio_base
==
NULL
) {
57
hv_dev_close
(context->
fd
);
58
return
-
ENODEV
;
59
}
60
61
return
0;
62
}
63
64
EXPORT_SYMBOL_GPL
(
gxio_usb_host_init
);
65
66
int
gxio_usb_host_destroy
(
gxio_usb_host_context_t
*
context
)
67
{
68
iounmap
((
void
__force
__iomem
*)(context->
mmio_base
));
69
hv_dev_close
(context->
fd
);
70
71
context->
mmio_base
=
NULL
;
72
context->
fd
= -1;
73
74
return
0;
75
}
76
77
EXPORT_SYMBOL_GPL
(
gxio_usb_host_destroy
);
78
79
void
*
gxio_usb_host_get_reg_start
(
gxio_usb_host_context_t
*
context
)
80
{
81
return
context->
mmio_base
;
82
}
83
84
EXPORT_SYMBOL_GPL
(
gxio_usb_host_get_reg_start
);
85
86
size_t
gxio_usb_host_get_reg_len
(
gxio_usb_host_context_t
*
context
)
87
{
88
return
HV_USB_HOST_MMIO_SIZE
;
89
}
90
91
EXPORT_SYMBOL_GPL
(
gxio_usb_host_get_reg_len
);
Generated on Thu Jan 10 2013 13:18:56 for Linux Kernel by
1.8.2