Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: arch/arm/cpu/arm_cortexa9/tegra2/ap20.c

Issue 4841001: Tegra2: implement Warmboot code and lp0_vec (Closed) Base URL: http://git.chromium.org/git/u-boot-next.git@chromeos-v2010.09
Patch Set: Add GPL headers & fix some 80-column issues Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « arch/arm/cpu/arm_cortexa9/tegra2/ap20.h ('k') | arch/arm/cpu/arm_cortexa9/tegra2/warmboot.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) Copyright 2010 2 * (C) Copyright 2010
3 * NVIDIA Corporation <www.nvidia.com> 3 * NVIDIA Corporation <www.nvidia.com>
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 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 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 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 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23
24 #include <common.h>
23 #include "ap20.h" 25 #include "ap20.h"
24 26
25 #define NV_ASSERT(p) \ 27 #define NV_ASSERT(p) \
26 { if ((p) == 0) { \ 28 { if ((p) == 0) { \
27 uart_post('C'); \ 29 uart_post('C'); \
28 uart_post('o'); \ 30 uart_post('o'); \
29 uart_post('l'); \ 31 uart_post('l'); \
30 uart_post('d'); \ 32 uart_post('d'); \
31 }; \ 33 }; \
32 } 34 }
33 35
36 #ifdef CONFIG_TEGRA2_LP0
37 /** Scratch register macros **/
38
39 /** NV_SF_NUM - define a new scratch register value.
40
41 @param s scratch register name (APBDEV_PMC_s)
42 @param f register field
43 @param n defined value for the field
44 */
45 #define NV_SF_NUM(s,f,n) \
46 (((n)& NV_FIELD_MASK(APBDEV_PMC_##s##_0_##f##_RANGE)) << \
47 NV_FIELD_SHIFT(APBDEV_PMC_##s##_0_##f##_RANGE))
48
49
50 /** NV_FLD_SET_SR_NUM - modify a scratch register field.
51
52 @param s scratch register name (APBDEV_PMC_s)
53 @param f register field
54 @param n numeric field value
55 */
56 #define NV_FLD_SET_SF_NUM(s,f,n) \
57 ((s & ~NV_FIELD_SHIFTMASK(APBDEV_PMC_##s##_0_##f##_RANGE))\
58 | NV_SF_NUM(s,f,n))
59
60
61 /** NV_SDRF_NUM - define a new scratch register value.
62
63 @param s scratch register name (APBDEV_PMC_s)
64 @param d register domain (hardware block)
65 @param r register name
66 @param f register field
67 @param n defined value for the field
68 */
69 #define NV_SDRF_NUM(s,d,r,f,n) \
70 (((n)& NV_FIELD_MASK(APBDEV_PMC_##s##_0_##d##_##r##_0_##f##_RANGE)) << \
71 NV_FIELD_SHIFT(APBDEV_PMC_##s##_0_##d##_##r##_0_##f##_RANGE))
72
73
74 /** NV_FLD_SET_SDRF_NUM - modify a scratch register field.
75
76 @param s scratch register name (APBDEV_PMC_s)
77 @param d register domain (hardware block)
78 @param r register name
79 @param f register field
80 @param n numeric field value
81 */
82 #define NV_FLD_SET_SDRF_NUM(s,d,r,f,n) \
83 ((s & ~NV_FIELD_SHIFTMASK(APBDEV_PMC_##s##_0_##d##_##r##_0_##f##_RANGE)) \
84 | NV_SDRF_NUM(s,d,r,f,n))
85
86
87 /** SCRATCH_REGS() - PMC scratch registers (list of SCRATCH_REG() macros).
88 SCRATCH_REG(s) - PMC scratch register name:
89
90 @param s Scratch register name (APBDEV_PMC_s)
91 */
92 #define SCRATCH_REGS() \
93 SCRATCH_REG(SCRATCH2) \
94 SCRATCH_REG(SCRATCH4) \
95 SCRATCH_REG(SCRATCH24) \
96 /* End-of-List*/
97
98 #define SCRATCH_REG(s) static NvU32 s = 0;
99 SCRATCH_REGS()
100 #undef SCRATCH_REG
101
102 #define REGS() \
103 /* CLK_RST Group */ \
104 REG(SCRATCH2, CLK_RST_CONTROLLER, OSC_CTRL, XOBP) \
105 REG(SCRATCH2, CLK_RST_CONTROLLER, PLLM_BASE, PLLM_DIVM) \
106 REG(SCRATCH2, CLK_RST_CONTROLLER, PLLM_BASE, PLLM_DIVN) \
107 REG(SCRATCH2, CLK_RST_CONTROLLER, PLLM_BASE, PLLM_DIVP) \
108 REG(SCRATCH2, CLK_RST_CONTROLLER, PLLM_MISC, PLLM_CPCON) \
109 REG(SCRATCH2, CLK_RST_CONTROLLER, PLLM_MISC, PLLM_LFCON) \
110 /**/ \
111 /* EMC Group */ \
112 REG2(SCRATCH4, EMC, FBIO_SPARE, CFG_FBIO_SPARE_WB0) \
113 /* APB_MISC Group */ \
114 REG3(SCRATCH2, APB_MISC, GP_XM2CFGAPADCTRL, CFG2TMC_XM2CFGA_PREE MP_EN) \
115 REG3(SCRATCH2, APB_MISC, GP_XM2CFGDPADCTRL, CFG2TMC_XM2CFGD_SCHM T_EN) \
116 /**/ \
117 /* BCT SdramParams Group*/ \
118 RAM(SCRATCH2, MEMORY_TYPE, MemoryType) \
119 /**/ \
120 RAM(SCRATCH4, EMC_CLOCK_DIVIDER, EmcClockDivider) \
121 CONSTANT(SCRATCH4, PLLM_STABLE_TIME, ~0) /* Stuff the maximum va lue */ \
122 CONSTANT(SCRATCH4, PLLX_STABLE_TIME, ~0) /* Stuff the maximum va lue */ \
123 /**/ \
124 RAM(SCRATCH24, EMC_AUTO_CAL_WAIT, EmcAutoCalWait) \
125 RAM(SCRATCH24, EMC_PIN_PROGRAM_WAIT, EmcPinProgramWait) \
126 RAM(SCRATCH24, WARMBOOT_WAIT, WarmBootWait)
127
128 /*Correct names */
129 #define APBDEV_PMC_SCRATCH2_0_CLK_RST_CONTROLLER_OSC_CTRL_0_XOBP_RANGE\
130 APBDEV_PMC_SCRATCH2_0_CLK_RST_OSC_CTRL_XOBP_RANGE
131 #define APBDEV_PMC_SCRATCH2_0_CLK_RST_CONTROLLER_PLLM_BASE_0_PLLM_DIVM_RANGE\
132 APBDEV_PMC_SCRATCH2_0_CLK_RST_PLLM_BASE_PLLM_DIVM_RANGE
133 #define APBDEV_PMC_SCRATCH2_0_CLK_RST_CONTROLLER_PLLM_BASE_0_PLLM_DIVN_RANGE\
134 APBDEV_PMC_SCRATCH2_0_CLK_RST_PLLM_BASE_PLLM_DIVN_RANGE
135 #define APBDEV_PMC_SCRATCH2_0_CLK_RST_CONTROLLER_PLLM_BASE_0_PLLM_DIVP_RANGE\
136 APBDEV_PMC_SCRATCH2_0_CLK_RST_PLLM_BASE_PLLM_DIVP_RANGE
137 #define APBDEV_PMC_SCRATCH2_0_CLK_RST_CONTROLLER_PLLM_MISC_0_PLLM_CPCON_RANGE\
138 APBDEV_PMC_SCRATCH2_0_CLK_RST_PLLM_MISC_CPCON_RANGE
139 #define APBDEV_PMC_SCRATCH2_0_CLK_RST_CONTROLLER_PLLM_MISC_0_PLLM_LFCON_RANGE\
140 APBDEV_PMC_SCRATCH2_0_CLK_RST_PLLM_MISC_LFCON_RANGE
141
142 #define SDRAM_PARAMS_BASE_ADDR (0x40000000 + 0x100 + 0x88)
143
144 void NvBlSaveSdramParams(void)
145 {
146 NvU32 reg; /* Module register contents */
147 NvU32 val; /* Register field contents */
148 NvBootSdramParams sdram_params;
149
150 memcpy (&sdram_params, (char *)SDRAM_PARAMS_BASE_ADDR,
151 sizeof(NvBootSdramParams));
152
153 /* REG(s,d,r,f)
154 * s = destination Scratch register
155 * d = Device name
156 * r = Register name
157 * f = register Field
158 */
159 #define REG(s,d,r,f) \
160 reg = NV_CAR_REGR(CLK_RST_PA_BASE, r); \
161 val = NV_DRF_VAL(d,r,f,reg); \
162 s = NV_FLD_SET_SDRF_NUM(s,d,r,f,val);
163
164 #define REG2(s,d,r,f) \
165 reg = NV_EMC_REGR(EMC_PA_BASE, r); \
166 val = NV_DRF_VAL(d,r,f,reg); \
167 s = NV_FLD_SET_SDRF_NUM(s,d,r,f,val);
168
169 #define REG3(s,d,r,f) \
170 reg = NV_MISC_REGR(MISC_PA_BASE, r);\
171 val = NV_DRF_VAL(d,r,f,reg); \
172 s = NV_FLD_SET_SDRF_NUM(s,d,r,f,val);
173
174 /* RAM(s,f,n)
175 * s = destination Scratch register
176 * f = register Field
177 * v = bct Variable
178 */
179 #define RAM(s,f,v) \
180 s = NV_FLD_SET_SF_NUM(s,f,sdram_params.v);
181
182 /* Define the transformation macro that will stuff a PMC scratch
183 * register with a constant value.
184 */
185
186 /* CONSTANT(s,f,n)
187 * s = destination Scratch register
188 * f = register Field
189 * v = constant Value
190 */
191 #define CONSTANT(s,f,v) \
192 s = NV_FLD_SET_SF_NUM(s,f,v);
193
194 /*Instantiate all of the register transformations. */
195 REGS()
196 #undef RAM
197 #undef CONSTANT
198
199 /* Generate writes to the PMC scratch registers to copy the local
200 * variables to the actual registers.
201 */
202 #define SCRATCH_REG(s)\
203 NV_PMC_REGW(PMC_PA_BASE, s, s);
204 SCRATCH_REGS()
205 #undef SCRATCH_REG
206 }
207 #endif
208
34 void NvBlAvpStallUs(NvU32 MicroSec) 209 void NvBlAvpStallUs(NvU32 MicroSec)
35 { 210 {
36 NvU32 Reg; // Flow controller register 211 NvU32 Reg; // Flow controller register
37 NvU32 Delay; // Microsecond delay time 212 NvU32 Delay; // Microsecond delay time
38 NvU32 MaxUs; // Maximum flow controller delay 213 NvU32 MaxUs; // Maximum flow controller delay
39 214
40 // Get the maxium delay per loop. 215 // Get the maxium delay per loop.
41 MaxUs = NV_DRF_NUM(FLOW_CTLR, HALT_COP_EVENTS, ZERO, 0xFFFFFFFF); 216 MaxUs = NV_DRF_NUM(FLOW_CTLR, HALT_COP_EVENTS, ZERO, 0xFFFFFFFF);
42 217
43 while (MicroSec) 218 while (MicroSec)
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 710
536 //;------------------------------------------------------------------ 711 //;------------------------------------------------------------------
537 //; Should never get here. 712 //; Should never get here.
538 //;------------------------------------------------------------------ 713 //;------------------------------------------------------------------
539 "B . \n" 714 "B . \n"
540 ); 715 );
541 } 716 }
542 717
543 // we're hard coding the entry point for all AOS images 718 // we're hard coding the entry point for all AOS images
544 NvU32 cpu_boot_stack = NVAP_LIMIT_PA_IRAM_CPU_EARLY_BOOT_STACK; 719 NvU32 cpu_boot_stack = NVAP_LIMIT_PA_IRAM_CPU_EARLY_BOOT_STACK;
545 extern NvU32 _armboot_start;
546 NvU32 proc_tag = PG_UP_TAG_0_PID_CPU _AND_ 0xFF; 720 NvU32 proc_tag = PG_UP_TAG_0_PID_CPU _AND_ 0xFF;
547 NvU32 avp_boot_stack = NVAP_LIMIT_PA_IRAM_AVP_EARLY_BOOT_STACK; 721 NvU32 avp_boot_stack = NVAP_LIMIT_PA_IRAM_AVP_EARLY_BOOT_STACK;
548 NvU32 deadbeef = 0xdeadbeef; 722 NvU32 deadbeef = 0xdeadbeef;
549 723
550 NV_NAKED void ColdBoot_AP20( void ) 724 NV_NAKED void ColdBoot_AP20( void )
551 { 725 {
552 uart_post('C'); 726 uart_post('C');
553 asm volatile( 727 asm volatile(
554 "MSR CPSR_c, #0xd3 \n" 728 "MSR CPSR_c, #0xd3 \n"
555 //;------------------------------------------------------------------ 729 //;------------------------------------------------------------------
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 pPmc = (volatile NvU8 *)(NV_ADDRESS_MAP_PMC_BASE); 923 pPmc = (volatile NvU8 *)(NV_ADDRESS_MAP_PMC_BASE);
750 924
751 // SCRATCH0 is initialized by the boot ROM and shouldn't be cleared 925 // SCRATCH0 is initialized by the boot ROM and shouldn't be cleared
752 for (i=APBDEV_PMC_SCRATCH1_0; i<=APBDEV_PMC_SCRATCH23_0; i+=4) 926 for (i=APBDEV_PMC_SCRATCH1_0; i<=APBDEV_PMC_SCRATCH23_0; i+=4)
753 { 927 {
754 if (i==APBDEV_PMC_SCRATCH20_0) 928 if (i==APBDEV_PMC_SCRATCH20_0)
755 NV_WRITE32(pPmc+i, CONFIG_SYS_BOARD_ODMDATA); 929 NV_WRITE32(pPmc+i, CONFIG_SYS_BOARD_ODMDATA);
756 else 930 else
757 NV_WRITE32(pPmc+i, 0); 931 NV_WRITE32(pPmc+i, 0);
758 } 932 }
933
934 #ifdef CONFIG_TEGRA2_LP0
935 // Save Sdram params to PMC 2, 4, and 24 for WB0
936 NvBlSaveSdramParams();
937 #endif
759 } 938 }
760 939
761 NvU32 s_ChipId; 940 NvU32 s_ChipId;
762 volatile NvU32 s_bFirstBoot = 1; 941 volatile NvU32 s_bFirstBoot = 1;
763 942
764 void cpu_start( void ) 943 void cpu_start( void )
765 { 944 {
766 volatile NvU32 *jtagReg = (NvU32*)0x70000024;
767 NvU32 reg; 945 NvU32 reg;
768 946
769 // enable JTAG 947 // enable JTAG
770 *jtagReg = 192; 948 NV_MISC_REGW( MISC_PA_BASE, PP_CONFIG_CTL, 0xc0);
771 949
772 reg = NV_MISC_REGR( MISC_PA_BASE, GP_HIDREV ); 950 reg = NV_MISC_REGR( MISC_PA_BASE, GP_HIDREV );
773 951
774 // DRF macros generate too-complicated code for the arm7 952 // DRF macros generate too-complicated code for the arm7
775 s_ChipId = reg >> 8; 953 s_ChipId = reg >> 8;
776 s_ChipId &= 0xff; 954 s_ChipId &= 0xff;
777 if( s_bFirstBoot ) 955 if( s_bFirstBoot )
778 { 956 {
779 uart_post('i'); 957 uart_post('i');
780 /* need to set this before cold-booting, otherwise we'll end up in 958 /* need to set this before cold-booting, otherwise we'll end up in
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 /***********************************************************************/ 998 /***********************************************************************/
821 NvBlCacheConfigure(); 999 NvBlCacheConfigure();
822 1000
823 /* post code 'Yy' */ 1001 /* post code 'Yy' */
824 PostYy(); 1002 PostYy();
825 #endif 1003 #endif
826 1004
827 /* post code 'Xx' */ 1005 /* post code 'Xx' */
828 PostXx(); 1006 PostXx();
829 } 1007 }
OLDNEW
« no previous file with comments | « arch/arm/cpu/arm_cortexa9/tegra2/ap20.h ('k') | arch/arm/cpu/arm_cortexa9/tegra2/warmboot.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698