Received: by 10.192.165.148 with SMTP id m20csp3705923imm; Mon, 23 Apr 2018 10:53:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/cqdh8SLMAAJEVaQsf0iE1Gte0EucqZs5vfXPOMkUpPMfJcsq2kRiKLNLtRTS59BFH8wSr X-Received: by 10.99.4.69 with SMTP id 66mr18124540pge.323.1524506032661; Mon, 23 Apr 2018 10:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524506032; cv=none; d=google.com; s=arc-20160816; b=LjxSQqDZJg5VN1CT9DPZ62L/x5ECicYi/yVlaV5iaX/gR+ySC/F2Yvw1I1KfrSkg+k UTwr9lscUBfvH1lR/dJullxQ6NvmRie8yqwoJjn8NqTdnUpToNU/x4B4ZXLN/GXdIZkq 9J8vw8juTgfSuc3P7IsRGQpmRy2GLPbFSMdYMSmNk5VUGSLOIZRpHrmHdrsEQaEaKHOc gvas8IWlD5FW6Zz7ARwpNuceNtd3o3P+wKyvZAvkflPGokhKvg9OYejvYxiYV8zv0Ud7 gh1IkJbpq8ZN8+eBO4KkAXl4KGWAHlRlZGbcRnkNKl5UYrmPrk1hP2dnWP/4sujNb+Dy EWow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=SKtHDcUrqhsCXkW/vwuACGcfqcLKd9sIk8uEqDiOyuc=; b=PW+8Lg9mUty8nIda217M0dKa9xFhVIKqW/qg8vUSuNjcY65RETo7fjZPXtTlWXbTQM wZlInTDIPhoqoHWlEWu+nppY+PIZDUjSqctjHpXkTk0oKjiP2MOiUZYFgiaNjTj21Kx1 aQBcxcB519poP8sIDTtn0WJhdP3EoF5DpWrfqwPIIq/sJyuEBo8k24egOgM/NmP3hTqh 3VrkMxj/rQC9CnlNl6FKPZgpVXnzhJiUyyOdX3C5hgximdqx/9rZFaU0Na8fE/Pj6h6c 9YOzN4JfxCM+Kjb/Ant1A/iAZm3yPPpGys78CKrQzENWgqRL1zznaum9RrKXYyOv5Sef PAMg== 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 p11si9673717pfj.294.2018.04.23.10.53.38; Mon, 23 Apr 2018 10:53:52 -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; 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 S932273AbeDWRqR (ORCPT + 99 others); Mon, 23 Apr 2018 13:46:17 -0400 Received: from muru.com ([72.249.23.125]:38316 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932252AbeDWRqK (ORCPT ); Mon, 23 Apr 2018 13:46:10 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 3CB008179; Mon, 23 Apr 2018 17:47:54 +0000 (UTC) From: Tony Lindgren To: linux-omap@vger.kernel.org Cc: Dave Gerlach , Greg Kroah-Hartman , Nishanth Menon , Suman Anna , Tero Kristo , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Keerthy Subject: [PATCH 02/16] ARM: OMAP2+: Allow using ti-sysc for system timers Date: Mon, 23 Apr 2018 10:45:35 -0700 Message-Id: <20180423174549.57412-3-tony@atomide.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180423174549.57412-1-tony@atomide.com> References: <20180423174549.57412-1-tony@atomide.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a system timer is configured with an interrconnect target module in the dts, the ti,hwmods and module fck are at the interconnect target level. Then there's a separate fck for the timer child device. If the child device has a separate functional clock, we need to configure it directly. For example, timer clk clkctrl clock bit 0 is the module clock for the interconnect target, and bit 24 being the functional clock for the timer IP. For system timers, we already mark them as disabled. Now must also mark the interconnect target module as disabled to prevent ti-sysc to manage it instead of the system timer. Cc: Keerthy Cc: Tero Kristo Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/timer.c | 67 ++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c @@ -167,6 +167,43 @@ static const struct of_device_id omap_timer_match[] __initconst = { { } }; +static int omap_timer_add_disabled_property(struct device_node *np) +{ + struct property *prop; + + prop = kzalloc(sizeof(*prop), GFP_KERNEL); + if (!prop) + return -ENOMEM; + + prop->name = "status"; + prop->value = "disabled"; + prop->length = strlen(prop->value); + + return of_add_property(np, prop); +} + +static int omap_timer_update_dt(struct device_node *np) +{ + int error = 0; + + if (!of_device_is_compatible(np, "ti,omap-counter32k")) { + error = omap_timer_add_disabled_property(np); + if (error) + return error; + } + + /* No parent interconnect target module configured? */ + if (of_get_property(np, "ti,hwmods", NULL)) + return error; + + /* Tag parent interconnect target module disabled */ + error = omap_timer_add_disabled_property(np->parent); + if (error) + return error; + + return 0; +} + /** * omap_get_timer_dt - get a timer using device-tree * @match - device-tree match structure for matching a device type @@ -182,6 +219,7 @@ static struct device_node * __init omap_get_timer_dt(const struct of_device_id * const char *property) { struct device_node *np; + int error; for_each_matching_node(np, match) { if (!of_device_is_available(np)) @@ -196,17 +234,9 @@ static struct device_node * __init omap_get_timer_dt(const struct of_device_id * of_get_property(np, "ti,timer-secure", NULL))) continue; - if (!of_device_is_compatible(np, "ti,omap-counter32k")) { - struct property *prop; + error = omap_timer_update_dt(np); + WARN(error, "%s: Could not update dt: %i\n", __func__, error); - prop = kzalloc(sizeof(*prop), GFP_KERNEL); - if (!prop) - return NULL; - prop->name = "status"; - prop->value = "disabled"; - prop->length = strlen(prop->value); - of_add_property(np, prop); - } return np; } @@ -265,8 +295,12 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, return -ENODEV; of_property_read_string_index(np, "ti,hwmods", 0, &oh_name); - if (!oh_name) - return -ENODEV; + if (!oh_name) { + of_property_read_string_index(np->parent, "ti,hwmods", 0, + &oh_name); + if (!oh_name) + return -ENODEV; + } timer->irq = irq_of_parse_and_map(np, 0); if (!timer->irq) @@ -418,9 +452,12 @@ static int __init __maybe_unused omap2_sync32k_clocksource_init(void) if (!np) return -ENODEV; - of_property_read_string_index(np, "ti,hwmods", 0, &oh_name); - if (!oh_name) - return -ENODEV; + of_property_read_string_index(np->parent, "ti,hwmods", 0, &oh_name); + if (!oh_name) { + of_property_read_string_index(np, "ti,hwmods", 0, &oh_name); + if (!oh_name) + return -ENODEV; + } /* * First check hwmod data is available for sync32k counter -- 2.17.0