Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 2 | /* |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 3 | * (C) Copyright 2009, 2011, 2016 Freescale Semiconductor, Inc. |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 4 | * |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 5 | * (C) Copyright 2008, Excito Elektronik i Sk=E5ne AB |
| 6 | * |
| 7 | * Author: Tor Krill tor@excito.com |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 11 | #include <env.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 13 | #include <pci.h> |
| 14 | #include <usb.h> |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 15 | #include <asm/io.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 16 | #include <linux/delay.h> |
Mateusz Kulikowski | 3add69e | 2016-03-31 23:12:23 +0200 | [diff] [blame] | 17 | #include <usb/ehci-ci.h> |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 18 | #include <hwconfig.h> |
Nikhil Badola | 76c2f2e | 2014-09-30 11:22:43 +0530 | [diff] [blame] | 19 | #include <fsl_usb.h> |
Nikhil Badola | b6fd44c | 2014-10-20 16:50:49 +0530 | [diff] [blame] | 20 | #include <fdt_support.h> |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 21 | #include <dm.h> |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 22 | |
Jean-Christophe PLAGNIOL-VILLARD | 8f6bcf4 | 2009-04-03 12:46:58 +0200 | [diff] [blame] | 23 | #include "ehci.h" |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 24 | |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
Nikhil Badola | b6fd44c | 2014-10-20 16:50:49 +0530 | [diff] [blame] | 27 | #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT |
| 28 | #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 |
| 29 | #endif |
| 30 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 31 | #if CONFIG_IS_ENABLED(DM_USB) |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 32 | struct ehci_fsl_priv { |
| 33 | struct ehci_ctrl ehci; |
| 34 | fdt_addr_t hcd_base; |
| 35 | char *phy_type; |
| 36 | }; |
| 37 | #endif |
| 38 | |
Nikhil Badola | b0b48da | 2014-04-07 08:46:14 +0530 | [diff] [blame] | 39 | static void set_txfifothresh(struct usb_ehci *, u32); |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 40 | #if CONFIG_IS_ENABLED(DM_USB) |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 41 | static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, |
| 42 | struct ehci_hccr *hccr, struct ehci_hcor *hcor); |
| 43 | #else |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 44 | static int ehci_fsl_init(int index, struct usb_ehci *ehci, |
| 45 | struct ehci_hccr *hccr, struct ehci_hcor *hcor); |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 46 | #endif |
Nikhil Badola | b0b48da | 2014-04-07 08:46:14 +0530 | [diff] [blame] | 47 | |
Shengzhou Liu | d407e1f | 2012-10-22 13:18:24 +0800 | [diff] [blame] | 48 | /* Check USB PHY clock valid */ |
| 49 | static int usb_phy_clk_valid(struct usb_ehci *ehci) |
| 50 | { |
| 51 | if (!((in_be32(&ehci->control) & PHY_CLK_VALID) || |
| 52 | in_be32(&ehci->prictrl))) { |
| 53 | printf("USB PHY clock invalid!\n"); |
| 54 | return 0; |
| 55 | } else { |
| 56 | return 1; |
| 57 | } |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 58 | } |
| 59 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 60 | #if CONFIG_IS_ENABLED(DM_USB) |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 61 | static int ehci_fsl_ofdata_to_platdata(struct udevice *dev) |
| 62 | { |
| 63 | struct ehci_fsl_priv *priv = dev_get_priv(dev); |
| 64 | const void *prop; |
| 65 | |
Simon Glass | dd79d6e | 2017-01-17 16:52:55 -0700 | [diff] [blame] | 66 | prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy_type", |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 67 | NULL); |
| 68 | if (prop) { |
| 69 | priv->phy_type = (char *)prop; |
| 70 | debug("phy_type %s\n", priv->phy_type); |
| 71 | } |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | static int ehci_fsl_init_after_reset(struct ehci_ctrl *ctrl) |
| 77 | { |
| 78 | struct usb_ehci *ehci = NULL; |
| 79 | struct ehci_fsl_priv *priv = container_of(ctrl, struct ehci_fsl_priv, |
| 80 | ehci); |
Yinbo Zhu | 8c8fd94 | 2019-04-11 11:02:05 +0000 | [diff] [blame] | 81 | #ifdef CONFIG_PPC |
| 82 | ehci = (struct usb_ehci *)lower_32_bits(priv->hcd_base); |
| 83 | #else |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 84 | ehci = (struct usb_ehci *)priv->hcd_base; |
Yinbo Zhu | 8c8fd94 | 2019-04-11 11:02:05 +0000 | [diff] [blame] | 85 | #endif |
| 86 | |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 87 | if (ehci_fsl_init(priv, ehci, priv->ehci.hccr, priv->ehci.hcor) < 0) |
| 88 | return -ENXIO; |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | static const struct ehci_ops fsl_ehci_ops = { |
| 94 | .init_after_reset = ehci_fsl_init_after_reset, |
| 95 | }; |
| 96 | |
| 97 | static int ehci_fsl_probe(struct udevice *dev) |
| 98 | { |
| 99 | struct ehci_fsl_priv *priv = dev_get_priv(dev); |
| 100 | struct usb_ehci *ehci = NULL; |
| 101 | struct ehci_hccr *hccr; |
| 102 | struct ehci_hcor *hcor; |
Chris Packham | 434f058 | 2018-10-04 20:03:53 +1300 | [diff] [blame] | 103 | struct ehci_ctrl *ehci_ctrl = &priv->ehci; |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * Get the base address for EHCI controller from the device node |
| 107 | */ |
Masahiro Yamada | a831cef | 2020-07-17 14:36:48 +0900 | [diff] [blame] | 108 | priv->hcd_base = dev_read_addr(dev); |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 109 | if (priv->hcd_base == FDT_ADDR_T_NONE) { |
| 110 | debug("Can't get the EHCI register base address\n"); |
| 111 | return -ENXIO; |
| 112 | } |
Yinbo Zhu | 8c8fd94 | 2019-04-11 11:02:05 +0000 | [diff] [blame] | 113 | #ifdef CONFIG_PPC |
| 114 | ehci = (struct usb_ehci *)lower_32_bits(priv->hcd_base); |
| 115 | #else |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 116 | ehci = (struct usb_ehci *)priv->hcd_base; |
Yinbo Zhu | 8c8fd94 | 2019-04-11 11:02:05 +0000 | [diff] [blame] | 117 | #endif |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 118 | hccr = (struct ehci_hccr *)(&ehci->caplength); |
| 119 | hcor = (struct ehci_hcor *) |
Ran Wang | 5444325 | 2017-12-20 10:34:19 +0800 | [diff] [blame] | 120 | ((void *)hccr + HC_LENGTH(ehci_readl(&hccr->cr_capbase))); |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 121 | |
Chris Packham | 434f058 | 2018-10-04 20:03:53 +1300 | [diff] [blame] | 122 | ehci_ctrl->has_fsl_erratum_a005275 = has_erratum_a005275(); |
| 123 | |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 124 | if (ehci_fsl_init(priv, ehci, hccr, hcor) < 0) |
| 125 | return -ENXIO; |
| 126 | |
Ran Wang | 5444325 | 2017-12-20 10:34:19 +0800 | [diff] [blame] | 127 | debug("ehci-fsl: init hccr %p and hcor %p hc_length %d\n", |
| 128 | (void *)hccr, (void *)hcor, |
| 129 | HC_LENGTH(ehci_readl(&hccr->cr_capbase))); |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 130 | |
| 131 | return ehci_register(dev, hccr, hcor, &fsl_ehci_ops, 0, USB_INIT_HOST); |
| 132 | } |
| 133 | |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 134 | static const struct udevice_id ehci_usb_ids[] = { |
| 135 | { .compatible = "fsl-usb2-mph", }, |
| 136 | { .compatible = "fsl-usb2-dr", }, |
| 137 | { } |
| 138 | }; |
| 139 | |
| 140 | U_BOOT_DRIVER(ehci_fsl) = { |
| 141 | .name = "ehci_fsl", |
| 142 | .id = UCLASS_USB, |
| 143 | .of_match = ehci_usb_ids, |
| 144 | .ofdata_to_platdata = ehci_fsl_ofdata_to_platdata, |
| 145 | .probe = ehci_fsl_probe, |
Masahiro Yamada | d41919b | 2016-09-06 22:17:34 +0900 | [diff] [blame] | 146 | .remove = ehci_deregister, |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 147 | .ops = &ehci_usb_ops, |
| 148 | .platdata_auto_alloc_size = sizeof(struct usb_platdata), |
| 149 | .priv_auto_alloc_size = sizeof(struct ehci_fsl_priv), |
| 150 | .flags = DM_FLAG_ALLOC_PRIV_DMA, |
| 151 | }; |
| 152 | #else |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 153 | /* |
| 154 | * Create the appropriate control structures to manage |
| 155 | * a new EHCI host controller. |
| 156 | * |
| 157 | * Excerpts from linux ehci fsl driver. |
| 158 | */ |
Troy Kisky | 7d6bbb9 | 2013-10-10 15:27:57 -0700 | [diff] [blame] | 159 | int ehci_hcd_init(int index, enum usb_init_type init, |
| 160 | struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 161 | { |
Chris Packham | 434f058 | 2018-10-04 20:03:53 +1300 | [diff] [blame] | 162 | struct ehci_ctrl *ehci_ctrl = container_of(hccr, |
| 163 | struct ehci_ctrl, hccr); |
ramneek mehresh | 16b0806 | 2013-09-12 16:35:49 +0530 | [diff] [blame] | 164 | struct usb_ehci *ehci = NULL; |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 165 | |
| 166 | switch (index) { |
| 167 | case 0: |
| 168 | ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR; |
| 169 | break; |
| 170 | case 1: |
| 171 | ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB2_ADDR; |
| 172 | break; |
| 173 | default: |
| 174 | printf("ERROR: wrong controller index!!\n"); |
| 175 | return -EINVAL; |
| 176 | }; |
| 177 | |
| 178 | *hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength); |
| 179 | *hcor = (struct ehci_hcor *)((uint32_t) *hccr + |
| 180 | HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); |
| 181 | |
Chris Packham | 434f058 | 2018-10-04 20:03:53 +1300 | [diff] [blame] | 182 | ehci_ctrl->has_fsl_erratum_a005275 = has_erratum_a005275(); |
| 183 | |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 184 | return ehci_fsl_init(index, ehci, *hccr, *hcor); |
| 185 | } |
| 186 | |
| 187 | /* |
| 188 | * Destroy the appropriate control structures corresponding |
| 189 | * the the EHCI host controller. |
| 190 | */ |
| 191 | int ehci_hcd_stop(int index) |
| 192 | { |
| 193 | return 0; |
| 194 | } |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 195 | #endif |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 196 | |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 197 | #if CONFIG_IS_ENABLED(DM_USB) |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 198 | static int ehci_fsl_init(struct ehci_fsl_priv *priv, struct usb_ehci *ehci, |
| 199 | struct ehci_hccr *hccr, struct ehci_hcor *hcor) |
| 200 | #else |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 201 | static int ehci_fsl_init(int index, struct usb_ehci *ehci, |
| 202 | struct ehci_hccr *hccr, struct ehci_hcor *hcor) |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 203 | #endif |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 204 | { |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 205 | const char *phy_type = NULL; |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 206 | #if !CONFIG_IS_ENABLED(DM_USB) |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 207 | size_t len; |
Nikhil Badola | eb97e25 | 2013-12-19 11:08:46 +0530 | [diff] [blame] | 208 | char current_usb_controller[5]; |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 209 | #endif |
Kumar Gala | 7b83c35 | 2011-11-09 10:04:15 -0600 | [diff] [blame] | 210 | #ifdef CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY |
| 211 | char usb_phy[5]; |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 212 | |
| 213 | usb_phy[0] = '\0'; |
Kumar Gala | 7b83c35 | 2011-11-09 10:04:15 -0600 | [diff] [blame] | 214 | #endif |
Nikhil Badola | 2613cfc | 2014-02-26 17:43:15 +0530 | [diff] [blame] | 215 | if (has_erratum_a007075()) { |
| 216 | /* |
| 217 | * A 5ms delay is needed after applying soft-reset to the |
| 218 | * controller to let external ULPI phy come out of reset. |
| 219 | * This delay needs to be added before re-initializing |
| 220 | * the controller after soft-resetting completes |
| 221 | */ |
| 222 | mdelay(5); |
| 223 | } |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 224 | |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 225 | /* Set to Host mode */ |
Vivek Mahajan | 32c5220 | 2009-06-19 17:56:00 +0530 | [diff] [blame] | 226 | setbits_le32(&ehci->usbmode, CM_HOST); |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 227 | |
Vivek Mahajan | 32c5220 | 2009-06-19 17:56:00 +0530 | [diff] [blame] | 228 | out_be32(&ehci->snoop1, SNOOP_SIZE_2GB); |
| 229 | out_be32(&ehci->snoop2, 0x80000000 | SNOOP_SIZE_2GB); |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 230 | |
| 231 | /* Init phy */ |
Sven Schwermer | 8a3cb9f1 | 2018-11-21 08:43:56 +0100 | [diff] [blame] | 232 | #if CONFIG_IS_ENABLED(DM_USB) |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 233 | if (priv->phy_type) |
| 234 | phy_type = priv->phy_type; |
| 235 | #else |
| 236 | memset(current_usb_controller, '\0', 5); |
| 237 | snprintf(current_usb_controller, sizeof(current_usb_controller), |
| 238 | "usb%d", index+1); |
| 239 | |
Nikhil Badola | eb97e25 | 2013-12-19 11:08:46 +0530 | [diff] [blame] | 240 | if (hwconfig_sub(current_usb_controller, "phy_type")) |
| 241 | phy_type = hwconfig_subarg(current_usb_controller, |
| 242 | "phy_type", &len); |
Rajesh Bhagat | 48c5c51 | 2016-07-01 18:51:46 +0530 | [diff] [blame] | 243 | #endif |
Vivek Mahajan | 288f7fb | 2009-05-25 17:23:16 +0530 | [diff] [blame] | 244 | else |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 245 | phy_type = env_get("usb_phy_type"); |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 246 | |
| 247 | if (!phy_type) { |
| 248 | #ifdef CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY |
| 249 | /* if none specified assume internal UTMI */ |
| 250 | strcpy(usb_phy, "utmi"); |
| 251 | phy_type = usb_phy; |
| 252 | #else |
| 253 | printf("WARNING: USB phy type not defined !!\n"); |
| 254 | return -1; |
| 255 | #endif |
| 256 | } |
| 257 | |
Nikhil Badola | 09a3b56 | 2014-02-17 16:58:36 +0530 | [diff] [blame] | 258 | if (!strncmp(phy_type, "utmi", 4)) { |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 259 | #if defined(CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY) |
Nikhil Badola | 369f663 | 2014-05-08 17:05:26 +0530 | [diff] [blame] | 260 | clrsetbits_be32(&ehci->control, CONTROL_REGISTER_W1C_MASK, |
| 261 | PHY_CLK_SEL_UTMI); |
| 262 | clrsetbits_be32(&ehci->control, CONTROL_REGISTER_W1C_MASK, |
| 263 | UTMI_PHY_EN); |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 264 | udelay(1000); /* delay required for PHY Clk to appear */ |
| 265 | #endif |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 266 | out_le32(&(hcor)->or_portsc[0], PORT_PTS_UTMI); |
Nikhil Badola | 369f663 | 2014-05-08 17:05:26 +0530 | [diff] [blame] | 267 | clrsetbits_be32(&ehci->control, CONTROL_REGISTER_W1C_MASK, |
| 268 | USB_EN); |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 269 | } else { |
Nikhil Badola | 369f663 | 2014-05-08 17:05:26 +0530 | [diff] [blame] | 270 | clrsetbits_be32(&ehci->control, CONTROL_REGISTER_W1C_MASK, |
| 271 | PHY_CLK_SEL_ULPI); |
| 272 | clrsetbits_be32(&ehci->control, UTMI_PHY_EN | |
| 273 | CONTROL_REGISTER_W1C_MASK, USB_EN); |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 274 | udelay(1000); /* delay required for PHY Clk to appear */ |
Shengzhou Liu | d407e1f | 2012-10-22 13:18:24 +0800 | [diff] [blame] | 275 | if (!usb_phy_clk_valid(ehci)) |
| 276 | return -EINVAL; |
Rajesh Bhagat | 2542d96 | 2016-07-01 18:51:45 +0530 | [diff] [blame] | 277 | out_le32(&(hcor)->or_portsc[0], PORT_PTS_ULPI); |
Ramneek Mehresh | 3fb68ee | 2011-03-23 15:20:43 +0530 | [diff] [blame] | 278 | } |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 279 | |
Vivek Mahajan | 32c5220 | 2009-06-19 17:56:00 +0530 | [diff] [blame] | 280 | out_be32(&ehci->prictrl, 0x0000000c); |
| 281 | out_be32(&ehci->age_cnt_limit, 0x00000040); |
| 282 | out_be32(&ehci->sictrl, 0x00000001); |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 283 | |
Vivek Mahajan | 32c5220 | 2009-06-19 17:56:00 +0530 | [diff] [blame] | 284 | in_le32(&ehci->usbmode); |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 285 | |
Nikhil Badola | 67f4b26 | 2014-10-17 09:12:07 +0530 | [diff] [blame] | 286 | if (has_erratum_a007798()) |
Nikhil Badola | b0b48da | 2014-04-07 08:46:14 +0530 | [diff] [blame] | 287 | set_txfifothresh(ehci, TXFIFOTHRESH); |
| 288 | |
Nikhil Badola | 288542c | 2014-11-21 17:25:21 +0530 | [diff] [blame] | 289 | if (has_erratum_a004477()) { |
| 290 | /* |
| 291 | * When reset is issued while any ULPI transaction is ongoing |
| 292 | * then it may result to corruption of ULPI Function Control |
| 293 | * Register which eventually causes phy clock to enter low |
| 294 | * power mode which stops the clock. Thus delay is required |
| 295 | * before reset to let ongoing ULPI transaction complete. |
| 296 | */ |
| 297 | udelay(1); |
| 298 | } |
Michael Trimarchi | e30a336 | 2008-11-28 13:22:09 +0100 | [diff] [blame] | 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | /* |
Nikhil Badola | b0b48da | 2014-04-07 08:46:14 +0530 | [diff] [blame] | 303 | * Setting the value of TXFIFO_THRESH field in TXFILLTUNING register |
| 304 | * to counter DDR latencies in writing data into Tx buffer. |
| 305 | * This prevents Tx buffer from getting underrun |
| 306 | */ |
| 307 | static void set_txfifothresh(struct usb_ehci *ehci, u32 txfifo_thresh) |
| 308 | { |
| 309 | u32 cmd; |
| 310 | cmd = ehci_readl(&ehci->txfilltuning); |
| 311 | cmd &= ~TXFIFO_THRESH_MASK; |
| 312 | cmd |= TXFIFO_THRESH(txfifo_thresh); |
| 313 | ehci_writel(&ehci->txfilltuning, cmd); |
| 314 | } |