wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004 Texas Insturments |
| 3 | * |
| 4 | * (C) Copyright 2002 |
| 5 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 6 | * Marius Groeger <mgroeger@sysgo.de> |
| 7 | * |
| 8 | * (C) Copyright 2002 |
| 9 | * Gary Jennejohn, DENX Software Engineering, <gj@denx.de> |
| 10 | * |
| 11 | * See file CREDITS for list of people who contributed to this |
| 12 | * project. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of |
| 17 | * the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 27 | * MA 02111-1307 USA |
| 28 | */ |
| 29 | |
| 30 | /* |
| 31 | * CPU specific code |
| 32 | */ |
| 33 | |
| 34 | #include <common.h> |
| 35 | #include <command.h> |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame^] | 36 | #include <asm/system.h> |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 37 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 38 | #ifdef CONFIG_USE_IRQ |
| 39 | DECLARE_GLOBAL_DATA_PTR; |
| 40 | #endif |
| 41 | |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 42 | static void cp_delay (void) |
| 43 | { |
| 44 | volatile int i; |
| 45 | |
| 46 | /* Many OMAP regs need at least 2 nops */ |
| 47 | for (i = 0; i < 100; i++); |
| 48 | } |
| 49 | |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 50 | int cpu_init (void) |
| 51 | { |
| 52 | /* |
| 53 | * setup up stacks if necessary |
| 54 | */ |
| 55 | #ifdef CONFIG_USE_IRQ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | IRQ_STACK_START = _armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4; |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 57 | FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ; |
| 58 | #endif |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | int cleanup_before_linux (void) |
| 63 | { |
| 64 | /* |
| 65 | * this function is called just before we call linux |
| 66 | * it prepares the processor for linux |
| 67 | * |
| 68 | * we turn off caches etc ... |
| 69 | */ |
| 70 | |
| 71 | unsigned long i; |
| 72 | |
| 73 | disable_interrupts (); |
| 74 | |
| 75 | #ifdef CONFIG_LCD |
| 76 | { |
| 77 | extern void lcd_disable(void); |
| 78 | extern void lcd_panel_disable(void); |
| 79 | |
| 80 | lcd_disable(); /* proper disable of lcd & panel */ |
| 81 | lcd_panel_disable(); |
| 82 | } |
| 83 | #endif |
| 84 | |
| 85 | /* turn off I/D-cache */ |
| 86 | asm ("mrc p15, 0, %0, c1, c0, 0":"=r" (i)); |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame^] | 87 | i &= ~(CR_C | CR_I); |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 88 | asm ("mcr p15, 0, %0, c1, c0, 0": :"r" (i)); |
| 89 | |
| 90 | /* flush I/D-cache */ |
| 91 | i = 0; |
wdenk | 2e405bf | 2005-01-10 00:01:04 +0000 | [diff] [blame] | 92 | asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i)); /* invalidate both caches and flush btb */ |
| 93 | asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (i)); /* mem barrier to sync things */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 94 | return(0); |
| 95 | } |
| 96 | |
| 97 | int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 98 | { |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 99 | disable_interrupts (); |
| 100 | reset_cpu (0); |
| 101 | /*NOTREACHED*/ |
| 102 | return(0); |
| 103 | } |
| 104 | |
| 105 | void icache_enable (void) |
| 106 | { |
| 107 | ulong reg; |
| 108 | |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame^] | 109 | reg = get_cr (); /* get control reg. */ |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 110 | cp_delay (); |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame^] | 111 | set_cr (reg | CR_I); |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | void icache_disable (void) |
| 115 | { |
| 116 | ulong reg; |
| 117 | |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame^] | 118 | reg = get_cr (); |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 119 | cp_delay (); |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame^] | 120 | set_cr (reg & ~CR_I); |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | int icache_status (void) |
| 124 | { |
Jean-Christophe PLAGNIOL-VILLARD | 9053b5a | 2009-04-05 13:02:43 +0200 | [diff] [blame^] | 125 | return(get_cr () & CR_I) != 0; |
wdenk | f806271 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 126 | } |