linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL for 4.14 64/67] clk: axi-clkgen: Correctly handle nocount bit in recalc_rate()
Date: Thu, 8 Mar 2018 04:58:01 +0000	[thread overview]
Message-ID: <20180308045641.7814-64-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180308045641.7814-1-alexander.levin@microsoft.com>

From: Lars-Peter Clausen <lars@metafoo.de>

[ Upstream commit 063578dc5f407f67d149133818efabe457daafda ]

If the nocount bit is set the divider is bypassed and the settings for the
divider count should be ignored and a divider value of 1 should be assumed.
Handle this correctly in the driver recalc_rate() callback.

While the driver sets up the part so that the read back dividers values
yield the correct result the power-on reset settings of the part might not
reflect this and hence calling e.g. clk_get_rate() without prior calls to
clk_set_rate() will yield the wrong result.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/clk/clk-axi-clkgen.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index 5e918e7afaba..95a6e9834392 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -40,6 +40,10 @@
 #define MMCM_REG_FILTER1	0x4e
 #define MMCM_REG_FILTER2	0x4f
 
+#define MMCM_CLKOUT_NOCOUNT	BIT(6)
+
+#define MMCM_CLK_DIV_NOCOUNT	BIT(12)
+
 struct axi_clkgen {
 	void __iomem *base;
 	struct clk_hw clk_hw;
@@ -315,12 +319,27 @@ static unsigned long axi_clkgen_recalc_rate(struct clk_hw *clk_hw,
 	unsigned int reg;
 	unsigned long long tmp;
 
-	axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, &reg);
-	dout = (reg & 0x3f) + ((reg >> 6) & 0x3f);
+	axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_2, &reg);
+	if (reg & MMCM_CLKOUT_NOCOUNT) {
+		dout = 1;
+	} else {
+		axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, &reg);
+		dout = (reg & 0x3f) + ((reg >> 6) & 0x3f);
+	}
+
 	axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_DIV, &reg);
-	d = (reg & 0x3f) + ((reg >> 6) & 0x3f);
-	axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, &reg);
-	m = (reg & 0x3f) + ((reg >> 6) & 0x3f);
+	if (reg & MMCM_CLK_DIV_NOCOUNT)
+		d = 1;
+	else
+		d = (reg & 0x3f) + ((reg >> 6) & 0x3f);
+
+	axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB2, &reg);
+	if (reg & MMCM_CLKOUT_NOCOUNT) {
+		m = 1;
+	} else {
+		axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, &reg);
+		m = (reg & 0x3f) + ((reg >> 6) & 0x3f);
+	}
 
 	if (d == 0 || dout == 0)
 		return 0;
-- 
2.14.1

  parent reply	other threads:[~2018-03-08  4:59 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08  4:57 [PATCH AUTOSEL for 4.14 01/67] Bluetooth: hci_qca: Avoid setup failure on missing rampatch Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 03/67] cpufreq: longhaul: Revert transition_delay_us to 200 ms Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 02/67] Bluetooth: btqcomsmd: Fix skb double free corruption Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 05/67] media: c8sectpfe: fix potential NULL pointer dereference in c8sectpfe_timer_interrupt Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 04/67] dt-bindings: net: add TI CC2560 Bluetooth chip Sasha Levin
