From patchwork Thu Feb 15 12:49:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 128421 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1711861ljc; Thu, 15 Feb 2018 04:51:19 -0800 (PST) X-Google-Smtp-Source: AH8x2250DjduQu7qQUCKNhHil8VTq/F5sjoo6wx6JWEGEBx5AggW+z8Q+XYB6oBhxW5F8qrX2CJA X-Received: by 2002:a17:902:2845:: with SMTP id e63-v6mr2437668plb.438.1518699079212; Thu, 15 Feb 2018 04:51:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518699079; cv=none; d=google.com; s=arc-20160816; b=kiY6kR+6QLBjOAm8dDivmcoHhq5TLneMV436ldEXZtZmqeDUpMehBMJhlbPCMpHUUO qUb6GsNX9PbxpJBL1UBvWl0M3jVigL+pk9lA+EVS+bJ2uK9qZ2C6IuipjBDKCXI6utiv ZEY9jirZwNDEEhW9GFwiPOuFmdmFWPn4KLsY6l8p5FoW8cx1zbTqNKtGFKSERX+DjdrM 8pbaYlmAg6GR8UUSQHUPosvnccV6GCuEwlscukbomrWBF/zqqvN4m48ByJrG78B6bSuy 4Mxr7YlQv2z64scYCH9MkMCqsFIBydJAT3kWXoP61d7GPW5OohWlbd1P5yKX2+08FE12 YUsQ== 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:dkim-signature :arc-authentication-results; bh=r6UvAf4fdj4luo6Ywokd8xH/2I4rDmDXk1BRsx6d2Jo=; b=e74lC6F0+m2V0eLAH88c5EXj/L4VY3k03/kYlj9ZJsStFe6H8gtlCrWzn7O4X7d3rE Bxo1FpwFAVlvngVlWp1b1D+mjRuLhCnQiwuev2RgM4U5KI9/lsOOiHDovAt9vSImI+T6 gp/5+fN8ftjzGQq+R5G8sLv7bZzkrgLk0PoK1AEQGD3Wi+berF3UpK1HONa/snVb1lqz RwirSDHOSsi7v36+yzVuSCuJOSXTpPFYzNUcpb27aIoS0yG7hU5EIjBpzpvfNtwr9AHV iIPHc8ANKzD4ozPAGs4KG3Qi+07/RCugidMJzxzVGMiM/R3HAdbd767KXT2j1iiO7Tbg 5jhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=bvZrINaO; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8si2411357pgu.551.2018.02.15.04.51.19; Thu, 15 Feb 2018 04:51:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=bvZrINaO; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031323AbeBOMvS (ORCPT + 6 others); Thu, 15 Feb 2018 07:51:18 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:50169 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031225AbeBOMvR (ORCPT ); Thu, 15 Feb 2018 07:51:17 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1FCocPn016594; Thu, 15 Feb 2018 06:50:38 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1518699038; bh=tEu7BHXSW4cmgfIMHpz9RVQFm2pP9qctLaYqgL5BdHM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bvZrINaOwI8JvOR/wO+UtTWzS5Ry9+6TqQGGkFD2jeGu2GrzKmAF713Y4VKRVIfs8 NqIeP7DKIUFD8LpTi8ChPf8iZFZjTe77pQMIK8YzUGGY4b7HitO4HdfvPxpP+sr/Pw e22M14Ve5QQyervY/Zv7RmNQCB8hWc82B+SIlTrE= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1FCoc4V019141; Thu, 15 Feb 2018 06:50:38 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 15 Feb 2018 06:50:37 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 15 Feb 2018 06:50:38 -0600 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1FCoKZG020487; Thu, 15 Feb 2018 06:50:32 -0600 From: Tero Kristo To: , , , , , CC: , , Subject: [PATCH 4/5] clk: ti: add support for clock latching to divider clocks Date: Thu, 15 Feb 2018 14:49:50 +0200 Message-ID: <1518698991-10099-5-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1518698991-10099-1-git-send-email-t-kristo@ti.com> References: <1518698991-10099-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Latching the clock settings is needed with certain clocks, where the setting is "cached" in HW before doing the actual re-programming of the clock source. This patch adds support for clock latching to the divider clock. Signed-off-by: Tero Kristo --- drivers/clk/ti/clock.h | 1 + drivers/clk/ti/divider.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) -- 1.9.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h index 2f8af8f..62b108c 100644 --- a/drivers/clk/ti/clock.h +++ b/drivers/clk/ti/clock.h @@ -22,6 +22,7 @@ struct clk_omap_divider { u8 shift; u8 width; u8 flags; + s8 latch; const struct clk_div_table *table; }; diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c index 77f93f6..aaa277d 100644 --- a/drivers/clk/ti/divider.c +++ b/drivers/clk/ti/divider.c @@ -263,6 +263,8 @@ static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, val |= value << divider->shift; ti_clk_ll_ops->clk_writel(val, ÷r->reg); + ti_clk_latch(÷r->reg, divider->latch); + return 0; } @@ -276,7 +278,8 @@ static struct clk *_register_divider(struct device *dev, const char *name, const char *parent_name, unsigned long flags, struct clk_omap_reg *reg, - u8 shift, u8 width, u8 clk_divider_flags, + u8 shift, u8 width, s8 latch, + u8 clk_divider_flags, const struct clk_div_table *table) { struct clk_omap_divider *div; @@ -305,6 +308,7 @@ static struct clk *_register_divider(struct device *dev, const char *name, memcpy(&div->reg, reg, sizeof(*reg)); div->shift = shift; div->width = width; + div->latch = latch; div->flags = clk_divider_flags; div->hw.init = &init; div->table = table; @@ -420,6 +424,7 @@ struct clk_hw *ti_clk_build_component_div(struct ti_clk_divider *setup) div->table = _get_div_table_from_setup(setup, &div->width); div->shift = setup->bit_shift; + div->latch = -EINVAL; return &div->hw; } @@ -452,7 +457,7 @@ struct clk *ti_clk_register_divider(struct ti_clk *setup) clk = _register_divider(NULL, setup->name, div->parent, flags, ®, div->bit_shift, - width, div_flags, table); + width, -EINVAL, div_flags, table); if (IS_ERR(clk)) kfree(table); @@ -556,7 +561,7 @@ static int _get_divider_width(struct device_node *node, static int __init ti_clk_divider_populate(struct device_node *node, struct clk_omap_reg *reg, const struct clk_div_table **table, - u32 *flags, u8 *div_flags, u8 *width, u8 *shift) + u32 *flags, u8 *div_flags, u8 *width, u8 *shift, s8 *latch) { u32 val; int ret; @@ -570,6 +575,13 @@ static int __init ti_clk_divider_populate(struct device_node *node, else *shift = 0; + if (latch) { + if (!of_property_read_u32(node, "ti,latch-bit", &val)) + *latch = val; + else + *latch = -EINVAL; + } + *flags = 0; *div_flags = 0; @@ -606,17 +618,18 @@ static void __init of_ti_divider_clk_setup(struct device_node *node) u8 clk_divider_flags = 0; u8 width = 0; u8 shift = 0; + s8 latch = -EINVAL; const struct clk_div_table *table = NULL; u32 flags = 0; parent_name = of_clk_get_parent_name(node, 0); if (ti_clk_divider_populate(node, ®, &table, &flags, - &clk_divider_flags, &width, &shift)) + &clk_divider_flags, &width, &shift, &latch)) goto cleanup; clk = _register_divider(NULL, node->name, parent_name, flags, ®, - shift, width, clk_divider_flags, table); + shift, width, latch, clk_divider_flags, table); if (!IS_ERR(clk)) { of_clk_add_provider(node, of_clk_src_simple_get, clk); @@ -639,7 +652,8 @@ static void __init of_ti_composite_divider_clk_setup(struct device_node *node) return; if (ti_clk_divider_populate(node, &div->reg, &div->table, &val, - &div->flags, &div->width, &div->shift) < 0) + &div->flags, &div->width, &div->shift, + NULL) < 0) goto cleanup; if (!ti_clk_add_component(node, &div->hw, CLK_COMPONENT_TYPE_DIVIDER))