From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751825AbcGPRet (ORCPT ); Sat, 16 Jul 2016 13:34:49 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:33359 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751667AbcGPReq (ORCPT ); Sat, 16 Jul 2016 13:34:46 -0400 Subject: Re: [PATCH v0 03/10] arm: orion5x: Add clk support for mv88f5181 To: Jamie Lentin , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Imre Kaloz , Florian Fainelli References: <1468679348-10522-1-git-send-email-jm@lentin.co.uk> <1468679348-10522-4-git-send-email-jm@lentin.co.uk> Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Sergei Shtylyov Message-ID: Date: Sat, 16 Jul 2016 20:34:43 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1468679348-10522-4-git-send-email-jm@lentin.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 7/16/2016 5:29 PM, Jamie Lentin wrote: > Referring to values in the u-boot port, add support for the mv88f5181 > > Signed-off-by: Jamie Lentin [...] > diff --git a/drivers/clk/mvebu/orion.c b/drivers/clk/mvebu/orion.c > index fd12956..a6e5bee 100644 > --- a/drivers/clk/mvebu/orion.c > +++ b/drivers/clk/mvebu/orion.c > @@ -21,6 +21,76 @@ static const struct coreclk_ratio orion_coreclk_ratios[] __initconst = { > }; > > /* > + * Orion 5181 > + */ > + > +#define SAR_MV88F5181_TCLK_FREQ 8 > +#define SAR_MV88F5181_TCLK_FREQ_MASK 0x3 > + > +static u32 __init mv88f5181_get_tclk_freq(void __iomem *sar) > +{ > + u32 opt = (readl(sar) >> SAR_MV88F5181_TCLK_FREQ) & > + SAR_MV88F5181_TCLK_FREQ_MASK; > + if (opt == 0) > + return 133333333; > + else if (opt == 1) > + return 150000000; > + else if (opt == 2) > + return 166666667; Do you know about the *switch* statement? :-) > + else > + return 0; > +} > + > +#define SAR_MV88F5181_CPU_FREQ 4 > +#define SAR_MV88F5181_CPU_FREQ_MASK 0xf > + > +static u32 __init mv88f5181_get_cpu_freq(void __iomem *sar) > +{ > + u32 opt = (readl(sar) >> SAR_MV88F5181_CPU_FREQ) & > + SAR_MV88F5181_CPU_FREQ_MASK; > + if (opt == 0) > + return 333333333; > + else if (opt == 1 || opt == 2) > + return 400000000; > + else if (opt == 3) > + return 500000000; Asks to be a *switch* as well... > + else > + return 0; > +} > + > +static void __init mv88f5181_get_clk_ratio(void __iomem *sar, int id, > + int *mult, int *div) > +{ > + u32 opt = (readl(sar) >> SAR_MV88F5181_CPU_FREQ) & > + SAR_MV88F5181_CPU_FREQ_MASK; > + if (opt == 0 || opt == 1) { > + *mult = 1; > + *div = 2; > + } else if (opt == 2 || opt == 3) { > + *mult = 1; > + *div = 3; > + } else { > + *mult = 0; > + *div = 1; > + } This one too... [...] MBR, Sergei