On Mon, Aug 18, 2025 at 03:47:28PM +0800, Icenowy Zheng wrote: > 在 2025-08-18星期一的 15:45 +0800,Troy Mitchell写道: > > On Sun, Aug 17, 2025 at 01:10:44AM +0800, Icenowy Zheng wrote: > > > 在 2025-08-16星期六的 19:24 +0300,Dmitry Baryshkov写道: > > > > On Fri, Aug 15, 2025 at 12:40:45AM +0800, Icenowy Zheng wrote: > > > > > T-Head TH1520 SoC contains a Synopsys DesignWare HDMI > > > > > controller > > > > > (paired > > > > > with DesignWare HDMI TX PHY Gen2) that takes the "DP" output > > > > > from > > > > > the > > > > > display controller. > > > > > > > > > > Add a driver for this controller utilizing the common > > > > > DesignWare > > > > > HDMI > > > > > code in the kernel. > > > > > > > > > > Signed-off-by: Icenowy Zheng <u...@icenowy.me> > > > > > --- [...] > > > > > +static int th1520_hdmi_phy_configure(struct dw_hdmi *hdmi, > > > > > void > > > > > *data, > > > > > + unsigned long mpixelclock) > > > > > +{ > > > > > + const struct th1520_hdmi_phy_params *params = > > > > > th1520_hdmi_phy_params; > > > > > + > > > > > + for (; params->mpixelclock != ~0UL; ++params) { > > > > > + if (mpixelclock <= params->mpixelclock) > > > > > + break; > > > > > > > > for (...) { > > > > if (mpixelclock <= params->mpixelclock) > > > > return th1520_program_phy(); > > > > > > There's no such a function here, and this check isn't used for > > > another > > > time, so having the matching code and programming code extracted > > > out > > > can help nothing. > > I think Dmitry meant that the following code should be moved into > > a new function, th1520_program_phy(). > > > > This makes the code cleaner and also avoids one extra if check. > > As there's no code reuse, it does not make code cleaner. I respect your opinion, but let's also see what Dmitry has to say.
- Troy > > > > > - Troy > > > > > > > } > > > > > > > > return -EINVAL; > > > > > > > > > + } > > > > > + > > > > > + if (params->mpixelclock == ~0UL) > > > > > + return -EINVAL; > > > > > + > > > > > + dw_hdmi_phy_i2c_write(hdmi, params->opmode_pllcfg, > > > > > + TH1520_HDMI_PHY_OPMODE_PLLCFG); > > > > > + dw_hdmi_phy_i2c_write(hdmi, params->pllcurrgmpctrl, > > > > > + TH1520_HDMI_PHY_PLLCURRGMPCTRL); > > > > > + dw_hdmi_phy_i2c_write(hdmi, params->plldivctrl, > > > > > + TH1520_HDMI_PHY_PLLDIVCTRL); > > > > > + dw_hdmi_phy_i2c_write(hdmi, params->vlevctrl, > > > > > + TH1520_HDMI_PHY_VLEVCTRL); > > > > > + dw_hdmi_phy_i2c_write(hdmi, params->cksymtxctrl, > > > > > + TH1520_HDMI_PHY_CKSYMTXCTRL); > > > > > + dw_hdmi_phy_i2c_write(hdmi, params->txterm, > > > > > + TH1520_HDMI_PHY_TXTERM); > > > > > + > > > > > + return 0; > > > > > +} > > > > > + > > > > > +static int th1520_dw_hdmi_probe(struct platform_device *pdev) > > > > > +{ > > > > > + struct th1520_hdmi *hdmi; > > > > > + struct dw_hdmi_plat_data *plat_data; > > > > > + struct device *dev = &pdev->dev; > > > > > + > > > > > + hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); > > > > > + if (!hdmi) > > > > > + return -ENOMEM; > > > > > + > > > > > + plat_data = &hdmi->plat_data; > > > > > + > > > > > + hdmi->pixclk = devm_clk_get_enabled(dev, "pix"); > > > > > + if (IS_ERR(hdmi->pixclk)) > > > > > + return dev_err_probe(dev, PTR_ERR(hdmi- > > > > > >pixclk), > > > > > + "Unable to get pixel > > > > > clock\n"); > > > > > + > > > > > + hdmi->mainrst = > > > > > devm_reset_control_get_exclusive_deasserted(dev, "main"); > > > > > + if (IS_ERR(hdmi->mainrst)) > > > > > + return dev_err_probe(dev, PTR_ERR(hdmi- > > > > > >mainrst), > > > > > + "Unable to get main > > > > > reset\n"); > > > > > + > > > > > + hdmi->prst = > > > > > devm_reset_control_get_exclusive_deasserted(dev, "apb"); > > > > > + if (IS_ERR(hdmi->prst)) > > > > > + return dev_err_probe(dev, PTR_ERR(hdmi->prst), > > > > > + "Unable to get apb > > > > > reset\n"); > > > > > + > > > > > + plat_data->output_port = 1; > > > > > + plat_data->mode_valid = th1520_hdmi_mode_valid; > > > > > + plat_data->configure_phy = th1520_hdmi_phy_configure; > > > > > + plat_data->priv_data = hdmi; > > > > > + > > > > > + hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data); > > > > > + if (IS_ERR(hdmi)) > > > > > + return PTR_ERR(hdmi); > > > > > + > > > > > + platform_set_drvdata(pdev, hdmi); > > > > > + > > > > > + return 0; > > > > > +} > > > > > + > > > > > +static void th1520_dw_hdmi_remove(struct platform_device > > > > > *pdev) > > > > > +{ > > > > > + struct dw_hdmi *hdmi = platform_get_drvdata(pdev); > > > > > + > > > > > + dw_hdmi_remove(hdmi); > > > > > +} > > > > > + > > > > > +static const struct of_device_id th1520_dw_hdmi_of_table[] = { > > > > > + { .compatible = "thead,th1520-dw-hdmi" }, > > > > > + { /* Sentinel */ }, > > > > > +}; > > > > > +MODULE_DEVICE_TABLE(of, th1520_dw_hdmi_of_table); > > > > > + > > > > > +static struct platform_driver th1520_dw_hdmi_platform_driver = > > > > > { > > > > > + .probe = th1520_dw_hdmi_probe, > > > > > + .remove = th1520_dw_hdmi_remove, > > > > > + .driver = { > > > > > + .name = "th1520-dw-hdmi", > > > > > + .of_match_table = th1520_dw_hdmi_of_table, > > > > > + }, > > > > > +}; > > > > > + > > > > > +module_platform_driver(th1520_dw_hdmi_platform_driver); > > > > > + > > > > > +MODULE_AUTHOR("Icenowy Zheng <u...@icenowy.me>"); > > > > > +MODULE_DESCRIPTION("T-Head TH1520 HDMI Encoder Driver"); > > > > > +MODULE_LICENSE("GPL"); > > > > > -- > > > > > 2.50.1 > > > > > > > > > > > > > > > _______________________________________________ > > > linux-riscv mailing list > > > linux-ri...@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/linux-riscv >