From nobody Wed Nov 27 08:51:39 2024 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B41F13D50A for ; Sat, 12 Oct 2024 07:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728717591; cv=none; b=dw01U+TZNs8+29A6QbdEhOYbv6l+gbVE5/W7rkJh1xX8Ei+M7XRxsDNq13YZNYuqbeDPoQk6neknSKAh7HP7biGGUX7jtNLppTCJljKzyZnbLKMS2r7CI/SGVLi0Hvud66eBBylUwcOx5SiNOP0eDhLw414RzFpbNZlz3JQd6Ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728717591; c=relaxed/simple; bh=y0fnOKUQDiED3PC2Orv9TeNTOXW0bTcc4bQfCqyChT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MNB2L7OVC+cALWj37N/5k7gq5DCZ3nykxJKDgF0TMaDUMoo0r7WynBXj+JbxPkPYcviOIWEkT5VN+GVQ593/hxTS7WfuKcpeT/vgO+NFoqx7bH8HYfKt3V6VmMumTSYIixQiq07va5gN1YNsz4lMq2Hc6yJ8gg+mVVol4zxIUFU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zo5pnkUe; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zo5pnkUe" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71df2de4ed4so1851966b3a.0 for ; Sat, 12 Oct 2024 00:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728717589; x=1729322389; darn=vger.kernel.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=ei1bnltRJdZvKwzxVRf43H9d7hPRtvBawiK2S1vBv6g=; b=Zo5pnkUe4h3zTjZjaxuom6LD6LYnVc8H5kMRABp/yaBK4R/s5UaaJz2Xf00OKCwNEu rws2xXo0ZuMq0oLMRXRoeHfRS/QSpXGpbXE1r8+dJYE8YsTt/JXfto6wODxBJDz0UkAb 6VJDheysQXdBR+JTeUZMCmqB6johrV2tR+/BGcZavBOGV9Li6UflCmd897/DGStwbe9B d5CyKVmXwsee7B6nsjBztyQ015TxAO4lT0yRC7DwFZRH/JQEFt51jPsmi4kzsAJuzoTO MDSLgSrFcivcl+NsaFHUR4M7uwyvXK8loWvfwxjX2Yn+P/OiqUGDKwwcQUIbtFSAmZBb uWtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728717589; x=1729322389; 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=ei1bnltRJdZvKwzxVRf43H9d7hPRtvBawiK2S1vBv6g=; b=usdSu6ES3dh51PDIadyzrBsaZ4MVyFIWe1dqap+qVFszcRE/k23DgdwLgyOXuP0K2v VTVI5TBDgp8xmFf3IHqBYaUHsFyDZIUfI7GKTZvgbUcXESbbbrWNqGADIGDSOq+AoV63 i2jaoGEc5lSgWOEbUItfVmz/q7jvfk84hw1AlYqguW/om3QwGE16mD+kV4kuIldVmyhH CU7u6Cq49/vVcTc+DrxdE9zjKyvl1ByFmJylx07JEyCWHcFMptfk7SPH/44SAV4Drlez R/S6nbvpRbgD5sNlLxrSwyEGAqGT2XYouVFW1S1ZMfG7CUUyVkSvrBF9hU6GewGSKQqv qfPw== X-Forwarded-Encrypted: i=1; AJvYcCV6nPQWzWYGlhSx/0XqzUBeEAWVGDg0w71/0kEfiGe1NODvfN1gNj/ak9vuUaxlMzLK1bs4E3kmS02haCU=@vger.kernel.org X-Gm-Message-State: AOJu0YxBNVRb041cgEM5NuohY7Ygbc9obujcSbzhVBbtt4ohiZtXaJL1 aeXaUPoYT/9d5/6hc8wKzxsvretYSwmRlBMIW0L+GLHwgeZ5f+bv X-Google-Smtp-Source: AGHT+IGHNnL0hR5nCBDTCirZJfQbJMU9jdSi821rPi96/CgZugLrK7sJ+5WJuuelZIParpqlLGUGPw== X-Received: by 2002:aa7:8e5a:0:b0:71d:f240:ec5 with SMTP id d2e1a72fcca58-71e26effbf5mr14046534b3a.14.1728717589354; Sat, 12 Oct 2024 00:19:49 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e2aaba171sm3664620b3a.161.2024.10.12.00.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Oct 2024 00:19:49 -0700 (PDT) From: Anand Moon To: Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner , Philipp Zabel , linux-phy@lists.infradead.org (open list:GENERIC PHY FRAMEWORK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-rockchip@lists.infradead.org (open list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon , Dan Carpenter Subject: [PATCH v3 3/6] phy: rockchip-pcie: Use regmap_read_poll_timeout() for PCIe reference clk PLL status Date: Sat, 12 Oct 2024 12:49:05 +0530 Message-ID: <20241012071919.3726-4-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241012071919.3726-1-linux.amoon@gmail.com> References: <20241012071919.3726-1-linux.amoon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace open-coded phy PCIe reference clk PLL status polling with regmap_read_poll_timeout API. This change simplifies the code without altering functionality. Signed-off-by: Anand Moon --- v3: None. v2: Fix the subject, add the missing () in the function name, Fix the typo reference v1: None. --- drivers/phy/rockchip/phy-rockchip-pcie.c | 56 +++++++----------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchi= p/phy-rockchip-pcie.c index b5b1b1a667b2..e60f24b0b363 100644 --- a/drivers/phy/rockchip/phy-rockchip-pcie.c +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -162,7 +162,6 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) struct rockchip_pcie_phy *rk_phy =3D to_pcie_phy(inst); int err =3D 0; u32 status; - unsigned long timeout; =20 mutex_lock(&rk_phy->pcie_mutex); =20 @@ -191,21 +190,11 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) * so we make it large enough here. And we use loop-break * method which should not be harmful. */ - timeout =3D jiffies + msecs_to_jiffies(1000); - - err =3D -EINVAL; - while (time_before(jiffies, timeout)) { - regmap_read(rk_phy->reg_base, - rk_phy->phy_data->pcie_status, - &status); - if (status & PHY_PLL_LOCKED) { - dev_dbg(&phy->dev, "pll locked!\n"); - err =3D 0; - break; - } - msleep(20); - } - + err =3D regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->phy_data->pcie_status, + status, + status & PHY_PLL_LOCKED, + 200, 100000); if (err) { dev_err(&phy->dev, "pll lock timeout!\n"); goto err_pll_lock; @@ -214,19 +203,11 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) phy_wr_cfg(rk_phy, PHY_CFG_CLK_TEST, PHY_CFG_SEPE_RATE); phy_wr_cfg(rk_phy, PHY_CFG_CLK_SCC, PHY_CFG_PLL_100M); =20 - err =3D -ETIMEDOUT; - while (time_before(jiffies, timeout)) { - regmap_read(rk_phy->reg_base, - rk_phy->phy_data->pcie_status, - &status); - if (!(status & PHY_PLL_OUTPUT)) { - dev_dbg(&phy->dev, "pll output enable done!\n"); - err =3D 0; - break; - } - msleep(20); - } - + err =3D regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->phy_data->pcie_status, + status, + !(status & PHY_PLL_OUTPUT), + 200, 100000); if (err) { dev_err(&phy->dev, "pll output enable timeout!\n"); goto err_pll_lock; @@ -236,19 +217,12 @@ static int rockchip_pcie_phy_power_on(struct phy *phy) HIWORD_UPDATE(PHY_CFG_PLL_LOCK, PHY_CFG_ADDR_MASK, PHY_CFG_ADDR_SHIFT)); - err =3D -EINVAL; - while (time_before(jiffies, timeout)) { - regmap_read(rk_phy->reg_base, - rk_phy->phy_data->pcie_status, - &status); - if (status & PHY_PLL_LOCKED) { - dev_dbg(&phy->dev, "pll relocked!\n"); - err =3D 0; - break; - } - msleep(20); - } =20 + err =3D regmap_read_poll_timeout(rk_phy->reg_base, + rk_phy->phy_data->pcie_status, + status, + status & PHY_PLL_LOCKED, + 200, 100000); if (err) { dev_err(&phy->dev, "pll relock timeout!\n"); goto err_pll_lock; --=20 2.44.0