From patchwork Sat Oct 26 13:19:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13852238 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 1EF4BD10BF7 for ; Sat, 26 Oct 2024 13:20:41 +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=yLN+yDI5x7LVpxCArai5BeiJI8uA29cqV8hbySNFsck=; b=UMENq0arNEnLJa t5jNGM99mlFk4tBTng6T2zTQfqIUuD8KxHl24BkNYI7AFwjoRJEM/GJmHFA0RFUDPggQIerf+NjRk mZ1VryXpsqa0c+krxIXAzix05q+MlFQiv/6oBz/wmRkYOQZOCG6SHgAFqcuj+NjGoHXugyFZDJeaz A5/TxDX/W7m1R7Msl7iQKNJ0pU6qKuIfbhJifzDwK1QaZt9QFGY9zh42ENpB78GjtNqqGKPwFMA73 0e/MzKkoRd9G1VDh3qMVzJOy9Y65c41QVTh7B0sJp/zqA6fMmZDX1yG2ODg2tnLXTmXRYaCZxpJeR Vn/bUWdybKKEQ/DOSjsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t4gie-00000006gTX-0e4S; Sat, 26 Oct 2024 13:20:40 +0000 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4gic-00000006gTC-0eQw for linux-phy@lists.infradead.org; Sat, 26 Oct 2024 13:20:39 +0000 Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-460c1ba306bso18724291cf.2 for ; Sat, 26 Oct 2024 06:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729948836; x=1730553636; 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=uanSZJQklmRmS033W3BHPfWcyF9MpcVddO3gFoIl8So=; b=ALafD+eDFQvMh6tH5h7UVOCxm6FDh+rqWwnsJpr68gNeprCQ4/Jr9bIiPDMOFrdlXs 7P0HDCqid+ib04n3EEVG782yh0dF9EX9jBu5T0xSykR2dihkH2qEkoq53PsmuWW6piTA xfscMlQt0gHkCnAcwf236jqHrY4Hh3ayzoQX+qAQl0Lvn8nMyNxChIGqbsFETFQTFKlZ D4m4wnKaHBe2Zd0lRC7q4FCGCOdRwAzWkIqIkVR0fGVgcHzv2gQs1bMfM+kmIpR57dpa PpawM9GrKitskecUhoE1dynOdT87K21/E/dWPCcQzFVD6kqvuCpb4s9uRNpx8Be30iX9 ZBoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729948836; x=1730553636; 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=uanSZJQklmRmS033W3BHPfWcyF9MpcVddO3gFoIl8So=; b=tb43hq46M2lWCIYRDveCUdgyWwmudJ3nnhUt9VZYcUclceEdbIvncK/67hlOEHmXAf 9L6oZZJKHrhoHQZMqprvWd6bywc7aBu1fm9oaNesdobX/OP3tASRi5QxgxpMph9Jb/s9 EF9gaSXre0d0uzoliKTYpT8BxaohvEq8h7XTNZadukT85LYLBo5h2flEiPGxurOZBiyq flWWE8BUakhGZFfd8dIsINxlPIww3ZQlzch5yCGtY4ul9QZbJlMRmk7gTK0b9/B1PWRt +aeyhgqzMQzWkOyJ0o6nAOcJMkRRo91edkS7XB1DQiWHU/Xy5RPx7KxtJta7qXurRng+ eyug== X-Gm-Message-State: AOJu0YyqjjBKUJs7lWcF5cyc7snXLtW50hlBsefH8pCuGiV857PMpRaV VAxZmM6CaoZB0+xq2Z/PkJBPbpFW01x/Ihdc8hwdv/eJmaXJQLTInv5LFA== X-Google-Smtp-Source: AGHT+IEn9n2HjtCV52Y/1LDU/GvFsvByPZwyUUanUzueyZ+W9E7vF3ceWB70i2LUB7RZuEYbi4EJdA== X-Received: by 2002:ac8:598f:0:b0:461:18fb:f0a2 with SMTP id d75a77b69052e-4613c1ba78amr42735431cf.52.1729948835938; Sat, 26 Oct 2024 06:20:35 -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 d75a77b69052e-4613211a1b2sm16372741cf.12.2024.10.26.06.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Oct 2024 06:20:34 -0700 (PDT) From: Adam Ford To: linux-phy@lists.infradead.org Cc: aford@beaconembedded.com, sandor.yu@nxp.com, Adam Ford , Frieder Schrempf , Vinod Koul , Kishon Vijay Abraham I , Dominique Martinet , Marco Felsch , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH V2 1/3] phy: freescale: fsl-samsung-hdmi: Expand Integer divider range Date: Sat, 26 Oct 2024 08:19:57 -0500 Message-ID: <20241026132014.73050-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-20241026_062038_220431_E96BD8CF X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. 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 --- V2: Fix typo in comment diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c index 2c8038864357..412c03b7dcd6 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, + * but it does show it as an 8-bit value, so 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 Sat Oct 26 13:19:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13852239 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 026A9D10BF7 for ; Sat, 26 Oct 2024 13:20:46 +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=djroLgSzOavDCG1TF8NIYd5b7RSr3m9KKmjTl5Ox2b0=; b=B7qxWqfFsMp/Kx IR7lpk/OW2XHXnN+jZsZt7LkzJVNzxd2ElRoFBpmrAQ4U+QdQ4m7dbk/uitgGcjTA4alqtRfpKAVv qDVapgJL+N8DWKvG8PG1B3ekBPvVppfbofloKRC4cMHjK8ztwA/tTbztLYPSvAVi4nqwFDzEuBPAi ArB6jtY0tTRH9JFlEf6l51q8YfD3UwqXbbnVbldTKZk/Q1g1GWAXuDvOizGajVdfM2B0d3L/pNq9i laQ67DAVBS1vMGsBKaZR9NrmlnFBwouePbS8Omh1xyyJ3T9xUo25LcW7gRymXJ2l912hmFwIIZfJB lAw2qHlfu9uLy90RZFpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t4gik-00000006gUe-32Ev; Sat, 26 Oct 2024 13:20:46 +0000 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4gii-00000006gTt-1DHa for linux-phy@lists.infradead.org; Sat, 26 Oct 2024 13:20:45 +0000 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-4609beb631aso20517811cf.2 for ; Sat, 26 Oct 2024 06:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729948842; x=1730553642; 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=IZv8I36kWC6/J2DlG1AGKo0oUQ6LOxCOA4JeVAxdYxo=; b=O5sDfDcqCA+Xjp4uyB3VrSnU9Pon0Chk0MUbrzkeUz7Xne2nb8eXoWXgV+p8zm7ywp 05m8GzDM7T9p1nLiGP28Fy7ktK8JovxCnhajunkyrPceKss++SAJGdveTZrvFBQbEepZ 3sgHH3fqonoIfE34kFLImbX1JhJPuI77OcG7/XuPDe1M9DqDZnyPQRLK9lgvpLAfS0uN dRDgF5S0qWnHEz6sFQmnkSBX+2A44hAIsk8YMbQxffdIwXjggIUh8KvsR5hhujWYVN01 rtghd1uf4dEEFs8eqxoF3zBCEoiJc+2cJt5/gOAt5FGj40YP9rKORwWBPT8H74N2ItC8 EI2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729948842; x=1730553642; 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=IZv8I36kWC6/J2DlG1AGKo0oUQ6LOxCOA4JeVAxdYxo=; b=SZMhuAu3dXdPYz5K9X13x5RDpsdNiMZSyCdUm3lurzEW18RzDx4XWNopZzupt6821W I3j5o9ZHOy1hR9Q2iyqPxX9jSP5FjOj+jxpV4liV7lZ/T3G2ZKm0UTMOu1tBQzQqz0ts MCzj7BqHK+B5KNSZR0UNdoGlTzzFG5sd2ha9L0CoqarfYxZxFXjA/tDFNBNEYFPHciRg FPSABpLwt0ynfZRuHUstn10WE7K7+ewC5VKbrdhR4tepnzG5yTs4/KMzP/qR9aSOhKWV 90yte+c2/KSLRMebTfcS0cQvuQ0SX8mPzz4BPvI+FSLiJYB9oxOHEhy0SvOzVd/HCdlj Jw2A== X-Gm-Message-State: AOJu0Yxj6huZFN/6qLHrehtGGubxqTF8PoNaAqlVSkD+1E3EjvAJjHth fU6EGEsV4j1rlELV0OfRkrZSa5p1dJYgVrGg1fUsNwvRdPFUk5q8RSke3A== X-Google-Smtp-Source: AGHT+IHPI2RVPdbW/ih/p6cee6z8h93uWBx4fzfT592gJDHi3Jb3aeqMbYKbdKADAzmiW3s2JC0xtw== X-Received: by 2002:ac8:584f:0:b0:460:a730:3176 with SMTP id d75a77b69052e-4613bfb6ce8mr40284151cf.11.1729948842179; Sat, 26 Oct 2024 06:20:42 -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 d75a77b69052e-4613211a1b2sm16372741cf.12.2024.10.26.06.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Oct 2024 06:20:41 -0700 (PDT) From: Adam Ford To: linux-phy@lists.infradead.org Cc: aford@beaconembedded.com, sandor.yu@nxp.com, Adam Ford , Frieder Schrempf , Vinod Koul , Kishon Vijay Abraham I , Dominique Martinet , Marco Felsch , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH V2 2/3] phy: freescale: fsl-samsung-hdmi: Stop searching when exact match is found Date: Sat, 26 Oct 2024 08:19:58 -0500 Message-ID: <20241026132014.73050-2-aford173@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241026132014.73050-1-aford173@gmail.com> References: <20241026132014.73050-1-aford173@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241026_062044_352478_AA13E405 X-CRM114-Status: GOOD ( 10.16 ) 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 --- V2: No Change diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c index 412c03b7dcd6..121f67455cec 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 Sat Oct 26 13:19:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13852240 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 662ACD10BF9 for ; Sat, 26 Oct 2024 13:20:52 +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=137jr5EJbBnJfAQPl8vvF/VZtrVNpR2Ga9MDybro10w=; b=niuXD4xNYG2vZw U7B98wcm035+Ip4OYegoLx/KjlU+gSWOXNAWt9JkWuRPSA5EMX2GgjFtINpyASUC/D7L5Nqje/F1H WGP355XBMDLTFuL41DEc30J8wARI5TcuwKFdliO8hkdJUaoslykzErtTnT9ndCprlkq0HBjsYags6 EKqeTVildocddBjGpenmnqyf8zLztfPwAcZAUPRxWmANnHMQTV6Ex+HCn2BPHSQBxxuTPE3Rk7MGO pylGwe9y4P1FdLBfUjJb9vKKPDfA5sawGjnFtV1ukS0KFyL8jgNYYk5X5D+p5AS0tAMMPVW70sPA/ /UbcFYVMg+tFV12BEcUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t4giq-00000006gXF-0aqC; Sat, 26 Oct 2024 13:20:52 +0000 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4gio-00000006gVu-0uCo for linux-phy@lists.infradead.org; Sat, 26 Oct 2024 13:20:51 +0000 Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-460c1ba306bso18725351cf.2 for ; Sat, 26 Oct 2024 06:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729948848; x=1730553648; 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=6SEXUwNq69Lxz2+rJU+Fb+Wv+ryIv6HHBu9+ALfzWIM=; b=eXty0qW9tZnDLAxHIhAr/HYPZaCjuqK91Ilyya4pxy0d5XqX7YU8ngDGpUcodXb4u8 4cIPC8qBzLbtymkGapoApeP73KQ/ex8y3U4lwZJSusxSmQ+UuuZiUgZ6yGXlhXpprqpO NCj2r2EXV3LKWFHSExbvmX+ESsAopDpqtGUtZdv949NDXjOndiECnDmfatkSfn3AkcGQ bYCQumaT0fmot2ESzMSQfqMQ4ptrjeAam2zHegOhgbcJxEaCRoO8zpHS+rfWqSUfpVyD N6S3Aj1JHPXm9UvqLgu2W6Zz1UIJYTeRGdpdXfD9kZaF80qJfhVACosqmxLSsD5JJvT0 Ia0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729948848; x=1730553648; 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=6SEXUwNq69Lxz2+rJU+Fb+Wv+ryIv6HHBu9+ALfzWIM=; b=dyqrlVw0q9I2s4A9bSbau+eEFJdY9P5+cnaj9SpyjbNqQESXnid6AsVo0lJwc9PRnm uaOer1bolI2WmnWvfbIFrDKpZ2uQBKzQ0V170pVyyC2jlk3UzrpEUoQ/fBaQqE54ZXBw RNFzXeVNxyBK5t/F/BNSvltXB3WX3AO4h99c5qwO73t0qpI8NpVi1dsA4yztdaqpk3lS gTWUADbDSgFNQHPbdTHuzKcVFGKr5v/JFk/WJ/FBe/NPPvI0eagVvDCYwWdn9DypojuP TTJOTLXaxygNoAi549q5t+O+s9MEaToz+hdLIPHyaB47vkUV2g6bVRYuGtKfMpYmIVMy dl+Q== X-Gm-Message-State: AOJu0YzPeF4mEV3LxeubYyy8VMhpBW1FRGOTU5BXE66FS1EZ2ty0+uM8 P2Q+xk//Z9mPGA0xYxwPTdvx38fe39cy3KBjIgQ+rC0ke2SsuwYKGwrxPg== X-Google-Smtp-Source: AGHT+IH46XosSRPTVvmPfs9D+20b96VP9CGzbRxqUxFucRtXiWXaKWZjWuE5wDGB97MeNbRY2AFijQ== X-Received: by 2002:ac8:5946:0:b0:461:141b:47a4 with SMTP id d75a77b69052e-4613c083788mr40894821cf.36.1729948848129; Sat, 26 Oct 2024 06:20:48 -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 d75a77b69052e-4613211a1b2sm16372741cf.12.2024.10.26.06.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Oct 2024 06:20:47 -0700 (PDT) From: Adam Ford To: linux-phy@lists.infradead.org Cc: aford@beaconembedded.com, sandor.yu@nxp.com, Adam Ford , Frieder Schrempf , Vinod Koul , Kishon Vijay Abraham I , Dominique Martinet , Marco Felsch , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH V2 3/3] phy: freescale: fsl-samsung-hdmi: Clean up fld_tg_code calculation Date: Sat, 26 Oct 2024 08:19:59 -0500 Message-ID: <20241026132014.73050-3-aford173@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241026132014.73050-1-aford173@gmail.com> References: <20241026132014.73050-1-aford173@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241026_062050_276479_F9C2E029 X-CRM114-Status: GOOD ( 11.20 ) 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 --- V2: No change diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c index 121f67455cec..5eac70a1e858 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),