Received: by 10.223.185.116 with SMTP id b49csp6531265wrg; Thu, 8 Mar 2018 08:56:56 -0800 (PST) X-Google-Smtp-Source: AG47ELsuMkoBAig8yLV3ULF2YeosXDQrj7mUyUagSVhvNnE+P8nD44wKrUSTjqkjCNMMNsVyq2cW X-Received: by 10.98.7.68 with SMTP id b65mr26769451pfd.39.1520528216181; Thu, 08 Mar 2018 08:56:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520528216; cv=none; d=google.com; s=arc-20160816; b=il6Sw5skeQM6HssQkwHnUyju4pNGCs2FYGwsFRLYLbTeiSpFsqdefrjHErMVD0kquI 0pbVyrGphll7rnFRatE0fAr3RHgAWaE/J+FrSMfbPwVuNn8IhxMdqYVUDVTmcMmzj/hZ uWvQhsmU9zjHnloOitMa5KIFpHD866RFSenu7PF6RIHpWW/1xFE8TFMV5nnkh1YsPFK3 jDSVsTBUQzUX6cdYTRaaFXkHm7K0Ugq/XwEZ5QQX8hRE2UoCPgV72G8YSkQ37vm+4c5y NvZB8FB+QBs7ShJPw+/EQTQOef4o6OzAG5UP/Rruyb3Mjc7v/J4pVco8V77YNYHvguum uCuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=8UVduAi0PIG8Vx0/gGVHaDcwa/9RMTlTaKZvrgI8wUw=; b=BEkVmnn9tFDI1KJO0Sl/6g1Cl9w5fVG9V4K4770cmWj8+8bX4B1hDL6ogTjlSX8+8N nptbCfaFynLI12umZUP2+n6m5JzlYEKNZJG6POFXMoTtS+DLCmimUIzEGiX/VPlbUEK3 4lOmQDzApTu+4fPmxTyqPbkvT7PoAxyhUoBbRMFt0qRFyqvZSrBkpa9Pr4QmiAGv1wTY lieG+f1Q+oL9J4UYV+vHjMDOpkZSvjpQKh40xGDPzYdlAC6BMUbxQvjZG+5wIckaX77I LbXH1UOLacGS7fA/krRF/1Da62aL9IvI4wo5Sp+XH+oBAdsHI28HT/4ENuMO14PiHsE9 7Few== ARC-Authentication-Results: i=1; mx.google.com; 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 t9si15882811pfh.101.2018.03.08.08.56.41; Thu, 08 Mar 2018 08:56:56 -0800 (PST) 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; 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 S935944AbeCHQzC (ORCPT + 99 others); Thu, 8 Mar 2018 11:55:02 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:12286 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932076AbeCHQy6 (ORCPT ); Thu, 8 Mar 2018 11:54:58 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w28GsFew000545; Thu, 8 Mar 2018 17:54:22 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2gk83mra1n-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 08 Mar 2018 17:54:22 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 346703A; Thu, 8 Mar 2018 16:54:22 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag4node2.st.com [10.75.127.11]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0D0315093; Thu, 8 Mar 2018 16:54:22 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG4NODE2.st.com (10.75.127.11) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 8 Mar 2018 17:54:21 +0100 From: To: , Rob Herring , Mark Rutland , Lee Jones , Maxime Coquelin , Alexandre Torgue , Michael Turquette , Stephen Boyd , Gabriel Fernandez CC: , , , , , , Loic PALLARDY , benjamin GAIGNARD Subject: [PATCH v2 07/12] clk: stm32mp1: add Sub System clocks Date: Thu, 8 Mar 2018 17:54:00 +0100 Message-ID: <1520528045-18330-8-git-send-email-gabriel.fernandez@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520528045-18330-1-git-send-email-gabriel.fernandez@st.com> References: <1520528045-18330-1-git-send-email-gabriel.fernandez@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG4NODE2.st.com (10.75.127.11) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-08_09:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gabriel Fernandez The RCC handles three sub-system clocks: ck_mpuss, ck_axiss and ck_mcuss. This patch adds also some MUX system and several prescalers. Signed-off-by: Gabriel Fernandez --- drivers/clk/clk-stm32mp1.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/drivers/clk/clk-stm32mp1.c b/drivers/clk/clk-stm32mp1.c index 3a99ad7..77d96d9 100644 --- a/drivers/clk/clk-stm32mp1.c +++ b/drivers/clk/clk-stm32mp1.c @@ -116,6 +116,42 @@ "ck_hsi", "ck_hse", "ck_csi" }; +static const char * const cpu_src[] = { + "ck_hsi", "ck_hse", "pll1_p" +}; + +static const char * const axi_src[] = { + "ck_hsi", "ck_hse", "pll2_p", "pll3_p" +}; + +static const char * const per_src[] = { + "ck_hsi", "ck_csi", "ck_hse" +}; + +static const char * const mcu_src[] = { + "ck_hsi", "ck_hse", "ck_csi", "pll3_p" +}; + +static const struct clk_div_table axi_div_table[] = { + { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 4 }, + { 4, 4 }, { 5, 4 }, { 6, 4 }, { 7, 4 }, + { 0 }, +}; + +static const struct clk_div_table mcu_div_table[] = { + { 0, 1 }, { 1, 2 }, { 2, 4 }, { 3, 8 }, + { 4, 16 }, { 5, 32 }, { 6, 64 }, { 7, 128 }, + { 8, 512 }, { 9, 512 }, { 10, 512}, { 11, 512 }, + { 12, 512 }, { 13, 512 }, { 14, 512}, { 15, 512 }, + { 0 }, +}; + +static const struct clk_div_table apb_div_table[] = { + { 0, 1 }, { 1, 2 }, { 2, 4 }, { 3, 8 }, + { 4, 16 }, { 5, 16 }, { 6, 16 }, { 7, 16 }, + { 0 }, +}; + struct clock_config { u32 id; const char *name; @@ -781,6 +817,21 @@ struct clk_hw *_clk_register_pll(struct device *dev, _STM32_DIV(_div_offset, _div_shift, _div_width,\ _div_flags, _div_table, NULL)\ +#define _STM32_MUX(_offset, _shift, _width, _mux_flags, _ops)\ + .mux = &(struct stm32_mux_cfg) {\ + &(struct mux_cfg) {\ + .reg_off = _offset,\ + .shift = _shift,\ + .width = _width,\ + .mux_flags = _mux_flags,\ + .table = NULL,\ + },\ + .ops = _ops,\ + } + +#define _MUX(_offset, _shift, _width, _mux_flags)\ + _STM32_MUX(_offset, _shift, _width, _mux_flags, NULL)\ + #define PARENT(_parent) ((const char *[]) { _parent}) #define _NO_MUX .mux = NULL @@ -882,6 +933,40 @@ struct clk_hw *_clk_register_pll(struct device *dev, _GATE(RCC_PLL4CR, 6, 0), _NO_MUX, _DIV(RCC_PLL4CFGR2, 16, 7, 0, NULL)), + + /* MUX system clocks */ + MUX(CK_PER, "ck_per", per_src, CLK_OPS_PARENT_ENABLE, + RCC_CPERCKSELR, 0, 2, 0), + + MUX(CK_MPU, "ck_mpu", cpu_src, CLK_OPS_PARENT_ENABLE | + CLK_IS_CRITICAL, RCC_MPCKSELR, 0, 2, 0), + + COMPOSITE(CK_AXI, "ck_axi", axi_src, CLK_IS_CRITICAL | + CLK_OPS_PARENT_ENABLE, + _NO_GATE, + _MUX(RCC_ASSCKSELR, 0, 2, 0), + _DIV(RCC_AXIDIVR, 0, 3, 0, axi_div_table)), + + COMPOSITE(CK_MCU, "ck_mcu", mcu_src, CLK_IS_CRITICAL | + CLK_OPS_PARENT_ENABLE, + _NO_GATE, + _MUX(RCC_MSSCKSELR, 0, 2, 0), + _DIV(RCC_MCUDIVR, 0, 4, 0, mcu_div_table)), + + DIV_TABLE(NO_ID, "pclk1", "ck_mcu", CLK_IGNORE_UNUSED, RCC_APB1DIVR, 0, + 3, CLK_DIVIDER_READ_ONLY, apb_div_table), + + DIV_TABLE(NO_ID, "pclk2", "ck_mcu", CLK_IGNORE_UNUSED, RCC_APB2DIVR, 0, + 3, CLK_DIVIDER_READ_ONLY, apb_div_table), + + DIV_TABLE(NO_ID, "pclk3", "ck_mcu", CLK_IGNORE_UNUSED, RCC_APB3DIVR, 0, + 3, CLK_DIVIDER_READ_ONLY, apb_div_table), + + DIV_TABLE(NO_ID, "pclk4", "ck_axi", CLK_IGNORE_UNUSED, RCC_APB4DIVR, 0, + 3, CLK_DIVIDER_READ_ONLY, apb_div_table), + + DIV_TABLE(NO_ID, "pclk5", "ck_axi", CLK_IGNORE_UNUSED, RCC_APB5DIVR, 0, + 3, CLK_DIVIDER_READ_ONLY, apb_div_table), }; struct stm32_clock_match_data { -- 1.9.1