From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 3/5] [POWERPC] explicit dcr support
Date: Mon, 31 Mar 2008 09:04:07 +1100 [thread overview]
Message-ID: <1206914647.10388.134.camel@pasglop> (raw)
In-Reply-To: <20080328162617.E9E3017A008F@mail170-dub.bigfish.com>
On Fri, 2008-03-28 at 09:23 -0700, Stephen Neuendorffer wrote:
> Added literal mapping support if no device-tree support. Added
> CONFIG_OF to guard device-tree parts, since literal support works for
> arch=ppc.
>
> Signed-off-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>
I'll let others decide whether they want to do that addition
to arch/ppc (which is really what it is) or not ... I'd rather
not myself considering that arch/ppc is scheduled to go away
soon now.
Cheers,
Ben.
> ---
> arch/powerpc/sysdev/dcr.c | 82 ++++++++++++++++++++++++++++---------
> include/asm-powerpc/dcr-generic.h | 2 +
> include/asm-powerpc/dcr-mmio.h | 11 +++++
> include/asm-powerpc/dcr-native.h | 8 ++++
> include/asm-powerpc/dcr.h | 24 +++++++++++
> 5 files changed, 108 insertions(+), 19 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
> index d3de0ff..2ccae80 100644
> --- a/arch/powerpc/sysdev/dcr.c
> +++ b/arch/powerpc/sysdev/dcr.c
> @@ -20,9 +20,34 @@
> #undef DEBUG
>
> #include <linux/kernel.h>
> +#include <linux/module.h>
> #include <asm/prom.h>
> #include <asm/dcr.h>
>
> +#ifdef CONFIG_OF
> +static struct device_node *find_dcr_parent(struct device_node *node)
> +{
> + struct device_node *par, *tmp;
> + const u32 *p;
> +
> + for (par = of_node_get(node); par;) {
> + if (of_get_property(par, "dcr-controller", NULL))
> + break;
> + p = of_get_property(par, "dcr-parent", NULL);
> + tmp = par;
> + if (p == NULL)
> + par = of_get_parent(par);
> + else
> + par = of_find_node_by_phandle(*p);
> + of_node_put(tmp);
> + }
> + return par;
> +}
> +#endif /* CONFIG_OF */
> +
> +
> +/* Indirection layer for providing both NATIVE and MMIO support. */
> +
> #if defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO)
>
> bool dcr_map_ok_generic(dcr_host_t host)
> @@ -36,12 +61,24 @@ bool dcr_map_ok_generic(dcr_host_t host)
> }
> EXPORT_SYMBOL_GPL(dcr_map_ok_generic);
>
> +#ifdef CONFIG_OF
> dcr_host_t dcr_map_generic(struct device_node *dev,
> unsigned int dcr_n,
> unsigned int dcr_c)
> {
> dcr_host_t host;
> - const char *prop = of_get_property(dev, "dcr-access-method", NULL);
> + struct device_node *dp;
> +
> + dp = find_dcr_parent(dev);
> + if (dp == NULL) {
> + host.type = INVALID;
> + return host;
> + }
> +
> + const char *prop = of_get_property(dp, "dcr-access-method", NULL);
> +
> + pr_debug("dcr_map_generic(dcr-access-method = %s)\n",
> + prop);
>
> if (!strcmp(prop, "native")) {
> host.type = NATIVE;
> @@ -56,6 +93,8 @@ dcr_host_t dcr_map_generic(struct device_node *dev,
> }
> EXPORT_SYMBOL_GPL(dcr_map_generic);
>
> +#endif /* CONFIG_OF */
> +
> void dcr_unmap_generic(dcr_host_t host, unsigned int dcr_c)
> {
> if (host.type == NATIVE)
> @@ -85,9 +124,10 @@ EXPORT_SYMBOL_GPL(dcr_write_generic);
>
> #endif /* defined(CONFIG_PPC_DCR_NATIVE) && defined(CONFIG_PPC_DCR_MMIO) */
>
> +#ifdef CONFIG_OF
> unsigned int dcr_resource_start(struct device_node *np, unsigned int index)
> {
> - unsigned int ds;
> + int ds;
> const u32 *dr = of_get_property(np, "dcr-reg", &ds);
>
> if (dr == NULL || ds & 1 || index >= (ds / 8))
> @@ -99,7 +139,7 @@ EXPORT_SYMBOL_GPL(dcr_resource_start);
>
> unsigned int dcr_resource_len(struct device_node *np, unsigned int index)
> {
> - unsigned int ds;
> + int ds;
> const u32 *dr = of_get_property(np, "dcr-reg", &ds);
>
> if (dr == NULL || ds & 1 || index >= (ds / 8))
> @@ -109,26 +149,28 @@ unsigned int dcr_resource_len(struct device_node *np, unsigned int index)
> }
> EXPORT_SYMBOL_GPL(dcr_resource_len);
>
> +#endif /* CONFIG_OF */
> +
> +
> +
> +/* Support for MMIO */
> #ifdef CONFIG_PPC_DCR_MMIO
>
> -static struct device_node * find_dcr_parent(struct device_node * node)
> +dcr_host_mmio_t dcr_map_mmio_literal_mmio(resource_size_t mmio_start,
> + unsigned int stride,
> + unsigned int dcr_n,
> + unsigned int dcr_c)
> {
> - struct device_node *par, *tmp;
> - const u32 *p;
> -
> - for (par = of_node_get(node); par;) {
> - if (of_get_property(par, "dcr-controller", NULL))
> - break;
> - p = of_get_property(par, "dcr-parent", NULL);
> - tmp = par;
> - if (p == NULL)
> - par = of_get_parent(par);
> - else
> - par = of_find_node_by_phandle(*p);
> - of_node_put(tmp);
> - }
> - return par;
> + dcr_host_mmio_t host;
> + host.stride = stride;
> + host.token = ioremap(mmio_start, dcr_c * stride);
> + host.token -= dcr_n * stride;
> + host.base = dcr_n;
> + return host;
> }
> +EXPORT_SYMBOL_GPL(dcr_map_mmio_literal_mmio);
> +
> +#ifdef CONFIG_OF
>
> u64 of_translate_dcr_address(struct device_node *dev,
> unsigned int dcr_n,
> @@ -189,6 +231,8 @@ dcr_host_mmio_t dcr_map_mmio(struct device_node *dev,
> }
> EXPORT_SYMBOL_GPL(dcr_map_mmio);
>
> +#endif /* CONFIG_OF */
> +
> void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c)
> {
> dcr_host_mmio_t h = host;
> diff --git a/include/asm-powerpc/dcr-generic.h b/include/asm-powerpc/dcr-generic.h
> index 0ee74fb..8032795 100644
> --- a/include/asm-powerpc/dcr-generic.h
> +++ b/include/asm-powerpc/dcr-generic.h
> @@ -34,8 +34,10 @@ typedef struct {
>
> extern bool dcr_map_ok_generic(dcr_host_t host);
>
> +#ifdef CONFIG_OF
> extern dcr_host_t dcr_map_generic(struct device_node *dev, unsigned int dcr_n,
> unsigned int dcr_c);
> +#endif
> extern void dcr_unmap_generic(dcr_host_t host, unsigned int dcr_c);
>
> extern u32 dcr_read_generic(dcr_host_t host, unsigned int dcr_n);
> diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
> index acd491d..b12d291 100644
> --- a/include/asm-powerpc/dcr-mmio.h
> +++ b/include/asm-powerpc/dcr-mmio.h
> @@ -34,9 +34,18 @@ static inline bool dcr_map_ok_mmio(dcr_host_mmio_t host)
> return host.token != NULL;
> }
>
> +extern dcr_host_mmio_t dcr_map_mmio_literal_mmio(resource_size_t mmio_start,
> + unsigned int stride,
> + unsigned int dcr_n,
> + unsigned int dcr_c);
> +
> +
> +#ifdef CONFIG_OF
> extern dcr_host_mmio_t dcr_map_mmio(struct device_node *dev,
> unsigned int dcr_n,
> unsigned int dcr_c);
> +#endif
> +
> extern void dcr_unmap_mmio(dcr_host_mmio_t host, unsigned int dcr_c);
>
> static inline u32 dcr_read_mmio(dcr_host_mmio_t host, unsigned int dcr_n)
> @@ -51,9 +60,11 @@ static inline void dcr_write_mmio(dcr_host_mmio_t host,
> out_be32(host.token + ((host.base + dcr_n) * host.stride), value);
> }
>
> +#ifdef CONFIG_OF
> extern u64 of_translate_dcr_address(struct device_node *dev,
> unsigned int dcr_n,
> unsigned int *stride);
> +#endif
>
> #endif /* __KERNEL__ */
> #endif /* _ASM_POWERPC_DCR_MMIO_H */
> diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
> index 67832e5..9b3e255 100644
> --- a/include/asm-powerpc/dcr-native.h
> +++ b/include/asm-powerpc/dcr-native.h
> @@ -33,6 +33,14 @@ static inline bool dcr_map_ok_native(dcr_host_native_t host)
> return 1;
> }
>
> +static inline
> +dcr_host_native_t dcr_map_native_literal_native(unsigned int dcr_n)
> +{
> + dcr_host_native_t host;
> + host.base = dcr_n;
> + return host;
> +}
> +
> #define dcr_map_native(dev, dcr_n, dcr_c) \
> ((dcr_host_native_t){ .base = (dcr_n) })
> #define dcr_unmap_native(host, dcr_c) do {} while (0)
> diff --git a/include/asm-powerpc/dcr.h b/include/asm-powerpc/dcr.h
> index 6b86322..dfd1c24 100644
> --- a/include/asm-powerpc/dcr.h
> +++ b/include/asm-powerpc/dcr.h
> @@ -35,6 +35,27 @@
>
> #include <asm/dcr-generic.h>
>
> +static inline
> +dcr_host_t dcr_map_mmio_literal(resource_size_t mmio_start,
> + unsigned int stride,
> + unsigned int dcr_n,
> + unsigned int dcr_c)
> +{
> + dcr_host_t host;
> + host.type = MMIO;
> + host.host.mmio =
> + dcr_map_mmio_literal_mmio(mmio_start, stride, dcr_n, dcr_c);
> + return host;
> +}
> +static inline
> +dcr_host_t dcr_map_native_literal(unsigned int dcr_n)
> +{
> + dcr_host_t host;
> + host.type = NATIVE;
> + host.host.native = dcr_map_native_literal_native(dcr_n);
> + return host;
> +}
> +
> #define DCR_MAP_OK(host) dcr_map_ok_generic(host)
> #define dcr_map(dev, dcr_n, dcr_c) dcr_map_generic(dev, dcr_n, dcr_c)
> #define dcr_unmap(host, dcr_c) dcr_unmap_generic(host, dcr_c)
> @@ -45,6 +66,7 @@
>
> #ifdef CONFIG_PPC_DCR_NATIVE
> typedef dcr_host_native_t dcr_host_t;
> +#define dcr_map_native_literal(dcr_n) dcr_map_native_literal_native(dcr_n)
> #define DCR_MAP_OK(host) dcr_map_ok_native(host)
> #define dcr_map(dev, dcr_n, dcr_c) dcr_map_native(dev, dcr_n, dcr_c)
> #define dcr_unmap(host, dcr_c) dcr_unmap_native(host, dcr_c)
> @@ -52,6 +74,8 @@ typedef dcr_host_native_t dcr_host_t;
> #define dcr_write(host, dcr_n, value) dcr_write_native(host, dcr_n, value)
> #else
> typedef dcr_host_mmio_t dcr_host_t;
> +#define dcr_map_mmio_literal(mmio_start, stride, dcr_n, dcr_c) \
> + dcr_map_mmio_literal_mmio(mmio_start, stride, dcr_n, dcr_c)
> #define DCR_MAP_OK(host) dcr_map_ok_mmio(host)
> #define dcr_map(dev, dcr_n, dcr_c) dcr_map_mmio(dev, dcr_n, dcr_c)
> #define dcr_unmap(host, dcr_c) dcr_unmap_mmio(host, dcr_c)
next prev parent reply other threads:[~2008-03-30 22:04 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1206401313-1625-1-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:20 ` [PATCH 1/5] [v2][POWERPC] refactor dcr code Stephen Neuendorffer
[not found] ` <1206721237-17982-1-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:20 ` [PATCH 2/5] [POWERPC] Xilinx: Virtex: Enable dcr for MMIO and NATIVE Stephen Neuendorffer
[not found] ` <1206721237-17982-2-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:20 ` [PATCH 3/5] [POWERPC] explicit dcr support Stephen Neuendorffer
[not found] ` <1206721237-17982-3-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:20 ` [PATCH 4/5] [POWERPC] Xilinx: Framebuffer: Use dcr infrastructure Stephen Neuendorffer
[not found] ` <1206721237-17982-4-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:20 ` [PATCH 5/5] [RFC][PPC] Use DCR for arch ppc, and enable MMIO and NATIVE for virtex Stephen Neuendorffer
2008-03-28 16:23 ` [PATCH 1/5] [v2][POWERPC] refactor dcr code Stephen Neuendorffer
2008-03-30 22:02 ` Benjamin Herrenschmidt
2008-04-01 20:16 ` Stephen Neuendorffer
2008-04-04 22:02 ` Stephen Neuendorffer
2008-04-04 22:10 ` Benjamin Herrenschmidt
2008-04-18 21:49 ` Stephen Neuendorffer
2008-04-18 21:55 ` [PATCH 1/2] [v3][POWERPC] " Stephen Neuendorffer
2008-04-19 2:30 ` Grant Likely
2008-04-19 3:04 ` Benjamin Herrenschmidt
2008-04-19 14:35 ` Josh Boyer
2008-04-21 3:56 ` Stephen Neuendorffer
2008-04-21 13:03 ` Josh Boyer
2008-05-05 17:56 ` [PATCH 0/4] [v4][POWERPC] " Stephen Neuendorffer
[not found] ` <1210010201-28436-1-git-send-email-stephen.neuendorffer@xilinx.com>
2008-05-05 17:56 ` [PATCH 1/4] " Stephen Neuendorffer
2008-05-06 0:12 ` Benjamin Herrenschmidt
2008-05-06 3:40 ` Stephen Rothwell
2008-05-06 4:02 ` Benjamin Herrenschmidt
2008-05-06 17:34 ` Stephen Neuendorffer
2008-05-06 17:40 ` Josh Boyer
2008-05-06 18:29 ` [PATCH 1/4] [v5][POWERPC] " Stephen Neuendorffer
[not found] ` <1210010201-28436-2-git-send-email-stephen.neuendorffer@xilinx.com>
2008-05-05 17:56 ` [PATCH 2/4] [POWERPC] Xilinx: Virtex: Enable dcr for MMIO and NATIVE Stephen Neuendorffer
2008-05-06 0:11 ` Benjamin Herrenschmidt
2008-05-06 17:33 ` [PATCH 2/4] [POWERPC] Xilinx: Virtex: Enable dcr for MMIO andNATIVE Stephen Neuendorffer
[not found] ` <1210010201-28436-3-git-send-email-stephen.neuendorffer@xilinx.com>
2008-05-05 17:56 ` [PATCH 3/4] [POWERPC] Xilinx: Framebuffer: remove platform device support Stephen Neuendorffer
[not found] ` <1210010201-28436-4-git-send-email-stephen.neuendorffer@xilinx.com>
2008-05-05 17:56 ` [PATCH 4/4] [POWERPC] Xilinx: Framebuffer: Use dcr infrastructure Stephen Neuendorffer
2008-05-06 4:55 ` Grant Likely
2008-05-06 6:14 ` David Gibson
2008-05-06 10:56 ` Segher Boessenkool
2008-05-08 1:57 ` David Gibson
2008-05-06 17:43 ` [PATCH 4/4] [POWERPC] Xilinx: Framebuffer: Use dcrinfrastructure Stephen Neuendorffer
2008-05-08 1:59 ` David Gibson
2008-05-08 4:46 ` [PATCH 4/4] [POWERPC] Xilinx: Framebuffer: Usedcrinfrastructure Stephen Neuendorffer
2008-05-08 7:01 ` David Gibson
[not found] ` <1208555704-8978-1-git-send-email-stephen.neuendorffer@xilinx.com>
2008-04-18 21:55 ` [PATCH 2/2] [POWERPC] Xilinx: Virtex: Enable dcr for MMIO and NATIVE Stephen Neuendorffer
2008-04-19 2:31 ` Grant Likely
[not found] ` <1206721429-18276-1-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:23 ` [PATCH 2/5] " Stephen Neuendorffer
[not found] ` <1206721429-18276-2-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:23 ` [PATCH 3/5] [POWERPC] explicit dcr support Stephen Neuendorffer
2008-03-30 22:04 ` Benjamin Herrenschmidt [this message]
[not found] ` <1206721429-18276-3-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:23 ` [PATCH 4/5] [POWERPC] Xilinx: Framebuffer: Use dcr infrastructure Stephen Neuendorffer
[not found] ` <1206721429-18276-4-git-send-email-stephen.neuendorffer@xilinx.com>
2008-03-28 16:23 ` [PATCH 5/5] [RFC][PPC] Use DCR for arch ppc, and enable MMIO and NATIVE for virtex Stephen Neuendorffer
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=1206914647.10388.134.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=stephen.neuendorffer@xilinx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.