ohci.h

00001 /*
00002        ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader.
00003        ohci hardware support
00004 
00005 Copyright (C) 2009     Bernhard Urban <lewurm@gmx.net>
00006 Copyright (C) 2009     Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
00007 
00008 # This code is licensed to you under the terms of the GNU GPL, version 2;
00009 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
00010 */
00011 
00012 #ifndef __OHCI_H__
00013 #define __OHCI_H__
00014 
00015 #include <types.h>
00016 
00017 /* stolen from drivers/usb/host/ohci.h (linux-kernel) :) */
00018 
00019 /* OHCI CONTROL AND STATUS REGISTER MASKS */
00020 
00021 /*
00022  * HcControl (control) register masks
00023  */
00024 #define OHCI_CTRL_CBSR (3 << 0)        /* control/bulk service ratio */
00025 #define OHCI_CTRL_PLE  (1 << 2)        /* periodic list enable */
00026 #define OHCI_CTRL_IE   (1 << 3)        /* isochronous enable */
00027 #define OHCI_CTRL_CLE  (1 << 4)        /* control list enable */
00028 #define OHCI_CTRL_BLE  (1 << 5)        /* bulk list enable */
00029 #define OHCI_CTRL_HCFS (3 << 6)        /* host controller functional state */
00030 #define OHCI_CTRL_IR   (1 << 8)        /* interrupt routing */
00031 #define OHCI_CTRL_RWC  (1 << 9)        /* remote wakeup connected */
00032 #define OHCI_CTRL_RWE  (1 << 10)       /* remote wakeup enable */
00033 
00034 /* pre-shifted values for HCFS */
00035 #define OHCI_USB_RESET (0 << 6)
00036 #define OHCI_USB_RESUME        (1 << 6)
00037 #define OHCI_USB_OPER  (2 << 6)
00038 #define OHCI_USB_SUSPEND       (3 << 6)
00039 
00040 /*
00041  * HcCommandStatus (cmdstatus) register masks
00042  */
00043 #define OHCI_HCR       (1 << 0)        /* host controller reset */
00044 #define OHCI_CLF       (1 << 1)        /* control list filled */
00045 #define OHCI_BLF       (1 << 2)        /* bulk list filled */
00046 #define OHCI_OCR       (1 << 3)        /* ownership change request */
00047 #define OHCI_SOC       (3 << 16)       /* scheduling overrun count */
00048 
00049 /*
00050  * masks used with interrupt registers:
00051  * HcInterruptStatus (intrstatus)
00052  * HcInterruptEnable (intrenable)
00053  * HcInterruptDisable (intrdisable)
00054  */
00055 #define OHCI_INTR_SO   (1 << 0)        /* scheduling overrun */
00056 #define OHCI_INTR_WDH  (1 << 1)        /* writeback of done_head */
00057 #define OHCI_INTR_SF   (1 << 2)        /* start frame */
00058 #define OHCI_INTR_RD   (1 << 3)        /* resume detect */
00059 #define OHCI_INTR_UE   (1 << 4)        /* unrecoverable error */
00060 #define OHCI_INTR_FNO  (1 << 5)        /* frame number overflow */
00061 #define OHCI_INTR_RHSC (1 << 6)        /* root hub status change */
00062 #define OHCI_INTR_OC   (1 << 30)       /* ownership change */
00063 #define OHCI_INTR_MIE  (1 << 31)       /* master interrupt enable */
00064 
00065 /* For initializing controller (mask in an HCFS mode too) */
00066 #define OHCI_CONTROL_INIT      (3 << 0)
00067 #define        OHCI_INTR_INIT \
00068                (OHCI_INTR_MIE | OHCI_INTR_RHSC | OHCI_INTR_UE)
00069 
00070 /* OHCI ROOT HUB REGISTER MASKS */
00071 
00072 /* roothub.portstatus [i] bits */
00073 #define RH_PS_CCS            0x00000001                /* current connect status */
00074 #define RH_PS_PES            0x00000002                /* port enable status*/
00075 #define RH_PS_PSS            0x00000004                /* port suspend status */
00076 #define RH_PS_POCI           0x00000008                /* port over current indicator */
00077 #define RH_PS_PRS            0x00000010                /* port reset status */
00078 #define RH_PS_PPS            0x00000100                /* port power status */
00079 #define RH_PS_LSDA           0x00000200                /* low speed device attached */
00080 #define RH_PS_CSC            0x00010000                /* connect status change */
00081 #define RH_PS_PESC           0x00020000                /* port enable status change */
00082 #define RH_PS_PSSC           0x00040000                /* port suspend status change */
00083 #define RH_PS_OCIC           0x00080000                /* over current indicator change */
00084 #define RH_PS_PRSC           0x00100000                /* port reset status change */
00085 
00086 /* roothub.status bits */
00087 #define RH_HS_LPS           0x00000001         /* local power status */
00088 #define RH_HS_OCI           0x00000002         /* over current indicator */
00089 #define RH_HS_DRWE          0x00008000         /* device remote wakeup enable */
00090 #define RH_HS_LPSC          0x00010000         /* local power status change */
00091 #define RH_HS_OCIC          0x00020000         /* over current indicator change */
00092 #define RH_HS_CRWE          0x80000000         /* clear remote wakeup enable */
00093 
00094 /* roothub.b masks */
00095 #define RH_B_DR                0x0000ffff              /* device removable flags */
00096 #define RH_B_PPCM      0xffff0000              /* port power control mask */
00097 
00098 /* roothub.a masks */
00099 #define        RH_A_NDP        (0xff << 0)             /* number of downstream ports */
00100 #define        RH_A_PSM        (1 << 8)                /* power switching mode */
00101 #define        RH_A_NPS        (1 << 9)                /* no power switching */
00102 #define        RH_A_DT         (1 << 10)               /* device type (mbz) */
00103 #define        RH_A_OCPM       (1 << 11)               /* over current protection mode */
00104 #define        RH_A_NOCP       (1 << 12)               /* no over current protection */
00105 #define        RH_A_POTPGT     (0xff << 24)            /* power on to power good time */
00106 
00107 struct ohci_hcca {
00108 #define NUM_INITS 32
00109         u32 int_table[NUM_INITS]; /* periodic schedule */
00110         /*
00111          * OHCI defines u16 frame_no, followed by u16 zero pad.
00112          * Since some processors can't do 16 bit bus accesses,
00113          * portable access must be a 32 bits wide.
00114          */
00115         u32 frame_no;                   /* current frame number */
00116         u32 done_head;          /* info returned for an interrupt */
00117         u8 reserved_for_hc [116];
00118         u8 what [4];               /* spec only identifies 252 bytes :) */
00119 } ALIGNED(256);
00120 
00121 struct endpoint_descriptor {
00122         /* required by HC */
00123         u32 flags;
00124         u32 tailp;
00125         u32 headp;
00126         u32 nexted;
00127 
00128         /* required by software */
00129         u32 tdcount;
00130         u8 type;
00131 } ALIGNED(16);
00132 
00133 #define OHCI_ENDPOINT_ADDRESS_MASK                              0x0000007f
00134 #define OHCI_ENDPOINT_GET_DEVICE_ADDRESS(s)             ((s) & 0x7f)
00135 #define OHCI_ENDPOINT_SET_DEVICE_ADDRESS(s)             (s)
00136 #define OHCI_ENDPOINT_GET_ENDPOINT_NUMBER(s)    (((s) >> 7) & 0xf)
00137 #define OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(s)    ((s) << 7)
00138 #define OHCI_ENDPOINT_DIRECTION_MASK                    0x00001800
00139 #define OHCI_ENDPOINT_DIRECTION_DESCRIPTOR              0x00000000
00140 #define OHCI_ENDPOINT_DIRECTION_OUT                             0x00000800
00141 #define OHCI_ENDPOINT_DIRECTION_IN                              0x00001000
00142 #define OHCI_ENDPOINT_LOW_SPEED                                 0x00002000
00143 #define OHCI_ENDPOINT_FULL_SPEED                                0x00000000
00144 #define OHCI_ENDPOINT_SKIP                                              0x00004000
00145 #define OHCI_ENDPOINT_GENERAL_FORMAT                    0x00000000
00146 #define OHCI_ENDPOINT_ISOCHRONOUS_FORMAT                0x00008000
00147 #define OHCI_ENDPOINT_MAX_PACKET_SIZE_MASK              (0x7ff << 16)
00148 #define OHCI_ENDPOINT_GET_MAX_PACKET_SIZE(s)    (((s) >> 16) & 0x07ff)
00149 #define OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(s)    ((s) << 16)
00150 #define OHCI_ENDPOINT_HALTED                                    0x00000001
00151 #define OHCI_ENDPOINT_TOGGLE_CARRY                              0x00000002
00152 #define OHCI_ENDPOINT_HEAD_MASK                                 0xfffffffc
00153 
00154 
00155 struct general_td {
00156         /* required by HC */
00157         u32 flags;
00158         u32 cbp;
00159         u32 nexttd;
00160         u32 be;
00161 
00162         /* required by software */
00163         u32 bufaddr;
00164         u32 buflen;
00165         u32 pad1;
00166         u32 pad2;
00167 } ALIGNED(16);
00168 
00169 #define OHCI_TD_BUFFER_ROUNDING                 0x00040000
00170 #define OHCI_TD_DIRECTION_PID_MASK              0x00180000
00171 #define OHCI_TD_DIRECTION_PID_SETUP             0x00000000
00172 #define OHCI_TD_DIRECTION_PID_OUT               0x00080000
00173 #define OHCI_TD_DIRECTION_PID_IN                0x00100000
00174 #define OHCI_TD_GET_DELAY_INTERRUPT(x)  (((x) >> 21) & 7)
00175 #define OHCI_TD_SET_DELAY_INTERRUPT(x)  ((x) << 21)
00176 #define OHCI_TD_INTERRUPT_MASK                  0x00e00000
00177 #define OHCI_TD_TOGGLE_CARRY                    0x00000000
00178 #define OHCI_TD_TOGGLE_0                                0x02000000
00179 #define OHCI_TD_TOGGLE_1                                0x03000000
00180 #define OHCI_TD_TOGGLE_MASK                             0x03000000
00181 #define OHCI_TD_GET_ERROR_COUNT(x)              (((x) >> 26) & 3)
00182 #define OHCI_TD_GET_CONDITION_CODE(x)   ((x) >> 28)
00183 #define OHCI_TD_SET_CONDITION_CODE(x)   ((x) << 28)
00184 #define OHCI_TD_CONDITION_CODE_MASK             0xf0000000
00185 
00186 #define OHCI_TD_INTERRUPT_IMMEDIATE                     0x00
00187 #define OHCI_TD_INTERRUPT_NONE                          0x07
00188 
00189 #define OHCI_TD_CONDITION_NO_ERROR                      0x00
00190 #define OHCI_TD_CONDITION_CRC_ERROR                     0x01
00191 #define OHCI_TD_CONDITION_BIT_STUFFING          0x02
00192 #define OHCI_TD_CONDITION_TOGGLE_MISMATCH       0x03
00193 #define OHCI_TD_CONDITION_STALL                         0x04
00194 #define OHCI_TD_CONDITION_NO_RESPONSE           0x05
00195 #define OHCI_TD_CONDITION_PID_CHECK_FAILURE     0x06
00196 #define OHCI_TD_CONDITION_UNEXPECTED_PID        0x07
00197 #define OHCI_TD_CONDITION_DATA_OVERRUN          0x08
00198 #define OHCI_TD_CONDITION_DATA_UNDERRUN         0x09
00199 #define OHCI_TD_CONDITION_BUFFER_OVERRUN        0x0c
00200 #define OHCI_TD_CONDITION_BUFFER_UNDERRUN       0x0d
00201 #define OHCI_TD_CONDITION_NOT_ACCESSED          0x0f
00202 
00203 #endif
00204 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated by  doxygen 1.6.3