Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1175829imd; Sat, 3 Nov 2018 20:15:40 -0700 (PDT) X-Google-Smtp-Source: AJdET5ezB/JeasYyH8xlxOYdXYm+HUZAC+FRrz1TtEAkFey/B2ppnPohxW5MCN63UGQaGKrzwdH9 X-Received: by 2002:a17:902:e101:: with SMTP id cc1-v6mr17550012plb.165.1541301340179; Sat, 03 Nov 2018 20:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541301340; cv=none; d=google.com; s=arc-20160816; b=pWf8fRCjnZ5qyymaghitTs4AWsMhAfXdL0i3TTgcF9yrnxXCcHSXs0j7c8zjMGRWUz ftzVoYoVYgCFc7RPLS/vYqobS1GY+NimeQDfppKD174eNvo3XFAaV98EZWHjJn9rWABo yJDwqjGHSGi8luQWHZnrNklzhZGXM0UQeIFglV+4284IMC0Alx3/RawwllbEwk5mtRXo zZVR5qt08hq8aQt1eeOKGHLqryv97ZjQbDyBPsRf4mo0PJytnLBcTO5KrBQGvb5TmbFl tGAi+YicW3HPDWsROc2WjO6IU5JwhwN0DrUtbxs6YsdqyLUiYpqicwWYsv+Yx7LN8Xdx eNQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature; bh=tfS2Ggj8qpG3yz8BMtFBiO5FbpDeaky6luvRnl5aWhc=; b=hVBvPEk8DxZ58ZWYCFHNNH0dlvHpXkLbFIUxDEQeZrcyy274xdAMwyUcV89RDPw9U7 UHpedA/ydfs+6Qpn6SwJYlHb1wnajmpienG0jxUuMxHw3MrRbrQDFViOEN0gziO2TH8T Ooj6yWR0/waV72yYBwX5KZDSB0fmiafVmZDKxev/AASw1wRMledoixYpOPXQ0arXJb0G hRY1KxF57COlEM9cFXF+KLphC14dJ7S5yghjYxrYshJpw+t6gB++VXEeAQRIGLuUy528 WoK9w9DZqmlJzUYgK7AxJFMRqOYkOT0KbP0VtomblJF4WtUVWqm6vKZy3+cZbNSvHypz aXkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oTX6wGuQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si6509927pgi.146.2018.11.03.20.15.25; Sat, 03 Nov 2018 20:15:40 -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; dkim=pass header.i=@kernel.org header.s=default header.b=oTX6wGuQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729000AbeKDMQC (ORCPT + 99 others); Sun, 4 Nov 2018 07:16:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:38746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727879AbeKDMQC (ORCPT ); Sun, 4 Nov 2018 07:16:02 -0500 Received: from localhost (unknown [104.132.0.74]) (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 6B6C32082E; Sun, 4 Nov 2018 03:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541300564; bh=LWiaBqbaUBB9hsXksYdoTynqgK8e123bd8/IBy+dSZg=; h=To:From:In-Reply-To:Cc:References:Subject:Date:From; b=oTX6wGuQ0f1Qnct/8WENr8/l2ESYmrlrIeukooc4S0mLty/7pQQB8KdsdQ/WqsPVi O8zqjkLZHhC2GdHNUPff6aYkEKmgiixhnoTnqe2B7hTNFCZgyVRnjjYpK5vzWcUEpc d9y4nVQoHgMGGlYwAht6tn6kwb06WX8axCNzjJJ8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Jerome Brunet , Jianxin Pan , Neil Armstrong From: Stephen Boyd In-Reply-To: <1541089855-19356-2-git-send-email-jianxin.pan@amlogic.com> Cc: Yixun Lan , Jianxin Pan , Kevin Hilman , Carlo Caione , Michael Turquette , Rob Herring , Miquel Raynal , Boris Brezillon , Martin Blumenstingl , Liang Yang , Jian Hu , Qiufang Dai , Hanjie Lin , Victor Wan , linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org References: <1541089855-19356-1-git-send-email-jianxin.pan@amlogic.com> <1541089855-19356-2-git-send-email-jianxin.pan@amlogic.com> Message-ID: <154130056376.88331.17004780065573288593@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v6 1/3] clk: meson: add emmc sub clock phase delay driver Date: Sat, 03 Nov 2018 20:02:43 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Jianxin Pan (2018-11-01 09:30:53) > diff --git a/drivers/clk/meson/clk-phase-delay.c b/drivers/clk/meson/clk-= phase-delay.c > new file mode 100644 > index 0000000..83e74ed > --- /dev/null > +++ b/drivers/clk/meson/clk-phase-delay.c > @@ -0,0 +1,66 @@ > +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) > +/* > + * Amlogic Meson MMC Sub Clock Controller Driver > + * > + * Copyright (c) 2017 Baylibre SAS. > + * Author: Jerome Brunet > + * > + * Copyright (c) 2018 Amlogic, inc. > + * Author: Yixun Lan > + * Author: Jianxin Pan > + */ > + > +#include > +#include "clkc.h" > + > +static int meson_clk_phase_delay_get_phase(struct clk_hw *hw) > +{ > + struct clk_regmap *clk =3D to_clk_regmap(hw); > + struct meson_clk_phase_delay_data *ph =3D > + meson_clk_get_phase_delay_data(clk); Nitpick: Do this after declaring variables because it splits a line. > + unsigned long period_ps, p, d; > + int degrees; > + > + p =3D meson_parm_read(clk->map, &ph->phase); > + degrees =3D p * 360 / (1 << (ph->phase.width)); Nitpick: Remove useless parenthesis. > + > + period_ps =3D DIV_ROUND_UP((unsigned long)NSEC_PER_SEC * 1000, Is the cast necessary? > + clk_hw_get_rate(hw)); > + > + d =3D meson_parm_read(clk->map, &ph->delay); > + degrees +=3D d * ph->delay_step_ps * 360 / period_ps; > + degrees %=3D 360; > + > + return degrees; > +} > + > +static int meson_clk_phase_delay_set_phase(struct clk_hw *hw, int degree= s) > +{ > + struct clk_regmap *clk =3D to_clk_regmap(hw); > + struct meson_clk_phase_delay_data *ph =3D > + meson_clk_get_phase_delay_data(clk); > + unsigned long period_ps, d =3D 0, r; > + u64 p; > + > + p =3D degrees % 360; We don't allow phase to be larger than 360 so this isn't needed. > + period_ps =3D DIV_ROUND_UP((unsigned long)NSEC_PER_SEC * 1000, Drop the cast? > + clk_hw_get_rate(hw)); > + > + /* First compute the phase index (p), the remainder (r) is the Nitpick: Please leave /* on it's own line. > + * part we'll try to acheive using the delays (d). > + */ > + r =3D do_div(p, 360 / (1 << (ph->phase.width))); Drop useless parenthesis please. > + d =3D DIV_ROUND_CLOSEST(r * period_ps, > + 360 * ph->delay_step_ps); > + d =3D min(d, PMASK(ph->delay.width)); > + > + meson_parm_write(clk->map, &ph->phase, p); > + meson_parm_write(clk->map, &ph->delay, d); > + return 0; > +}