0103-phy-allwinner-phy-sun6i-mipi-dphy-Make-RX-support-op.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 27c0c2cbe7b30b907b031016d2cd15fe9505cb1b Mon Sep 17 00:00:00 2001
  2. From: Samuel Holland <[email protected]>
  3. Date: Sun, 7 Aug 2022 12:11:53 -0500
  4. Subject: [PATCH 103/117] phy: allwinner: phy-sun6i-mipi-dphy: Make RX support
  5. optional
  6. While all variants of the DPHY likely support RX mode, the new variant
  7. in the A100 is not used in this direction by the BSP, and it has some
  8. analog register changes, so its RX power-on sequence is unknown. To be
  9. safe, limit RX support to variants where the power-on sequence is known.
  10. Signed-off-by: Samuel Holland <[email protected]>
  11. ---
  12. drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 25 +++++++++++++++++++--
  13. 1 file changed, 23 insertions(+), 2 deletions(-)
  14. --- a/drivers/phy/allwinner/phy-sun6i-mipi-dphy.c
  15. +++ b/drivers/phy/allwinner/phy-sun6i-mipi-dphy.c
  16. @@ -114,6 +114,10 @@ enum sun6i_dphy_direction {
  17. SUN6I_DPHY_DIRECTION_RX,
  18. };
  19. +struct sun6i_dphy_variant {
  20. + bool supports_rx;
  21. +};
  22. +
  23. struct sun6i_dphy {
  24. struct clk *bus_clk;
  25. struct clk *mod_clk;
  26. @@ -123,6 +127,7 @@ struct sun6i_dphy {
  27. struct phy *phy;
  28. struct phy_configure_opts_mipi_dphy config;
  29. + const struct sun6i_dphy_variant *variant;
  30. enum sun6i_dphy_direction direction;
  31. };
  32. @@ -409,6 +414,10 @@ static int sun6i_dphy_probe(struct platf
  33. if (!dphy)
  34. return -ENOMEM;
  35. + dphy->variant = device_get_match_data(&pdev->dev);
  36. + if (!dphy->variant)
  37. + return -EINVAL;
  38. +
  39. regs = devm_platform_ioremap_resource(pdev, 0);
  40. if (IS_ERR(regs)) {
  41. dev_err(&pdev->dev, "Couldn't map the DPHY encoder registers\n");
  42. @@ -445,8 +454,13 @@ static int sun6i_dphy_probe(struct platf
  43. ret = of_property_read_string(pdev->dev.of_node, "allwinner,direction",
  44. &direction);
  45. - if (!ret && !strncmp(direction, "rx", 2))
  46. + if (!ret && !strncmp(direction, "rx", 2)) {
  47. + if (!dphy->variant->supports_rx) {
  48. + dev_err(&pdev->dev, "RX not supported on this variant\n");
  49. + return -EOPNOTSUPP;
  50. + }
  51. dphy->direction = SUN6I_DPHY_DIRECTION_RX;
  52. + }
  53. phy_set_drvdata(dphy->phy, dphy);
  54. phy_provider = devm_of_phy_provider_register(&pdev->dev, of_phy_simple_xlate);
  55. @@ -454,8 +468,15 @@ static int sun6i_dphy_probe(struct platf
  56. return PTR_ERR_OR_ZERO(phy_provider);
  57. }
  58. +static const struct sun6i_dphy_variant sun6i_a31_mipi_dphy_variant = {
  59. + .supports_rx = true,
  60. +};
  61. +
  62. static const struct of_device_id sun6i_dphy_of_table[] = {
  63. - { .compatible = "allwinner,sun6i-a31-mipi-dphy" },
  64. + {
  65. + .compatible = "allwinner,sun6i-a31-mipi-dphy",
  66. + .data = &sun6i_a31_mipi_dphy_variant,
  67. + },
  68. { }
  69. };
  70. MODULE_DEVICE_TABLE(of, sun6i_dphy_of_table);