2018-03-08 16:09   ` David Lechner
2018-03-09 16:38     ` Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 06/67] drm/msm: fix leak in failed get_pages Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 08/67] dm: ensure bio submission follows a depth-first tree walk Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 07/67] net: fec: add phy_reset_after_clk_enable() support Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 09/67] RDMA/iwpm: Fix uninitialized error code in iwpm_send_mapinfo() Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 10/67] hv_netvsc: Fix the receive buffer size limit Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 11/67] hv_netvsc: Fix the TX/RX buffer default sizes Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 12/67] KVM: x86: add support for emulating UMIP Sasha Levin
2018-03-08  6:46   ` Paolo Bonzini
2018-03-19 15:22     ` Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 14/67] rtlwifi: rtl_pci: Fix the bug when inactiveps is enabled Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 13/67] spi: sh-msiof: Avoid writing to registers from spi_master.setup() Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 16/67] media: bt8xx: Fix err 'bt878_probe()' Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 15/67] rtlwifi: always initialize variables given to RT_TRACE() Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 17/67] ath10k: handling qos at STA side based on AP WMM enable/disable Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 19/67] qmi_wwan: set FLAG_SEND_ZLP to avoid network initiated disconnect Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 18/67] media: [RESEND] media: dvb-frontends: Add delay to Si2168 restart Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 20/67] tty: goldfish: Enable 'earlycon' only if built-in Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 21/67] serial: 8250_dw: Disable clock on error Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 23/67] watchdog: Fix potential kref imbalance when opening watchdog Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 22/67] cros_ec: fix nul-termination for firmware build info Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 24/67] watchdog: Fix kref imbalance seen if handle_boot_enabled=0 Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 26/67] dmaengine: zynqmp_dma: Fix race condition in the probe Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 25/67] platform/chrome: Use proper protocol transfer function Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 28/67] mmc: avoid removing non-removable hosts during suspend Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 27/67] drm/tilcdc: ensure nonatomic iowrite64 is not used Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 29/67] mmc: block: fix logical error to avoid memory leak Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 30/67] /dev/mem: Add bounce buffer for copy-out Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 33/67] sfp: fix non-detection of PHY Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 32/67] sfp: fix EEPROM reading in the case of non-SFF8472 SFPs Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 31/67] net: phy: meson-gxl: check phy_write return value Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 35/67] rtc: ac100: Fix multiple race conditions Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 34/67] media: s5p-mfc: Fix lock contention - request_firmware() once Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 37/67] RDMA/cma: Use correct size when writing netlink stats Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 36/67] IB/ipoib: Avoid memory leak if the SA returns a different DGID Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 38/67] IB/umem: Fix use of npages/nmap fields Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 39/67] iser-target: avoid reinitializing rdma contexts for isert commands Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 42/67] mmc: sdhci-xenon: wait 5ms after set 1.8V signal enable Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 41/67] omapdrm: panel: fix compatible vendor string for td028ttec1 Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 40/67] vgacon: Set VGA struct resource types Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 44/67] pty: cancel pty slave port buf's work in tty_release Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 43/67] drm/omap: DMM: Check for DMM readiness after successful transaction commit Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 46/67] PCI: designware-ep: Fix ->get_msi() to check MSI_EN bit Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 45/67] coresight: Fix disabling of CoreSight TPIU Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 49/67] media: davinci: fix a debug printk Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 47/67] PCI: endpoint: Fix find_first_zero_bit() usage Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 48/67] PCI: rcar: Handle rcar_pcie_parse_request_of_pci_ranges() failures Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 51/67] pinctrl: rockchip: enable clock when reading pin direction register Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 50/67] pinctrl: Really force states during suspend/resume Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 53/67] ip6_vti: adjust vti mtu according to mtu of lower device Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 52/67] iommu/vt-d: clean up pr_irq if request_threaded_irq fails Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 55/67] ip_gre: fix potential memory leak in erspan_rcv Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 54/67] ip_gre: fix error path when erspan_rcv failed Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 56/67] soc: qcom: smsm: fix child-node lookup Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 58/67] scsi: lpfc: Fix issues connecting with nvme initiator Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 57/67] scsi: lpfc: Fix SCSI LUN discovery when SCSI and NVME enabled Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 59/67] RDMA/ocrdma: Fix permissions for OCRDMA_RESET_STATS Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 60/67] ARM: dts: aspeed-evb: Add unit name to memory node Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 61/67] nfsd4: permit layoutget of executable-only files Sasha Levin
2018-03-08  4:57 ` [PATCH AUTOSEL for 4.14 62/67] clk: at91: pmc: Wait for clocks when resuming Sasha Levin
2018-03-08  4:58 ` [PATCH AUTOSEL for 4.14 63/67] clk: Don't touch hardware when reparenting during registration Sasha Levin
2018-03-08  4:58 ` Sasha Levin [this message]
2018-03-08  4:58 ` [PATCH AUTOSEL for 4.14 65/67] clk: si5351: Rename internal plls to avoid name collisions Sasha Levin
2018-03-08  4:58 ` [PATCH AUTOSEL for 4.14 66/67] crypto: artpec6 - set correct iv size for gcm(aes) Sasha Levin
2018-03-08  4:58 ` [PATCH AUTOSEL for 4.14 67/67] dmaengine: ti-dma-crossbar: Fix event mapping for TPCC_EVT_MUX_60_63 Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180308045641.7814-64-alexander.levin@microsoft.com \
    --to=alexander.levin@microsoft.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).