3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <ppc_asm.tmpl>
26 #include <asm/cache.h>
28 #define CACHE_CMD_ENABLE 0x02000000
29 #define CACHE_CMD_DISABLE 0x04000000
30 #define CACHE_CMD_LOAD_LOCK 0x06000000
31 #define CACHE_CMD_UNLOCK_LINE 0x08000000
32 #define CACHE_CMD_UNLOCK_ALL 0x0A000000
33 #define CACHE_CMD_INVALIDATE 0x0C000000
34 #define SPEED_PLPRCR_WAIT_5CYC 150
35 #define _CACHE_ALIGN_SIZE 16
40 .globl plprcr_write_866
43 * void plprcr_write_866 (long plprcr)
44 * Write PLPRCR, including workaround for device errata SIU4 and SIU9.
48 mfspr r10, LR /* save the Link Register value */
50 /* turn instruction cache on (no MMU required for instructions)
52 lis r4, CACHE_CMD_ENABLE@h
53 ori r4, r4, CACHE_CMD_ENABLE@l
57 /* clear IC_CST error bits
66 /* calculate relocation offset
69 ori r4, r4, plprcr_here@l
72 /* calculate first address of this function
74 lis r6, plprcr_write_866@h
75 ori r6, r6, plprcr_write_866@l
78 /* calculate end address of this function
81 ori r7, r7, plprcr_end@l
84 /* load and lock code addresses
90 addi r5, r5, _CACHE_ALIGN_SIZE /* increment by one line */
92 lis r4, CACHE_CMD_LOAD_LOCK@h
93 ori r4, r4, CACHE_CMD_LOAD_LOCK@l
100 /* IC_CST error bits not evaluated
105 mfspr r4, IMMR /* read IMMR */
106 rlwinm r4, r4, 0, 0, 15 /* only high 16 bits count */
108 /* write sequence according to MPC866 Errata
113 lis r3, SPEED_PLPRCR_WAIT_5CYC@h
114 ori r3, r3, SPEED_PLPRCR_WAIT_5CYC@l
125 /* unlock instruction cache but leave it enabled
127 lis r4, CACHE_CMD_UNLOCK_ALL@h
128 ori r4, r4, CACHE_CMD_UNLOCK_ALL@l
132 mtspr LR, r10 /* restore original Link Register value */