From patchwork Sun Apr 8 09:44:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin X-Patchwork-Id: 10328259 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 0AF0D6037F for ; Sun, 8 Apr 2018 09:44:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBB8B29052 for ; Sun, 8 Apr 2018 09:44:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDBC129065; Sun, 8 Apr 2018 09:44:52 +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 52BCC29052 for ; Sun, 8 Apr 2018 09:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752539AbeDHJov (ORCPT ); Sun, 8 Apr 2018 05:44:51 -0400 Received: from sender-of-o52.zoho.com ([135.84.80.217]:21467 "EHLO sender-of-o52.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752447AbeDHJov (ORCPT ); Sun, 8 Apr 2018 05:44:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1523180665; s=somekey; d=ziemianowicz.com; i=marcin@ziemianowicz.com; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; l=1170; bh=FsmjuKR48x5ahHpZTiAHkuYhlNvyv4VghGG20i8sGOg=; b=d+qjV2R4sMKWSe8ZCq8bVWmaFYQmgrooeUm9NvsSmkgcTxFdH1FPpT6fb4ZLJww+ bYXP8fYQ7a+w/yRkafXM0FwwU8kOQTHZc9Y4MDAG1TysUyI81PPu/pNAJ8UXOi62kkb SJgydt2VRkSU8IDjJ/aNleT039i0dbGCy9j5MPcM= Received: from hak8or (98.15.121.23 [98.15.121.23]) by mx.zohomail.com with SMTPS id 1523180665671560.0497849189027; Sun, 8 Apr 2018 02:44:25 -0700 (PDT) Date: Sun, 8 Apr 2018 05:44:23 -0400 From: Marcin To: Boris Brezillon , Nicolas Ferre , Alexandre Belloni Cc: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] clk: at91: Fix for PLL set_rate changes not being actually written to PLL peripheral bits Message-ID: <20180408094423.GA51702@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; }