1 /* cmode.S: clock mode management
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Woodhouse (dwmw2@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
13 #include <linux/sys.h>
14 #include <linux/config.h>
15 #include <linux/linkage.h>
16 #include <asm/setup.h>
17 #include <asm/segment.h>
18 #include <asm/ptrace.h>
19 #include <asm/errno.h>
20 #include <asm/cache.h>
21 #include <asm/spr-regs.h>
23 #define __addr_MASK 0xfeff9820 /* interrupt controller mask */
25 #define __addr_SDRAMC 0xfe000400 /* SDRAM controller regs */
26 #define SDRAMC_DSTS 0x28 /* SDRAM status */
27 #define SDRAMC_DSTS_SSI 0x00000001 /* indicates that the SDRAM is in self-refresh mode */
28 #define SDRAMC_DRCN 0x30 /* SDRAM refresh control */
29 #define SDRAMC_DRCN_SR 0x00000001 /* transition SDRAM into self-refresh mode */
30 #define __addr_CLKC 0xfeff9a00
31 #define CLKC_SWCMODE 0x00000008
32 #define __addr_LEDS 0xe1200004
43 ###############################################################################
46 # - void frv_change_cmode(int cmode)
48 ###############################################################################
49 .globl frv_change_cmode
50 .type frv_change_cmode,@function
67 # Shift argument left by 24 bits to fit in SWCMODE register later.
70 # (1) Set '0' in the PSR.ET bit, and prohibit interrupts.
72 andi gr14,#~PSR_ET,gr3
75 #if 0 // Fujitsu recommend to skip this and will update docs.
76 # (2) Set '0' to all bits of the MASK register of the interrupt
77 # controller, and mask interrupts.
84 # (3) Stop the transfer function of DMAC. Stop all the bus masters
85 # to access SDRAM and the internal resources.
87 # (already done by caller)
89 # (4) Preload a series of following instructions to the instruction
91 li #__cmode_icache_lock_start,gr3
92 li #__cmode_icache_lock_end,gr4
95 addi gr3,#L1_CACHE_BYTES,gr3
99 # Set up addresses in regs for later steps.
100 setlos SDRAMC_DRCN_SR,gr3
107 bra __cmode_icache_lock_start
109 .balign L1_CACHE_BYTES
110 __cmode_icache_lock_start:
112 # (5) Flush the content of all caches by the DCEF instruction.
115 # (6) Execute loading the dummy for SDRAM.
118 # (7) Set '1' to the DRCN.SR bit, and change SDRAM to the
119 # self-refresh mode. Execute the dummy load to all memory
120 # devices set to cacheable on the external bus side in parallel
122 sti gr3,@(gr4,#SDRAMC_DRCN)
124 # (8) Execute memory barrier instruction (MEMBAR).
127 # (9) Read the DSTS register repeatedly until '1' stands in the
129 1: ldi @(gr4,#SDRAMC_DSTS),gr3
130 andicc gr3,#SDRAMC_DSTS_SSI,gr3,icc0
133 # (10) Execute memory barrier instruction (MEMBAR).
137 # (11) Set the value of CMODE that you want to change to
139 sti gr8,@(gr5,#CLKC_SWCMODE)
141 # (12) Set '1' to the CLKC.SWEN bit. In that case, do not change
142 # fields other than SWEN of the CLKC register.
145 # (13) Execute the instruction just after the memory barrier
146 # instruction that executes the self-loop 256 times. (Meanwhile,
147 # the CMODE switch is done.)
150 2: subicc gr7,#1,gr7,icc0
155 # (14) Release the self-refresh of SDRAM.
156 sti gr0,@(gr4,#SDRAMC_DRCN)
159 3: ldi @(gr4,#SDRAMC_DSTS),gr3
160 andicc gr3,#SDRAMC_DSTS_SSI,gr3,icc0
165 4: subicc gr10,#1,gr10,icc0
170 __cmode_icache_lock_end:
172 li #__cmode_icache_lock_start,gr3
173 li #__cmode_icache_lock_end,gr4
176 addi gr3,#L1_CACHE_BYTES,gr3
180 #if 0 // Fujitsu recommend to skip this and will update docs.
181 # (15) Release the interrupt mask setting of the MASK register of
182 # the interrupt controller if necessary.
185 # (16) Set 1' in the PSR.ET bit, and permit interrupt.
190 .size frv_change_cmode, .-frv_change_cmode