Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1618751ybv; Fri, 21 Feb 2020 00:24:05 -0800 (PST) X-Google-Smtp-Source: APXvYqyv5UCS9WETEH6gQC5Vxpu9DkejCF+RU96iTxl9KgsxP824KYv2HMtqjcuFH7Ldp7Ef1BGg X-Received: by 2002:a9d:5d09:: with SMTP id b9mr26683921oti.207.1582273445272; Fri, 21 Feb 2020 00:24:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273445; cv=none; d=google.com; s=arc-20160816; b=yYle3PTMxk6LSW5iMLgi2gCpQlWq1b9V86l9f+E7mXQca+H4CTajy3GFE05O7IrUut 1yCYGzESgrRPqZcVaOVLMd1f+BWtXvWhzJVagY4RHQv892YYLdJq5whiaVE9qmElpYuP gp1rR62nUilekKZYkFdpyEled1KxykaU1yFpVbODPL10R+i5iqR5XLUOZo1nAym6Bjpl Y7P1+LSq+kTJFY5B80e15ikzmO+uu76o2spC6AeXssawA156F5Px3f0a6IaeYXqvHMMW c8XuthQYA0C3deRa8eJR1ZE87lSj7YIbZvgjgHsRiQfTSaA9RRsEnCGSP10vQEdiETvi 7mJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HJlLLHXqSPMD8WaLFMJN0JIck3cK6L7Hgiky29ouBGs=; b=hErJ0RKFU76K+R3jomMWUpzYRwY1DHjJZzZYybbXj4Ybsshbx2iFydS1EJhHm9tldV h8nT4IKrm0RHedF68EUdtK+CrbsbTgB1jc892Jv/uP/EAXSQaupO7ELjbIZ5BbKARthy Qangh7mlw/P21c+y20lee310Ma9htOZI5pr9ckOWtK0ZO4Zl+GxrlqSZRCIlb/axOrbp 8zFOMP9dAQdp4y7kCDBv31++VvM7y/cEdBWLML3Vv94nOG2x9uOezlbT/sLk/VGVKjtB nbngAt/0YLDqqAkTe68o1YPoFT2pdFHYc8ldKKUAo4+rhCjglRPc/jc3Rbp+5DsIPEwc jfKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vfG3vU2G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si1083408otr.159.2020.02.21.00.23.53; Fri, 21 Feb 2020 00:24:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vfG3vU2G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388271AbgBUIWR (ORCPT + 99 others); Fri, 21 Feb 2020 03:22:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:33822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388038AbgBUIWP (ORCPT ); Fri, 21 Feb 2020 03:22:15 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBD5424673; Fri, 21 Feb 2020 08:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273335; bh=tUg751Affnoyn3FW3QZPYI49oz153hfQFyw6kq9w/7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vfG3vU2GIwfGshzYa6JUlYpF4b7KVSx5rhRVwg4unap1Q+nkxnKQJ9tgawE+Thu7G LYyBkIhqTifISsWaUp26vp0qffscjXnJhYtt+miwipNn/ivs/16vMV+WD5y1XT+L8K +M8wZ7POIyu8P+4myyjcvrnoJFHU+XlTC8IiaA0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Icenowy Zheng , Vasily Khoruzhick , Maxime Ripard , Sasha Levin Subject: [PATCH 4.19 094/191] clk: sunxi-ng: add mux and pll notifiers for A64 CPU clock Date: Fri, 21 Feb 2020 08:41:07 +0100 Message-Id: <20200221072302.330809496@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Icenowy Zheng [ Upstream commit ec97faff743b398e21f74a54c81333f3390093aa ] The A64 PLL_CPU clock has the same instability if some factor changed without the PLL gated like other SoCs with sun6i-style CCU, e.g. A33, H3. Add the mux and pll notifiers for A64 CPU clock to workaround the problem. Fixes: c6a0637460c2 ("clk: sunxi-ng: Add A64 clocks") Signed-off-by: Icenowy Zheng Signed-off-by: Vasily Khoruzhick Signed-off-by: Maxime Ripard Signed-off-by: Sasha Levin --- drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c index dec4a130390a3..9ac6c299e0744 100644 --- a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c +++ b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c @@ -901,11 +901,26 @@ static const struct sunxi_ccu_desc sun50i_a64_ccu_desc = { .num_resets = ARRAY_SIZE(sun50i_a64_ccu_resets), }; +static struct ccu_pll_nb sun50i_a64_pll_cpu_nb = { + .common = &pll_cpux_clk.common, + /* copy from pll_cpux_clk */ + .enable = BIT(31), + .lock = BIT(28), +}; + +static struct ccu_mux_nb sun50i_a64_cpu_nb = { + .common = &cpux_clk.common, + .cm = &cpux_clk.mux, + .delay_us = 1, /* > 8 clock cycles at 24 MHz */ + .bypass_index = 1, /* index of 24 MHz oscillator */ +}; + static int sun50i_a64_ccu_probe(struct platform_device *pdev) { struct resource *res; void __iomem *reg; u32 val; + int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); reg = devm_ioremap_resource(&pdev->dev, res); @@ -919,7 +934,18 @@ static int sun50i_a64_ccu_probe(struct platform_device *pdev) writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG); - return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc); + ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc); + if (ret) + return ret; + + /* Gate then ungate PLL CPU after any rate changes */ + ccu_pll_notifier_register(&sun50i_a64_pll_cpu_nb); + + /* Reparent CPU during PLL CPU rate changes */ + ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk, + &sun50i_a64_cpu_nb); + + return 0; } static const struct of_device_id sun50i_a64_ccu_ids[] = { -- 2.20.1