From patchwork Wed Jul 26 20:31:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 108798 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1233385qge; Wed, 26 Jul 2017 13:31:51 -0700 (PDT) X-Received: by 10.84.137.169 with SMTP id 38mr2008608pln.331.1501101111267; Wed, 26 Jul 2017 13:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501101111; cv=none; d=google.com; s=arc-20160816; b=lGwGMXnTiQqJXJWXeYuI/WVfd7Ttse37PUQPlymhebdIck5ygdk5Q8xl2npO8UCOBC xnl4v3XR1vK5M3pH6u1Tsh/20qnDXkmqIhWo+HiUxz9Os2G6UtITl+sZZ9drxF6ul2Rt S0NvSp2jcVDm6B+oEXoQzdgrE+LUJSz67TPt5wE9PW0v3jENG0SuBWVruN74PenhUsC6 X/o9CKmlijvy17/B9PhFiWSIKBuCdyce44Vyz0iVauWByqWtsPXtsuJRmMn5VWJdaL4F rjJN3KcgJhInllCximBJzfFvhDom4QklKCK+l7sXwIGoICHXgfmJfUojvRMLX2eHxYlf /ZNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=4eSS/fmMe6uKWQXFB4sMv5cbl9yxlhwJBn9ZUNq//wY=; b=EBnIEQJy0Tq7mkH1ZECL3AkqWBogWFiV6F2xJCBoRbALv1BAXyaLUZZsQ147sUJt7q qBW37cxhYoDMm5oC3jhlCYIWkiB+7qeEDSHEhfW5lS/1Nn0b2nMElYdCwjGbhygNT9Ov Ffdj/SU2sAFkDYnUPFSh3meQdg6RKIn4P8YRGUGkFHUq4e6/vzY4csK6X9kE1Pc75uRj OA97A/USiRqU3OsvqwzTF16A82K8KV0R5pQoFhZoJcxrI9Lkot6NAAhBFZKjGT44WH1+ 2IOwryoY2NHP/AEpoB48WXTmhNFUPUxIVI/pYXvyooRE/KaLtUlbUxXGVtCUv0QTk2Bd OsTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.b=0b20BNhn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z68si9948822pfa.375.2017.07.26.13.31.50; Wed, 26 Jul 2017 13:31:51 -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=@baylibre-com.20150623.gappssmtp.com header.b=0b20BNhn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751454AbdGZUbs (ORCPT + 26 others); Wed, 26 Jul 2017 16:31:48 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36157 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751034AbdGZUbp (ORCPT ); Wed, 26 Jul 2017 16:31:45 -0400 Received: by mail-wm0-f52.google.com with SMTP id t201so82534483wmt.1 for ; Wed, 26 Jul 2017 13:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=4eSS/fmMe6uKWQXFB4sMv5cbl9yxlhwJBn9ZUNq//wY=; b=0b20BNhnIX3xRPAoByq4sV1Jh5vuLN+pj/0PxWzCSsEpk4Wx7Ldn/jyfegqYJwsWYs c/GMmYICwWo9uoi3uiXZ7GrsL6bf9m0O9g8Dr6xacSvK1MM6fqrEdO5TNdwNQsrGxFTc 78VLDFUzah17fBGe4qsgu1uaUcSwXGnzowtUb1B5rnPz2NefoEAIkSy65pFJEsv8VXAJ aee+YnW/+35bSzKqThYKHIpOtNTzQ/3gpnsvjj5QUoNVYMBV5zZj7x+iolFOVUHiAkyg xp5jRODTj/zS6309KVKiqsm/ogzK/plIkPkK7OHeDgjH3zlvvzaXwXna0IZVZKzelywA adyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4eSS/fmMe6uKWQXFB4sMv5cbl9yxlhwJBn9ZUNq//wY=; b=U5jvo7wwR6hIaKGtT9C7V4mH6MgsMaGN1sBYw0zVTg+B/njJuHxJF7Ss3rUaxGByXm nvVwfVIvB7PmEuBdaT/ui5cPsoVFrrWclu3FKJ7L0YqIB9RO2zgoCSlScG2O8SO3wUSu 0k30ijn2JRgStVEkEvHV2HZ/59ya2jSiv39sUzrbgv8kPxdpCpvcnrzuFmQuKaQAx8xN chhIBIqgJYbIfhwNdxEI9TuDf0UZFtH1TR1GDYHw0xWbNiubuJvymFYrGPMCFKjy5SUe wnWY2p+IJeKuxmu6qkLFuyFw7Zu+LSkxNDCJ0YrQbZJpoym3j+HlI/R1hrAYrZ5Naczd 6i6Q== X-Gm-Message-State: AIVw110Wx8irIJo/rA93Ji2FsH7fDUSwYHMPJFveM4+lyt5+2TObyoCL 6B7Wq2cjJRAnddRt X-Received: by 10.28.34.130 with SMTP id i124mr1635671wmi.135.1501101103589; Wed, 26 Jul 2017 13:31:43 -0700 (PDT) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id 1sm13457637wmn.32.2017.07.26.13.31.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 13:31:43 -0700 (PDT) From: Jerome Brunet To: Neil Armstrong , Michael Turquette , Stephen Boyd , Kevin Hilman Cc: Jerome Brunet , Carlo Caione , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: meson: gxbb: add sd_emmc clk0 clocks Date: Wed, 26 Jul 2017 22:31:38 +0200 Message-Id: <20170726203138.11367-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Input source 0 of the mmc controllers are not the xtal, as currently described in DT, but composite clocks (the usual mux, divider and gate). The muxes can take the crytal (default) and any of the fclk_div clocks which should provide any rate an mmc/nand could request. The mux should also be able to take mpll2, mpll3 and gp0_pll but these are precious clock for other usage. It is better if the mmc does not use these them. For this reason, mpll2, mpll3 and gp0_pll is not listed among the possible parent. Signed-off-by: Jerome Brunet --- drivers/clk/meson/gxbb.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/meson/gxbb.h | 11 +++- 2 files changed, 177 insertions(+), 1 deletion(-) -- 2.9.4 diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index a897ea45327c..d466901e88a2 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -974,6 +974,146 @@ static struct clk_mux gxbb_32k_clk_sel = { }, }; +static const char * const gxbb_sd_emmc_clk0_parent_names[] = { + "xtal", "fclk_div2", "fclk_div3", "fclk_div5", "fclk_div7", + + /* + * Following these clocks, we should also have had mpll2, mpll3 + * and gp0_pll but these clocks are too precious to be used here. + * All the necessary rates for MMC and NAND operation can acheived + * using the xtal and the fclk_div clocks + */ +}; + +/* SDIO clock */ +static struct clk_mux gxbb_sd_emmc_a_clk0_sel = { + .reg = (void *)HHI_SD_EMMC_CLK_CNTL, + .mask = 0x7, + .shift = 9, + .lock = &clk_lock, + .hw.init = &(struct clk_init_data) { + .name = "sd_emmc_a_clk0_sel", + .ops = &clk_mux_ops, + .parent_names = gxbb_sd_emmc_clk0_parent_names, + .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names), + .flags = CLK_SET_RATE_PARENT, + }, +}; + +static struct clk_divider gxbb_sd_emmc_a_clk0_div = { + .reg = (void *)HHI_SD_EMMC_CLK_CNTL, + .shift = 0, + .width = 7, + .lock = &clk_lock, + .flags = CLK_DIVIDER_ROUND_CLOSEST, + .hw.init = &(struct clk_init_data) { + .name = "sd_emmc_a_clk0_div", + .ops = &clk_divider_ops, + .parent_names = (const char *[]){ "sd_emmc_a_clk0_sel" }, + .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, + }, +}; + +static struct clk_gate gxbb_sd_emmc_a_clk0 = { + .reg = (void *)HHI_SD_EMMC_CLK_CNTL, + .bit_idx = 7, + .lock = &clk_lock, + .hw.init = &(struct clk_init_data){ + .name = "sd_emmc_a_clk0", + .ops = &clk_gate_ops, + .parent_names = (const char *[]){ "sd_emmc_a_clk0_div" }, + .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, + }, +}; + +/* SDcard clock */ +static struct clk_mux gxbb_sd_emmc_b_clk0_sel = { + .reg = (void *)HHI_SD_EMMC_CLK_CNTL, + .mask = 0x7, + .shift = 25, + .lock = &clk_lock, + .hw.init = &(struct clk_init_data) { + .name = "sd_emmc_b_clk0_sel", + .ops = &clk_mux_ops, + .parent_names = gxbb_sd_emmc_clk0_parent_names, + .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names), + .flags = CLK_SET_RATE_PARENT, + }, +}; + +static struct clk_divider gxbb_sd_emmc_b_clk0_div = { + .reg = (void *)HHI_SD_EMMC_CLK_CNTL, + .shift = 16, + .width = 7, + .lock = &clk_lock, + .flags = CLK_DIVIDER_ROUND_CLOSEST, + .hw.init = &(struct clk_init_data) { + .name = "sd_emmc_b_clk0_div", + .ops = &clk_divider_ops, + .parent_names = (const char *[]){ "sd_emmc_b_clk0_sel" }, + .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, + }, +}; + +static struct clk_gate gxbb_sd_emmc_b_clk0 = { + .reg = (void *)HHI_SD_EMMC_CLK_CNTL, + .bit_idx = 23, + .lock = &clk_lock, + .hw.init = &(struct clk_init_data){ + .name = "sd_emmc_b_clk0", + .ops = &clk_gate_ops, + .parent_names = (const char *[]){ "sd_emmc_b_clk0_div" }, + .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, + }, +}; + +/* EMMC/NAND clock */ +static struct clk_mux gxbb_sd_emmc_c_clk0_sel = { + .reg = (void *)HHI_NAND_CLK_CNTL, + .mask = 0x7, + .shift = 9, + .lock = &clk_lock, + .hw.init = &(struct clk_init_data) { + .name = "sd_emmc_c_clk0_sel", + .ops = &clk_mux_ops, + .parent_names = gxbb_sd_emmc_clk0_parent_names, + .num_parents = ARRAY_SIZE(gxbb_sd_emmc_clk0_parent_names), + .flags = CLK_SET_RATE_PARENT, + }, +}; + +static struct clk_divider gxbb_sd_emmc_c_clk0_div = { + .reg = (void *)HHI_NAND_CLK_CNTL, + .shift = 0, + .width = 7, + .lock = &clk_lock, + .flags = CLK_DIVIDER_ROUND_CLOSEST, + .hw.init = &(struct clk_init_data) { + .name = "sd_emmc_c_clk0_div", + .ops = &clk_divider_ops, + .parent_names = (const char *[]){ "sd_emmc_c_clk0_sel" }, + .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, + }, +}; + +static struct clk_gate gxbb_sd_emmc_c_clk0 = { + .reg = (void *)HHI_NAND_CLK_CNTL, + .bit_idx = 7, + .lock = &clk_lock, + .hw.init = &(struct clk_init_data){ + .name = "sd_emmc_c_clk0", + .ops = &clk_gate_ops, + .parent_names = (const char *[]){ "sd_emmc_c_clk0_div" }, + .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, + }, +}; + /* Everything Else (EE) domain gates */ static MESON_GATE(gxbb_ddr, HHI_GCLK_MPEG0, 0); static MESON_GATE(gxbb_dos, HHI_GCLK_MPEG0, 1); @@ -1183,6 +1323,15 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = { [CLKID_32K_CLK] = &gxbb_32k_clk.hw, [CLKID_32K_CLK_SEL] = &gxbb_32k_clk_sel.hw, [CLKID_32K_CLK_DIV] = &gxbb_32k_clk_div.hw, + [CLKID_SD_EMMC_A_CLK0_SEL] = &gxbb_sd_emmc_a_clk0_sel.hw, + [CLKID_SD_EMMC_A_CLK0_DIV] = &gxbb_sd_emmc_a_clk0_div.hw, + [CLKID_SD_EMMC_A_CLK0] = &gxbb_sd_emmc_a_clk0.hw, + [CLKID_SD_EMMC_B_CLK0_SEL] = &gxbb_sd_emmc_b_clk0_sel.hw, + [CLKID_SD_EMMC_B_CLK0_DIV] = &gxbb_sd_emmc_b_clk0_div.hw, + [CLKID_SD_EMMC_B_CLK0] = &gxbb_sd_emmc_b_clk0.hw, + [CLKID_SD_EMMC_C_CLK0_SEL] = &gxbb_sd_emmc_c_clk0_sel.hw, + [CLKID_SD_EMMC_C_CLK0_DIV] = &gxbb_sd_emmc_c_clk0_div.hw, + [CLKID_SD_EMMC_C_CLK0] = &gxbb_sd_emmc_c_clk0.hw, }, .num = NR_CLKS, }; @@ -1305,6 +1454,15 @@ static struct clk_hw_onecell_data gxl_hw_onecell_data = { [CLKID_32K_CLK] = &gxbb_32k_clk.hw, [CLKID_32K_CLK_SEL] = &gxbb_32k_clk_sel.hw, [CLKID_32K_CLK_DIV] = &gxbb_32k_clk_div.hw, + [CLKID_SD_EMMC_A_CLK0_SEL] = &gxbb_sd_emmc_a_clk0_sel.hw, + [CLKID_SD_EMMC_A_CLK0_DIV] = &gxbb_sd_emmc_a_clk0_div.hw, + [CLKID_SD_EMMC_A_CLK0] = &gxbb_sd_emmc_a_clk0.hw, + [CLKID_SD_EMMC_B_CLK0_SEL] = &gxbb_sd_emmc_b_clk0_sel.hw, + [CLKID_SD_EMMC_B_CLK0_DIV] = &gxbb_sd_emmc_b_clk0_div.hw, + [CLKID_SD_EMMC_B_CLK0] = &gxbb_sd_emmc_b_clk0.hw, + [CLKID_SD_EMMC_C_CLK0_SEL] = &gxbb_sd_emmc_c_clk0_sel.hw, + [CLKID_SD_EMMC_C_CLK0_DIV] = &gxbb_sd_emmc_c_clk0_div.hw, + [CLKID_SD_EMMC_C_CLK0] = &gxbb_sd_emmc_c_clk0.hw, }, .num = NR_CLKS, }; @@ -1420,6 +1578,9 @@ static struct clk_gate *const gxbb_clk_gates[] = { &gxbb_cts_amclk, &gxbb_cts_mclk_i958, &gxbb_32k_clk, + &gxbb_sd_emmc_a_clk0, + &gxbb_sd_emmc_b_clk0, + &gxbb_sd_emmc_c_clk0, }; static struct clk_mux *const gxbb_clk_muxes[] = { @@ -1432,6 +1593,9 @@ static struct clk_mux *const gxbb_clk_muxes[] = { &gxbb_cts_mclk_i958_sel, &gxbb_cts_i958, &gxbb_32k_clk_sel, + &gxbb_sd_emmc_a_clk0_sel, + &gxbb_sd_emmc_b_clk0_sel, + &gxbb_sd_emmc_c_clk0_sel, }; static struct clk_divider *const gxbb_clk_dividers[] = { @@ -1441,6 +1605,9 @@ static struct clk_divider *const gxbb_clk_dividers[] = { &gxbb_mali_1_div, &gxbb_cts_mclk_i958_div, &gxbb_32k_clk_div, + &gxbb_sd_emmc_a_clk0_div, + &gxbb_sd_emmc_b_clk0_div, + &gxbb_sd_emmc_c_clk0_div, }; static struct meson_clk_audio_divider *const gxbb_audio_dividers[] = { diff --git a/drivers/clk/meson/gxbb.h b/drivers/clk/meson/gxbb.h index d63e77e8433d..17e5629777dc 100644 --- a/drivers/clk/meson/gxbb.h +++ b/drivers/clk/meson/gxbb.h @@ -287,8 +287,17 @@ #define CLKID_32K_CLK 114 #define CLKID_32K_CLK_SEL 115 #define CLKID_32K_CLK_DIV 116 +#define CLKID_SD_EMMC_A_CLK0_SEL 117 +#define CLKID_SD_EMMC_A_CLK0_DIV 118 +#define CLKID_SD_EMMC_A_CLK0 119 +#define CLKID_SD_EMMC_B_CLK0_SEL 120 +#define CLKID_SD_EMMC_B_CLK0_DIV 121 +#define CLKID_SD_EMMC_B_CLK0 122 +#define CLKID_SD_EMMC_C_CLK0_SEL 123 +#define CLKID_SD_EMMC_C_CLK0_DIV 124 +#define CLKID_SD_EMMC_C_CLK0 125 -#define NR_CLKS 117 +#define NR_CLKS 126 /* include the CLKIDs that have been made part of the stable DT binding */ #include