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 D9F48C636CC for ; Tue, 31 Jan 2023 10:06:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9BC82859DE; Tue, 31 Jan 2023 11:06:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="sgVIfQtT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6C0AC85A2B; Tue, 31 Jan 2023 11:05:36 +0100 (CET) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 43B4185A0D for ; Tue, 31 Jan 2023 11:05:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=n-jain1@ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 30VA5NSa030528; Tue, 31 Jan 2023 04:05:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1675159523; bh=8+IzRbeLyqsOrPJwl7mVqx8F+6Cl6aFr6dkZDj/rl0I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sgVIfQtTVJEMD3v35BPlSB0HSAuQxFSxKujKqglWZUW3UpeHzGsgkvTRmXdPN1hYT 2RGAM3+XZu3x2I/B0vpDLnyoSdswMtR+pi4kWfuMjU3WbF04S5m2N67s7cQe3d6AyR +GugEeV8VRf5HmzkWLTGif2/SG4el1vqCuEHfA68= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 30VA5Mis007119 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 31 Jan 2023 04:05:22 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 31 Jan 2023 04:05:22 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 31 Jan 2023 04:05:22 -0600 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 30VA5LbS060180; Tue, 31 Jan 2023 04:05:22 -0600 From: Nikhil M Jain To: , , CC: , , , , , Subject: [PATCH v2 1/7] drivers: core: ofnode: Add panel timing decode. Date: Tue, 31 Jan 2023 15:35:14 +0530 Message-ID: <20230131100520.103093-2-n-jain1@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230131100520.103093-1-n-jain1@ti.com> References: <20230131100520.103093-1-n-jain1@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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 ofnode_decode_display_timing supports reading timing parameters from subnode of display-timings node, for displays supporting multiple resolution, in case if a display supports single resolution, it fails reading directly from display-timings node, to support it ofnode_decode_panel_timing is added. Signed-off-by: Nikhil M Jain --- drivers/core/ofnode.c | 47 +++++++++++++++++++++++++++++++++++++++++++ drivers/core/read.c | 6 ++++++ include/dm/ofnode.h | 12 +++++++++++ include/dm/read.h | 14 +++++++++++++ 4 files changed, 79 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 4d56b1a767..d08578e9c4 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -991,6 +991,53 @@ int ofnode_decode_display_timing(ofnode parent, int index, return ret; } +int ofnode_decode_panel_timing(ofnode parent, + struct display_timing *dt) +{ + ofnode timings; + u32 val = 0; + int ret = 0; + + timings = ofnode_find_subnode(parent, "panel-timings"); + if (!ofnode_valid(timings)) + return -EINVAL; + memset(dt, 0, sizeof(*dt)); + ret |= decode_timing_property(timings, "hback-porch", &dt->hback_porch); + ret |= decode_timing_property(timings, "hfront-porch", &dt->hfront_porch); + ret |= decode_timing_property(timings, "hactive", &dt->hactive); + ret |= decode_timing_property(timings, "hsync-len", &dt->hsync_len); + ret |= decode_timing_property(timings, "vback-porch", &dt->vback_porch); + ret |= decode_timing_property(timings, "vfront-porch", &dt->vfront_porch); + ret |= decode_timing_property(timings, "vactive", &dt->vactive); + ret |= decode_timing_property(timings, "vsync-len", &dt->vsync_len); + ret |= decode_timing_property(timings, "clock-frequency", &dt->pixelclock); + dt->flags = 0; + if (!ofnode_read_u32(timings, "vsync-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_VSYNC_HIGH : + DISPLAY_FLAGS_VSYNC_LOW; + } + if (!ofnode_read_u32(timings, "hsync-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_HSYNC_HIGH : + DISPLAY_FLAGS_HSYNC_LOW; + } + if (!ofnode_read_u32(timings, "de-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_DE_HIGH : + DISPLAY_FLAGS_DE_LOW; + } + if (!ofnode_read_u32(timings, "pixelclk-active", &val)) { + dt->flags |= val ? DISPLAY_FLAGS_PIXDATA_POSEDGE : + DISPLAY_FLAGS_PIXDATA_NEGEDGE; + } + if (ofnode_read_bool(timings, "interlaced")) + dt->flags |= DISPLAY_FLAGS_INTERLACED; + if (ofnode_read_bool(timings, "doublescan")) + dt->flags |= DISPLAY_FLAGS_DOUBLESCAN; + if (ofnode_read_bool(timings, "doubleclk")) + dt->flags |= DISPLAY_FLAGS_DOUBLECLK; + + return ret; +} + const void *ofnode_get_property(ofnode node, const char *propname, int *lenp) { if (ofnode_is_np(node)) diff --git a/drivers/core/read.c b/drivers/core/read.c index 3e5fea87d8..e0543bbad5 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -420,6 +420,12 @@ int dev_decode_display_timing(const struct udevice *dev, int index, return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } +int dev_decode_panel_timing(const struct udevice *dev, + struct display_timing *config) +{ + return ofnode_decode_panel_timing(dev_ofnode(dev), config); +} + ofnode dev_get_phy_node(const struct udevice *dev) { return ofnode_get_phy_node(dev_ofnode(dev)); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index fa9865602d..3f6b0843c5 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -974,6 +974,18 @@ struct display_timing; int ofnode_decode_display_timing(ofnode node, int index, struct display_timing *config); +/** + * ofnode_decode_panel_timing() - decode display timings + * + * Decode panel timings from the supplied 'panel-timings' node. + * + * @node: 'display-timing' node containing the timing subnodes + * @config: Place to put timings + * Return: 0 if OK, -FDT_ERR_NOTFOUND if not found + */ +int ofnode_decode_panel_timing(ofnode node, + struct display_timing *config); + /** * ofnode_get_property() - get a pointer to the value of a node property * diff --git a/include/dm/read.h b/include/dm/read.h index cc4f16196f..107d28e956 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -784,6 +784,20 @@ int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res); int dev_decode_display_timing(const struct udevice *dev, int index, struct display_timing *config); +/** + * dev_decode_panel_timing() - decode panel timings + * + * Decode display timings from the supplied 'panel-timings' node. + * + * @dev: device to read DT display timings from. The node linked to the device + * contains a child node called 'display-timings' which in turn contains + * one or more display timing nodes. + * @config: place to put timings + * Return: 0 if OK, -FDT_ERR_NOTFOUND if not found + */ +int dev_decode_panel_timing(const struct udevice *dev, + struct display_timing *config); + /** * dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link) * -- 2.34.1