Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F617C433FE for ; Mon, 28 Nov 2022 07:03:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19B80851FF; Mon, 28 Nov 2022 08:02:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="YuIzYGJK"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="filz4Z0c"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 96E73851C5; Mon, 28 Nov 2022 08:02:39 +0100 (CET) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A9007851F5 for ; Mon, 28 Nov 2022 08:02:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E3D6E5C00DB; Mon, 28 Nov 2022 02:02:33 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 28 Nov 2022 02:02:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1669618953; x=1669705353; bh=r0 PNZXFbK6VZYhjWWe2f1PH1foSsgjDW1ZW7ATs9NN0=; b=YuIzYGJKMu7mrWR9p5 MciYYJqMIqIwUcIhYqCd/CABVRnKTZI/aozTtWGRyyf6KAfEwftqm38TrdiA6Q9+ a5W4P/sH0Cbg8Xtur3MTT7sIEpdsrUJGWBU4mK1NpsW6n5Czzy0GKLJJQWqc5Ah7 g1VtJnUPPu0E7hQdvN5Cj8LXd9aZ0ZfnS9QP9cvsELLV7kK7Ojknig0GjlnEvLZ6 ftodddh90Idn65I5HhpCe6MukY30NdEfyiiaJ4M7ejto1uq/EPZR95Z6NUZ52Jb+ 4km8eXvAe/ASghJNj8rlSvfn/1qef7dHUut7/VVHecVnhcaF30rmPH42yWnuM59J 4EmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1669618953; x=1669705353; bh=r0PNZXFbK6VZY hjWWe2f1PH1foSsgjDW1ZW7ATs9NN0=; b=filz4Z0cbWVrCLcPNaRUIp+G36Cd2 PM1O17VxyC1qyQ/OXWt8XjcU7g0dtOM+mKwQSVdEi+2awN+DQNSszPm5RiLEmas5 T2sp4dzR7kXU0TDjjai4uzFmxHKeJ735wIQy705Q/030BoKM5oskKjmlmv4y1ano kfQsGLWG0Vd01N9VJszu4JUfbM4P9nWEa+e4tm59yqKp4Hbz8ExSCU5ELzINbwLm MbTEd3sg/tymw+dySZBwgPjQLlkvImKT0APAvFYYWLwbhO0C+JGZzSg7QshpT+vN 0gs8pQNZDKqG1FZ8eqtfWDrdv3nAwqWW9uY74Sk+WqcwbFDtmqKUZAkTw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrjedugddutdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 28 Nov 2022 02:02:33 -0500 (EST) From: Samuel Holland To: Andre Przywara , Jernej Skrabec , Anatolij Gustschin Cc: Samuel Holland , Jagan Teki , Lukasz Majewski , Sean Anderson , u-boot@lists.denx.de Subject: [PATCH 3/5] video: sunxi: dw-hdmi: Read address from DT node Date: Mon, 28 Nov 2022 01:02:26 -0600 Message-Id: <20221128070229.4394-4-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221128070229.4394-1-samuel@sholland.org> References: <20221128070229.4394-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Jernej Skrabec 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. Signed-off-by: Jernej Skrabec Signed-off-by: Samuel Holland --- 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, }; -- 2.37.4