{"id":815440,"url":"http://patchwork.ozlabs.org/api/patches/815440/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1505818701-49308-1-git-send-email-david.wu@rock-chips.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1505818701-49308-1-git-send-email-david.wu@rock-chips.com>","list_archive_url":null,"date":"2017-09-19T10:58:21","name":"[U-Boot,U-Boot,v2,06/14] clk: rockchip: Add rk3368 SARADC clock support","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"674d35643a3f5c86e805cdaf835ffb87db5adbc8","submitter":{"id":68083,"url":"http://patchwork.ozlabs.org/api/people/68083/?format=json","name":"David Wu","email":"david.wu@rock-chips.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1505818701-49308-1-git-send-email-david.wu@rock-chips.com/mbox/","series":[{"id":3839,"url":"http://patchwork.ozlabs.org/api/series/3839/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3839","date":"2017-09-19T10:53:11","name":"Add rockchip SARADC support","version":2,"mbox":"http://patchwork.ozlabs.org/series/3839/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815440/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815440/checks/","tags":{},"related":[],"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 3xxKdQ5yKpz9s7m\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 20:59:38 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 97CBCC21FB4; Tue, 19 Sep 2017 10:59:11 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 6EA6DC21F10;\n\tTue, 19 Sep 2017 10:59:08 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 08F56C21F10; Tue, 19 Sep 2017 10:59:04 +0000 (UTC)","from lucky1.263xmail.com (lucky1.263xmail.com [211.157.147.133])\n\tby lists.denx.de (Postfix) with ESMTPS id F1373C21FAA\n\tfor <u-boot@lists.denx.de>; Tue, 19 Sep 2017 10:59:03 +0000 (UTC)","from david.wu?rock-chips.com (unknown [192.168.167.223])\n\tby lucky1.263xmail.com (Postfix) with ESMTP id 1A94A8F7A3;\n\tTue, 19 Sep 2017 18:59:00 +0800 (CST)","from localhost.localdomain (localhost [127.0.0.1])\n\tby smtp.263.net (Postfix) with ESMTPA id 194B0369;\n\tTue, 19 Sep 2017 18:58:59 +0800 (CST)","from localhost.localdomain (unknown [58.22.7.114])\n\tby smtp.263.net (Postfix) whith ESMTP id 27406I6GNIU;\n\tTue, 19 Sep 2017 18:59:01 +0800 (CST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"****","X-Spam-Status":"No, score=4.2 required=5.0 tests=RCVD_IN_BL_SPAMCOP_NET,\n\tRCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L5,RCVD_IN_SORBS_WEB autolearn=no\n\tautolearn_force=no version=3.4.0","X-263anti-spam":"KSV:0;","X-MAIL-GRAY":"1","X-MAIL-DELIVERY":"0","X-KSVirus-check":"0","X-ABS-CHECKED":"4","X-RL-SENDER":"david.wu@rock-chips.com","X-FST-TO":"sjg@chromium.org","X-SENDER-IP":"58.22.7.114","X-LOGIN-NAME":"david.wu@rock-chips.com","X-UNIQUE-TAG":"<f08cf91e707b175e5116eb91902b0d0c>","X-ATTACHMENT-NUM":"0","X-SENDER":"wdc@rock-chips.com","X-DNS-TYPE":"0","From":"David Wu <david.wu@rock-chips.com>","To":"sjg@chromium.org,\n\tphilipp.tomsich@theobroma-systems.com","Date":"Tue, 19 Sep 2017 18:58:21 +0800","Message-Id":"<1505818701-49308-1-git-send-email-david.wu@rock-chips.com>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1505818405-49082-1-git-send-email-david.wu@rock-chips.com>","References":"<1505818405-49082-1-git-send-email-david.wu@rock-chips.com>","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":"[U-Boot] [U-Boot, v2,\n\t06/14] clk: rockchip: Add rk3368 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>","MIME-Version":"1.0","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>"},"content":"The clk_saradc is dividing from the 24M, clk_saradc=24MHz/(saradc_div_con+1).\nSARADC integer divider control register is 8-bits width.\n\nSigned-off-by: David Wu <david.wu@rock-chips.com>\nAcked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>\nReviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>\n---\n\nChange in v2:\n - Use GENMASK.\n\n arch/arm/include/asm/arch-rockchip/cru_rk3368.h |  5 ++++\n drivers/clk/rockchip/clk_rk3368.c               | 32 +++++++++++++++++++++++++\n 2 files changed, 37 insertions(+)","diff":"diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3368.h b/arch/arm/include/asm/arch-rockchip/cru_rk3368.h\nindex 2b1197f..5f6a5fb 100644\n--- a/arch/arm/include/asm/arch-rockchip/cru_rk3368.h\n+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3368.h\n@@ -89,6 +89,11 @@ enum {\n \tMCU_CLK_DIV_SHIFT\t\t= 0,\n \tMCU_CLK_DIV_MASK\t\t= GENMASK(4, 0),\n \n+\t/* CLKSEL_CON25 */\n+\tCLK_SARADC_DIV_CON_SHIFT\t= 8,\n+\tCLK_SARADC_DIV_CON_MASK\t\t= GENMASK(15, 8),\n+\tCLK_SARADC_DIV_CON_WIDTH\t= 8,\n+\n \t/* CLKSEL43_CON */\n \tGMAC_MUX_SEL_EXTCLK             = BIT(8),\n \ndiff --git a/drivers/clk/rockchip/clk_rk3368.c b/drivers/clk/rockchip/clk_rk3368.c\nindex 2be1f57..2eedf77 100644\n--- a/drivers/clk/rockchip/clk_rk3368.c\n+++ b/drivers/clk/rockchip/clk_rk3368.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/arch/clock.h>\n #include <asm/arch/cru_rk3368.h>\n #include <asm/arch/hardware.h>\n@@ -397,6 +398,31 @@ static ulong rk3368_spi_set_clk(struct rk3368_cru *cru, ulong clk_id, uint hz)\n \treturn rk3368_spi_get_clk(cru, clk_id);\n }\n \n+static ulong rk3368_saradc_get_clk(struct rk3368_cru *cru)\n+{\n+\tu32 div, val;\n+\n+\tval = readl(&cru->clksel_con[25]);\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 rk3368_saradc_set_clk(struct rk3368_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[25],\n+\t\t     CLK_SARADC_DIV_CON_MASK,\n+\t\t     src_clk_div << CLK_SARADC_DIV_CON_SHIFT);\n+\n+\treturn rk3368_saradc_get_clk(cru);\n+}\n+\n static ulong rk3368_clk_get_rate(struct clk *clk)\n {\n \tstruct rk3368_clk_priv *priv = dev_get_priv(clk->dev);\n@@ -419,6 +445,9 @@ static ulong rk3368_clk_get_rate(struct clk *clk)\n \t\trate = rk3368_mmc_get_clk(priv->cru, clk->id);\n \t\tbreak;\n #endif\n+\tcase SCLK_SARADC:\n+\t\trate = rk3368_saradc_get_clk(priv->cru);\n+\t\tbreak;\n \tdefault:\n \t\treturn -ENOENT;\n \t}\n@@ -453,6 +482,9 @@ static ulong rk3368_clk_set_rate(struct clk *clk, ulong rate)\n \t\tret = rk3368_gmac_set_clk(priv->cru, clk->id, rate);\n \t\tbreak;\n #endif\n+\tcase SCLK_SARADC:\n+\t\tret =  rk3368_saradc_set_clk(priv->cru, rate);\n+\t\tbreak;\n \tdefault:\n \t\treturn -ENOENT;\n \t}\n","prefixes":["U-Boot","U-Boot","v2","06/14"]}