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