Received: by 10.213.65.68 with SMTP id h4csp3610542imn; Tue, 10 Apr 2018 01:36:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx487OuMI5MZ/ZHgS+njWpoF1VF9dYd4eCArsel5P7ohDRvyz4tz2/kSoVOWI1If10Euf+X7B X-Received: by 10.98.172.15 with SMTP id v15mr1966438pfe.129.1523349384060; Tue, 10 Apr 2018 01:36:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523349384; cv=none; d=google.com; s=arc-20160816; b=UHUndY8n8AnB1g7JlupMF0k/41Jb3iPmSZ+NzS368HNc6TKmJBrDdgEEsoKBUnwWPT 0SfLcHxcSgOi6jfmzG7ecIzODFFfaSQ6gXsXauUh56nqucwn4sRtAaCIdHbjZ1PH3Occ C9NM1JlseEqvJaUQ2PPO3LvglAVs/wgFLfU/JTcYUj9dTcdU/wuFbUtR39WNnvpFnQPj Hacz9HFF73KqUGL3esAF0nrv9H8VW3c2+LoimH+TVZtGj9dkPvGTe9aiYHJzu2pOw04W qFFQ+fnNdZAt5bL7CiVKR5vuBAcon+3S2x0GIz/ei1DW8OFU410LdVncwB82H32tp9uw 3prA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=uTejhy9mkjNmE3beakON2t7s16NaUfMRMhLbUVbWFo0=; b=e2oltB8/jFjH6kOsPUrWAB4rFJxiFppI+zhXIKh6/1j7AeGRRVj1pNk2CBYI+SGyBU sURGe3Qjmk+phGUjv+7m+y/TRB8Aqb1PUdaBSiibhjLg4KaNodQ0Mcab+sjagrcJKQwY kYJ636e2gj0M5WFACbzwdi7Vy5Xh1l8SH8OVYwONnJQeO494lT8iig9rnBdUpUWymKug DVWMqLKdm4btRMKksFL7W2CRll571KgyKAkuuPy4ncYO/MMezVw6pamFkLFFn3BZHuO7 CPd0H5yZ0fF2fINoiseSB6GFJ4P/nLQcBRInY7laIcFiMcaNND7lFVF92VYAbuPIkRTL 6xaQ== ARC-Authentication-Results: i=1; mx.google.com; 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 r16si1484690pgr.560.2018.04.10.01.35.46; Tue, 10 Apr 2018 01:36:24 -0700 (PDT) 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; 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 S1752410AbeDJIcQ (ORCPT + 99 others); Tue, 10 Apr 2018 04:32:16 -0400 Received: from mail.bootlin.com ([62.4.15.54]:39293 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751849AbeDJIcO (ORCPT ); Tue, 10 Apr 2018 04:32:14 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id E3738206A0; Tue, 10 Apr 2018 10:32:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 8267020146; Tue, 10 Apr 2018 10:32:12 +0200 (CEST) Date: Tue, 10 Apr 2018 10:32:12 +0200 From: Boris Brezillon To: Marcin Ziemianowicz Cc: Boris Brezillon , Nicolas Ferre , Alexandre Belloni , Greg Kroah-Hartman , Michael Turquette , Stephen Boyd , Alan Stern , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v2 2/2] clk: at91: Fix for PLL set_rate changes not being actually written to PLL peripheral bits Message-ID: <20180410103212.7bb1d48c@bbrezillon> In-Reply-To: <20180410001649.GA62245@hak8or> References: <20180410001649.GA62245@hak8or> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marcin, On Mon, 9 Apr 2018 20:16:49 -0400 Marcin Ziemianowicz wrote: > When a USB device is connected to the USB host port on the SAM9N12 then > you get "-62" error which seems to indicate USB replies from the device > are timing out. Looking around, I saw the USB bus was running at half > speed. Going further, it seems that in ..._set_rate() the PLL wasn't > actually being adjusted. Writing the multiplier and divider values to > the peripheral fixes the bus running at half speed. > > Signed-off-by: Marcin Ziemianowicz > --- > drivers/clk/at91/clk-pll.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c > index 534961766ae5..db7155fe9346 100644 > --- a/drivers/clk/at91/clk-pll.c > +++ b/drivers/clk/at91/clk-pll.c > @@ -288,6 +288,14 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, > pll->div = div; > pll->mul = mul; > > + // Set the PLL as per above div and mil values. ^ mul Please do not use C++-style comments, use /* comment */ instead. > + regmap_update_bits(pll->regmap, AT91_CKGR_PLLBR, You hardcode the PLL ID here. What if this function if called for PLLA? > + AT91_PMC_DIV | AT91_PMC_MUL, You should use PLL_MUL_MASK(layout) and PLL_DIV_MASK to do that. > + (div << 0) | (mul << 16)); This is wrong. The clk has the CLK_SET_RATE_GATE set, which means the rate cannot be updated if the PLL is not gated, and if you look at clk_pll_prepare(), you'll see that div and mul fields are updated there. Now, maybe there's a bug in clk_pll_prepare(), but clk_pll_set_rate() is definitely not the place where we want ->div and ->mul to be written to the register. > + > + pr_debug("clk-pll: setting new rate, (%lu hz / %u) * %u = %lu hz\n", > + parent_rate, div, mul, rate); > + > return 0; > } > Regards, Boris