Simon Glass | 08d6ec2 | 2012-02-27 10:52:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The Chromium OS Authors. |
| 3 | * See file CREDITS for list of people who contributed to this |
| 4 | * project. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of |
| 9 | * the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 19 | * MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TEGRA_USB_H_ |
| 23 | #define _TEGRA_USB_H_ |
| 24 | |
| 25 | |
| 26 | /* USB Controller (USBx_CONTROLLER_) regs */ |
| 27 | struct usb_ctlr { |
| 28 | /* 0x000 */ |
| 29 | uint id; |
| 30 | uint reserved0; |
| 31 | uint host; |
| 32 | uint device; |
| 33 | |
| 34 | /* 0x010 */ |
| 35 | uint txbuf; |
| 36 | uint rxbuf; |
| 37 | uint reserved1[2]; |
| 38 | |
| 39 | /* 0x020 */ |
| 40 | uint reserved2[56]; |
| 41 | |
| 42 | /* 0x100 */ |
| 43 | u16 cap_length; |
| 44 | u16 hci_version; |
| 45 | uint hcs_params; |
| 46 | uint hcc_params; |
| 47 | uint reserved3[5]; |
| 48 | |
| 49 | /* 0x120 */ |
| 50 | uint dci_version; |
| 51 | uint dcc_params; |
| 52 | uint reserved4[6]; |
| 53 | |
| 54 | /* 0x140 */ |
| 55 | uint usb_cmd; |
| 56 | uint usb_sts; |
| 57 | uint usb_intr; |
| 58 | uint frindex; |
| 59 | |
| 60 | /* 0x150 */ |
| 61 | uint reserved5; |
| 62 | uint periodic_list_base; |
| 63 | uint async_list_addr; |
| 64 | uint async_tt_sts; |
| 65 | |
| 66 | /* 0x160 */ |
| 67 | uint burst_size; |
| 68 | uint tx_fill_tuning; |
| 69 | uint reserved6; /* is this port_sc1 on some controllers? */ |
| 70 | uint icusb_ctrl; |
| 71 | |
| 72 | /* 0x170 */ |
| 73 | uint ulpi_viewport; |
| 74 | uint reserved7; |
| 75 | uint endpt_nak; |
| 76 | uint endpt_nak_enable; |
| 77 | |
| 78 | /* 0x180 */ |
| 79 | uint reserved; |
| 80 | uint port_sc1; |
| 81 | uint reserved8[6]; |
| 82 | |
| 83 | /* 0x1a0 */ |
| 84 | uint reserved9; |
| 85 | uint otgsc; |
| 86 | uint usb_mode; |
| 87 | uint endpt_setup_stat; |
| 88 | |
| 89 | /* 0x1b0 */ |
| 90 | uint reserved10[20]; |
| 91 | |
| 92 | /* 0x200 */ |
| 93 | uint reserved11[0x80]; |
| 94 | |
| 95 | /* 0x400 */ |
| 96 | uint susp_ctrl; |
| 97 | uint phy_vbus_sensors; |
| 98 | uint phy_vbus_wakeup_id; |
| 99 | uint phy_alt_vbus_sys; |
| 100 | |
| 101 | /* 0x410 */ |
| 102 | uint usb1_legacy_ctrl; |
| 103 | uint reserved12[3]; |
| 104 | |
| 105 | /* 0x420 */ |
| 106 | uint reserved13[56]; |
| 107 | |
| 108 | /* 0x500 */ |
| 109 | uint reserved14[64 * 3]; |
| 110 | |
| 111 | /* 0x800 */ |
| 112 | uint utmip_pll_cfg0; |
| 113 | uint utmip_pll_cfg1; |
| 114 | uint utmip_xcvr_cfg0; |
| 115 | uint utmip_bias_cfg0; |
| 116 | |
| 117 | /* 0x810 */ |
| 118 | uint utmip_hsrx_cfg0; |
| 119 | uint utmip_hsrx_cfg1; |
| 120 | uint utmip_fslsrx_cfg0; |
| 121 | uint utmip_fslsrx_cfg1; |
| 122 | |
| 123 | /* 0x820 */ |
| 124 | uint utmip_tx_cfg0; |
| 125 | uint utmip_misc_cfg0; |
| 126 | uint utmip_misc_cfg1; |
| 127 | uint utmip_debounce_cfg0; |
| 128 | |
| 129 | /* 0x830 */ |
| 130 | uint utmip_bat_chrg_cfg0; |
| 131 | uint utmip_spare_cfg0; |
| 132 | uint utmip_xcvr_cfg1; |
| 133 | uint utmip_bias_cfg1; |
| 134 | }; |
| 135 | |
| 136 | |
| 137 | /* USB1_LEGACY_CTRL */ |
| 138 | #define USB1_NO_LEGACY_MODE 1 |
| 139 | |
| 140 | #define VBUS_SENSE_CTL_SHIFT 1 |
| 141 | #define VBUS_SENSE_CTL_MASK (3 << VBUS_SENSE_CTL_SHIFT) |
| 142 | #define VBUS_SENSE_CTL_VBUS_WAKEUP 0 |
| 143 | #define VBUS_SENSE_CTL_AB_SESS_VLD_OR_VBUS_WAKEUP 1 |
| 144 | #define VBUS_SENSE_CTL_AB_SESS_VLD 2 |
| 145 | #define VBUS_SENSE_CTL_A_SESS_VLD 3 |
| 146 | |
| 147 | /* USBx_IF_USB_SUSP_CTRL_0 */ |
| 148 | #define UTMIP_PHY_ENB (1 << 12) |
| 149 | #define UTMIP_RESET (1 << 11) |
| 150 | #define USB_PHY_CLK_VALID (1 << 7) |
| 151 | |
| 152 | /* USBx_UTMIP_MISC_CFG1 */ |
| 153 | #define UTMIP_PLLU_STABLE_COUNT_SHIFT 6 |
| 154 | #define UTMIP_PLLU_STABLE_COUNT_MASK \ |
| 155 | (0xfff << UTMIP_PLLU_STABLE_COUNT_SHIFT) |
| 156 | #define UTMIP_PLL_ACTIVE_DLY_COUNT_SHIFT 18 |
| 157 | #define UTMIP_PLL_ACTIVE_DLY_COUNT_MASK \ |
| 158 | (0x1f << UTMIP_PLL_ACTIVE_DLY_COUNT_SHIFT) |
| 159 | #define UTMIP_PHY_XTAL_CLOCKEN (1 << 30) |
| 160 | |
| 161 | /* USBx_UTMIP_PLL_CFG1_0 */ |
| 162 | #define UTMIP_PLLU_ENABLE_DLY_COUNT_SHIFT 27 |
| 163 | #define UTMIP_PLLU_ENABLE_DLY_COUNT_MASK \ |
| 164 | (0xf << UTMIP_PLLU_ENABLE_DLY_COUNT_SHIFT) |
| 165 | #define UTMIP_XTAL_FREQ_COUNT_SHIFT 0 |
| 166 | #define UTMIP_XTAL_FREQ_COUNT_MASK 0xfff |
| 167 | |
| 168 | /* USBx_UTMIP_BIAS_CFG1_0 */ |
| 169 | #define UTMIP_BIAS_PDTRK_COUNT_SHIFT 3 |
| 170 | #define UTMIP_BIAS_PDTRK_COUNT_MASK \ |
| 171 | (0x1f << UTMIP_BIAS_PDTRK_COUNT_SHIFT) |
| 172 | |
| 173 | #define UTMIP_DEBOUNCE_CFG0_SHIFT 0 |
| 174 | #define UTMIP_DEBOUNCE_CFG0_MASK 0xffff |
| 175 | |
| 176 | /* USBx_UTMIP_TX_CFG0_0 */ |
| 177 | #define UTMIP_FS_PREAMBLE_J (1 << 19) |
| 178 | |
| 179 | /* USBx_UTMIP_BAT_CHRG_CFG0_0 */ |
| 180 | #define UTMIP_PD_CHRG 1 |
| 181 | |
| 182 | /* USBx_UTMIP_XCVR_CFG0_0 */ |
| 183 | #define UTMIP_XCVR_LSBIAS_SE (1 << 21) |
| 184 | |
| 185 | /* USBx_UTMIP_SPARE_CFG0_0 */ |
| 186 | #define FUSE_SETUP_SEL (1 << 3) |
| 187 | |
| 188 | /* USBx_UTMIP_HSRX_CFG0_0 */ |
| 189 | #define UTMIP_IDLE_WAIT_SHIFT 15 |
| 190 | #define UTMIP_IDLE_WAIT_MASK (0x1f << UTMIP_IDLE_WAIT_SHIFT) |
| 191 | #define UTMIP_ELASTIC_LIMIT_SHIFT 10 |
| 192 | #define UTMIP_ELASTIC_LIMIT_MASK \ |
| 193 | (0x1f << UTMIP_ELASTIC_LIMIT_SHIFT) |
| 194 | |
| 195 | /* USBx_UTMIP_HSRX_CFG0_1 */ |
| 196 | #define UTMIP_HS_SYNC_START_DLY_SHIFT 1 |
| 197 | #define UTMIP_HS_SYNC_START_DLY_MASK \ |
| 198 | (0xf << UTMIP_HS_SYNC_START_DLY_SHIFT) |
| 199 | |
| 200 | /* USBx_CONTROLLER_2_USB2D_ICUSB_CTRL_0 */ |
| 201 | #define IC_ENB1 (1 << 3) |
| 202 | |
| 203 | /* SB2_CONTROLLER_2_USB2D_PORTSC1_0 */ |
| 204 | #define PTS_SHIFT 30 |
| 205 | #define PTS_MASK (3U << PTS_SHIFT) |
| 206 | #define PTS_UTMI 0 |
| 207 | #define PTS_RESERVED 1 |
| 208 | #define PTS_ULP 2 |
| 209 | #define PTS_ICUSB_SER 3 |
| 210 | |
| 211 | #define STS (1 << 29) |
| 212 | |
| 213 | /* USBx_UTMIP_XCVR_CFG0_0 */ |
| 214 | #define UTMIP_FORCE_PD_POWERDOWN (1 << 14) |
| 215 | #define UTMIP_FORCE_PD2_POWERDOWN (1 << 16) |
| 216 | #define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18) |
| 217 | |
| 218 | /* USBx_UTMIP_XCVR_CFG1_0 */ |
| 219 | #define UTMIP_FORCE_PDDISC_POWERDOWN (1 << 0) |
| 220 | #define UTMIP_FORCE_PDCHRP_POWERDOWN (1 << 2) |
| 221 | #define UTMIP_FORCE_PDDR_POWERDOWN (1 << 4) |
| 222 | |
| 223 | /* USB3_IF_USB_PHY_VBUS_SENSORS_0 */ |
| 224 | #define VBUS_VLD_STS (1 << 26) |
| 225 | |
| 226 | |
| 227 | /* Change the USB host port into host mode */ |
| 228 | void usb_set_host_mode(void); |
| 229 | |
| 230 | /* Setup USB on the board */ |
| 231 | int board_usb_init(const void *blob); |
| 232 | |
| 233 | /** |
| 234 | * Start up the given port number (ports are numbered from 0 on each board). |
| 235 | * This returns values for the appropriate hccr and hcor addresses to use for |
| 236 | * USB EHCI operations. |
| 237 | * |
| 238 | * @param portnum port number to start |
| 239 | * @param hccr returns start address of EHCI HCCR registers |
| 240 | * @param hcor returns start address of EHCI HCOR registers |
| 241 | * @return 0 if ok, -1 on error (generally invalid port number) |
| 242 | */ |
| 243 | int tegrausb_start_port(unsigned portnum, u32 *hccr, u32 *hcor); |
| 244 | |
| 245 | /** |
| 246 | * Stop the current port |
| 247 | * |
| 248 | * @return 0 if ok, -1 if no port was active |
| 249 | */ |
| 250 | int tegrausb_stop_port(void); |
| 251 | |
| 252 | #endif /* _TEGRA_USB_H_ */ |