[processor-sdk/pdk.git] / packages / ti / boot / sbl / tools / omapl13x_boot_utils / OMAP-L137 / GNU / Common / AISGenLib / AISGen_OMAP-L137.cs
1 /*
2 * AISGen_OMAP-L137.cs
3 */
5 /*
6 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
7 */
9 /*
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the
20 * distribution.
21 *
22 * Neither the name of Texas Instruments Incorporated nor the names of
23 * its contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 */
39 /* --------------------------------------------------------------------------
40 FILE : AISGen_OMAP-L137.cs
41 PROJECT : TI Booting and Flashing Utilities
42 AUTHOR : Daniel Allred
43 DESC : Concrete AISGen class implemenatation for OMAP-L137
44 ----------------------------------------------------------------------------- */
46 using System;
47 using System.Text;
48 using System.Text.RegularExpressions;
49 using System.IO;
50 using System.IO.Ports;
51 using System.Reflection;
52 using System.Threading;
53 using System.Globalization;
54 using System.Collections;
55 using TI.UtilLib.IO;
56 using TI.UtilLib.CRC;
58 namespace TI.AISLib
59 {
60 /// <summary>
61 /// AISGen class that is specific to the device (inherits from abtract base class AISGen)
62 /// </summary>
63 public class AISGen_OMAP_L137:AISGen
64 {
65 /// <summary>
66 /// String definitions for built-in ROM functions
67 /// </summary>
68 public struct ROMFunctionNames
69 {
70 public const String PLLConfig = "PLLConfig";
71 public const String PeriphClockConfig = "PeriphClockConfig";
72 public const String EMIF3CConfigSDRAM = "EMIF3CConfigSDRAM";
73 public const String EMIF25ConfigSDRAM = "EMIF25ConfigSDRAM";
74 public const String EMIF25ConfigAsync = "EMIF25ConfigAsync";
75 public const String PLLandClockConfig = "PLLandClockConfig";
76 public const String PSCConfig = "PSCConfig";
77 public const String PINMUXConfig = "PinMuxConfig";
78 public const String FastBoot = "FastBoot";
79 }
81 /// <summary>
82 /// The public constructor for the OMAP_L137 device AIS generator.
83 /// The constructor is where the device differentiation is defined.
84 /// </summary>
85 public AISGen_OMAP_L137() : base()
86 {
87 // Define the device name - used for default file names
88 devNameShort = "OMAP-L137";
89 devNameLong = "OMAPL137";
91 // Define OMAP-L138 ROM boot loader functions
92 ROMFunc = new AisROMFunction[9];
94 ROMFunc[0].funcName = ROMFunctionNames.PLLConfig;
95 ROMFunc[0].iniSectionName = "PLLCONFIG";
96 ROMFunc[0].numParams = 2;
97 ROMFunc[0].paramNames = new String[2] { "PLLCFG0", "PLLCFG1" };
99 ROMFunc[1].funcName = ROMFunctionNames.PeriphClockConfig;
100 ROMFunc[1].iniSectionName = "PERIPHCLKCFG";
101 ROMFunc[1].numParams = 1;
102 ROMFunc[1].paramNames = new String[1] { "PERIPHCLKCFG" };
104 ROMFunc[2].funcName = ROMFunctionNames.EMIF3CConfigSDRAM;
105 ROMFunc[2].iniSectionName = "EMIF3SDRAM";
106 ROMFunc[2].numParams = 4;
107 ROMFunc[2].paramNames = new String[4] { "SDCR", "SDTIMR", "SDTIMR2", "SDRCR" };
109 ROMFunc[3].funcName = ROMFunctionNames.EMIF25ConfigSDRAM;
110 ROMFunc[3].iniSectionName = "EMIF25SDRAM";
111 ROMFunc[3].numParams = 4;
112 ROMFunc[3].paramNames = new String[4] { "SDBCR", "SDTIMR", "SDRSRPDEXIT", "SDRCR"};
114 ROMFunc[4].funcName = ROMFunctionNames.EMIF25ConfigAsync;
115 ROMFunc[4].iniSectionName = "EMIF25ASYNC";
116 ROMFunc[4].numParams = 4;
117 ROMFunc[4].paramNames = new String[4] { "A1CR", "A2CR", "A3CR", "A4CR" };
119 ROMFunc[5].funcName = ROMFunctionNames.PLLandClockConfig;
120 ROMFunc[5].iniSectionName = "PLLANDCLOCKCONFIG";
121 ROMFunc[5].numParams = 3;
122 ROMFunc[5].paramNames = new String[3] { "PLLCFG0", "PLLCFG1", "PERIPHCLKCFG" };
124 ROMFunc[6].funcName = ROMFunctionNames.PSCConfig;
125 ROMFunc[6].iniSectionName = "PSCCONFIG";
126 ROMFunc[6].numParams = 1;
127 ROMFunc[6].paramNames = new String[1] { "LPSCCFG" };
129 ROMFunc[7].funcName = ROMFunctionNames.PINMUXConfig;
130 ROMFunc[7].iniSectionName = "PINMUX";
131 ROMFunc[7].numParams = 3;
132 ROMFunc[7].paramNames = new String[3] { "REGNUM", "MASK", "VALUE" };
134 ROMFunc[8].funcName = ROMFunctionNames.FastBoot;
135 ROMFunc[8].iniSectionName = "FASTBOOT";
136 ROMFunc[8].numParams = 0;
137 ROMFunc[8].paramNames = null;
139 AISExtraFunc = new AisExtraFunction[4];
140 AISExtraFunc[0].funcName = "setEmifB45Div";
141 AISExtraFunc[0].aisExtraFileName = "DSP_AISExtra_"+devNameShort+".out";
142 AISExtraFunc[0].iniSectionName = "DSP_SET_EMIFB_45DIV";
143 AISExtraFunc[0].numParams = 0;
144 AISExtraFunc[0].paramNames = null;
145 AISExtraFunc[0].isInitFunc = false;
147 AISExtraFunc[1].funcName = "setEmifB45Div";
148 AISExtraFunc[1].aisExtraFileName = "ARM_AISExtra_"+devNameShort+".out";
149 AISExtraFunc[1].iniSectionName = "ARM_SET_EMIFB_45DIV";
150 AISExtraFunc[1].numParams = 0;
151 AISExtraFunc[1].paramNames = null;
152 AISExtraFunc[1].isInitFunc = false;
154 AISExtraFunc[2].funcName = "setEmifA45Div";
155 AISExtraFunc[2].aisExtraFileName = "DSP_AISExtra_"+devNameShort+".out";
156 AISExtraFunc[2].iniSectionName = "DSP_SET_EMIFA_45DIV";
157 AISExtraFunc[2].numParams = 0;
158 AISExtraFunc[2].paramNames = null;
159 AISExtraFunc[2].isInitFunc = false;
161 AISExtraFunc[3].funcName = "setEmifA45Div";
162 AISExtraFunc[3].aisExtraFileName = "ARM_AISExtra_"+devNameShort+".out";
163 AISExtraFunc[3].iniSectionName = "ARM_SET_EMIFA_45DIV";
164 AISExtraFunc[3].numParams = 0;
165 AISExtraFunc[3].paramNames = null;
166 AISExtraFunc[3].isInitFunc = false;
168 // OMAP-L137 is little endian
169 devEndian = Endian.LittleEndian;
171 // OMAP-L137 AIS data is little endian;
172 devAISEndian = Endian.LittleEndian;
174 // Create default CRC object for this device
175 devCRC = new CRC32(0x04C11DB7, 0x00000000, 0x00000000, false, 1, UtilLib.CRC.CRCType.INCREMENTAL, UtilLib.CRC.CRCCalcMethod.BITWISE);
176 }
178 public override retType InsertAISPreamble()
179 {
180 EndianBinaryWriter ebw = new EndianBinaryWriter( this.devAISStream, this.devEndian);
182 switch (this.bootMode)
183 {
184 case AisBootModes.EMIFA:
185 {
186 if (this.busWidth == 16)
187 {
188 this.writer.Write((UInt32)(0x1 << 0)|(0x2 << 4));
189 }
190 else
191 {
192 this.writer.Write((UInt32)(0x0 << 0)|(0x2 << 4));
193 }
194 this.writer.Write((UInt32)AisOps.MagicNumber);
195 break;
196 }
197 default:
198 {
199 this.writer.Write((UInt32)AisOps.MagicNumber);
200 break;
201 }
202 }
204 // Add the AIS magic number to signature buffer if a secure boot image
205 if ( this.SecureType != AisSecureType.NONE )
206 {
207 sigWriter.Write((UInt32)AisOps.MagicNumber);
208 }
210 return retType.SUCCESS;
211 }
212 }
213 } //end of AISGenLib namespace