From patchwork Tue Apr 10 00:16:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin X-Patchwork-Id: 10332149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A5CCE6020F for ; Tue, 10 Apr 2018 00:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97038288E2 for ; Tue, 10 Apr 2018 00:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B69F28C6E; Tue, 10 Apr 2018 00:17:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14018288E2 for ; Tue, 10 Apr 2018 00:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbeDJARP (ORCPT ); Mon, 9 Apr 2018 20:17:15 -0400 Received: from sender-of-o52.zoho.com ([135.84.80.217]:21357 "EHLO sender-of-o52.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751629AbeDJARO (ORCPT ); Mon, 9 Apr 2018 20:17:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1523319412; s=somekey; d=ziemianowicz.com; i=marcin@ziemianowicz.com; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; l=1170; bh=MglSacAcCxFDhrbYEw99COxIM8zRWq9KhZ4wSD7RQMk=; b=Z/Kt2CwaC2q+e+kX/tgZqwPG+t0auHvY1ZMAEqBw7sGQ19VIrdrwxsPklJbVmy4u sUxsHCSH+qYGxhpHpMp3t7SnwJYNfc5xSA/uVGozeL0nwz9sibraAEp8ZCJPzH8e4QJ ygDWACg59opR29aXMFyWQt612KY7FYId+JHeiCg0= Received: from hak8or (98.15.121.23 [98.15.121.23]) by mx.zohomail.com with SMTPS id 15233194120511004.612107987669; Mon, 9 Apr 2018 17:16:52 -0700 (PDT) Date: Mon, 9 Apr 2018 20:16:49 -0400 From: Marcin Ziemianowicz To: Boris Brezillon , Nicolas Ferre , Alexandre Belloni , Greg Kroah-Hartman Cc: 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: [PATCH v2 2/2] clk: at91: Fix for PLL set_rate changes not being actually written to PLL peripheral bits Message-ID: <20180410001649.GA62245@hak8or> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-ZohoMailClient: External Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. + regmap_update_bits(pll->regmap, AT91_CKGR_PLLBR, + AT91_PMC_DIV | AT91_PMC_MUL, + (div << 0) | (mul << 16)); + + pr_debug("clk-pll: setting new rate, (%lu hz / %u) * %u = %lu hz\n", + parent_rate, div, mul, rate); + return 0; }