Skip to content

Commit a709ae5

Browse files
smaeulvinodkoul
authored andcommitted
phy: allwinner: phy-sun6i-mipi-dphy: Make RX support optional
While all variants of the DPHY likely support RX mode, the new variant in the A100 is not used in this direction by the BSP, and it has some analog register changes, so its RX power-on sequence is unknown. To be safe, limit RX support to variants where the power-on sequence is known. Signed-off-by: Samuel Holland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent e7a8386 commit a709ae5

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

drivers/phy/allwinner/phy-sun6i-mipi-dphy.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ enum sun6i_dphy_direction {
114114
SUN6I_DPHY_DIRECTION_RX,
115115
};
116116

117+
struct sun6i_dphy_variant {
118+
bool rx_supported;
119+
};
120+
117121
struct sun6i_dphy {
118122
struct clk *bus_clk;
119123
struct clk *mod_clk;
@@ -123,6 +127,7 @@ struct sun6i_dphy {
123127
struct phy *phy;
124128
struct phy_configure_opts_mipi_dphy config;
125129

130+
const struct sun6i_dphy_variant *variant;
126131
enum sun6i_dphy_direction direction;
127132
};
128133

@@ -409,6 +414,10 @@ static int sun6i_dphy_probe(struct platform_device *pdev)
409414
if (!dphy)
410415
return -ENOMEM;
411416

417+
dphy->variant = device_get_match_data(&pdev->dev);
418+
if (!dphy->variant)
419+
return -EINVAL;
420+
412421
regs = devm_platform_ioremap_resource(pdev, 0);
413422
if (IS_ERR(regs)) {
414423
dev_err(&pdev->dev, "Couldn't map the DPHY encoder registers\n");
@@ -445,17 +454,30 @@ static int sun6i_dphy_probe(struct platform_device *pdev)
445454
ret = of_property_read_string(pdev->dev.of_node, "allwinner,direction",
446455
&direction);
447456

448-
if (!ret && !strncmp(direction, "rx", 2))
457+
if (!ret && !strncmp(direction, "rx", 2)) {
458+
if (!dphy->variant->rx_supported) {
459+
dev_err(&pdev->dev, "RX not supported on this variant\n");
460+
return -EOPNOTSUPP;
461+
}
462+
449463
dphy->direction = SUN6I_DPHY_DIRECTION_RX;
464+
}
450465

451466
phy_set_drvdata(dphy->phy, dphy);
452467
phy_provider = devm_of_phy_provider_register(&pdev->dev, of_phy_simple_xlate);
453468

454469
return PTR_ERR_OR_ZERO(phy_provider);
455470
}
456471

472+
static const struct sun6i_dphy_variant sun6i_a31_mipi_dphy_variant = {
473+
.rx_supported = true,
474+
};
475+
457476
static const struct of_device_id sun6i_dphy_of_table[] = {
458-
{ .compatible = "allwinner,sun6i-a31-mipi-dphy" },
477+
{
478+
.compatible = "allwinner,sun6i-a31-mipi-dphy",
479+
.data = &sun6i_a31_mipi_dphy_variant,
480+
},
459481
{ }
460482
};
461483
MODULE_DEVICE_TABLE(of, sun6i_dphy_of_table);

0 commit comments

Comments
 (0)