From patchwork Tue Jul 29 11:42:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 4639981 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 342B5C0338 for ; Tue, 29 Jul 2014 11:44:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F1BE2015D for ; Tue, 29 Jul 2014 11:44:42 +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 86C3A20158 for ; Tue, 29 Jul 2014 11:44:41 +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 1XC5o2-0003U4-2i; Tue, 29 Jul 2014 11:42:58 +0000 Received: from ns.mm-sol.com ([37.157.136.199] helo=extserv.mm-sol.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XC5ny-0003Lt-GQ for linux-arm-kernel@lists.infradead.org; Tue, 29 Jul 2014 11:42:56 +0000 Received: from [192.168.25.155] (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 91845C7D9; Tue, 29 Jul 2014 14:42:31 +0300 (EEST) Message-ID: <53D788A7.4020303@mm-sol.com> Date: Tue, 29 Jul 2014 14:42:31 +0300 From: Stanimir Varbanov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 MIME-Version: 1.0 To: Grant Likely , Rob Herring , Rob Herring Subject: use IORESOURCE_REG resource type for non-translatable addresses in DT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140729_044254_980796_9C5A31C4 X-CRM114-Status: GOOD ( 11.64 ) X-Spam-Score: -0.7 (/) Cc: "devicetree@vger.kernel.org" , Mark Brown , "linux-arm-msm@vger.kernel.org" , Stephen Boyd , "linux-kernel@vger.kernel.org" , Lee Jones , linux-arm-kernel@lists.infradead.org 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,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 Hi, While looking in MFD drivers I saw that few of them (88pm860x-core, max8925-core and wm831x-core) allow use of IORESOURCE_REG as resource type when calling platform_get_resource() by their child drivers. The resources for these child devices are filled by core MFD driver manually and then passed to mfd_add_devices() as mfd_cells. During development and review comments of the MFD core driver for Qualcomm SPMI PMICs we came down to a need to describe PMIC peripheral addresses (the PMIC sub-functions) through *reg* property in DT. The PMIC peripheral drivers will be scattered over the /drivers and they will call platform_get_resource() to extract their peripheral base addresses from resource->start. The issue we have encountered is that these addresses are non-translatable thus of_address_to_resource returns OF_BAD_ADDR. Stephen Boyd have made a suggestion to solve the issue here [1]. Is that approach acceptable? Or do we have better way? How similar issues could be solved. Our DT node for SPMI PMICs can be seen below [2]. Please do comment. PS: I have made a little change in __of_address_to_resource() to illustrate what I meant above. unsigned long port; [1] https://lkml.org/lkml/2014/7/17/680 [2] Simplistic PMIC DT node. spmi@fc4cf000 { compatible = "qcom,spmi-pmic-arb"; reg = <0xfc4cf000 0x1000>, <0xfc4cb000 0x1000>, <0xfc4ca000 0x1000>; reg-names = "core", "intr", "cnfg"; #address-cells = <2>; #size-cells = <0>; interrupt-controller; #interrupt-cells = <4>; pm8941@0 { compatible = "qcom,pm8941"; reg = <0x0 SPMI_USID>; #size-cells = <1>; #address-cells = <1>; rtc { compatible = "qcom,pm8941-rtc"; reg = <0x6000 0x100>, <0x6100 0x100>; reg-names = "rtc", "alarm"; interrupts = <0x0 0x61 0x1 0>; interrupt-names = "alarm"; }; }; pm8941@1 { compatible = "qcom,pm8941"; reg = <0x1 SPMI_USID>; }; } diff --git a/drivers/of/address.c b/drivers/of/address.c index 5edfcb0..898741e 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -617,9 +617,24 @@ static int __of_address_to_resource(struct device_node *dev, if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0) return -EINVAL; + taddr = of_translate_address(dev, addrp); - if (taddr == OF_BAD_ADDR) - return -EINVAL; + /* + * if the address is non-translatable to cpu physical address + * fallback to a IORESOURCE_REG resource. + */ + if (taddr == OF_BAD_ADDR) { + memset(r, 0, sizeof(*r)); + taddr = of_read_number(addrp, 1); + if (taddr == OF_BAD_ADDR) + return -EINVAL; + r->start = taddr; + r->end = taddr + size - 1; + r->flags = IORESOURCE_REG; + r->name = name ? name : dev->full_name; + return 0; + } + memset(r, 0, sizeof(struct resource)); if (flags & IORESOURCE_IO) {