Patrick Georgi | 7f43dc1 | 2010-09-25 17:01:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the libpayload project. |
| 3 | * |
| 4 | * Copyright (C) 2010 coresystems GmbH |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * 3. The name of the author may not be used to endorse or promote products |
| 15 | * derived from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #ifndef __EHCI_PRIVATE_H |
| 31 | #define __EHCI_PRIVATE_H |
| 32 | |
| 33 | #include <pci.h> |
| 34 | #include <usb/usb.h> |
| 35 | |
| 36 | #define USBBASE 0x10 |
| 37 | #define FLADJ 0x61 |
| 38 | #define FLADJ_framelength(x) (((x)-59488)/16) |
| 39 | |
Patrick Georgi | 8fa2787 | 2011-11-24 13:19:57 +0100 | [diff] [blame] | 40 | typedef volatile u32 portsc_t; |
| 41 | #define P_CURR_CONN_STATUS (1 << 0) |
| 42 | #define P_CONN_STATUS_CHANGE (1 << 1) |
| 43 | #define P_PORT_ENABLE (1 << 2) |
| 44 | #define P_PORT_RESET (1 << 8) |
| 45 | #define P_LINE_STATUS (3 << 10) |
| 46 | #define P_LINE_STATUS_LOWSPEED (1 << 10) |
| 47 | #define P_PP (1 << 12) |
| 48 | #define P_PORT_OWNER (1 << 13) |
Patrick Georgi | 7f43dc1 | 2010-09-25 17:01:13 +0000 | [diff] [blame] | 49 | |
Patrick Georgi | 8bbdb61 | 2011-08-16 15:47:15 +0200 | [diff] [blame] | 50 | typedef volatile struct { |
Patrick Georgi | 8fa2787 | 2011-11-24 13:19:57 +0100 | [diff] [blame] | 51 | #define HCS_NPORTS_MASK 0xf |
Patrick Georgi | 7f43dc1 | 2010-09-25 17:01:13 +0000 | [diff] [blame] | 52 | u8 caplength; |
| 53 | u8 res1; |
| 54 | u16 hciversion; |
Patrick Georgi | 8fa2787 | 2011-11-24 13:19:57 +0100 | [diff] [blame] | 55 | u32 hcsparams; |
| 56 | u32 hccparams; |
| 57 | u64 hcsp_portroute; |
Patrick Georgi | 7f43dc1 | 2010-09-25 17:01:13 +0000 | [diff] [blame] | 58 | } __attribute__ ((packed)) hc_cap_t; |
| 59 | |
Patrick Georgi | 8bbdb61 | 2011-08-16 15:47:15 +0200 | [diff] [blame] | 60 | typedef volatile struct { |
Patrick Georgi | 8fa2787 | 2011-11-24 13:19:57 +0100 | [diff] [blame] | 61 | u32 usbcmd; |
| 62 | #define HC_OP_RS 1 |
| 63 | #define HC_OP_ASYNC_SCHED_EN_SHIFT 5 |
| 64 | #define HC_OP_ASYNC_SCHED_EN (1 << HC_OP_ASYNC_SCHED_EN_SHIFT) |
| 65 | u32 usbsts; |
| 66 | #define HC_OP_ASYNC_SCHED_STAT_SHIFT 15 |
| 67 | #define HC_OP_ASYNC_SCHED_STAT (1 << HC_OP_ASYNC_SCHED_STAT_SHIFT) |
| 68 | u32 usbintr; |
Patrick Georgi | 7f43dc1 | 2010-09-25 17:01:13 +0000 | [diff] [blame] | 69 | u32 frindex; |
| 70 | u32 ctrldssegment; |
| 71 | u32 periodiclistbase; |
| 72 | u32 asynclistaddr; |
| 73 | u8 res1[0x3f-0x1c]; |
| 74 | u32 configflag; |
| 75 | portsc_t portsc[0]; |
| 76 | } hc_op_t; |
| 77 | |
Patrick Georgi | 8bbdb61 | 2011-08-16 15:47:15 +0200 | [diff] [blame] | 78 | typedef volatile struct { |
Patrick Georgi | 8fa2787 | 2011-11-24 13:19:57 +0100 | [diff] [blame] | 79 | #define QTD_TERMINATE 1 |
| 80 | u32 next_qtd; |
| 81 | u32 alt_next_qtd; |
| 82 | u32 token; |
| 83 | #define QTD_STATUS_MASK 0xff |
Patrick Georgi | 3e0bd19 | 2012-01-31 14:37:59 +0100 | [diff] [blame^] | 84 | #define QTD_HALTED (1 << 6) |
| 85 | #define QTD_ACTIVE (1 << 7) |
Patrick Georgi | 8fa2787 | 2011-11-24 13:19:57 +0100 | [diff] [blame] | 86 | #define QTD_PID_SHIFT 8 |
| 87 | #define QTD_PID_MASK (3 << QTD_PID_SHIFT) |
| 88 | #define QTD_CERR_SHIFT 10 |
| 89 | #define QTD_CERR_MASK (3 << QTD_CERR_SHIFT) |
| 90 | #define QTD_CPAGE_SHIFT 12 |
| 91 | #define QTD_CPAGE_MASK (7 << QTD_CPAGE_SHIFT) |
| 92 | #define QTD_TOTAL_LEN_SHIFT 16 |
| 93 | #define QTD_TOTAL_LEN_MASK (((1<<15)-1) << QTD_TOTAL_LEN_SHIFT) |
| 94 | #define QTD_TOGGLE_SHIFT 31 |
| 95 | #define QTD_TOGGLE_MASK (1 << 31) |
| 96 | #define QTD_TOGGLE_DATA0 0 |
| 97 | #define QTD_TOGGLE_DATA1 (1 << QTD_TOGGLE_SHIFT) |
| 98 | u32 bufptrs[5]; |
Patrick Georgi | 7f43dc1 | 2010-09-25 17:01:13 +0000 | [diff] [blame] | 99 | u32 bufptrs64[5]; |
| 100 | } __attribute__ ((packed)) qtd_t; |
| 101 | |
Patrick Georgi | 8bbdb61 | 2011-08-16 15:47:15 +0200 | [diff] [blame] | 102 | typedef volatile struct { |
Patrick Georgi | 8fa2787 | 2011-11-24 13:19:57 +0100 | [diff] [blame] | 103 | u32 horiz_link_ptr; |
| 104 | #define QH_TERMINATE 1 |
| 105 | #define QH_iTD (0<<1) |
| 106 | #define QH_QH (1<<1) |
| 107 | #define QH_siTD (2<<1) |
| 108 | #define QH_FSTN (3<<1) |
| 109 | u32 epchar; |
| 110 | #define QH_EP_SHIFT 8 |
| 111 | #define QH_EPS_SHIFT 12 |
| 112 | #define QH_DTC_SHIFT 14 |
| 113 | #define QH_RECLAIM_HEAD_SHIFT 15 |
| 114 | #define QH_MPS_SHIFT 16 |
| 115 | #define QH_NON_HS_CTRL_EP_SHIFT 27 |
| 116 | #define QH_NAK_CNT_SHIFT 28 |
| 117 | u32 epcaps; |
| 118 | #define QH_PIPE_MULTIPLIER_SHIFT 30 |
Patrick Georgi | 7f43dc1 | 2010-09-25 17:01:13 +0000 | [diff] [blame] | 119 | volatile u32 current_td_ptr; |
| 120 | volatile qtd_t td; |
| 121 | } ehci_qh_t; |
| 122 | |
| 123 | typedef struct ehci { |
| 124 | hc_cap_t *capabilities; |
| 125 | hc_op_t *operation; |
| 126 | } ehci_t; |
| 127 | |
| 128 | |
| 129 | #define EHCI_INST(controller) ((ehci_t*)((controller)->instance)) |
| 130 | |
| 131 | #endif |