From: Stanimir Varbanov <svarbanov@mm-sol.com>
To: Grant Likely <grant.likely@linaro.org>,
Rob Herring <rob.herring@linaro.org>,
Rob Herring <robherring2@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org,
Stephen Boyd <sboyd@codeaurora.org>,
Mark Brown <broonie@linaro.org>
Subject: use IORESOURCE_REG resource type for non-translatable addresses in DT
Date: Tue, 29 Jul 2014 14:42:31 +0300 [thread overview]
Message-ID: <53D788A7.4020303@mm-sol.com> (raw)
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.
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) {
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>;
};
}
--
regards,
Stan
next reply other threads:[~2014-07-29 11:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 11:42 Stanimir Varbanov [this message]
2014-07-29 12:00 ` use IORESOURCE_REG resource type for non-translatable addresses in DT Arnd Bergmann
2014-07-29 14:06 ` Stanimir Varbanov
2014-07-29 15:29 ` Rob Herring
2014-07-29 23:45 ` Grant Likely
2014-07-30 1:07 ` Stephen Boyd
2014-07-30 2:53 ` Rob Herring
2014-07-30 6:06 ` Stephen Boyd
2014-08-27 16:27 ` Stanimir Varbanov
2014-08-27 18:24 ` Bjorn Andersson
2014-08-27 21:55 ` Stephen Boyd
2014-08-29 4:09 ` Bjorn Andersson
2014-08-28 7:58 ` Stanimir Varbanov
2014-09-02 15:45 ` [PATCH] RFC: add function for localbus address Stanimir Varbanov
2014-09-05 23:29 ` Stephen Boyd
2014-09-08 14:52 ` Grant Likely
2014-09-08 20:22 ` Stephen Boyd
2014-09-08 21:21 ` Mark Brown
2014-09-14 4:46 ` Grant Likely
2014-10-22 23:01 ` Stephen Boyd
2014-10-22 23:20 ` Russell King - ARM Linux
2014-10-22 23:53 ` Stephen Boyd
2014-10-22 23:51 ` Mark Brown
2014-09-09 15:07 ` Stanimir Varbanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53D788A7.4020303@mm-sol.com \
--to=svarbanov@mm-sol.com \
--cc=broonie@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rob.herring@linaro.org \
--cc=robherring2@gmail.com \
--cc=sboyd@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox