Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: OMAP: Introduce omap_globals and prcm access functions for multi-omap

New struct omap_globals contains the omap processor specific
module bases. Use omap_globals to set the various base addresses
to make detecting omap chip type simpler.

Also introduce OMAP1_IO_ADDRESS and OMAP2_IO_ADDRESS for future multi-omap
patches.

Signed-off-by: Tony Lindgren <tony@atomide.com>

+149 -57
+3 -8
arch/arm/mach-omap2/cm.h
··· 96 96 /* Clock management domain register get/set */ 97 97 98 98 #ifndef __ASSEMBLER__ 99 - static inline void cm_write_mod_reg(u32 val, s16 module, s16 idx) 100 - { 101 - __raw_writel(val, OMAP_CM_REGADDR(module, idx)); 102 - } 103 99 104 - static inline u32 cm_read_mod_reg(s16 module, s16 idx) 105 - { 106 - return __raw_readl(OMAP_CM_REGADDR(module, idx)); 107 - } 100 + extern u32 cm_read_mod_reg(s16 module, u16 idx); 101 + extern void cm_write_mod_reg(u32 val, s16 module, u16 idx); 102 + 108 103 #endif 109 104 110 105 /* CM register bits shared between 24XX and 3430 */
+7 -17
arch/arm/mach-omap2/control.c
··· 13 13 #undef DEBUG 14 14 15 15 #include <linux/kernel.h> 16 + #include <linux/io.h> 16 17 17 - #include <asm/io.h> 18 - 18 + #include <asm/arch/common.h> 19 19 #include <asm/arch/control.h> 20 20 21 - static u32 omap2_ctrl_base; 21 + static void __iomem *omap2_ctrl_base; 22 22 23 - #define OMAP_CTRL_REGADDR(reg) (void __iomem *)IO_ADDRESS(omap2_ctrl_base \ 24 - + (reg)) 23 + #define OMAP_CTRL_REGADDR(reg) (omap2_ctrl_base + (reg)) 25 24 26 - void omap_ctrl_base_set(u32 base) 25 + void __init omap2_set_globals_control(struct omap_globals *omap2_globals) 27 26 { 28 - omap2_ctrl_base = base; 27 + omap2_ctrl_base = omap2_globals->ctrl; 29 28 } 30 29 31 - u32 omap_ctrl_base_get(void) 30 + void __iomem *omap_ctrl_base_get(void) 32 31 { 33 32 return omap2_ctrl_base; 34 33 } ··· 49 50 50 51 void omap_ctrl_writeb(u8 val, u16 offset) 51 52 { 52 - pr_debug("omap_ctrl_writeb: writing 0x%0x to 0x%0x\n", val, 53 - (u32)OMAP_CTRL_REGADDR(offset)); 54 - 55 53 __raw_writeb(val, OMAP_CTRL_REGADDR(offset)); 56 54 } 57 55 58 56 void omap_ctrl_writew(u16 val, u16 offset) 59 57 { 60 - pr_debug("omap_ctrl_writew: writing 0x%0x to 0x%0x\n", val, 61 - (u32)OMAP_CTRL_REGADDR(offset)); 62 - 63 58 __raw_writew(val, OMAP_CTRL_REGADDR(offset)); 64 59 } 65 60 66 61 void omap_ctrl_writel(u32 val, u16 offset) 67 62 { 68 - pr_debug("omap_ctrl_writel: writing 0x%0x to 0x%0x\n", val, 69 - (u32)OMAP_CTRL_REGADDR(offset)); 70 - 71 63 __raw_writel(val, OMAP_CTRL_REGADDR(offset)); 72 64 } 73 65
+9 -2
arch/arm/mach-omap2/memory.c
··· 24 24 25 25 #include <asm/io.h> 26 26 27 + #include <asm/arch/common.h> 27 28 #include <asm/arch/clock.h> 28 29 #include <asm/arch/sram.h> 29 30 ··· 33 32 #include "memory.h" 34 33 #include "sdrc.h" 35 34 36 - unsigned long omap2_sdrc_base; 37 - unsigned long omap2_sms_base; 35 + void __iomem *omap2_sdrc_base; 36 + void __iomem *omap2_sms_base; 38 37 39 38 static struct memory_timings mem_timings; 40 39 static u32 curr_perf_level = CORE_CLK_SRC_DPLL_X2; ··· 153 152 154 153 /* 90 degree phase for anything below 133Mhz + disable DLL filter */ 155 154 mem_timings.slow_dll_ctrl |= ((1 << 1) | (3 << 8)); 155 + } 156 + 157 + void __init omap2_set_globals_memory(struct omap_globals *omap2_globals) 158 + { 159 + omap2_sdrc_base = omap2_globals->sdrc; 160 + omap2_sms_base = omap2_globals->sms; 156 161 } 157 162 158 163 /* turn on smart idle modes for SDRAM scheduler and controller */
+1 -1
arch/arm/mach-omap2/mux.c
··· 236 236 warn = (orig != reg); 237 237 if (debug || warn) 238 238 printk(KERN_WARNING 239 - "MUX: setup %s (0x%08x): 0x%02x -> 0x%02x\n", 239 + "MUX: setup %s (0x%p): 0x%04x -> 0x%04x\n", 240 240 cfg->name, omap_ctrl_base_get() + cfg->mux_reg, 241 241 orig, reg); 242 242 }
+54 -1
arch/arm/mach-omap2/prcm.c
··· 16 16 #include <linux/module.h> 17 17 #include <linux/init.h> 18 18 #include <linux/clk.h> 19 + #include <linux/io.h> 19 20 20 - #include <asm/io.h> 21 + #include <asm/arch/common.h> 22 + #include <asm/arch/prcm.h> 21 23 24 + #include "clock.h" 22 25 #include "prm.h" 23 26 #include "prm-regbits-24xx.h" 27 + 28 + static void __iomem *prm_base; 29 + static void __iomem *cm_base; 24 30 25 31 extern void omap2_clk_prepare_for_reboot(void); 26 32 ··· 46 40 wkup = prm_read_mod_reg(WKUP_MOD, RM_RSTCTRL) | OMAP_RST_DPLL3; 47 41 prm_write_mod_reg(wkup, WKUP_MOD, RM_RSTCTRL); 48 42 } 43 + } 44 + 45 + static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg) 46 + { 47 + BUG_ON(!base); 48 + return __raw_readl(base + module + reg); 49 + } 50 + 51 + static inline void __omap_prcm_write(u32 value, void __iomem *base, 52 + s16 module, u16 reg) 53 + { 54 + BUG_ON(!base); 55 + __raw_writel(value, base + module + reg); 56 + } 57 + 58 + /* Read a register in a PRM module */ 59 + u32 prm_read_mod_reg(s16 module, u16 idx) 60 + { 61 + return __omap_prcm_read(prm_base, module, idx); 62 + } 63 + EXPORT_SYMBOL(prm_read_mod_reg); 64 + 65 + /* Write into a register in a PRM module */ 66 + void prm_write_mod_reg(u32 val, s16 module, u16 idx) 67 + { 68 + __omap_prcm_write(val, prm_base, module, idx); 69 + } 70 + EXPORT_SYMBOL(prm_write_mod_reg); 71 + 72 + /* Read a register in a CM module */ 73 + u32 cm_read_mod_reg(s16 module, u16 idx) 74 + { 75 + return __omap_prcm_read(cm_base, module, idx); 76 + } 77 + EXPORT_SYMBOL(cm_read_mod_reg); 78 + 79 + /* Write into a register in a CM module */ 80 + void cm_write_mod_reg(u32 val, s16 module, u16 idx) 81 + { 82 + __omap_prcm_write(val, cm_base, module, idx); 83 + } 84 + EXPORT_SYMBOL(cm_write_mod_reg); 85 + 86 + void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals) 87 + { 88 + prm_base = omap2_globals->prm; 89 + cm_base = omap2_globals->cm; 49 90 }
+2 -10
arch/arm/mach-omap2/prm.h
··· 166 166 #ifndef __ASSEMBLER__ 167 167 168 168 /* Power/reset management domain register get/set */ 169 - 170 - static inline void prm_write_mod_reg(u32 val, s16 module, s16 idx) 171 - { 172 - __raw_writel(val, OMAP_PRM_REGADDR(module, idx)); 173 - } 174 - 175 - static inline u32 prm_read_mod_reg(s16 module, s16 idx) 176 - { 177 - return __raw_readl(OMAP_PRM_REGADDR(module, idx)); 178 - } 169 + extern u32 prm_read_mod_reg(s16 module, u16 idx); 170 + extern void prm_write_mod_reg(u32 val, s16 module, u16 idx); 179 171 180 172 #endif 181 173
+4 -6
arch/arm/mach-omap2/sdrc.h
··· 18 18 #include <asm/arch/sdrc.h> 19 19 20 20 #ifndef __ASSEMBLER__ 21 - extern unsigned long omap2_sdrc_base; 22 - extern unsigned long omap2_sms_base; 21 + extern void __iomem *omap2_sdrc_base; 22 + extern void __iomem *omap2_sms_base; 23 23 24 - #define OMAP_SDRC_REGADDR(reg) \ 25 - (void __iomem *)IO_ADDRESS(omap2_sdrc_base + (reg)) 26 - #define OMAP_SMS_REGADDR(reg) \ 27 - (void __iomem *)IO_ADDRESS(omap2_sms_base + (reg)) 24 + #define OMAP_SDRC_REGADDR(reg) (omap2_sdrc_base + (reg)) 25 + #define OMAP_SMS_REGADDR(reg) (omap2_sms_base + (reg)) 28 26 29 27 /* SDRC global register get/set */ 30 28
+50 -9
arch/arm/plat-omap/common.c
··· 26 26 #include <asm/io.h> 27 27 #include <asm/setup.h> 28 28 29 + #include <asm/arch/common.h> 29 30 #include <asm/arch/board.h> 30 31 #include <asm/arch/control.h> 31 32 #include <asm/arch/mux.h> ··· 242 241 243 242 /* Global address base setup code */ 244 243 244 + #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 245 + 246 + static struct omap_globals *omap2_globals; 247 + 248 + static void __init __omap2_set_globals(void) 249 + { 250 + omap2_set_globals_memory(omap2_globals); 251 + omap2_set_globals_control(omap2_globals); 252 + omap2_set_globals_prcm(omap2_globals); 253 + } 254 + 255 + #endif 256 + 245 257 #if defined(CONFIG_ARCH_OMAP2420) 258 + 259 + static struct omap_globals omap242x_globals = { 260 + .tap = (__force void __iomem *)OMAP2_IO_ADDRESS(0x48014000), 261 + .sdrc = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_SDRC_BASE), 262 + .sms = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_SMS_BASE), 263 + .ctrl = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_CTRL_BASE), 264 + .prm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_PRM_BASE), 265 + .cm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2420_CM_BASE), 266 + }; 267 + 246 268 void __init omap2_set_globals_242x(void) 247 269 { 248 - omap2_sdrc_base = OMAP2420_SDRC_BASE; 249 - omap2_sms_base = OMAP2420_SMS_BASE; 250 - omap_ctrl_base_set(OMAP2420_CTRL_BASE); 270 + omap2_globals = &omap242x_globals; 271 + __omap2_set_globals(); 251 272 } 252 273 #endif 253 274 254 275 #if defined(CONFIG_ARCH_OMAP2430) 276 + 277 + static struct omap_globals omap243x_globals = { 278 + .tap = (__force void __iomem *)OMAP2_IO_ADDRESS(0x4900a000), 279 + .sdrc = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP243X_SDRC_BASE), 280 + .sms = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP243X_SMS_BASE), 281 + .ctrl = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP243X_CTRL_BASE), 282 + .prm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2430_PRM_BASE), 283 + .cm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP2430_CM_BASE), 284 + }; 285 + 255 286 void __init omap2_set_globals_243x(void) 256 287 { 257 - omap2_sdrc_base = OMAP243X_SDRC_BASE; 258 - omap2_sms_base = OMAP243X_SMS_BASE; 259 - omap_ctrl_base_set(OMAP243X_CTRL_BASE); 288 + omap2_globals = &omap243x_globals; 289 + __omap2_set_globals(); 260 290 } 261 291 #endif 262 292 263 293 #if defined(CONFIG_ARCH_OMAP3430) 294 + 295 + static struct omap_globals omap343x_globals = { 296 + .tap = (__force void __iomem *)OMAP2_IO_ADDRESS(0x4830A000), 297 + .sdrc = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP343X_SDRC_BASE), 298 + .sms = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP343X_SMS_BASE), 299 + .ctrl = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP343X_CTRL_BASE), 300 + .prm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP3430_PRM_BASE), 301 + .cm = (__force void __iomem *)OMAP2_IO_ADDRESS(OMAP3430_CM_BASE), 302 + }; 303 + 264 304 void __init omap2_set_globals_343x(void) 265 305 { 266 - omap2_sdrc_base = OMAP343X_SDRC_BASE; 267 - omap2_sms_base = OMAP343X_SMS_BASE; 268 - omap_ctrl_base_set(OMAP343X_CTRL_BASE); 306 + omap2_globals = &omap343x_globals; 307 + __omap2_set_globals(); 269 308 } 270 309 #endif 271 310
+15
include/asm-arm/arch-omap/common.h
··· 47 47 } 48 48 #endif 49 49 50 + /* IO bases for various OMAP processors */ 51 + struct omap_globals { 52 + void __iomem *tap; /* Control module ID code */ 53 + void __iomem *sdrc; /* SDRAM Controller */ 54 + void __iomem *sms; /* SDRAM Memory Scheduler */ 55 + void __iomem *ctrl; /* System Control Module */ 56 + void __iomem *prm; /* Power and Reset Management */ 57 + void __iomem *cm; /* Clock Management */ 58 + }; 59 + 50 60 void omap2_set_globals_242x(void); 51 61 void omap2_set_globals_243x(void); 52 62 void omap2_set_globals_343x(void); 63 + 64 + /* These get called from omap2_set_globals_xxxx(), do not call these */ 65 + void omap2_set_globals_memory(struct omap_globals *); 66 + void omap2_set_globals_control(struct omap_globals *); 67 + void omap2_set_globals_prcm(struct omap_globals *); 53 68 54 69 #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
+1 -3
include/asm-arm/arch-omap/control.h
··· 167 167 168 168 #ifndef __ASSEMBLY__ 169 169 #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 170 - extern void omap_ctrl_base_set(u32 base); 171 - extern u32 omap_ctrl_base_get(void); 170 + extern void __iomem *omap_ctrl_base_get(void); 172 171 extern u8 omap_ctrl_readb(u16 offset); 173 172 extern u16 omap_ctrl_readw(u16 offset); 174 173 extern u32 omap_ctrl_readl(u16 offset); ··· 175 176 extern void omap_ctrl_writew(u16 val, u16 offset); 176 177 extern void omap_ctrl_writel(u32 val, u16 offset); 177 178 #else 178 - #define omap_ctrl_base_set(x) WARN_ON(1) 179 179 #define omap_ctrl_base_get() 0 180 180 #define omap_ctrl_readb(x) 0 181 181 #define omap_ctrl_readw(x) 0
+3
include/asm-arm/arch-omap/io.h
··· 60 60 #define IO_SIZE 0x40000 61 61 #define IO_VIRT (IO_PHYS - IO_OFFSET) 62 62 #define IO_ADDRESS(pa) ((pa) - IO_OFFSET) 63 + #define OMAP1_IO_ADDRESS(pa) ((pa) - IO_OFFSET) 63 64 #define io_p2v(pa) ((pa) - IO_OFFSET) 64 65 #define io_v2p(va) ((va) + IO_OFFSET) 65 66 ··· 92 91 93 92 #define IO_OFFSET 0x90000000 94 93 #define IO_ADDRESS(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */ 94 + #define OMAP2_IO_ADDRESS(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */ 95 95 #define io_p2v(pa) ((pa) + IO_OFFSET) /* Works for L3 and L4 */ 96 96 #define io_v2p(va) ((va) - IO_OFFSET) /* Works for L3 and L4 */ 97 97 ··· 150 148 151 149 #define IO_OFFSET 0x90000000 152 150 #define IO_ADDRESS(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ 151 + #define OMAP2_IO_ADDRESS(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ 153 152 #define io_p2v(pa) ((pa) + IO_OFFSET)/* Works for L3 and L4 */ 154 153 #define io_v2p(va) ((va) - IO_OFFSET)/* Works for L3 and L4 */ 155 154