Chris Metcalf | d1cc173 | 2012-05-09 12:25:02 -0400 | [diff] [blame] | 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 | #ifndef _GXIO_USB_H_ |
| 15 | #define _GXIO_USB_H_ |
| 16 | |
David Howells | a1ce392 | 2012-10-02 18:01:25 +0100 | [diff] [blame] | 17 | #include <gxio/common.h> |
Chris Metcalf | d1cc173 | 2012-05-09 12:25:02 -0400 | [diff] [blame] | 18 | |
| 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. */ |
| 34 | typedef 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 Metcalf | 126eb08 | 2013-09-16 13:52:45 -0400 | [diff] [blame] | 56 | extern int gxio_usb_host_init(gxio_usb_host_context_t *context, int usb_index, |
Chris Metcalf | d1cc173 | 2012-05-09 12:25:02 -0400 | [diff] [blame] | 57 | 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 Metcalf | 126eb08 | 2013-09-16 13:52:45 -0400 | [diff] [blame] | 71 | extern int gxio_usb_host_destroy(gxio_usb_host_context_t *context); |
Chris Metcalf | d1cc173 | 2012-05-09 12:25:02 -0400 | [diff] [blame] | 72 | |
| 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 Metcalf | 126eb08 | 2013-09-16 13:52:45 -0400 | [diff] [blame] | 78 | extern void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t *context); |
Chris Metcalf | d1cc173 | 2012-05-09 12:25:02 -0400 | [diff] [blame] | 79 | |
| 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 Metcalf | 126eb08 | 2013-09-16 13:52:45 -0400 | [diff] [blame] | 85 | extern size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t *context); |
Chris Metcalf | d1cc173 | 2012-05-09 12:25:02 -0400 | [diff] [blame] | 86 | |
| 87 | #endif /* _GXIO_USB_H_ */ |