Received: by 10.223.176.5 with SMTP id f5csp783781wra; Fri, 2 Feb 2018 06:07:58 -0800 (PST) X-Google-Smtp-Source: AH8x225ZrsKIGAy72i5Zsb7C2wcBsabRQ+SKEe0y75AZFXKwN88PBZf5wXdb0kRcgygszhXqEOYk X-Received: by 10.98.46.2 with SMTP id u2mr40359719pfu.30.1517580478647; Fri, 02 Feb 2018 06:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517580478; cv=none; d=google.com; s=arc-20160816; b=FpqJ/5VGiw2NiFMACmpZa1ugUCEtxbYUqeAq9Qu9xtknF9XOTecpI7BFW+Km8cTdRb s7E4IZHbVdCVgZ0dKpTyBr+WPGX2AG5rXNghwxrzEnyJMoDSPjpZiF+mLMIlX2VZ5h8F VZelobLuZbe5M5uRXcx65kCIkBB9j1SMHz3mWepIU6anbt+6cyGtvBG2fDwabIm6lbAH auWiSZObqmQEzvgPEpxujDF3M+0TqEkA8nDRQAMm/vpuDEr0r0NQROqEaLDAvjw9WKdB RBnWxgDRJzffmNiwdVAMxodrnK78zzQMmtnAN5HF0ylGeWT/UtGLBg28D19T/g+D25PU Xzdg== 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=BeL1d/h0nRF1Ni2BvuelO4BU5XL06yQ5Huw/+TZKlpk=; b=KS7DZ1AR0yGLqNpWmIZHs10eCNK7+XJop+mwYJCFty4CcMAGg7msAt6J3ZGAaXWSeD RCygDrtZoXumwKjhlZjVYPgBB5Lv1q86tEnRMigHKZnLr6kpWdpF2+86WUayXddn0lgu WSDCOiA06Pbivd6ltdmB+ETJVSexaegfmVNAOCuYaqnVrzLR8MT7NdENC8FluQl0KZIV lx5hqB1tKsqUCn3aGcZbQvC30/mDZ0CEttC2FrrShte7WwCDL6YCh3kZXGUMVbXOazdn lz5h7TJPxMg4n5xlvvPI5nWdFHyuiVeQM9OdzW1zZycPyDoDPOkWhz+i3/yg031RZQmx 9Z9A== 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 m3-v6si1835426plb.330.2018.02.02.06.07.43; Fri, 02 Feb 2018 06:07:58 -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 S1752436AbeBBOGg (ORCPT + 99 others); Fri, 2 Feb 2018 09:06:36 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:64811 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752019AbeBBOFO (ORCPT ); Fri, 2 Feb 2018 09:05:14 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w12DxVqk004731; Fri, 2 Feb 2018 15:04:13 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2fvr4u0frr-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 02 Feb 2018 15:04:13 +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 2763434; Fri, 2 Feb 2018 14:04:13 +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 077865228; Fri, 2 Feb 2018 14:04:13 +0000 (GMT) Received: from localhost (10.75.127.44) by SFHDAG4NODE2.st.com (10.75.127.11) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 2 Feb 2018 15:04:12 +0100 From: To: Rob Herring , Mark Rutland , Lee Jones , Maxime Coquelin , Alexandre Torgue , Michael Turquette , Stephen Boyd , Gabriel Fernandez CC: , , , , , Subject: [PATCH 05/14] clk: stm32mp1: add Source Clocks for PLLs Date: Fri, 2 Feb 2018 15:03:33 +0100 Message-ID: <1517580222-23301-6-git-send-email-gabriel.fernandez@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517580222-23301-1-git-send-email-gabriel.fernandez@st.com> References: <1517580222-23301-1-git-send-email-gabriel.fernandez@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) To SFHDAG4NODE2.st.com (10.75.127.11) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-02_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gabriel Fernandez This patch adds source clocks for PLLs This patch also introduces MUX clock API. Signed-off-by: Gabriel Fernandez --- drivers/clk/clk-stm32mp1.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/clk/clk-stm32mp1.c b/drivers/clk/clk-stm32mp1.c index be5a4e5..1c9a84a 100644 --- a/drivers/clk/clk-stm32mp1.c +++ b/drivers/clk/clk-stm32mp1.c @@ -368,6 +368,14 @@ struct div_cfg { const struct clk_div_table *table; }; +struct mux_cfg { + u32 reg_off; + u8 shift; + u8 width; + u8 mux_flags; + u32 *table; +}; + static struct clk_hw * _clk_hw_register_gate(struct device *dev, struct clk_hw_onecell_data *clk_data, @@ -419,6 +427,20 @@ struct div_cfg { lock); } +static struct clk_hw * +_clk_hw_register_mux(struct device *dev, + struct clk_hw_onecell_data *clk_data, + void __iomem *base, spinlock_t *lock, + const struct clock_config *cfg) +{ + struct mux_cfg *mux_cfg = cfg->cfg; + + return clk_hw_register_mux(dev, cfg->name, cfg->parent_names, + cfg->num_parents, cfg->flags, + mux_cfg->reg_off + base, mux_cfg->shift, + mux_cfg->width, mux_cfg->mux_flags, lock); +} + /* MP1 Gate clock with set & clear registers */ static int mp1_gate_clk_enable(struct clk_hw *hw) @@ -550,6 +572,22 @@ static struct clk_hw *clk_register_mp1_gate(struct device *dev, DIV_TABLE(_id, _name, _parent, _flags, _offset, _shift, _width,\ _div_flags, NULL) +#define MUX(_id, _name, _parents, _flags, _offset, _shift, _width, _mux_flags)\ +{\ + .id = _id,\ + .name = _name,\ + .parent_names = _parents,\ + .num_parents = ARRAY_SIZE(_parents),\ + .flags = _flags,\ + .cfg = &(struct mux_cfg) {\ + .reg_off = _offset,\ + .shift = _shift,\ + .width = _width,\ + .mux_flags = _mux_flags,\ + },\ + .func = _clk_hw_register_mux,\ +} + #define MP1_GATE(_id, _name, _parent, _flags, _offset, _bit_idx, _gate_flags)\ {\ .id = _id,\ @@ -577,6 +615,16 @@ static struct clk_hw *clk_register_mp1_gate(struct device *dev, GATE(CK_LSE, "ck_lse", "clk-lse", 0, RCC_BDCR, 0, 0), FIXED_FACTOR(CK_HSE_DIV2, "clk-hse-div2", "ck_hse", 0, 1, 2), + + /* ref clock pll */ + MUX(NO_ID, "ref1", ref12_parents, CLK_OPS_PARENT_ENABLE, RCC_RCK12SELR, + 0, 2, CLK_MUX_READ_ONLY), + + MUX(NO_ID, "ref3", ref3_parents, CLK_OPS_PARENT_ENABLE, RCC_RCK3SELR, + 0, 2, CLK_MUX_READ_ONLY), + + MUX(NO_ID, "ref4", ref4_parents, CLK_OPS_PARENT_ENABLE, RCC_RCK4SELR, + 0, 2, CLK_MUX_READ_ONLY), }; struct stm32_clock_match_data { -- 1.9.1