* [PATCH 1/5] Store the base address in dcr_host_t
@ 2007-06-22 6:18 Michael Ellerman
2007-06-22 6:18 ` [PATCH 3/5] Use dcr_host_t.base in ibm_emac_mal Michael Ellerman
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Michael Ellerman @ 2007-06-22 6:18 UTC (permalink / raw)
To: linuxppc-dev
In its current form, dcr_map() doesn't remember the base address you passed
it, which means you need to store it somewhere else. Rather than adding the
base to another struct it seems simpler to store it in the dcr_host_t.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/sysdev/dcr.c | 2 +-
include/asm-powerpc/dcr-mmio.h | 6 +++++-
include/asm-powerpc/dcr-native.h | 6 ++++--
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index 574b6ef..f3c5646 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -102,7 +102,7 @@ u64 of_translate_dcr_address(struct device_node *dev,
dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
unsigned int dcr_c)
{
- dcr_host_t ret = { .token = NULL, .stride = 0 };
+ dcr_host_t ret = { .token = NULL, .stride = 0, .base = dcr_n };
u64 addr;
pr_debug("dcr_map(%s, 0x%x, 0x%x)\n",
diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
index 5dbfca8..6b82c3b 100644
--- a/include/asm-powerpc/dcr-mmio.h
+++ b/include/asm-powerpc/dcr-mmio.h
@@ -23,7 +23,11 @@
#include <asm/io.h>
-typedef struct { void __iomem *token; unsigned int stride; } dcr_host_t;
+typedef struct {
+ void __iomem *token;
+ unsigned int stride;
+ unsigned int base;
+} dcr_host_t;
#define DCR_MAP_OK(host) ((host).token != NULL)
diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
index 05af081..f41058c 100644
--- a/include/asm-powerpc/dcr-native.h
+++ b/include/asm-powerpc/dcr-native.h
@@ -22,11 +22,13 @@
#ifdef __KERNEL__
#ifndef __ASSEMBLY__
-typedef struct {} dcr_host_t;
+typedef struct {
+ unsigned int base;
+} dcr_host_t;
#define DCR_MAP_OK(host) (1)
-#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){})
+#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
#define dcr_unmap(host, dcr_n, dcr_c) do {} while (0)
#define dcr_read(host, dcr_n) mfdcr(dcr_n)
#define dcr_write(host, dcr_n, value) mtdcr(dcr_n, value)
--
1.5.1.3.g7a33b
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/5] Update mpic to use dcr_host_t.base
2007-06-22 6:18 [PATCH 1/5] Store the base address in dcr_host_t Michael Ellerman
2007-06-22 6:18 ` [PATCH 3/5] Use dcr_host_t.base in ibm_emac_mal Michael Ellerman
@ 2007-06-22 6:18 ` Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-06-22 6:18 ` [PATCH 4/5] Add dcr_host_t.base in dcr_read()/dcr_write() Michael Ellerman
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Michael Ellerman @ 2007-06-22 6:18 UTC (permalink / raw)
To: linuxppc-dev
Now that dcr_host_t contains the base address, we can use that in the mpic
code, rather than storing it separately.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/sysdev/mpic.c | 28 +++++++++++-----------------
include/asm-powerpc/mpic.h | 6 ------
2 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 75aad38..6c2e467 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -156,8 +156,7 @@ static inline u32 _mpic_read(enum mpic_reg_type type,
switch(type) {
#ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
- return dcr_read(rb->dhost,
- rb->dbase + reg + rb->doff);
+ return dcr_read(rb->dhost, rb->dhost.base + reg);
#endif
case mpic_access_mmio_be:
return in_be32(rb->base + (reg >> 2));
@@ -174,8 +173,7 @@ static inline void _mpic_write(enum mpic_reg_type type,
switch(type) {
#ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
- return dcr_write(rb->dhost,
- rb->dbase + reg + rb->doff, value);
+ return dcr_write(rb->dhost, rb->dhost.base + reg, value);
#endif
case mpic_access_mmio_be:
return out_be32(rb->base + (reg >> 2), value);
@@ -269,9 +267,11 @@ static void _mpic_map_mmio(struct mpic *mpic, unsigned long phys_addr,
static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb,
unsigned int offset, unsigned int size)
{
- rb->dbase = mpic->dcr_base;
- rb->doff = offset;
- rb->dhost = dcr_map(mpic->of_node, rb->dbase + rb->doff, size);
+ const u32 *dbasep;
+
+ dbasep = of_get_property(mpic->of_node, "dcr-reg", NULL);
+
+ rb->dhost = dcr_map(mpic->of_node, *dbasep + offset, size);
BUG_ON(!DCR_MAP_OK(rb->dhost));
}
@@ -1047,20 +1047,14 @@ struct mpic * __init mpic_alloc(struct device_node *node,
BUG_ON(paddr == 0 && node == NULL);
/* If no physical address passed in, check if it's dcr based */
- if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL)
- mpic->flags |= MPIC_USES_DCR;
-
+ if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL) {
#ifdef CONFIG_PPC_DCR
- if (mpic->flags & MPIC_USES_DCR) {
- const u32 *dbasep;
- dbasep = of_get_property(node, "dcr-reg", NULL);
- BUG_ON(dbasep == NULL);
- mpic->dcr_base = *dbasep;
+ mpic->flags |= MPIC_USES_DCR;
mpic->reg_type = mpic_access_dcr;
- }
#else
- BUG_ON (mpic->flags & MPIC_USES_DCR);
+ BUG();
#endif /* CONFIG_PPC_DCR */
+ }
/* If the MPIC is not DCR based, and no physical address was passed
* in, try to obtain one
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
index 2ffb06a..11b8e51 100644
--- a/include/asm-powerpc/mpic.h
+++ b/include/asm-powerpc/mpic.h
@@ -224,8 +224,6 @@ struct mpic_reg_bank {
u32 __iomem *base;
#ifdef CONFIG_PPC_DCR
dcr_host_t dhost;
- unsigned int dbase;
- unsigned int doff;
#endif /* CONFIG_PPC_DCR */
};
@@ -292,10 +290,6 @@ struct mpic
struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS];
struct mpic_reg_bank isus[MPIC_MAX_ISU];
-#ifdef CONFIG_PPC_DCR
- unsigned int dcr_base;
-#endif
-
#ifdef CONFIG_MPIC_WEIRD
/* Pointer to HW info array */
u32 *hw_set;
--
1.5.1.3.g7a33b
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/5] Use dcr_host_t.base in ibm_emac_mal
2007-06-22 6:18 [PATCH 1/5] Store the base address in dcr_host_t Michael Ellerman
@ 2007-06-22 6:18 ` Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-06-22 6:18 ` [PATCH 2/5] Update mpic to use dcr_host_t.base Michael Ellerman
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Michael Ellerman @ 2007-06-22 6:18 UTC (permalink / raw)
To: linuxppc-dev
This requires us to do a sort-of fake dcr_map(), so that base is set
properly. This will be fixed/removed when the device-tree-aware emac driver
is merged.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
drivers/net/ibm_emac/ibm_emac_mal.c | 5 ++++-
drivers/net/ibm_emac/ibm_emac_mal.h | 5 ++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.c b/drivers/net/ibm_emac/ibm_emac_mal.c
index cabd984..b08da96 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.c
+++ b/drivers/net/ibm_emac/ibm_emac_mal.c
@@ -421,7 +421,10 @@ static int __init mal_probe(struct ocp_device *ocpdev)
ocpdev->def->index);
return -ENOMEM;
}
- mal->dcrbase = maldata->dcr_base;
+
+ /* XXX This only works for native dcr for now */
+ mal->dcrhost = dcr_map(NULL, maldata->dcr_base, 0);
+
mal->def = ocpdev->def;
INIT_LIST_HEAD(&mal->poll_list);
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
index 64bc338..6b1fbeb 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -191,7 +191,6 @@ struct mal_commac {
};
struct ibm_ocp_mal {
- int dcrbase;
dcr_host_t dcrhost;
struct list_head poll_list;
@@ -209,12 +208,12 @@ struct ibm_ocp_mal {
static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
{
- return dcr_read(mal->dcrhost, mal->dcrbase + reg);
+ return dcr_read(mal->dcrhost, mal->dcrhost.base + reg);
}
static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
{
- dcr_write(mal->dcrhost, mal->dcrbase + reg, val);
+ dcr_write(mal->dcrhost, mal->dcrhost.base + reg, val);
}
/* Register MAL devices */
--
1.5.1.3.g7a33b
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/5] Add dcr_host_t.base in dcr_read()/dcr_write()
2007-06-22 6:18 [PATCH 1/5] Store the base address in dcr_host_t Michael Ellerman
2007-06-22 6:18 ` [PATCH 3/5] Use dcr_host_t.base in ibm_emac_mal Michael Ellerman
2007-06-22 6:18 ` [PATCH 2/5] Update mpic to use dcr_host_t.base Michael Ellerman
@ 2007-06-22 6:18 ` Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-06-22 6:18 ` [PATCH 5/5] Add dcr_map_reg() helper Michael Ellerman
2007-07-12 0:28 ` [PATCH 1/5] Store the base address in dcr_host_t Benjamin Herrenschmidt
4 siblings, 1 reply; 10+ messages in thread
From: Michael Ellerman @ 2007-06-22 6:18 UTC (permalink / raw)
To: linuxppc-dev
Now that all users of dcr_read()/dcr_write() add the dcr_host_t.base, we can
save them the trouble and do it in dcr_read()/dcr_write().
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/sysdev/mpic.c | 4 ++--
drivers/net/ibm_emac/ibm_emac_mal.h | 4 ++--
include/asm-powerpc/dcr-mmio.h | 4 ++--
include/asm-powerpc/dcr-native.h | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 6c2e467..8cb8e13 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -156,7 +156,7 @@ static inline u32 _mpic_read(enum mpic_reg_type type,
switch(type) {
#ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
- return dcr_read(rb->dhost, rb->dhost.base + reg);
+ return dcr_read(rb->dhost, reg);
#endif
case mpic_access_mmio_be:
return in_be32(rb->base + (reg >> 2));
@@ -173,7 +173,7 @@ static inline void _mpic_write(enum mpic_reg_type type,
switch(type) {
#ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
- return dcr_write(rb->dhost, rb->dhost.base + reg, value);
+ return dcr_write(rb->dhost, reg, value);
#endif
case mpic_access_mmio_be:
return out_be32(rb->base + (reg >> 2), value);
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
index 6b1fbeb..10dc978 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -208,12 +208,12 @@ struct ibm_ocp_mal {
static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
{
- return dcr_read(mal->dcrhost, mal->dcrhost.base + reg);
+ return dcr_read(mal->dcrhost, reg);
}
static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
{
- dcr_write(mal->dcrhost, mal->dcrhost.base + reg, val);
+ dcr_write(mal->dcrhost, reg, val);
}
/* Register MAL devices */
diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
index 6b82c3b..a7d9eaf 100644
--- a/include/asm-powerpc/dcr-mmio.h
+++ b/include/asm-powerpc/dcr-mmio.h
@@ -37,12 +37,12 @@ extern void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c);
static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n)
{
- return in_be32(host.token + dcr_n * host.stride);
+ return in_be32(host.token + ((host.base + dcr_n) * host.stride));
}
static inline void dcr_write(dcr_host_t host, unsigned int dcr_n, u32 value)
{
- out_be32(host.token + dcr_n * host.stride, value);
+ out_be32(host.token + ((host.base + dcr_n) * host.stride), value);
}
extern u64 of_translate_dcr_address(struct device_node *dev,
diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
index f41058c..3bc780f 100644
--- a/include/asm-powerpc/dcr-native.h
+++ b/include/asm-powerpc/dcr-native.h
@@ -30,8 +30,8 @@ typedef struct {
#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
#define dcr_unmap(host, dcr_n, dcr_c) do {} while (0)
-#define dcr_read(host, dcr_n) mfdcr(dcr_n)
-#define dcr_write(host, dcr_n, value) mtdcr(dcr_n, value)
+#define dcr_read(host, dcr_n) mfdcr(dcr_n + host.base)
+#define dcr_write(host, dcr_n, value) mtdcr(dcr_n + host.base, value)
/* Device Control Registers */
void __mtdcr(int reg, unsigned int val);
--
1.5.1.3.g7a33b
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/5] Add dcr_map_reg() helper
2007-06-22 6:18 [PATCH 1/5] Store the base address in dcr_host_t Michael Ellerman
` (2 preceding siblings ...)
2007-06-22 6:18 ` [PATCH 4/5] Add dcr_host_t.base in dcr_read()/dcr_write() Michael Ellerman
@ 2007-06-22 6:18 ` Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-07-12 0:28 ` [PATCH 1/5] Store the base address in dcr_host_t Benjamin Herrenschmidt
4 siblings, 1 reply; 10+ messages in thread
From: Michael Ellerman @ 2007-06-22 6:18 UTC (permalink / raw)
To: linuxppc-dev
Add a helper routine to map dcr's based on the "dcr-reg" property of
a device node.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/sysdev/dcr.c | 17 +++++++++++++++++
include/asm-powerpc/dcr.h | 1 +
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index f3c5646..da2ac7c 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -123,6 +123,23 @@ dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
return ret;
}
+dcr_host_t dcr_map_reg(struct device_node *dev, unsigned int index)
+{
+ dcr_host_t ret = { .token = NULL };
+
+ unsigned int dcr_n, dcr_c;
+
+ dcr_n = dcr_resource_start(dev, index);
+ if (!dcr_n)
+ return ret;
+
+ dcr_c = dcr_resource_len(dev, index);
+ if (!dcr_c)
+ return ret;
+
+ return dcr_map(dev, dcr_n, dcr_c);
+}
+
void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c)
{
dcr_host_t h = host;
diff --git a/include/asm-powerpc/dcr.h b/include/asm-powerpc/dcr.h
index 9338d50..4d42f01 100644
--- a/include/asm-powerpc/dcr.h
+++ b/include/asm-powerpc/dcr.h
@@ -38,6 +38,7 @@ extern unsigned int dcr_resource_start(struct device_node *np,
unsigned int index);
extern unsigned int dcr_resource_len(struct device_node *np,
unsigned int index);
+extern dcr_host_t dcr_map_reg(struct device_node *np, unsigned int index);
#endif /* CONFIG_PPC_MERGE */
#endif /* CONFIG_PPC_DCR */
--
1.5.1.3.g7a33b
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/5] Store the base address in dcr_host_t
2007-06-22 6:18 [PATCH 1/5] Store the base address in dcr_host_t Michael Ellerman
` (3 preceding siblings ...)
2007-06-22 6:18 ` [PATCH 5/5] Add dcr_map_reg() helper Michael Ellerman
@ 2007-07-12 0:28 ` Benjamin Herrenschmidt
4 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-07-12 0:28 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
On Fri, 2007-06-22 at 16:18 +1000, Michael Ellerman wrote:
> In its current form, dcr_map() doesn't remember the base address you passed
> it, which means you need to store it somewhere else. Rather than adding the
> base to another struct it seems simpler to store it in the dcr_host_t.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/sysdev/dcr.c | 2 +-
> include/asm-powerpc/dcr-mmio.h | 6 +++++-
> include/asm-powerpc/dcr-native.h | 6 ++++--
> 3 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
> index 574b6ef..f3c5646 100644
> --- a/arch/powerpc/sysdev/dcr.c
> +++ b/arch/powerpc/sysdev/dcr.c
> @@ -102,7 +102,7 @@ u64 of_translate_dcr_address(struct device_node *dev,
> dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
> unsigned int dcr_c)
> {
> - dcr_host_t ret = { .token = NULL, .stride = 0 };
> + dcr_host_t ret = { .token = NULL, .stride = 0, .base = dcr_n };
> u64 addr;
>
> pr_debug("dcr_map(%s, 0x%x, 0x%x)\n",
> diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
> index 5dbfca8..6b82c3b 100644
> --- a/include/asm-powerpc/dcr-mmio.h
> +++ b/include/asm-powerpc/dcr-mmio.h
> @@ -23,7 +23,11 @@
>
> #include <asm/io.h>
>
> -typedef struct { void __iomem *token; unsigned int stride; } dcr_host_t;
> +typedef struct {
> + void __iomem *token;
> + unsigned int stride;
> + unsigned int base;
> +} dcr_host_t;
>
> #define DCR_MAP_OK(host) ((host).token != NULL)
>
> diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
> index 05af081..f41058c 100644
> --- a/include/asm-powerpc/dcr-native.h
> +++ b/include/asm-powerpc/dcr-native.h
> @@ -22,11 +22,13 @@
> #ifdef __KERNEL__
> #ifndef __ASSEMBLY__
>
> -typedef struct {} dcr_host_t;
> +typedef struct {
> + unsigned int base;
> +} dcr_host_t;
>
> #define DCR_MAP_OK(host) (1)
>
> -#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){})
> +#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
> #define dcr_unmap(host, dcr_n, dcr_c) do {} while (0)
> #define dcr_read(host, dcr_n) mfdcr(dcr_n)
> #define dcr_write(host, dcr_n, value) mtdcr(dcr_n, value)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/5] Update mpic to use dcr_host_t.base
2007-06-22 6:18 ` [PATCH 2/5] Update mpic to use dcr_host_t.base Michael Ellerman
@ 2007-07-12 0:30 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-07-12 0:30 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
On Fri, 2007-06-22 at 16:18 +1000, Michael Ellerman wrote:
> Now that dcr_host_t contains the base address, we can use that in the mpic
> code, rather than storing it separately.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/sysdev/mpic.c | 28 +++++++++++-----------------
> include/asm-powerpc/mpic.h | 6 ------
> 2 files changed, 11 insertions(+), 23 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index 75aad38..6c2e467 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -156,8 +156,7 @@ static inline u32 _mpic_read(enum mpic_reg_type type,
> switch(type) {
> #ifdef CONFIG_PPC_DCR
> case mpic_access_dcr:
> - return dcr_read(rb->dhost,
> - rb->dbase + reg + rb->doff);
> + return dcr_read(rb->dhost, rb->dhost.base + reg);
> #endif
> case mpic_access_mmio_be:
> return in_be32(rb->base + (reg >> 2));
> @@ -174,8 +173,7 @@ static inline void _mpic_write(enum mpic_reg_type type,
> switch(type) {
> #ifdef CONFIG_PPC_DCR
> case mpic_access_dcr:
> - return dcr_write(rb->dhost,
> - rb->dbase + reg + rb->doff, value);
> + return dcr_write(rb->dhost, rb->dhost.base + reg, value);
> #endif
> case mpic_access_mmio_be:
> return out_be32(rb->base + (reg >> 2), value);
> @@ -269,9 +267,11 @@ static void _mpic_map_mmio(struct mpic *mpic, unsigned long phys_addr,
> static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb,
> unsigned int offset, unsigned int size)
> {
> - rb->dbase = mpic->dcr_base;
> - rb->doff = offset;
> - rb->dhost = dcr_map(mpic->of_node, rb->dbase + rb->doff, size);
> + const u32 *dbasep;
> +
> + dbasep = of_get_property(mpic->of_node, "dcr-reg", NULL);
> +
> + rb->dhost = dcr_map(mpic->of_node, *dbasep + offset, size);
> BUG_ON(!DCR_MAP_OK(rb->dhost));
> }
>
> @@ -1047,20 +1047,14 @@ struct mpic * __init mpic_alloc(struct device_node *node,
> BUG_ON(paddr == 0 && node == NULL);
>
> /* If no physical address passed in, check if it's dcr based */
> - if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL)
> - mpic->flags |= MPIC_USES_DCR;
> -
> + if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL) {
> #ifdef CONFIG_PPC_DCR
> - if (mpic->flags & MPIC_USES_DCR) {
> - const u32 *dbasep;
> - dbasep = of_get_property(node, "dcr-reg", NULL);
> - BUG_ON(dbasep == NULL);
> - mpic->dcr_base = *dbasep;
> + mpic->flags |= MPIC_USES_DCR;
> mpic->reg_type = mpic_access_dcr;
> - }
> #else
> - BUG_ON (mpic->flags & MPIC_USES_DCR);
> + BUG();
> #endif /* CONFIG_PPC_DCR */
> + }
>
> /* If the MPIC is not DCR based, and no physical address was passed
> * in, try to obtain one
> diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
> index 2ffb06a..11b8e51 100644
> --- a/include/asm-powerpc/mpic.h
> +++ b/include/asm-powerpc/mpic.h
> @@ -224,8 +224,6 @@ struct mpic_reg_bank {
> u32 __iomem *base;
> #ifdef CONFIG_PPC_DCR
> dcr_host_t dhost;
> - unsigned int dbase;
> - unsigned int doff;
> #endif /* CONFIG_PPC_DCR */
> };
>
> @@ -292,10 +290,6 @@ struct mpic
> struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS];
> struct mpic_reg_bank isus[MPIC_MAX_ISU];
>
> -#ifdef CONFIG_PPC_DCR
> - unsigned int dcr_base;
> -#endif
> -
> #ifdef CONFIG_MPIC_WEIRD
> /* Pointer to HW info array */
> u32 *hw_set;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/5] Use dcr_host_t.base in ibm_emac_mal
2007-06-22 6:18 ` [PATCH 3/5] Use dcr_host_t.base in ibm_emac_mal Michael Ellerman
@ 2007-07-12 0:30 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-07-12 0:30 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
On Fri, 2007-06-22 at 16:18 +1000, Michael Ellerman wrote:
> This requires us to do a sort-of fake dcr_map(), so that base is set
> properly. This will be fixed/removed when the device-tree-aware emac driver
> is merged.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> drivers/net/ibm_emac/ibm_emac_mal.c | 5 ++++-
> drivers/net/ibm_emac/ibm_emac_mal.h | 5 ++---
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ibm_emac/ibm_emac_mal.c b/drivers/net/ibm_emac/ibm_emac_mal.c
> index cabd984..b08da96 100644
> --- a/drivers/net/ibm_emac/ibm_emac_mal.c
> +++ b/drivers/net/ibm_emac/ibm_emac_mal.c
> @@ -421,7 +421,10 @@ static int __init mal_probe(struct ocp_device *ocpdev)
> ocpdev->def->index);
> return -ENOMEM;
> }
> - mal->dcrbase = maldata->dcr_base;
> +
> + /* XXX This only works for native dcr for now */
> + mal->dcrhost = dcr_map(NULL, maldata->dcr_base, 0);
> +
> mal->def = ocpdev->def;
>
> INIT_LIST_HEAD(&mal->poll_list);
> diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
> index 64bc338..6b1fbeb 100644
> --- a/drivers/net/ibm_emac/ibm_emac_mal.h
> +++ b/drivers/net/ibm_emac/ibm_emac_mal.h
> @@ -191,7 +191,6 @@ struct mal_commac {
> };
>
> struct ibm_ocp_mal {
> - int dcrbase;
> dcr_host_t dcrhost;
>
> struct list_head poll_list;
> @@ -209,12 +208,12 @@ struct ibm_ocp_mal {
>
> static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
> {
> - return dcr_read(mal->dcrhost, mal->dcrbase + reg);
> + return dcr_read(mal->dcrhost, mal->dcrhost.base + reg);
> }
>
> static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
> {
> - dcr_write(mal->dcrhost, mal->dcrbase + reg, val);
> + dcr_write(mal->dcrhost, mal->dcrhost.base + reg, val);
> }
>
> /* Register MAL devices */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/5] Add dcr_host_t.base in dcr_read()/dcr_write()
2007-06-22 6:18 ` [PATCH 4/5] Add dcr_host_t.base in dcr_read()/dcr_write() Michael Ellerman
@ 2007-07-12 0:30 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-07-12 0:30 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
On Fri, 2007-06-22 at 16:18 +1000, Michael Ellerman wrote:
> Now that all users of dcr_read()/dcr_write() add the dcr_host_t.base, we can
> save them the trouble and do it in dcr_read()/dcr_write().
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/sysdev/mpic.c | 4 ++--
> drivers/net/ibm_emac/ibm_emac_mal.h | 4 ++--
> include/asm-powerpc/dcr-mmio.h | 4 ++--
> include/asm-powerpc/dcr-native.h | 4 ++--
> 4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index 6c2e467..8cb8e13 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -156,7 +156,7 @@ static inline u32 _mpic_read(enum mpic_reg_type type,
> switch(type) {
> #ifdef CONFIG_PPC_DCR
> case mpic_access_dcr:
> - return dcr_read(rb->dhost, rb->dhost.base + reg);
> + return dcr_read(rb->dhost, reg);
> #endif
> case mpic_access_mmio_be:
> return in_be32(rb->base + (reg >> 2));
> @@ -173,7 +173,7 @@ static inline void _mpic_write(enum mpic_reg_type type,
> switch(type) {
> #ifdef CONFIG_PPC_DCR
> case mpic_access_dcr:
> - return dcr_write(rb->dhost, rb->dhost.base + reg, value);
> + return dcr_write(rb->dhost, reg, value);
> #endif
> case mpic_access_mmio_be:
> return out_be32(rb->base + (reg >> 2), value);
> diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
> index 6b1fbeb..10dc978 100644
> --- a/drivers/net/ibm_emac/ibm_emac_mal.h
> +++ b/drivers/net/ibm_emac/ibm_emac_mal.h
> @@ -208,12 +208,12 @@ struct ibm_ocp_mal {
>
> static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
> {
> - return dcr_read(mal->dcrhost, mal->dcrhost.base + reg);
> + return dcr_read(mal->dcrhost, reg);
> }
>
> static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
> {
> - dcr_write(mal->dcrhost, mal->dcrhost.base + reg, val);
> + dcr_write(mal->dcrhost, reg, val);
> }
>
> /* Register MAL devices */
> diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
> index 6b82c3b..a7d9eaf 100644
> --- a/include/asm-powerpc/dcr-mmio.h
> +++ b/include/asm-powerpc/dcr-mmio.h
> @@ -37,12 +37,12 @@ extern void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c);
>
> static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n)
> {
> - return in_be32(host.token + dcr_n * host.stride);
> + return in_be32(host.token + ((host.base + dcr_n) * host.stride));
> }
>
> static inline void dcr_write(dcr_host_t host, unsigned int dcr_n, u32 value)
> {
> - out_be32(host.token + dcr_n * host.stride, value);
> + out_be32(host.token + ((host.base + dcr_n) * host.stride), value);
> }
>
> extern u64 of_translate_dcr_address(struct device_node *dev,
> diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
> index f41058c..3bc780f 100644
> --- a/include/asm-powerpc/dcr-native.h
> +++ b/include/asm-powerpc/dcr-native.h
> @@ -30,8 +30,8 @@ typedef struct {
>
> #define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
> #define dcr_unmap(host, dcr_n, dcr_c) do {} while (0)
> -#define dcr_read(host, dcr_n) mfdcr(dcr_n)
> -#define dcr_write(host, dcr_n, value) mtdcr(dcr_n, value)
> +#define dcr_read(host, dcr_n) mfdcr(dcr_n + host.base)
> +#define dcr_write(host, dcr_n, value) mtdcr(dcr_n + host.base, value)
>
> /* Device Control Registers */
> void __mtdcr(int reg, unsigned int val);
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 5/5] Add dcr_map_reg() helper
2007-06-22 6:18 ` [PATCH 5/5] Add dcr_map_reg() helper Michael Ellerman
@ 2007-07-12 0:30 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2007-07-12 0:30 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
On Fri, 2007-06-22 at 16:18 +1000, Michael Ellerman wrote:
> Add a helper routine to map dcr's based on the "dcr-reg" property of
> a device node.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/sysdev/dcr.c | 17 +++++++++++++++++
> include/asm-powerpc/dcr.h | 1 +
> 2 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
> index f3c5646..da2ac7c 100644
> --- a/arch/powerpc/sysdev/dcr.c
> +++ b/arch/powerpc/sysdev/dcr.c
> @@ -123,6 +123,23 @@ dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
> return ret;
> }
>
> +dcr_host_t dcr_map_reg(struct device_node *dev, unsigned int index)
> +{
> + dcr_host_t ret = { .token = NULL };
> +
> + unsigned int dcr_n, dcr_c;
> +
> + dcr_n = dcr_resource_start(dev, index);
> + if (!dcr_n)
> + return ret;
> +
> + dcr_c = dcr_resource_len(dev, index);
> + if (!dcr_c)
> + return ret;
> +
> + return dcr_map(dev, dcr_n, dcr_c);
> +}
> +
> void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c)
> {
> dcr_host_t h = host;
> diff --git a/include/asm-powerpc/dcr.h b/include/asm-powerpc/dcr.h
> index 9338d50..4d42f01 100644
> --- a/include/asm-powerpc/dcr.h
> +++ b/include/asm-powerpc/dcr.h
> @@ -38,6 +38,7 @@ extern unsigned int dcr_resource_start(struct device_node *np,
> unsigned int index);
> extern unsigned int dcr_resource_len(struct device_node *np,
> unsigned int index);
> +extern dcr_host_t dcr_map_reg(struct device_node *np, unsigned int index);
> #endif /* CONFIG_PPC_MERGE */
>
> #endif /* CONFIG_PPC_DCR */
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-07-12 0:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-22 6:18 [PATCH 1/5] Store the base address in dcr_host_t Michael Ellerman
2007-06-22 6:18 ` [PATCH 3/5] Use dcr_host_t.base in ibm_emac_mal Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-06-22 6:18 ` [PATCH 2/5] Update mpic to use dcr_host_t.base Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-06-22 6:18 ` [PATCH 4/5] Add dcr_host_t.base in dcr_read()/dcr_write() Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-06-22 6:18 ` [PATCH 5/5] Add dcr_map_reg() helper Michael Ellerman
2007-07-12 0:30 ` Benjamin Herrenschmidt
2007-07-12 0:28 ` [PATCH 1/5] Store the base address in dcr_host_t Benjamin Herrenschmidt
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).