From patchwork Tue Dec 9 22:27:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 5465401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9EC2DBEEA8 for ; Tue, 9 Dec 2014 22:31:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9B11201E4 for ; Tue, 9 Dec 2014 22:31:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD532201C8 for ; Tue, 9 Dec 2014 22:31:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyTHF-0005Gu-CC; Tue, 09 Dec 2014 22:29:05 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyTGY-00052i-EK for linux-arm-kernel@lists.infradead.org; Tue, 09 Dec 2014 22:28:24 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id sB9MS0Po011079; Tue, 9 Dec 2014 16:28:00 -0600 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id sB9MRxYV032689; Tue, 9 Dec 2014 16:27:59 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Tue, 9 Dec 2014 16:27:59 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id sB9MRxcd019058; Tue, 9 Dec 2014 16:27:59 -0600 From: Felipe Balbi To: Tony Lindgren Subject: [RFC/PATCH 4/7] arm: omap: device: add support for generating sysconfig data from DT Date: Tue, 9 Dec 2014 16:27:49 -0600 Message-ID: <1418164072-19087-5-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.2.0 In-Reply-To: <1418164072-19087-1-git-send-email-balbi@ti.com> References: <1418164072-19087-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141209_142822_628080_B5382AA1 X-CRM114-Status: GOOD ( 13.71 ) X-Spam-Score: -5.0 (-----) Cc: Nishanth Menon , devicetree@vger.kernel.org, Paul Walmsley , Felipe Balbi , Linux OMAP Mailing List , Linux ARM Kernel Mailing List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After moving sysconfig data to DT, we need to make sure we can generate the same data we have today in C files out of the DT provided properties. This patch adds support for all optional properties documented by a previous commit. Signed-off-by: Felipe Balbi --- arch/arm/mach-omap2/omap_device.c | 115 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c index abd622b..ea729aa 100644 --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c @@ -25,6 +25,7 @@ */ #undef DEBUG +#include #include #include #include @@ -109,6 +110,115 @@ static void _add_hwmod_clocks_clkdev(struct omap_device *od, _add_clkdev(od, oh->opt_clks[i].role, oh->opt_clks[i].clk); } +static int omap_hwmod_has_sysc_bindings(struct device *dev) +{ + struct device_node *node = dev->of_node; + char *properties[] = { + "ti,rev_offs", + "ti,sysc_offs", + "ti,syss_offs", + "ti,sysc_flags", + "ti,srst_udelay", + "ti,idlemodes", + "ti,clockact", + "ti,sysc_type", + NULL + }; + char **tmp = properties; + + while (*tmp) { + if (of_property_read_bool(node, *tmp)) { + return true; + } + tmp++; + } + + return 0; +} + +static int omap_hwmod_init_sysc(struct device *dev, + struct omap_hwmod *oh, int index) +{ + struct device_node *node = dev->of_node; + struct omap_hwmod_class *class = oh->class; + struct omap_hwmod_class_sysconfig *sysc; + int ret; + int i; + char name[128]; + const char *tmp = oh->name; + u32 prop; + + /* if data isn't provided by DT, skip */ + if ((class && class->sysc) || !omap_hwmod_has_sysc_bindings(dev)) + return 0; + + class = kzalloc(sizeof(*class), GFP_KERNEL); + if (!class) + return -ENOMEM; + + i = 0; + while (*tmp) { + if (isalpha(*tmp)) + name[i++] = *tmp; + tmp++; + } + name[i] = '\0'; + + class->name = kzalloc(sizeof(name), GFP_KERNEL); + if (!class->name) + return -ENOMEM; + strncpy(class->name, name, sizeof(name) - 1); + + sysc = kzalloc(sizeof(*sysc), GFP_KERNEL); + if (!sysc) + return -ENOMEM; + + ret = of_property_read_u32_index(node, "ti,rev_offs", index, &prop); + if (!ret) + sysc->rev_offs = prop; + + ret = of_property_read_u32_index(node, "ti,sysc_offs", index, &prop); + if (!ret) + sysc->sysc_offs = prop; + + ret = of_property_read_u32_index(node, "ti,syss_offs", index, &prop); + if (!ret) + sysc->syss_offs = prop; + + ret = of_property_read_u32_index(node, "ti,sysc_flags", index, &prop); + if (!ret) + sysc->sysc_flags = prop & 0xffff; + + ret = of_property_read_u32_index(node, "ti,srst_udelay", index, &prop); + if (!ret) + sysc->srst_udelay = prop & 0xff; + + ret = of_property_read_u32_index(node, "ti,idlemodes", index, &prop); + if (!ret) + sysc->idlemodes = prop & 0xff; + + ret = of_property_read_u32_index(node, "ti,clockact", index, &prop); + if (!ret) + sysc->clockact = prop & 0xff; + + ret = of_property_read_u32_index(node, "ti,sysc_type", index, &prop); + if (ret) + prop = 1; + + switch (prop) { + case 2: + sysc->sysc_fields = &omap_hwmod_sysc_type2; + break; + case 3: + sysc->sysc_fields = &omap_hwmod_sysc_type3; + break; + case 1: + default: + sysc->sysc_fields = &omap_hwmod_sysc_type1; + } + + return 0; +} /** * omap_device_build_from_dt - build an omap_device with multiple hwmods @@ -154,6 +264,11 @@ static int omap_device_build_from_dt(struct platform_device *pdev) goto odbfd_exit1; } hwmods[i] = oh; + + ret = omap_hwmod_init_sysc(&pdev->dev, oh, i); + if (ret) + goto odbfd_exit1; + if (oh->flags & HWMOD_INIT_NO_IDLE) device_active = true;