phy-uniphier-pcie.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * phy_uniphier_pcie.c - Socionext UniPhier PCIe PHY driver
  4. * Copyright 2019-2021 Socionext, Inc.
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <generic-phy.h>
  9. #include <linux/bitops.h>
  10. #include <linux/compat.h>
  11. #include <regmap.h>
  12. #include <syscon.h>
  13. /* SG */
  14. #define SG_USBPCIESEL 0x590
  15. #define SG_USBPCIESEL_PCIE BIT(0)
  16. struct uniphier_pciephy_priv {
  17. int dummy;
  18. };
  19. static int uniphier_pciephy_init(struct phy *phy)
  20. {
  21. return 0;
  22. }
  23. static int uniphier_pciephy_probe(struct udevice *dev)
  24. {
  25. struct regmap *regmap;
  26. regmap = syscon_regmap_lookup_by_phandle(dev,
  27. "socionext,syscon");
  28. if (!IS_ERR(regmap))
  29. regmap_update_bits(regmap, SG_USBPCIESEL,
  30. SG_USBPCIESEL_PCIE, SG_USBPCIESEL_PCIE);
  31. return 0;
  32. }
  33. static struct phy_ops uniphier_pciephy_ops = {
  34. .init = uniphier_pciephy_init,
  35. };
  36. static const struct udevice_id uniphier_pciephy_ids[] = {
  37. { .compatible = "socionext,uniphier-pro5-pcie-phy" },
  38. { .compatible = "socionext,uniphier-ld20-pcie-phy" },
  39. { .compatible = "socionext,uniphier-pxs3-pcie-phy" },
  40. { }
  41. };
  42. U_BOOT_DRIVER(uniphier_pcie_phy) = {
  43. .name = "uniphier-pcie-phy",
  44. .id = UCLASS_PHY,
  45. .of_match = uniphier_pciephy_ids,
  46. .ops = &uniphier_pciephy_ops,
  47. .probe = uniphier_pciephy_probe,
  48. .priv_auto = sizeof(struct uniphier_pciephy_priv),
  49. };