From: Andre Przywara <andre.przywara@arm.com>
To: Samuel Holland <samuel@sholland.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>,
Anatolij Gustschin <agust@denx.de>,
Jagan Teki <jagan@amarulasolutions.com>,
Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>,
u-boot@lists.denx.de
Subject: Re: [PATCH 3/5] video: sunxi: dw-hdmi: Read address from DT node
Date: Mon, 23 Jan 2023 01:09:33 +0000 [thread overview]
Message-ID: <20230123010933.019edcab@slackpad.lan> (raw)
In-Reply-To: <20221128070229.4394-4-samuel@sholland.org>
On Mon, 28 Nov 2022 01:02:26 -0600
Samuel Holland <samuel@sholland.org> wrote:
Hi,
> From: Jernej Skrabec <jernej.skrabec@gmail.com>
>
> Currently HDMI controller MMIO address is hardcoded. Change that so
> address is read from DT node. That will make adding support for new
> variants a bit easier.
Looks good:
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Cheers,
Andre
> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
> drivers/video/sunxi/sunxi_dw_hdmi.c | 39 ++++++++++++++++++-----------
> 1 file changed, 24 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c b/drivers/video/sunxi/sunxi_dw_hdmi.c
> index e7265af7d8f..4f5d0989286 100644
> --- a/drivers/video/sunxi/sunxi_dw_hdmi.c
> +++ b/drivers/video/sunxi/sunxi_dw_hdmi.c
> @@ -56,10 +56,10 @@ static int sunxi_dw_hdmi_get_divider(uint clock)
> return 1;
> }
>
> -static void sunxi_dw_hdmi_phy_init(void)
> +static void sunxi_dw_hdmi_phy_init(struct dw_hdmi *hdmi)
> {
> struct sunxi_hdmi_phy * const phy =
> - (struct sunxi_hdmi_phy *)(SUNXI_HDMI_BASE + HDMI_PHY_OFFS);
> + (struct sunxi_hdmi_phy *)(hdmi->ioaddr + HDMI_PHY_OFFS);
> unsigned long tmo;
> u32 tmp;
>
> @@ -113,10 +113,10 @@ static void sunxi_dw_hdmi_phy_init(void)
> writel(0x42494E47, &phy->unscramble);
> }
>
> -static void sunxi_dw_hdmi_phy_set(uint clock, int phy_div)
> +static void sunxi_dw_hdmi_phy_set(struct dw_hdmi *hdmi, uint clock, int phy_div)
> {
> struct sunxi_hdmi_phy * const phy =
> - (struct sunxi_hdmi_phy *)(SUNXI_HDMI_BASE + HDMI_PHY_OFFS);
> + (struct sunxi_hdmi_phy *)(hdmi->ioaddr + HDMI_PHY_OFFS);
> int div = sunxi_dw_hdmi_get_divider(clock);
> u32 tmp;
>
> @@ -270,7 +270,7 @@ static int sunxi_dw_hdmi_phy_cfg(struct dw_hdmi *hdmi, uint mpixelclock)
> int phy_div;
>
> sunxi_dw_hdmi_pll_set(mpixelclock / 1000, &phy_div);
> - sunxi_dw_hdmi_phy_set(mpixelclock, phy_div);
> + sunxi_dw_hdmi_phy_set(hdmi, mpixelclock, phy_div);
>
> return 0;
> }
> @@ -291,10 +291,10 @@ static bool sunxi_dw_hdmi_mode_valid(struct udevice *dev,
> static int sunxi_dw_hdmi_enable(struct udevice *dev, int panel_bpp,
> const struct display_timing *edid)
> {
> + struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
> struct sunxi_hdmi_phy * const phy =
> - (struct sunxi_hdmi_phy *)(SUNXI_HDMI_BASE + HDMI_PHY_OFFS);
> + (struct sunxi_hdmi_phy *)(priv->hdmi.ioaddr + HDMI_PHY_OFFS);
> struct display_plat *uc_plat = dev_get_uclass_plat(dev);
> - struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
> int ret;
>
> ret = dw_hdmi_enable(&priv->hdmi, edid);
> @@ -316,7 +316,7 @@ static int sunxi_dw_hdmi_enable(struct udevice *dev, int panel_bpp,
> * again or othwerwise BSP driver won't work. Dummy read is
> * needed or otherwise last write doesn't get written correctly.
> */
> - (void)readb(SUNXI_HDMI_BASE);
> + (void)readb(priv->hdmi.ioaddr);
> writel(0, &phy->unscramble);
>
> return 0;
> @@ -345,13 +345,7 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
> /* Clock on */
> setbits_le32(&ccm->hdmi_clk_cfg, CCM_HDMI_CTRL_GATE);
>
> - sunxi_dw_hdmi_phy_init();
> -
> - priv->hdmi.ioaddr = SUNXI_HDMI_BASE;
> - priv->hdmi.i2c_clk_high = 0xd8;
> - priv->hdmi.i2c_clk_low = 0xfe;
> - priv->hdmi.reg_io_width = 1;
> - priv->hdmi.phy_set = sunxi_dw_hdmi_phy_cfg;
> + sunxi_dw_hdmi_phy_init(&priv->hdmi);
>
> ret = dw_hdmi_phy_wait_for_hpd(&priv->hdmi);
> if (ret < 0) {
> @@ -364,6 +358,20 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev)
> return 0;
> }
>
> +static int sunxi_dw_hdmi_of_to_plat(struct udevice *dev)
> +{
> + struct sunxi_dw_hdmi_priv *priv = dev_get_priv(dev);
> + struct dw_hdmi *hdmi = &priv->hdmi;
> +
> + hdmi->ioaddr = (ulong)dev_read_addr(dev);
> + hdmi->i2c_clk_high = 0xd8;
> + hdmi->i2c_clk_low = 0xfe;
> + hdmi->reg_io_width = 1;
> + hdmi->phy_set = sunxi_dw_hdmi_phy_cfg;
> +
> + return 0;
> +}
> +
> static const struct dm_display_ops sunxi_dw_hdmi_ops = {
> .read_edid = sunxi_dw_hdmi_read_edid,
> .enable = sunxi_dw_hdmi_enable,
> @@ -380,6 +388,7 @@ U_BOOT_DRIVER(sunxi_dw_hdmi) = {
> .id = UCLASS_DISPLAY,
> .of_match = sunxi_dw_hdmi_ids,
> .probe = sunxi_dw_hdmi_probe,
> + .of_to_plat = sunxi_dw_hdmi_of_to_plat,
> .priv_auto = sizeof(struct sunxi_dw_hdmi_priv),
> .ops = &sunxi_dw_hdmi_ops,
> };
next prev parent reply other threads:[~2023-01-23 1:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 7:02 [PATCH 0/5] video: sunxi: dw-hdmi: Partial OF conversion Samuel Holland
2022-11-28 7:02 ` [PATCH 1/5] clk: sunxi: Add DE2 display-related clocks/resets Samuel Holland
2022-12-03 17:14 ` Andre Przywara
2022-11-28 7:02 ` [PATCH 2/5] video: sunxi: dw-hdmi: Probe driver by compatible Samuel Holland
2022-12-03 17:14 ` Andre Przywara
2022-11-28 7:02 ` [PATCH 3/5] video: sunxi: dw-hdmi: Read address from DT node Samuel Holland
2023-01-23 1:09 ` Andre Przywara [this message]
2022-11-28 7:02 ` [PATCH 4/5] video: sunxi: dw-hdmi: Use DM for clock gates and resets Samuel Holland
2023-01-23 0:47 ` Andre Przywara
2022-11-28 7:02 ` [PATCH 5/5] video: sunxi: dw-hdmi: Use DM for HVCC regulator Samuel Holland
2023-01-23 1:10 ` Andre Przywara
2022-12-03 9:48 ` [PATCH 0/5] video: sunxi: dw-hdmi: Partial OF conversion Jernej Škrabec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230123010933.019edcab@slackpad.lan \
--to=andre.przywara@arm.com \
--cc=agust@denx.de \
--cc=jagan@amarulasolutions.com \
--cc=jernej.skrabec@gmail.com \
--cc=lukma@denx.de \
--cc=samuel@sholland.org \
--cc=seanga2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox