[{"id":1768148,"web_url":"http://patchwork.ozlabs.org/comment/1768148/","msgid":"<E1dsDwm-0004RU-9o@mail.theobroma-systems.com>","list_archive_url":null,"date":"2017-09-13T20:07:44","subject":"Re: [U-Boot] [U-Boot,\n\t7/8] clk: rockchip: Add rk3399 Saradc clock support","submitter":{"id":53488,"url":"http://patchwork.ozlabs.org/api/people/53488/","name":"Philipp Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"content":"> The clk_saradc is dividing from the 24M, clk_saradc=24MHz/(saradc_div_con+1).\n> Saradc integer divider control register is 8-bits width.\n> \n> Signed-off-by: David Wu <david.wu@rock-chips.com>\n> ---\n>  drivers/clk/rockchip/clk_rk3399.c | 34 ++++++++++++++++++++++++++++++++++\n>  1 file changed, 34 insertions(+)\n> \n\nAcked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xstfW4Rr4z9sNw\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 06:33:39 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 62C2EC22300; Wed, 13 Sep 2017 20:33:35 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 0C82AC22168;\n\tWed, 13 Sep 2017 20:33:33 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 74996C22168; Wed, 13 Sep 2017 20:33:32 +0000 (UTC)","from mail.theobroma-systems.com (vegas.theobroma-systems.com\n\t[144.76.126.164])\n\tby lists.denx.de (Postfix) with ESMTPS id 4F0A5C21F61\n\tfor <u-boot@lists.denx.de>; Wed, 13 Sep 2017 20:33:31 +0000 (UTC)","from 89-104-28-141.customer.bnet.at ([89.104.28.141]:62926\n\thelo=vpn-10-11-0-14.lan) by mail.theobroma-systems.com with esmtpsa\n\t(TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80)\n\t(envelope-from <philipp.tomsich@theobroma-systems.com>)\n\tid 1dsDwm-0004RU-9o; Wed, 13 Sep 2017 22:07:44 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0","MIME-Version":"1.0","From":"Philipp Tomsich <philipp.tomsich@theobroma-systems.com>","To":"David Wu <david.wu@rock-chips.com>","In-Reply-To":"<1505302438-74792-1-git-send-email-david.wu@rock-chips.com>","References":"<1505302438-74792-1-git-send-email-david.wu@rock-chips.com>","Message-Id":"<E1dsDwm-0004RU-9o@mail.theobroma-systems.com>","Date":"Wed, 13 Sep 2017 22:07:44 +0200","Cc":"huangtao@rock-chips.com, zhangqing@rock-chips.com, u-boot@lists.denx.de, \n\tDavid Wu <david.wu@rock-chips.com>, andy.yan@rock-chips.com,\n\tchenjh@rock-chips.com","Subject":"Re: [U-Boot] [U-Boot,\n\t7/8] clk: rockchip: Add rk3399 Saradc clock support","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1768160,"web_url":"http://patchwork.ozlabs.org/comment/1768160/","msgid":"<alpine.OSX.2.21.1709132241520.52090@vpn-10-11-0-14.lan>","list_archive_url":null,"date":"2017-09-13T20:42:43","subject":"Re: [U-Boot] [U-Boot,\n\t7/8] clk: rockchip: Add rk3399 Saradc clock support","submitter":{"id":53488,"url":"http://patchwork.ozlabs.org/api/people/53488/","name":"Philipp Tomsich","email":"philipp.tomsich@theobroma-systems.com"},"content":"On Wed, 13 Sep 2017, David Wu wrote:\n\n> The clk_saradc is dividing from the 24M, clk_saradc=24MHz/(saradc_div_con+1).\n> Saradc integer divider control register is 8-bits width.\n>\n> Signed-off-by: David Wu <david.wu@rock-chips.com>\n\nReviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>\n\n> ---\n> drivers/clk/rockchip/clk_rk3399.c | 34 ++++++++++++++++++++++++++++++++++\n> 1 file changed, 34 insertions(+)\n>\n> diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c\n> index 3edafea..5efe2c2 100644\n> --- a/drivers/clk/rockchip/clk_rk3399.c\n> +++ b/drivers/clk/rockchip/clk_rk3399.c\n> @@ -12,6 +12,7 @@\n> #include <errno.h>\n> #include <mapmem.h>\n> #include <syscon.h>\n> +#include <bitfield.h>\n> #include <asm/io.h>\n> #include <asm/arch/clock.h>\n> #include <asm/arch/cru_rk3399.h>\n> @@ -182,6 +183,7 @@ enum {\n> \t/* CLKSEL_CON26 */\n> \tCLK_SARADC_DIV_CON_SHIFT\t= 8,\n> \tCLK_SARADC_DIV_CON_MASK\t\t= 0xff << CLK_SARADC_DIV_CON_SHIFT,\n\nCan we use GENMASK here?\n\n> +\tCLK_SARADC_DIV_CON_WIDTH\t= 8,\n>\n> \t/* CLKSEL_CON27 */\n> \tCLK_TSADC_SEL_X24M\t\t= 0x0,\n> @@ -860,6 +862,32 @@ static ulong rk3399_ddr_set_clk(struct rk3399_cru *cru,\n>\n> \treturn set_rate;\n> }\n> +\n> +static ulong rk3399_saradc_get_clk(struct rk3399_cru *cru)\n> +{\n> +\tu32 div, val;\n> +\n> +\tval = readl(&cru->clksel_con[26]);\n> +\tdiv = bitfield_extract(val, CLK_SARADC_DIV_CON_SHIFT,\n> +\t\t\t       CLK_SARADC_DIV_CON_WIDTH);\n> +\n> +\treturn DIV_TO_RATE(OSC_HZ, div);\n> +}\n> +\n> +static ulong rk3399_saradc_set_clk(struct rk3399_cru *cru, uint hz)\n> +{\n> +\tint src_clk_div;\n> +\n> +\tsrc_clk_div = DIV_ROUND_UP(OSC_HZ, hz) - 1;\n> +\tassert(src_clk_div < 128);\n> +\n> +\trk_clrsetreg(&cru->clksel_con[26],\n> +\t\t     CLK_SARADC_DIV_CON_MASK,\n> +\t\t     src_clk_div << CLK_SARADC_DIV_CON_SHIFT);\n> +\n> +\treturn rk3399_saradc_get_clk(cru);\n> +}\n> +\n> static ulong rk3399_clk_get_rate(struct clk *clk)\n> {\n> \tstruct rk3399_clk_priv *priv = dev_get_priv(clk->dev);\n> @@ -895,6 +923,9 @@ static ulong rk3399_clk_get_rate(struct clk *clk)\n> \t\tbreak;\n> \tcase PCLK_EFUSE1024NS:\n> \t\tbreak;\n> +\tcase SCLK_SARADC:\n> +\t\trate = rk3399_saradc_get_clk(priv->cru);\n> +\t\tbreak;\n> \tdefault:\n> \t\treturn -ENOENT;\n> \t}\n> @@ -943,6 +974,9 @@ static ulong rk3399_clk_set_rate(struct clk *clk, ulong rate)\n> \t\tbreak;\n> \tcase PCLK_EFUSE1024NS:\n> \t\tbreak;\n> +\tcase SCLK_SARADC:\n> +\t\tret = rk3399_saradc_set_clk(priv->cru, rate);\n> +\t\tbreak;\n> \tdefault:\n> \t\treturn -ENOENT;\n> \t}\n>","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xstsK3dlhz9ryv\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 06:43:01 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid C9E16C2242F; Wed, 13 Sep 2017 20:42:52 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 74EF6C22294;\n\tWed, 13 Sep 2017 20:42:49 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 53A25C22294; Wed, 13 Sep 2017 20:42:47 +0000 (UTC)","from mail.theobroma-systems.com (vegas.theobroma-systems.com\n\t[144.76.126.164])\n\tby lists.denx.de (Postfix) with ESMTPS id 1B93EC22168\n\tfor <u-boot@lists.denx.de>; Wed, 13 Sep 2017 20:42:47 +0000 (UTC)","from [86.59.122.178] (port=60372 helo=android.lan)\n\tby mail.theobroma-systems.com with esmtps\n\t(TLS1.2:RSA_AES_128_CBC_SHA1:128)\n\t(Exim 4.80) (envelope-from <philipp.tomsich@theobroma-systems.com>)\n\tid 1dsEUf-0005b4-0t; Wed, 13 Sep 2017 22:42:45 +0200","from [10.11.0.14] (helo=vpn-10-11-0-14.lan)\n\tby android.lan with esmtp (Exim 4.84_2)\n\t(envelope-from <philipp.tomsich@theobroma-systems.com>)\n\tid 1dsEUe-00084Q-HQ; Wed, 13 Sep 2017 22:42:44 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0","Date":"Wed, 13 Sep 2017 22:42:43 +0200 (CEST)","From":"Philipp Tomsich <philipp.tomsich@theobroma-systems.com>","X-X-Sender":"ptomsich@vpn-10-11-0-14.lan","To":"David Wu <david.wu@rock-chips.com>","In-Reply-To":"<1505302438-74792-1-git-send-email-david.wu@rock-chips.com>","Message-ID":"<alpine.OSX.2.21.1709132241520.52090@vpn-10-11-0-14.lan>","References":"<1505302438-74792-1-git-send-email-david.wu@rock-chips.com>","User-Agent":"Alpine 2.21 (OSX 202 2017-01-01)","MIME-Version":"1.0","Cc":"huangtao@rock-chips.com, zhangqing@rock-chips.com, u-boot@lists.denx.de, \n\tandy.yan@rock-chips.com, chenjh@rock-chips.com","Subject":"Re: [U-Boot] [U-Boot,\n\t7/8] clk: rockchip: Add rk3399 Saradc clock support","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Transfer-Encoding":"base64","Content-Type":"text/plain; charset=\"utf-8\"; Format=\"flowed\"","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}}]