blob: 93c9636d2dd7879bf4867a17c65039ebd325eb93 [file] [log] [blame]
Chris Metcalfd1cc1732012-05-09 12:25:02 -04001/*
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#ifndef _GXIO_USB_H_
15#define _GXIO_USB_H_
16
David Howellsa1ce3922012-10-02 18:01:25 +010017#include <gxio/common.h>
Chris Metcalfd1cc1732012-05-09 12:25:02 -040018
19#include <hv/drv_usb_host_intf.h>
20#include <hv/iorpc.h>
21
22/*
23 *
24 * An API for manipulating general-purpose I/O pins.
25 */
26
27/*
28 *
29 * The USB shim allows access to the processor's Universal Serial Bus
30 * connections.
31 */
32
33/* A context object used to manage USB hardware resources. */
34typedef struct {
35
36 /* File descriptor for calling up to the hypervisor. */
37 int fd;
38
39 /* The VA at which our MMIO registers are mapped. */
40 char *mmio_base;
41} gxio_usb_host_context_t;
42
43/* Initialize a USB context.
44 *
45 * A properly initialized context must be obtained before any of the other
46 * gxio_usb_host routines may be used.
47 *
48 * @param context Pointer to a gxio_usb_host_context_t, which will be
49 * initialized by this routine, if it succeeds.
50 * @param usb_index Index of the USB shim to use.
51 * @param is_ehci Nonzero to use the EHCI interface; zero to use the OHCI
52 * intereface.
53 * @return Zero if the context was successfully initialized, else a
54 * GXIO_ERR_xxx error code.
55 */
Chris Metcalf126eb082013-09-16 13:52:45 -040056extern int gxio_usb_host_init(gxio_usb_host_context_t *context, int usb_index,
Chris Metcalfd1cc1732012-05-09 12:25:02 -040057 int is_ehci);
58
59/* Destroy a USB context.
60 *
61 * Once destroyed, a context may not be used with any gxio_usb_host routines
62 * other than gxio_usb_host_init(). After this routine returns, no further
63 * interrupts or signals requested on this context will be delivered. The
64 * state and configuration of the pins which had been attached to this
65 * context are unchanged by this operation.
66 *
67 * @param context Pointer to a gxio_usb_host_context_t.
68 * @return Zero if the context was successfully destroyed, else a
69 * GXIO_ERR_xxx error code.
70 */
Chris Metcalf126eb082013-09-16 13:52:45 -040071extern int gxio_usb_host_destroy(gxio_usb_host_context_t *context);
Chris Metcalfd1cc1732012-05-09 12:25:02 -040072
73/* Retrieve the address of the shim's MMIO registers.
74 *
75 * @param context Pointer to a properly initialized gxio_usb_host_context_t.
76 * @return The address of the shim's MMIO registers.
77 */
Chris Metcalf126eb082013-09-16 13:52:45 -040078extern void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t *context);
Chris Metcalfd1cc1732012-05-09 12:25:02 -040079
80/* Retrieve the length of the shim's MMIO registers.
81 *
82 * @param context Pointer to a properly initialized gxio_usb_host_context_t.
83 * @return The length of the shim's MMIO registers.
84 */
Chris Metcalf126eb082013-09-16 13:52:45 -040085extern size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t *context);
Chris Metcalfd1cc1732012-05-09 12:25:02 -040086
87#endif /* _GXIO_USB_H_ */