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

MIPS: Alchemy: add helpers to access static memory ctrl registers.

This patch changes the static memory controller registers to offsets
from base, prefixes them with AU1000_ to avoid silent failures due to
changed addresses and introduces helpers to access them.

No functional changes, comparing assembly of a few select functions shows
no differences.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Cc: Linux-MIPS <linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/7463/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Manuel Lauss and committed by
Ralf Baechle
9cf12167 1d09de7d

+62 -52
+24 -24
arch/mips/alchemy/common/power.c
··· 64 64 sleep_sys_pinfunc = alchemy_rdsys(AU1000_SYS_PINFUNC); 65 65 66 66 /* Save the static memory controller configuration. */ 67 - sleep_static_memctlr[0][0] = au_readl(MEM_STCFG0); 68 - sleep_static_memctlr[0][1] = au_readl(MEM_STTIME0); 69 - sleep_static_memctlr[0][2] = au_readl(MEM_STADDR0); 70 - sleep_static_memctlr[1][0] = au_readl(MEM_STCFG1); 71 - sleep_static_memctlr[1][1] = au_readl(MEM_STTIME1); 72 - sleep_static_memctlr[1][2] = au_readl(MEM_STADDR1); 73 - sleep_static_memctlr[2][0] = au_readl(MEM_STCFG2); 74 - sleep_static_memctlr[2][1] = au_readl(MEM_STTIME2); 75 - sleep_static_memctlr[2][2] = au_readl(MEM_STADDR2); 76 - sleep_static_memctlr[3][0] = au_readl(MEM_STCFG3); 77 - sleep_static_memctlr[3][1] = au_readl(MEM_STTIME3); 78 - sleep_static_memctlr[3][2] = au_readl(MEM_STADDR3); 67 + sleep_static_memctlr[0][0] = alchemy_rdsmem(AU1000_MEM_STCFG0); 68 + sleep_static_memctlr[0][1] = alchemy_rdsmem(AU1000_MEM_STTIME0); 69 + sleep_static_memctlr[0][2] = alchemy_rdsmem(AU1000_MEM_STADDR0); 70 + sleep_static_memctlr[1][0] = alchemy_rdsmem(AU1000_MEM_STCFG1); 71 + sleep_static_memctlr[1][1] = alchemy_rdsmem(AU1000_MEM_STTIME1); 72 + sleep_static_memctlr[1][2] = alchemy_rdsmem(AU1000_MEM_STADDR1); 73 + sleep_static_memctlr[2][0] = alchemy_rdsmem(AU1000_MEM_STCFG2); 74 + sleep_static_memctlr[2][1] = alchemy_rdsmem(AU1000_MEM_STTIME2); 75 + sleep_static_memctlr[2][2] = alchemy_rdsmem(AU1000_MEM_STADDR2); 76 + sleep_static_memctlr[3][0] = alchemy_rdsmem(AU1000_MEM_STCFG3); 77 + sleep_static_memctlr[3][1] = alchemy_rdsmem(AU1000_MEM_STTIME3); 78 + sleep_static_memctlr[3][2] = alchemy_rdsmem(AU1000_MEM_STADDR3); 79 79 } 80 80 81 81 static void restore_core_regs(void) ··· 95 95 alchemy_wrsys(sleep_sys_pinfunc, AU1000_SYS_PINFUNC); 96 96 97 97 /* Restore the static memory controller configuration. */ 98 - au_writel(sleep_static_memctlr[0][0], MEM_STCFG0); 99 - au_writel(sleep_static_memctlr[0][1], MEM_STTIME0); 100 - au_writel(sleep_static_memctlr[0][2], MEM_STADDR0); 101 - au_writel(sleep_static_memctlr[1][0], MEM_STCFG1); 102 - au_writel(sleep_static_memctlr[1][1], MEM_STTIME1); 103 - au_writel(sleep_static_memctlr[1][2], MEM_STADDR1); 104 - au_writel(sleep_static_memctlr[2][0], MEM_STCFG2); 105 - au_writel(sleep_static_memctlr[2][1], MEM_STTIME2); 106 - au_writel(sleep_static_memctlr[2][2], MEM_STADDR2); 107 - au_writel(sleep_static_memctlr[3][0], MEM_STCFG3); 108 - au_writel(sleep_static_memctlr[3][1], MEM_STTIME3); 109 - au_writel(sleep_static_memctlr[3][2], MEM_STADDR3); 98 + alchemy_wrsmem(sleep_static_memctlr[0][0], AU1000_MEM_STCFG0); 99 + alchemy_wrsmem(sleep_static_memctlr[0][1], AU1000_MEM_STTIME0); 100 + alchemy_wrsmem(sleep_static_memctlr[0][2], AU1000_MEM_STADDR0); 101 + alchemy_wrsmem(sleep_static_memctlr[1][0], AU1000_MEM_STCFG1); 102 + alchemy_wrsmem(sleep_static_memctlr[1][1], AU1000_MEM_STTIME1); 103 + alchemy_wrsmem(sleep_static_memctlr[1][2], AU1000_MEM_STADDR1); 104 + alchemy_wrsmem(sleep_static_memctlr[2][0], AU1000_MEM_STCFG2); 105 + alchemy_wrsmem(sleep_static_memctlr[2][1], AU1000_MEM_STTIME2); 106 + alchemy_wrsmem(sleep_static_memctlr[2][2], AU1000_MEM_STADDR2); 107 + alchemy_wrsmem(sleep_static_memctlr[3][0], AU1000_MEM_STCFG3); 108 + alchemy_wrsmem(sleep_static_memctlr[3][1], AU1000_MEM_STTIME3); 109 + alchemy_wrsmem(sleep_static_memctlr[3][2], AU1000_MEM_STADDR3); 110 110 } 111 111 112 112 void au_sleep(void)
+1 -1
arch/mips/alchemy/devboards/db1200.c
··· 246 246 247 247 static int au1200_nand_device_ready(struct mtd_info *mtd) 248 248 { 249 - return __raw_readl((void __iomem *)MEM_STSTAT) & 1; 249 + return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; 250 250 } 251 251 252 252 static struct mtd_partition db1200_nand_parts[] = {
+1 -1
arch/mips/alchemy/devboards/db1300.c
··· 169 169 170 170 static int au1300_nand_device_ready(struct mtd_info *mtd) 171 171 { 172 - return __raw_readl((void __iomem *)MEM_STSTAT) & 1; 172 + return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; 173 173 } 174 174 175 175 static struct mtd_partition db1300_nand_parts[] = {
+2 -2
arch/mips/alchemy/devboards/db1550.c
··· 151 151 152 152 static int au1550_nand_device_ready(struct mtd_info *mtd) 153 153 { 154 - return __raw_readl((void __iomem *)MEM_STSTAT) & 1; 154 + return alchemy_rdsmem(AU1000_MEM_STSTAT) & 1; 155 155 } 156 156 157 157 static struct mtd_partition db1550_nand_parts[] = { ··· 217 217 218 218 static void __init pb1550_nand_setup(void) 219 219 { 220 - int boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) | 220 + int boot_swapboot = (alchemy_rdsmem(AU1000_MEM_STSTAT) & (0x7 << 1)) | 221 221 ((bcsr_read(BCSR_STATUS) >> 6) & 0x1); 222 222 223 223 gpio_direction_input(206); /* de-assert NAND CS# */
+31 -19
arch/mips/include/asm/mach-au1x00/au1000.h
··· 309 309 #define AU1550_MEM_SDSREF 0x08D0 310 310 #define AU1550_MEM_SDSLEEP MEM_SDSREF 311 311 312 - /* Static Bus Controller */ 313 - #define MEM_STCFG0 0xB4001000 314 - #define MEM_STTIME0 0xB4001004 315 - #define MEM_STADDR0 0xB4001008 316 - 317 - #define MEM_STCFG1 0xB4001010 318 - #define MEM_STTIME1 0xB4001014 319 - #define MEM_STADDR1 0xB4001018 320 - 321 - #define MEM_STCFG2 0xB4001020 322 - #define MEM_STTIME2 0xB4001024 323 - #define MEM_STADDR2 0xB4001028 324 - 325 - #define MEM_STCFG3 0xB4001030 326 - #define MEM_STTIME3 0xB4001034 327 - #define MEM_STADDR3 0xB4001038 328 - 329 - #define MEM_STNDCTL 0xB4001100 330 - #define MEM_STSTAT 0xB4001104 312 + /* Static Bus Controller register offsets */ 313 + #define AU1000_MEM_STCFG0 0x000 314 + #define AU1000_MEM_STTIME0 0x004 315 + #define AU1000_MEM_STADDR0 0x008 316 + #define AU1000_MEM_STCFG1 0x010 317 + #define AU1000_MEM_STTIME1 0x014 318 + #define AU1000_MEM_STADDR1 0x018 319 + #define AU1000_MEM_STCFG2 0x020 320 + #define AU1000_MEM_STTIME2 0x024 321 + #define AU1000_MEM_STADDR2 0x028 322 + #define AU1000_MEM_STCFG3 0x030 323 + #define AU1000_MEM_STTIME3 0x034 324 + #define AU1000_MEM_STADDR3 0x038 325 + #define AU1000_MEM_STNDCTL 0x100 326 + #define AU1000_MEM_STSTAT 0x104 331 327 332 328 #define MEM_STNAND_CMD 0x0 333 329 #define MEM_STNAND_ADDR 0x4 ··· 704 708 static inline void alchemy_wrsys(unsigned long v, int regofs) 705 709 { 706 710 void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR); 711 + 712 + __raw_writel(v, b + regofs); 713 + wmb(); /* drain writebuffer */ 714 + } 715 + 716 + /* helpers to access static memctrl registers */ 717 + static inline unsigned long alchemy_rdsmem(int regofs) 718 + { 719 + void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_STATIC_MEM_PHYS_ADDR); 720 + 721 + return __raw_readl(b + regofs); 722 + } 723 + 724 + static inline void alchemy_wrsmem(unsigned long v, int regofs) 725 + { 726 + void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_STATIC_MEM_PHYS_ADDR); 707 727 708 728 __raw_writel(v, b + regofs); 709 729 wmb(); /* drain writebuffer */
+3 -5
drivers/mtd/nand/au1550nd.c
··· 223 223 224 224 case NAND_CTL_SETNCE: 225 225 /* assert (force assert) chip enable */ 226 - au_writel((1 << (4 + ctx->cs)), MEM_STNDCTL); 226 + alchemy_wrsmem((1 << (4 + ctx->cs)), AU1000_MEM_STNDCTL); 227 227 break; 228 228 229 229 case NAND_CTL_CLRNCE: 230 230 /* deassert chip enable */ 231 - au_writel(0, MEM_STNDCTL); 231 + alchemy_wrsmem(0, AU1000_MEM_STNDCTL); 232 232 break; 233 233 } 234 234 ··· 240 240 241 241 int au1550_device_ready(struct mtd_info *mtd) 242 242 { 243 - int ret = (au_readl(MEM_STSTAT) & 0x1) ? 1 : 0; 244 - au_sync(); 245 - return ret; 243 + return (alchemy_rdsmem(AU1000_MEM_STSTAT) & 0x1) ? 1 : 0; 246 244 } 247 245 248 246 /**