samsung_usb_phy.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // SPDX-License-Identifier: GPL-2.0
  2. /**
  3. * samsung_usb_phy.c - DesignWare USB3 (DWC3) PHY handling file
  4. *
  5. * Copyright (C) 2015 Samsung Electronics
  6. *
  7. * Author: Joonyoung Shim <jy0922.shim@samsung.com>
  8. */
  9. #include <common.h>
  10. #include <asm/arch/power.h>
  11. #include <asm/arch/xhci-exynos.h>
  12. void exynos5_usb3_phy_init(struct exynos_usb3_phy *phy)
  13. {
  14. u32 reg;
  15. /* Reset USB 3.0 PHY */
  16. writel(0x0, &phy->phy_reg0);
  17. clrbits_le32(&phy->phy_param0,
  18. /* Select PHY CLK source */
  19. PHYPARAM0_REF_USE_PAD |
  20. /* Set Loss-of-Signal Detector sensitivity */
  21. PHYPARAM0_REF_LOSLEVEL_MASK);
  22. setbits_le32(&phy->phy_param0, PHYPARAM0_REF_LOSLEVEL);
  23. writel(0x0, &phy->phy_resume);
  24. /*
  25. * Setting the Frame length Adj value[6:1] to default 0x20
  26. * See xHCI 1.0 spec, 5.2.4
  27. */
  28. setbits_le32(&phy->link_system,
  29. LINKSYSTEM_XHCI_VERSION_CONTROL |
  30. LINKSYSTEM_FLADJ(0x20));
  31. /* Set Tx De-Emphasis level */
  32. clrbits_le32(&phy->phy_param1, PHYPARAM1_PCS_TXDEEMPH_MASK);
  33. setbits_le32(&phy->phy_param1, PHYPARAM1_PCS_TXDEEMPH);
  34. setbits_le32(&phy->phy_batchg, PHYBATCHG_UTMI_CLKSEL);
  35. /* PHYTEST POWERDOWN Control */
  36. clrbits_le32(&phy->phy_test,
  37. PHYTEST_POWERDOWN_SSP |
  38. PHYTEST_POWERDOWN_HSP);
  39. /* UTMI Power Control */
  40. writel(PHYUTMI_OTGDISABLE, &phy->phy_utmi);
  41. /* Use core clock from main PLL */
  42. reg = PHYCLKRST_REFCLKSEL_EXT_REFCLK |
  43. /* Default 24Mhz crystal clock */
  44. PHYCLKRST_FSEL(FSEL_CLKSEL_24M) |
  45. PHYCLKRST_MPLL_MULTIPLIER_24MHZ_REF |
  46. PHYCLKRST_SSC_REFCLKSEL(0) |
  47. /* Force PortReset of PHY */
  48. PHYCLKRST_PORTRESET |
  49. /* Digital power supply in normal operating mode */
  50. PHYCLKRST_RETENABLEN |
  51. /* Enable ref clock for SS function */
  52. PHYCLKRST_REF_SSP_EN |
  53. /* Enable spread spectrum */
  54. PHYCLKRST_SSC_EN |
  55. /* Power down HS Bias and PLL blocks in suspend mode */
  56. PHYCLKRST_COMMONONN;
  57. writel(reg, &phy->phy_clk_rst);
  58. /* giving time to Phy clock to settle before resetting */
  59. udelay(10);
  60. reg &= ~PHYCLKRST_PORTRESET;
  61. writel(reg, &phy->phy_clk_rst);
  62. }