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