From patchwork Sun Oct 20 16:50:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13843156 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C075D3C92A for ; Sun, 20 Oct 2024 16:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+vxnxQou8FFtl+6NLIdjq4enwNfxLV1I+Xpk5jczg4M=; b=P6qYp82Sgf6ADs M94SA3xopi6spwdeqg/b7Pk+U3BbVfsyhWwJgsiZ0fTFzRygi9g2v46VWfizpFoKYJ439ofVLzoQ+ B9CVd3oWyJ5h1p37YXgI5w88IvZJekVOsr2Vp4R1vpbMmDBZz3BXlyG7GZT59FxuN5MrhwLhHwuoH LNXiZ5Y8jIkRbJ72zUhjcRiF5gt7vOgKen9pRUEvmpPDIKYLqbmElCRG+72FsyG5Eu6f9ODbjxXSv GBPRM05VeuxioU3cVhTqQs+dX3rAyNmH1UixKU7ucw0OZjKEk2U2ncb6HZp+oT2JCfdZzClet/8We UY1xBdUJyb8uiGZlGCqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2Z95-000000059F5-08Jc; Sun, 20 Oct 2024 16:51:11 +0000 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2Z92-000000059Ec-1Uwk for linux-phy@lists.infradead.org; Sun, 20 Oct 2024 16:51:09 +0000 Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-3a39620ff54so13514975ab.1 for ; Sun, 20 Oct 2024 09:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729443066; x=1730047866; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=83791tpaLyYi3ZWkO6Z9ZFEE4sUYJWOvQU7P98DEjZo=; b=EnJEFm4leBWvOy52trQrkqbjmCA/wNiDzLKET7Rrvqs/yiGVF3NAu05YENf6a0yLjQ 2h6q1+vnZID4i3xWBAgVQ0q+PJZDC6xi0FxqHj+KQkLnA5Uxr9wISgCCya/vUVzuyqjD kA/Jq2aob2tNNNip3GdUO7Zoo/UUen/ZZrXCGMKVrSsdMFJvK1s/1BwuJ9osY+3GZuCM 6bMg9CEM4TSYANxMIU/zp5d9kM/qXcD6ebZoGnd/E4etR4aY6WYu3ufmUOu5NaGBoqJI cgQtyIJreDw1KlXn688zyqtEZBZUB48bzMxKPOPNfKz/ncokPC5ItiPdTrZ1IhiOusop y3ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729443066; x=1730047866; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=83791tpaLyYi3ZWkO6Z9ZFEE4sUYJWOvQU7P98DEjZo=; b=UGSjqREYxxci8AwZPTtL1kdURROoMOxg+CIt61gVjGk+83LKDEqP5HfBtcE/dLI5e2 K58Nd//ZSoMOtC64wzs4adWIFJzAtDmk+0XKxgUgSG4eujxpkNHWEXBOVTKC5QNM7d0u N3EorF8eo0ldMCS9rsu4q9gq3ZyZrYHLm6ryDqLRaW31AbKSMpafwn1GlKuPdMn0oajm DyHXIz6DNY7qPz1Yadna7a+jOEEv2UvyYUY5s8ZdOL9bWAftbZ/+wvGguOduD6Qc7+MZ qF9ZzzVj5xVPZ8nVv5+ozdDbakQBH8sAHjO4s59l7yvf/VxHbcRFlG+2wKniH/OwyKvn sD6A== X-Gm-Message-State: AOJu0YyfG+QCiTBfbuMajdp417fZKj+cyJp+2r36WIWPlBkKxg8EwkZ6 xktuJ8LDjPzwNbG2pDDqaZj6OXDMgNu1tOiw10IvCMDhlXF8rc2pDnPikg== X-Google-Smtp-Source: AGHT+IGZSuHCfLPLCFrOJy8WIidvXYITJodQVFuPRmWCdbvG7lYSa4Vi6MUftNfbdwhE6XcysTCphQ== X-Received: by 2002:a05:6e02:154c:b0:3a3:972a:3991 with SMTP id e9e14a558f8ab-3a3f40a859dmr79426105ab.16.1729443065996; Sun, 20 Oct 2024 09:51:05 -0700 (PDT) Received: from aford-System-Version.. (c-75-72-162-184.hsd1.mn.comcast.net. [75.72.162.184]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc2a52fab3sm533821173.35.2024.10.20.09.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 09:51:05 -0700 (PDT) From: Adam Ford To: linux-phy@lists.infradead.org Cc: aford@beaconembedded.com, sandor.yu@nxp.com, Adam Ford , Vinod Koul , Kishon Vijay Abraham I , Frieder Schrempf , Dominique Martinet , Marco Felsch , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] phy: freescale: fsl-samsung-hdmi: Expand Integer divider range Date: Sun, 20 Oct 2024 11:50:45 -0500 Message-ID: <20241020165102.340838-1-aford173@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241020_095108_415195_0E4068AD X-CRM114-Status: GOOD ( 11.82 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org The Integer divder uses values of P,M, and S to determine the PLL rate. Currently, the range of M was set based on a series of table entries where the range was limited. Since the ref manual shows it is 8-bit wide, expand the range to be up to 255. Signed-off-by: Adam Ford Reviewed-by: Frieder Schrempf --- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c index 2c8038864357..3f9578f3f0ac 100644 --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c @@ -406,16 +406,15 @@ static unsigned long fsl_samsung_hdmi_phy_find_pms(unsigned long fout, u8 *p, u1 continue; /* - * TODO: Ref Manual doesn't state the range of _m - * so this should be further refined if possible. - * This range was set based on the original values - * in the lookup table + * The Ref manual doesn't explicitly state the range of M, + * bit it does show it as an 8-bit value, so we'll reject + * any value above 255. */ tmp = (u64)fout * (_p * _s); do_div(tmp, 24 * MHZ); - _m = tmp; - if (_m < 0x30 || _m > 0x7b) + if (tmp > 255) continue; + _m = tmp; /* * Rev 2 of the Ref Manual states the From patchwork Sun Oct 20 16:50:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13843157 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F330CD3C92A for ; Sun, 20 Oct 2024 16:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+yy/vTeXcWWvChlzHm5yxhKwherZ4uh/VH1pcPwwb3o=; b=PgSY5rrhTVBDX4 JSahUa67aZjOkiwqNf95XmorM6HCj4HghppNMglxjdfTZbIXLVHygWoA5Bceck32VAeNfX+K4s7SZ GWtZUs6nH34uvJ9viNv5aVitic9wwaxSihYpBGEJPzgWzWjYhww2hc76yvyPiMfJscpX7VhzYn64x 5zsrn2sPNc7Lg0uj4K+qPdNqU3dvBUsxlFLIaX2TW1i8gh3aDJdnUvP+meO5doOKz6DR2zLybiz0X eB+aM32yWZ2YzU7P4dl7qHP9sPkFFUzdPlur183Ui62i2oLro4p6zBEVzbF3udkd9ZVbf5x7mdnKQ DvyTawRFOw5kUuU0RHwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2Z99-000000059Fu-1mb0; Sun, 20 Oct 2024 16:51:15 +0000 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2Z97-000000059FP-2Nol for linux-phy@lists.infradead.org; Sun, 20 Oct 2024 16:51:14 +0000 Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-3a394418442so11388905ab.0 for ; Sun, 20 Oct 2024 09:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729443071; x=1730047871; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oYBLg6rMRxWp9iLFroMdP8/SxVXSgHBiuOWN86UrkIw=; b=av7SAy8pI8vAmlIqLN7tXo+tOt4C2pJzG4zjMhZSkva+D0Q0PccMR63Og9dOCfr7fh pJVZIO2C74xT+EL3w5k2j1bxnlJfhCkgq0L8OsFzLswkfPPBHqV5Luel2YywTRs4vrvm CI0v+hskdqUQXUUdnVqDV0Kd44bJ2zrugiq1X0GLTXTkqadFKwH4ruka/V/N/kHdDWhm YCd9kvbJedTrMp+IMUwLgZOGFZZfnozimFN/JMpZlodiDr7A6m2B6GM7PmHvs3Q6FuXv EFJEp4ihCKb+vUgaOcJZUIrmkaUGABoegaJKA8QHZsiIGZmaPSvtDoNUqns7ApqWhwJX 6yxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729443071; x=1730047871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oYBLg6rMRxWp9iLFroMdP8/SxVXSgHBiuOWN86UrkIw=; b=KRs6iMHQJSfAw/u840w4NqmNBtBq5dtMcmW6cYsXv7mZBvuzj2FVpYPpJXoh6hRH5t xJ4s8ncRk3fwzwxTaGtUtaLkqnea3ww1OS8yJ7e5uOC7pqTDjXB3sX85Jx+KIBH3fvLd nMZ8jNAkT4QaAC8/6Ne/Qrq94x/639i50vuTUl1PWf1m3V5HRe8vOYI6Ps13zdosKzX5 Hj181Tz0n5hDH2iEq3FJqywr3FYCHmly3uAwQeQTE89G5AHDur6EasYBJsHY/y4FhqmJ bkfs4+/YcT3XntXE+UCK5wuE4uBYc5WLjXN9WD8c03XooLSzP8fvd6rQwHdjERiBX43M ANLA== X-Gm-Message-State: AOJu0Yx4z55H6F5BI6EIvT99Go9FmZLBXQX0rrF1mtt1lDIJyuQYOqyS qJiJtXS1wgP9pKjBbbqjSrfa+ApArouhJ5ZYqssNSia8KP39nlpE9USsSw== X-Google-Smtp-Source: AGHT+IFuzOTVocMaas7n+dappwDJvhkG7PkLCuHn3PZpVgaEfKIahES5jrLYoOT+UvM5KMHwUDN6Ww== X-Received: by 2002:a05:6e02:1564:b0:3a0:a71b:75e5 with SMTP id e9e14a558f8ab-3a3f4054351mr81781465ab.7.1729443071006; Sun, 20 Oct 2024 09:51:11 -0700 (PDT) Received: from aford-System-Version.. (c-75-72-162-184.hsd1.mn.comcast.net. [75.72.162.184]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc2a52fab3sm533821173.35.2024.10.20.09.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 09:51:10 -0700 (PDT) From: Adam Ford To: linux-phy@lists.infradead.org Cc: aford@beaconembedded.com, sandor.yu@nxp.com, Adam Ford , Vinod Koul , Kishon Vijay Abraham I , Frieder Schrempf , Dominique Martinet , Marco Felsch , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] phy: freescale: fsl-samsung-hdmi: Stop searching when exact match is found Date: Sun, 20 Oct 2024 11:50:46 -0500 Message-ID: <20241020165102.340838-2-aford173@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241020165102.340838-1-aford173@gmail.com> References: <20241020165102.340838-1-aford173@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241020_095113_629456_B6AFC3EC X-CRM114-Status: GOOD ( 12.51 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org There are a series of for-loops which check various values of P and S for the integer divder PLL. The for loops search all entries and use the one closest to the nominal, but it continues to searches through all for loops even after the nominal is achieved. Ending when the nominal value is found stops wasting time, since it will not find a better value than a deviation of 0 Hz. Signed-off-by: Adam Ford Reviewed-by: Frieder Schrempf --- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c index 3f9578f3f0ac..719f8972cb5a 100644 --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c @@ -440,9 +440,13 @@ static unsigned long fsl_samsung_hdmi_phy_find_pms(unsigned long fout, u8 *p, u1 min_delta = delta; best_freq = tmp; } + + /* If we have an exact match, stop looking for a better value */ + if (!delta) + goto done; } } - +done: if (best_freq) { *p = best_p; *m = best_m; From patchwork Sun Oct 20 16:50:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13843158 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B3CAD3C92A for ; Sun, 20 Oct 2024 16:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nik7lO6V4H4uGYxza97luxINcSFgXoM0X2hdtvH6zEw=; b=iUE09ZeFAHeIp1 1WoquLnMrKOwcg72EJbncKhiP54xG4V8wzfiKAlScbv2wAcbG9spX1eS/6GnsgItDiyOdyaYXYyzA XmkIlekyqg4vgix51poVyWluXSFS7ga7nOm6oIoyXnRmvSzcQwV6MU+eCxopZJncTJE+/CoFlXOn7 YW9i1oGYIfr2jOJvU0z08+3vGu1jafSahtXmS3jKJdClKWdOYy5byPSGc//kw+2jyZkbfk+8f0O0s u/SMQTnWzGhlBjMyHBiJv08sN8eABjkMNab7Qd5hg8Bf1GgHp51CfH8hYV3IQLhKkQSsHkpKsr2Xg u60SxuJ2FzUPYtvkZ/Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2Z9E-000000059Hl-3VQb; Sun, 20 Oct 2024 16:51:20 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2Z9C-000000059GY-1e0f for linux-phy@lists.infradead.org; Sun, 20 Oct 2024 16:51:19 +0000 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3a39f73a2c7so15283985ab.0 for ; Sun, 20 Oct 2024 09:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729443076; x=1730047876; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A4PED3h42QBV+YaBIauxPbyLrEm2xxjav8Dffh6+wwU=; b=KAZxDuLmrCMgY8ubSnHv1CWVduCVmmcoEH809q+f6ZcNTRNd5OGaGcGsMX6Wu934Xb B36wSDCTNPGcsZbyR/fX+0ft5KJ41WKbssliKsu4LcCbuXz+i7rGSj1Eye0eQOv1yBiJ 1j5K2+l/V04nlgvdlnOsw+oXHlicpHHUFElI9BjKw/I2PjyArLlLV8eZa9z75EKzIqUT 1uCQzFfT1YUP9EFthg46E6Hb+qUrGLvqed2RxmAo0lWNSJMb8sr+IcW/WZrutB+MWzYV gRJFmDHEg1UIWsmXNdQDGE/V3WCdmUBLSanAMDCJ52XlmlB3AizVrDiOfS/SoeUF7XHI Itjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729443076; x=1730047876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A4PED3h42QBV+YaBIauxPbyLrEm2xxjav8Dffh6+wwU=; b=Qx+zhVuZQFk8AIrvYfuYMlrze97JlKRfM89KU1GiY72EFliYw8Rv0D5tusAgx7iKGK DAFoFNXc9Fwl/f+ESmByBlmgN4or1zJBHNbVu1yUXr7201XHGcNrweD2AUakmNgp0nid ODoB2XAVAqEOR6QvWdl5acRBKLWnoHRarvM5TZaQfp2YDn8QFNYzyvwlLiTxYGA5esbV nuRd5PKsX7nXcXB4mcziw3BRIrxXUV9tBteKf+lrG7QYaLuU0fRa3MmV7+Lme09XST40 UMMEXr6U48CiB3tUV4eC5YRc5RvIn/6awoevr3qjj0J3vuFBNb4aIjBYzIJnLR7Zqa02 z5lg== X-Gm-Message-State: AOJu0YwmG/sn+oxLMVgm05bwqKNlwogEh4ZxJ/MmpwNwkT+0+avuiQmC rzTCzAfG5BwLO/fW/QTnSkfy1xOm4UhgOb83YT8GRSHF72Ynhhl1wftacA== X-Google-Smtp-Source: AGHT+IHH2y8nl7UH4g5w15MP7jiZ7UfDxgkm0T52N9hzFqOm27QrT3RjtYmQFfua2l0RZFUrcEYtHg== X-Received: by 2002:a92:cd83:0:b0:3a3:96c4:29bc with SMTP id e9e14a558f8ab-3a3f406fe98mr81856035ab.11.1729443076248; Sun, 20 Oct 2024 09:51:16 -0700 (PDT) Received: from aford-System-Version.. (c-75-72-162-184.hsd1.mn.comcast.net. [75.72.162.184]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dc2a52fab3sm533821173.35.2024.10.20.09.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 09:51:15 -0700 (PDT) From: Adam Ford To: linux-phy@lists.infradead.org Cc: aford@beaconembedded.com, sandor.yu@nxp.com, Adam Ford , Vinod Koul , Kishon Vijay Abraham I , Frieder Schrempf , Dominique Martinet , Marco Felsch , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] phy: freescale: fsl-samsung-hdmi: Clean up fld_tg_code calculation Date: Sun, 20 Oct 2024 11:50:47 -0500 Message-ID: <20241020165102.340838-3-aford173@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241020165102.340838-1-aford173@gmail.com> References: <20241020165102.340838-1-aford173@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241020_095118_453076_9D876CE6 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Currently, the calcuation for fld_tg_code is based on a lookup table, but there are gaps in the lookup table, and frequencies in these gaps may not properly use the correct divider. Based on the description of FLD_CK_DIV, the internal PLL frequency should be less than 50 MHz, so directly calcuate the value of FLD_CK_DIV from pixclk. This allow for proper calcuation of any pixel clock and eliminates a few gaps in the LUT. Since the value of the int_pllclk is in Hz, do the fixed-point math in Hz to achieve a more accurate value and reduces the complexity of the caluation to 24MHz * (256 / int_pllclk). Fixes: 6ad082bee902 ("phy: freescale: add Samsung HDMI PHY") Signed-off-by: Adam Ford Reviewed-by: Frieder Schrempf --- drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 32 +++++++------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c index 719f8972cb5a..0bfe0c0907a0 100644 --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c @@ -331,25 +331,17 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy, { u32 pclk = cfg->pixclk; u32 fld_tg_code; - u32 pclk_khz; - u8 div = 1; - - switch (cfg->pixclk) { - case 22250000 ... 47500000: - div = 1; - break; - case 50349650 ... 99000000: - div = 2; - break; - case 100699300 ... 198000000: - div = 4; - break; - case 205000000 ... 297000000: - div = 8; - break; + u32 int_pllclk; + u8 div; + + /* Find int_pllclk speed */ + for (div = 0; div < 4; div++) { + int_pllclk = pclk / (1 << div); + if (int_pllclk < (50 * MHZ)) + break; } - writeb(FIELD_PREP(REG12_CK_DIV_MASK, ilog2(div)), phy->regs + PHY_REG(12)); + writeb(FIELD_PREP(REG12_CK_DIV_MASK, div), phy->regs + PHY_REG(12)); /* * Calculation for the frequency lock detector target code (fld_tg_code) @@ -362,10 +354,8 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy, * settings rounding up always too. TODO: Check if that is * correct. */ - pclk /= div; - pclk_khz = pclk / 1000; - fld_tg_code = 256 * 1000 * 1000 / pclk_khz * 24; - fld_tg_code = DIV_ROUND_UP(fld_tg_code, 1000); + + fld_tg_code = DIV_ROUND_UP(24 * MHZ * 256, int_pllclk); /* FLD_TOL and FLD_RP_CODE taken from downstream driver */ writeb(FIELD_PREP(REG13_TG_CODE_LOW_MASK, fld_tg_code),