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 | |
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>
-rw-r--r-- | arch/powerpc/sysdev/cpm2_common.c | 56 | ||||
-rw-r--r-- | arch/powerpc/sysdev/cpm2_pic.c | 2 | ||||
-rw-r--r-- | include/asm-powerpc/cpm2.h | 2 | ||||
-rw-r--r-- | include/asm-powerpc/fs_pd.h | 19 | ||||
-rw-r--r-- | include/asm-powerpc/immap_cpm2.h | 4 |
5 files changed, 49 insertions, 34 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. |
diff --git a/arch/powerpc/sysdev/cpm2_pic.c b/arch/powerpc/sysdev/cpm2_pic.c index d5b36e0ecbda..5fe65b2f8f3a 100644 --- a/arch/powerpc/sysdev/cpm2_pic.c +++ b/arch/powerpc/sysdev/cpm2_pic.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #define CPM2_IRQ_PORTC15 48 | 48 | #define CPM2_IRQ_PORTC15 48 |
49 | #define CPM2_IRQ_PORTC0 63 | 49 | #define CPM2_IRQ_PORTC0 63 |
50 | 50 | ||
51 | static intctl_cpm2_t *cpm2_intctl; | 51 | static intctl_cpm2_t __iomem *cpm2_intctl; |
52 | 52 | ||
53 | static struct irq_host *cpm2_pic_host; | 53 | static struct irq_host *cpm2_pic_host; |
54 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) | 54 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) |
diff --git a/include/asm-powerpc/cpm2.h b/include/asm-powerpc/cpm2.h index 12a2860f9a9c..c03650609792 100644 --- a/include/asm-powerpc/cpm2.h +++ b/include/asm-powerpc/cpm2.h | |||
@@ -107,7 +107,7 @@ | |||
107 | /* Export the base address of the communication processor registers | 107 | /* Export the base address of the communication processor registers |
108 | * and dual port ram. | 108 | * and dual port ram. |
109 | */ | 109 | */ |
110 | extern cpm_cpm2_t *cpmp; /* Pointer to comm processor */ | 110 | extern cpm_cpm2_t __iomem *cpmp; /* Pointer to comm processor */ |
111 | 111 | ||
112 | extern unsigned long cpm_dpalloc(uint size, uint align); | 112 | extern unsigned long cpm_dpalloc(uint size, uint align); |
113 | extern int cpm_dpfree(unsigned long offset); | 113 | extern int cpm_dpfree(unsigned long offset); |
diff --git a/include/asm-powerpc/fs_pd.h b/include/asm-powerpc/fs_pd.h index 77e04d01749c..64706a0532d3 100644 --- a/include/asm-powerpc/fs_pd.h +++ b/include/asm-powerpc/fs_pd.h | |||
@@ -23,22 +23,9 @@ | |||
23 | #include <asm/mpc85xx.h> | 23 | #include <asm/mpc85xx.h> |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | #define cpm2_map(member) \ | 26 | #define cpm2_map(member) (&cpm2_immr->member) |
27 | ({ \ | 27 | #define cpm2_map_size(member, size) (&cpm2_immr->member) |
28 | u32 offset = offsetof(cpm2_map_t, member); \ | 28 | #define cpm2_unmap(addr) do {} while(0) |
29 | void *addr = ioremap (CPM_MAP_ADDR + offset, \ | ||
30 | sizeof( ((cpm2_map_t*)0)->member)); \ | ||
31 | addr; \ | ||
32 | }) | ||
33 | |||
34 | #define cpm2_map_size(member, size) \ | ||
35 | ({ \ | ||
36 | u32 offset = offsetof(cpm2_map_t, member); \ | ||
37 | void *addr = ioremap (CPM_MAP_ADDR + offset, size); \ | ||
38 | addr; \ | ||
39 | }) | ||
40 | |||
41 | #define cpm2_unmap(addr) iounmap(addr) | ||
42 | #endif | 29 | #endif |
43 | 30 | ||
44 | #ifdef CONFIG_8xx | 31 | #ifdef CONFIG_8xx |
diff --git a/include/asm-powerpc/immap_cpm2.h b/include/asm-powerpc/immap_cpm2.h index f316a91c628a..4080bab0468c 100644 --- a/include/asm-powerpc/immap_cpm2.h +++ b/include/asm-powerpc/immap_cpm2.h | |||
@@ -10,6 +10,8 @@ | |||
10 | #ifndef __IMMAP_CPM2__ | 10 | #ifndef __IMMAP_CPM2__ |
11 | #define __IMMAP_CPM2__ | 11 | #define __IMMAP_CPM2__ |
12 | 12 | ||
13 | #include <linux/types.h> | ||
14 | |||
13 | /* System configuration registers. | 15 | /* System configuration registers. |
14 | */ | 16 | */ |
15 | typedef struct sys_82xx_conf { | 17 | typedef struct sys_82xx_conf { |
@@ -642,7 +644,7 @@ typedef struct immap { | |||
642 | u8 res11[4096]; | 644 | u8 res11[4096]; |
643 | } cpm2_map_t; | 645 | } cpm2_map_t; |
644 | 646 | ||
645 | extern cpm2_map_t *cpm2_immr; | 647 | extern cpm2_map_t __iomem *cpm2_immr; |
646 | 648 | ||
647 | #endif /* __IMMAP_CPM2__ */ | 649 | #endif /* __IMMAP_CPM2__ */ |
648 | #endif /* __KERNEL__ */ | 650 | #endif /* __KERNEL__ */ |