diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2007-10-15 05:34:36 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-15 14:29:49 -0400 |
commit | 83f34df4e7c8794a5a81ede663fe184f4201308a (patch) | |
tree | c109c113ee02c5d656cd1b211ba2bc67d5dfd270 /include | |
parent | 0f18e719dc0d36ad91fe94b0b3dd08fdcdd2faa2 (diff) |
Add dcr_host_t.base in dcr_read()/dcr_write()
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-powerpc/dcr-mmio.h | 4 | ||||
-rw-r--r-- | include/asm-powerpc/dcr-native.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h index 6b82c3ba495a..a7d9eaf22702 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); | |||
37 | 37 | ||
38 | static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n) | 38 | static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n) |
39 | { | 39 | { |
40 | return in_be32(host.token + dcr_n * host.stride); | 40 | return in_be32(host.token + ((host.base + dcr_n) * host.stride)); |
41 | } | 41 | } |
42 | 42 | ||
43 | static inline void dcr_write(dcr_host_t host, unsigned int dcr_n, u32 value) | 43 | static inline void dcr_write(dcr_host_t host, unsigned int dcr_n, u32 value) |
44 | { | 44 | { |
45 | out_be32(host.token + dcr_n * host.stride, value); | 45 | out_be32(host.token + ((host.base + dcr_n) * host.stride), value); |
46 | } | 46 | } |
47 | 47 | ||
48 | extern u64 of_translate_dcr_address(struct device_node *dev, | 48 | 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 f41058c0f6cb..3bc780f6513a 100644 --- a/include/asm-powerpc/dcr-native.h +++ b/include/asm-powerpc/dcr-native.h | |||
@@ -30,8 +30,8 @@ typedef struct { | |||
30 | 30 | ||
31 | #define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) }) | 31 | #define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) }) |
32 | #define dcr_unmap(host, dcr_n, dcr_c) do {} while (0) | 32 | #define dcr_unmap(host, dcr_n, dcr_c) do {} while (0) |
33 | #define dcr_read(host, dcr_n) mfdcr(dcr_n) | 33 | #define dcr_read(host, dcr_n) mfdcr(dcr_n + host.base) |
34 | #define dcr_write(host, dcr_n, value) mtdcr(dcr_n, value) | 34 | #define dcr_write(host, dcr_n, value) mtdcr(dcr_n + host.base, value) |
35 | 35 | ||
36 | /* Device Control Registers */ | 36 | /* Device Control Registers */ |
37 | void __mtdcr(int reg, unsigned int val); | 37 | void __mtdcr(int reg, unsigned int val); |