From: Matthias Brugger <matthias.bgg@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
rdunlap@infradead.org, linux@arm.linux.org.uk,
daniel.lezcano@linaro.org, tglx@linutronix.de,
grant.likely@linaro.org, matthias.bgg@gmail.com,
thierry.reding@gmail.com, florian.vaussard@epfl.ch,
jic23@kernel.org, jason@lakedaemon.net, andrew@lunn.ch,
silvio.fricke@gmail.com, heiko.stuebner@bq.com, olof@lixom.net,
sebastian.hesselbarth@gmail.com, sboyd@codeaurora.org,
gregory.clement@free-electrons.com, arnd@arndb.de,
robherring2@gmail.com, marc.zyngier@arm.com,
maxime.ripard@free-electrons.com, soren.brinkmann@xilinx.com,
shawn.guo@freescale.com, anders.berg@lsi.com,
linus.walleij@linaro.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH v9.1] of: Provide function to request and map memory
Date: Fri, 20 Jun 2014 14:28:48 +0200 [thread overview]
Message-ID: <1403267328-23085-1-git-send-email-matthias.bgg@gmail.com> (raw)
In-Reply-To: <1403264929-21325-2-git-send-email-matthias.bgg@gmail.com>
A call to of_iomap does not request the memory region.
This patch adds the function of_io_request_and_map which requests
the memory region before mapping it.
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Suggested-by: Rob Herring <robh@kernel.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
---
Changes for v9.1:
- fixed the Author email address
drivers/of/address.c | 29 +++++++++++++++++++++++++++++
include/linux/of_address.h | 8 ++++++++
2 files changed, 37 insertions(+)
diff --git a/drivers/of/address.c b/drivers/of/address.c
index cb4242a..09074ba 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -721,3 +721,32 @@ void __iomem *of_iomap(struct device_node *np, int index)
return ioremap(res.start, resource_size(&res));
}
EXPORT_SYMBOL(of_iomap);
+
+/*
+ * of_io_request_and_map - Requests a resource and maps the memory mapped IO
+ * for a given device_node
+ * @device: the device whose io range will be mapped
+ * @index: index of the io range
+ * @name: name of the resource
+ *
+ * Returns a pointer to the requested and mapped memory
+ */
+void __iomem *of_io_request_and_map(struct device_node *np, int index,
+ char *name)
+{
+ struct resource res;
+ void __iomem *mem;
+
+ if (of_address_to_resource(np, index, &res))
+ return NULL;
+
+ if (!request_mem_region(res.start, resource_size(&res), name))
+ return NULL;
+
+ mem = ioremap(res.start, resource_size(&res));
+ if (!mem)
+ release_mem_region(res.start, resource_size(&res));
+
+ return mem;
+}
+EXPORT_SYMBOL(of_io_request_and_map);
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 5f6ed6b..725b875 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -96,6 +96,8 @@ static inline struct of_pci_range *of_pci_range_parser_one(
extern int of_address_to_resource(struct device_node *dev, int index,
struct resource *r);
void __iomem *of_iomap(struct device_node *node, int index);
+void __iomem *of_io_request_and_map(struct device_node *device,
+ int index, char *name);
#else
static inline int of_address_to_resource(struct device_node *dev, int index,
struct resource *r)
@@ -107,6 +109,12 @@ static inline void __iomem *of_iomap(struct device_node *device, int index)
{
return NULL;
}
+
+static inline void __iomem *of_io_request_and_map(struct device_node *device,
+ int index, char *name)
+{
+ return NULL;
+}
#endif
#if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_PCI)
--
1.7.9.5
next prev parent reply other threads:[~2014-06-20 12:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 11:48 [PATCH v9 0/3] arm: Add basic support for Mediatek Cortex-A7 SoCs Matthias Brugger
[not found] ` <1403264929-21325-1-git-send-email-matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-06-20 11:48 ` [PATCH v9 1/3] of: Provide function to request and map memory Matthias Brugger
2014-06-20 12:28 ` Matthias Brugger [this message]
2014-06-20 16:00 ` [PATCH v9.1] " Russell King - ARM Linux
2014-06-20 11:48 ` [PATCH v9 2/3] clocksource: Add support for the Mediatek SoCs Matthias Brugger
2014-06-20 11:48 ` [PATCH v9 3/3] dt-bindings: add mtk-timer bindings Matthias Brugger
2014-06-20 12:36 ` Mark Rutland
2014-07-01 17:46 ` Matthias Brugger
2014-07-01 18:00 ` Sören Brinkmann
2014-07-05 0:28 ` Matthias Brugger
2014-07-07 15:49 ` Sören Brinkmann
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=1403267328-23085-1-git-send-email-matthias.bgg@gmail.com \
--to=matthias.bgg@gmail.com \
--cc=anders.berg@lsi.com \
--cc=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=florian.vaussard@epfl.ch \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=gregory.clement@free-electrons.com \
--cc=heiko.stuebner@bq.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jason@lakedaemon.net \
--cc=jic23@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=maxime.ripard@free-electrons.com \
--cc=olof@lixom.net \
--cc=pawel.moll@arm.com \
--cc=rdunlap@infradead.org \
--cc=robh+dt@kernel.org \
--cc=robherring2@gmail.com \
--cc=sboyd@codeaurora.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=shawn.guo@freescale.com \
--cc=silvio.fricke@gmail.com \
--cc=soren.brinkmann@xilinx.com \
--cc=tglx@linutronix.de \
--cc=thierry.reding@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).