diff options
author | Scott Wood <scottwood@freescale.com> | 2007-09-14 16:30:44 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-10-04 12:02:04 -0400 |
commit | 449012daa92a60e42f0d55478641cfa796d51528 (patch) | |
tree | 0d79f3259147e7fda762ab1e07586697c22641a2 /arch/powerpc/sysdev/cpm2_common.c | |
parent | 544cdabe642e5508e784de709530a74d0775d070 (diff) |
[POWERPC] cpm2: Infrastructure code cleanup.
Mostly sparse fixes (__iomem annotations, etc); also, cpm2_immr
is used rather than creating many temporary mappings.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev/cpm2_common.c')
-rw-r--r-- | arch/powerpc/sysdev/cpm2_common.c | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/sysdev/cpm2_common.c index 3bf89b324760..0330ca490928 100644 --- a/arch/powerpc/sysdev/cpm2_common.c +++ b/arch/powerpc/sysdev/cpm2_common.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/of.h> | ||
37 | |||
36 | #include <asm/io.h> | 38 | #include <asm/io.h> |
37 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
38 | #include <asm/mpc8260.h> | 40 | #include <asm/mpc8260.h> |
@@ -45,13 +47,12 @@ | |||
45 | #include <sysdev/fsl_soc.h> | 47 | #include <sysdev/fsl_soc.h> |
46 | 48 | ||
47 | static void cpm2_dpinit(void); | 49 | static void cpm2_dpinit(void); |
48 | cpm_cpm2_t *cpmp; /* Pointer to comm processor space */ | 50 | cpm_cpm2_t __iomem *cpmp; /* Pointer to comm processor space */ |
49 | 51 | ||
50 | /* We allocate this here because it is used almost exclusively for | 52 | /* We allocate this here because it is used almost exclusively for |
51 | * the communication processor devices. | 53 | * the communication processor devices. |
52 | */ | 54 | */ |
53 | cpm2_map_t *cpm2_immr; | 55 | cpm2_map_t __iomem *cpm2_immr; |
54 | intctl_cpm2_t *cpm2_intctl; | ||
55 | 56 | ||
56 | #define CPM_MAP_SIZE (0x40000) /* 256k - the PQ3 reserve this amount | 57 | #define CPM_MAP_SIZE (0x40000) /* 256k - the PQ3 reserve this amount |
57 | of space for CPM as it is larger | 58 | of space for CPM as it is larger |
@@ -60,8 +61,11 @@ intctl_cpm2_t *cpm2_intctl; | |||
60 | void | 61 | void |
61 | cpm2_reset(void) | 62 | cpm2_reset(void) |
62 | { | 63 | { |
63 | cpm2_immr = (cpm2_map_t *)ioremap(CPM_MAP_ADDR, CPM_MAP_SIZE); | 64 | #ifdef CONFIG_PPC_85xx |
64 | cpm2_intctl = cpm2_map(im_intctl); | 65 | cpm2_immr = ioremap(CPM_MAP_ADDR, CPM_MAP_SIZE); |
66 | #else | ||
67 | cpm2_immr = ioremap(get_immrbase(), CPM_MAP_SIZE); | ||
68 | #endif | ||
65 | 69 | ||
66 | /* Reclaim the DP memory for our use. | 70 | /* Reclaim the DP memory for our use. |
67 | */ | 71 | */ |
@@ -91,7 +95,7 @@ cpm2_reset(void) | |||
91 | void | 95 | void |
92 | cpm_setbrg(uint brg, uint rate) | 96 | cpm_setbrg(uint brg, uint rate) |
93 | { | 97 | { |
94 | volatile uint *bp; | 98 | u32 __iomem *bp; |
95 | 99 | ||
96 | /* This is good enough to get SMCs running..... | 100 | /* This is good enough to get SMCs running..... |
97 | */ | 101 | */ |
@@ -113,7 +117,8 @@ cpm_setbrg(uint brg, uint rate) | |||
113 | void | 117 | void |
114 | cpm2_fastbrg(uint brg, uint rate, int div16) | 118 | cpm2_fastbrg(uint brg, uint rate, int div16) |
115 | { | 119 | { |
116 | volatile uint *bp; | 120 | u32 __iomem *bp; |
121 | u32 val; | ||
117 | 122 | ||
118 | if (brg < 4) { | 123 | if (brg < 4) { |
119 | bp = cpm2_map_size(im_brgc1, 16); | 124 | bp = cpm2_map_size(im_brgc1, 16); |
@@ -123,10 +128,11 @@ cpm2_fastbrg(uint brg, uint rate, int div16) | |||
123 | brg -= 4; | 128 | brg -= 4; |
124 | } | 129 | } |
125 | bp += brg; | 130 | bp += brg; |
126 | *bp = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN; | 131 | val = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN; |
127 | if (div16) | 132 | if (div16) |
128 | *bp |= CPM_BRG_DIV16; | 133 | val |= CPM_BRG_DIV16; |
129 | 134 | ||
135 | out_be32(bp, val); | ||
130 | cpm2_unmap(bp); | 136 | cpm2_unmap(bp); |
131 | } | 137 | } |
132 | 138 | ||
@@ -135,8 +141,8 @@ int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode) | |||
135 | int ret = 0; | 141 | int ret = 0; |
136 | int shift; | 142 | int shift; |
137 | int i, bits = 0; | 143 | int i, bits = 0; |
138 | cpmux_t *im_cpmux; | 144 | cpmux_t __iomem *im_cpmux; |
139 | u32 *reg; | 145 | u32 __iomem *reg; |
140 | u32 mask = 7; | 146 | u32 mask = 7; |
141 | u8 clk_map [24][3] = { | 147 | u8 clk_map [24][3] = { |
142 | {CPM_CLK_FCC1, CPM_BRG5, 0}, | 148 | {CPM_CLK_FCC1, CPM_BRG5, 0}, |
@@ -228,13 +234,33 @@ static spinlock_t cpm_dpmem_lock; | |||
228 | * until the memory subsystem goes up... */ | 234 | * until the memory subsystem goes up... */ |
229 | static rh_block_t cpm_boot_dpmem_rh_block[16]; | 235 | static rh_block_t cpm_boot_dpmem_rh_block[16]; |
230 | static rh_info_t cpm_dpmem_info; | 236 | static rh_info_t cpm_dpmem_info; |
231 | static u8* im_dprambase; | 237 | static u8 __iomem *im_dprambase; |
232 | 238 | ||
233 | static void cpm2_dpinit(void) | 239 | static void cpm2_dpinit(void) |
234 | { | 240 | { |
235 | spin_lock_init(&cpm_dpmem_lock); | 241 | struct resource r; |
242 | |||
243 | #ifdef CONFIG_PPC_CPM_NEW_BINDING | ||
244 | struct device_node *np; | ||
245 | |||
246 | np = of_find_compatible_node(NULL, NULL, "fsl,cpm2"); | ||
247 | if (!np) | ||
248 | panic("Cannot find CPM2 node"); | ||
236 | 249 | ||
237 | im_dprambase = ioremap(CPM_MAP_ADDR, CPM_DATAONLY_BASE + CPM_DATAONLY_SIZE); | 250 | if (of_address_to_resource(np, 1, &r)) |
251 | panic("Cannot get CPM2 resource 1"); | ||
252 | |||
253 | of_node_put(np); | ||
254 | #else | ||
255 | r.start = CPM_MAP_ADDR; | ||
256 | r.end = r.start + CPM_DATAONLY_BASE + CPM_DATAONLY_SIZE - 1; | ||
257 | #endif | ||
258 | |||
259 | im_dprambase = ioremap(r.start, r.end - r.start + 1); | ||
260 | if (!im_dprambase) | ||
261 | panic("Cannot map DPRAM"); | ||
262 | |||
263 | spin_lock_init(&cpm_dpmem_lock); | ||
238 | 264 | ||
239 | /* initialize the info header */ | 265 | /* initialize the info header */ |
240 | rh_init(&cpm_dpmem_info, 1, | 266 | rh_init(&cpm_dpmem_info, 1, |
@@ -248,7 +274,7 @@ static void cpm2_dpinit(void) | |||
248 | * varies with the processor and the microcode patches activated. | 274 | * varies with the processor and the microcode patches activated. |
249 | * But the following should be at least safe. | 275 | * But the following should be at least safe. |
250 | */ | 276 | */ |
251 | rh_attach_region(&cpm_dpmem_info, CPM_DATAONLY_BASE, CPM_DATAONLY_SIZE); | 277 | rh_attach_region(&cpm_dpmem_info, 0, r.end - r.start + 1); |
252 | } | 278 | } |
253 | 279 | ||
254 | /* This function returns an index into the DPRAM area. | 280 | /* This function returns an index into the DPRAM area. |