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
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.
12 Signed-off-by: Samuel Holland <samuel@sholland.org>
14 drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 25 +++++++++++++++++++--
15 1 file changed, 23 insertions(+), 2 deletions(-)
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,
23 +struct sun6i_dphy_variant {
30 @@ -123,6 +127,7 @@ struct sun6i_dphy {
32 struct phy_configure_opts_mipi_dphy config;
34 + const struct sun6i_dphy_variant *variant;
35 enum sun6i_dphy_direction direction;
38 @@ -409,6 +414,10 @@ static int sun6i_dphy_probe(struct platf
42 + dphy->variant = device_get_match_data(&pdev->dev);
46 regs = devm_platform_ioremap_resource(pdev, 0);
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",
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");
59 dphy->direction = SUN6I_DPHY_DIRECTION_RX;
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);
68 +static const struct sun6i_dphy_variant sun6i_a31_mipi_dphy_variant = {
69 + .supports_rx = true,
72 static const struct of_device_id sun6i_dphy_of_table[] = {
73 - { .compatible = "allwinner,sun6i-a31-mipi-dphy" },
75 + .compatible = "allwinner,sun6i-a31-mipi-dphy",
76 + .data = &sun6i_a31_mipi_dphy_variant,
80 MODULE_DEVICE_TABLE(of, sun6i_dphy_of_table);