]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Add dcr_host_t.base in dcr_read()/dcr_write()
authorMichael Ellerman <michael@ellerman.id.au>
Mon, 15 Oct 2007 09:34:36 +0000 (19:34 +1000)
committerJeff Garzik <jeff@garzik.org>
Mon, 15 Oct 2007 18:29:49 +0000 (14:29 -0400)
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().

As some background to why we just went through all this jiggery-pokery,
benh sayeth:

 Initially the goal of the dcr_read/dcr_write routines was to operate like
 mfdcr/mtdcr which take absolute DCR numbers. The reason is that on 4xx
 hardware, indirect DCR access is a pain (goes through a table of
 instructions) and it's useful to have the compiler resolve an absolute DCR
 inline.

 We decided that wasn't worth the API bastardisation since most places
 where absolute DCR values are used are low level 4xx-only code which may
 as well continue using mfdcr/mtdcr, while the new API is designed for
 device "instances" that can exist on 4xx and Axon type platforms and may
 be located at variable DCR offsets.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
arch/powerpc/platforms/cell/axon_msi.c
arch/powerpc/sysdev/mpic.c
drivers/net/ibm_emac/ibm_emac_mal.h
drivers/net/ibm_newemac/mal.h
include/asm-powerpc/dcr-mmio.h
include/asm-powerpc/dcr-native.h

index 1245b2f517bb669eb0cec7bcbd6d641ba57f1d73..aca15007a01c0a30decd61bd62de9569f2dfedc8 100644 (file)
@@ -77,12 +77,12 @@ static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val)
 {
        pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n);
 
-       dcr_write(msic->dcr_host, msic->dcr_host.base + dcr_n, val);
+       dcr_write(msic->dcr_host, dcr_n, val);
 }
 
 static u32 msic_dcr_read(struct axon_msic *msic, unsigned int dcr_n)
 {
-       return dcr_read(msic->dcr_host, msic->dcr_host.base + dcr_n);
+       return dcr_read(msic->dcr_host, dcr_n);
 }
 
 static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
index 893e65439e851584c0e0b46d3248de1e1fa97f00..e47938899a9268c3e926979f7f15e73394810c3d 100644 (file)
@@ -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);
index aa76d3f0dfce2f2482ff8d3b53a1d93c2c6f981c..b8adbe6d4b015e31145ece21a3470b73f2b818e8 100644 (file)
@@ -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 */
index 6daa98e5992e8fd264d1950b84abb19e177dc727..784edb8ea8220a285198e16e73c2bd1d67b73c32 100644 (file)
@@ -212,12 +212,12 @@ struct mal_instance {
 
 static inline u32 get_mal_dcrn(struct mal_instance *mal, int reg)
 {
-       return dcr_read(mal->dcr_host, mal->dcr_host.base + reg);
+       return dcr_read(mal->dcr_host, reg);
 }
 
 static inline void set_mal_dcrn(struct mal_instance *mal, int reg, u32 val)
 {
-       dcr_write(mal->dcr_host, mal->dcr_host.base + reg, val);
+       dcr_write(mal->dcr_host, reg, val);
 }
 
 /* Register MAL devices */
index 6b82c3ba495a37c14b0d9b3df4d426fc4b78e5b7..a7d9eaf22702f5a39621c157e1bf3e9f50b2deee 100644 (file)
@@ -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,
index f41058c0f6cb95ebc2d18db98ac7d5210b65b2c8..3bc780f6513a6bcbd40db77d01c0b6aaeb87056a 100644 (file)
@@ -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);