1.将文件夹2009.11.1修改,在makefile中修改相应的版本号
2.在board\freescale\新建myboard_v2文件夹,拷贝myboard文件夹中内容到此,将atdbaord.c重命名为myboard_v2.c,在include\configs中建立myboard_v2.h,在makefile中添加myboard_v2_config:选项,修改板子类型,在myboard_v2.h中添加 #define CONFIG_MYBOARD_V2 1 宏定义。
3.有start.S开始修改。
bootcold:
cpu_early_init: 这部分比较 uboot5125 for linux 和uboot5121无区别,注意HID0和MSR是e300 core内部的寄存器,mpc125和mpc5121e核心不变,此处不用修改
修改norflash 大小的宏 #define CONFIG_SYS_FLASH_SIZE 0x02000000 (32M)用于LocalPlus Boot Access Window Register的赋值
修改norflash 复用方式 #define CONFIG_SYS_CS0_CFG 0x00209140//为 地址和数据复用方式 Muxed,注意此处定义
inflash:
修改内部SRAM的大小 #define CONFIG_SYS_SRAM_SIZE 0x00020000 // 32k SRAM
cpu_init_f: 修改 immap *im的定义,在inlcude\asm-ppc\immap_512x.h,重新定义memory map
typedef struct immap {
sysconf512x_t sysconf; /* System configuration */
u8 res0[0x700];
wdt512x_t wdt; /* Watch Dog Timer (WDT) */
rtclk512x_t rtc; /* Real Time Clock Module */
gpt512x_t gpt1; /* General Purpose Timer 1*/
ipic512x_t ipic; /* Integrated Programmable Interrupt Controller */
arbiter512x_t arbiter; /* CSB Arbiter */
reset512x_t reset; /* Reset Module */
clk512x_t clk; /* Clock Module */
pmc512x_t pmc; /* Power Management Control Module */
gpio512x_t gpio; /* General purpose I/O module */
gpio512x_t gpio2; /* General purpose I/O module */
u8 res1[0x100];
mscan512x_t mscan12; /* MSCAN 12*/
bdlc512x_t bdlc; /* BDLC */
sdhc512x_t sdhc; /* SDHC 1*/
u8 res2[0x100]; /* no SPDIF */
i2c512x_t i2c; /* I2C Controllers */
u8 res3[0x800];
u8 res4[0x100]; /* no AXE */
diu512x_t diu; /* Display Interface Unit */
u8 res5[0x100]; /* no Clock Frequency Measurement */
mscan512x_t mscan34; /* MSCAN 34*/
u8 res6[0x400];
fec512x_t fec; /* Fast Ethernet Controller 1*/
ulpi512x_t ulpi1; /* USB ULPI 1*/
u8 res7[0xc00];
ulpi512x_t ulpi2; /* USB ULPI 2*/
u8 res8[0x800];
fec512x_t fec2; /* Fast Ethernet Controller 2*/
gpt512x_t gpt2; /* General Purpose Timer 2*/
sdhc512x_t sdhc2; /* SDHC 2*/
u8 res9[0x3e00];
ddr512x_t mddrc; /* Multi-port DDR Memory Controller */
ioctrl512x_t io_ctrl; /* IO Control */
iim512x_t iim; /* IC Identification module */
u8 res10[0x4000];
lpc512x_t lpc; /* LocalPlus Controller */
u8 res11[0xe00];
psc512x_t psc[10]; /* PSCs */
u8 res12[0x500];
fifoc512x_t fifoc; /* FIFO Controller */
u8 res13[0x2000];
dma512x_t dma; /* DMA */
u8 res14[0xea800];
} immap_t;
保证对于CSB arbiter 和 Reset module以及clock module初始化的正确。arbiter512x_t ,reset512x_t 定义无变化,
修改clock module
typedef struct clk512x {
u32 spmr; /* System PLL Mode Register */
u32 sccr[2]; /* System Clock Control Registers */
u32 scfr[2]; /* System Clock Frequency Registers */
u8 res0[4];
u32 bcr; /* Bread Crumb Register */
u32 pscccr[10]; /* PSC0-9 Clock Control Registers */
u8 res1[10];
u32 dccr; /* DIU Clock Control Register */
u32 msccr[4]; /* MSCAN1-4 Clock Control Registers */
u8 res2[0x98];
} clk512x_t;
board_init_f: ( lib_ppc/board.c )
初始化 init_fnc_t的函数
1.board_early_init_f ( freescale/atdboard_v2.c ) 主要作用是对CS0配置寄存器进行设置
其中对于lpc时序的设置,immap_512x.h中 lpc512x定义不用修改,修改关于sysconf512x结构体的定义
typedef struct sysconf512x {
u32 immrbar; /* Internal memory map base address register */
u8 res0[0x1c];
u32 lpbaw; /* LP Boot Access Window */
u32 lpcs0aw; /* LP CS0 Access Window */
u32 lpcs1aw; /* LP CS1 Access Window */
u32 lpcs2aw; /* LP CS2 Access Window */
u32 lpcs3aw; /* LP CS3 Access Window */
u32 lpcs4aw; /* LP CS4 Access Window */
u32 lpcs5aw; /* LP CS5 Access Window */
u32 lpcs6aw; /* LP CS6 Access Window */
u32 lpcs7aw; /* LP CS7 Access Window */
u8 res1[0x1c];
law512x_t pcilaw[3]; /* PCI Local Access Window 0-2 Registers */
u8 res2[0x28];
law512x_t ddrlaw; /* DDR Local Access Window */
u8 res3[0x18];
u32 mbxbar; /* MBX Base Address */
u32 srambar; /* SRAM Base Address */
u32 nfcbar; /* NFC Base Address */
u8 res4[0x34];
u32 spridr; /* System Part and Revision ID Register */
u32 spcr; /* System Priority Configuration Register */
u8 res5[0xf8];
} sysconf512x_t;
对于flash的时序进行配置,配置CS0寄存器以及CS is asserted together with the assertion of Address latch (ALE) = 2lpc_clocks 注意这一点需不需要
在 mpc512x.h 中定义 CS_ALE_TIMING_CONFIG 1
#ifdef CONFIG_ATDBOARD_V2
out_be32(&im->lpc.cs_cfg[0], CONFIG_SYS_CS0_CFG);
out_be32((u32 *)(CONFIG_SYS_IMMR + LPC_OFFSET + CS_ALE_TIMING_CONFIG),CONFIG_SYS_CS_ALETIMING);
#endif
2.get_clocks (在cpu\mpc512x\speed.c) 主要作用是读取时钟配置寄存器,获得各总线的时钟,并存储在环境变量中。MPC5125裁减掉了一些不经常用的外设,在时钟模块方面也有所修改,也就是说有些外设的基地址需要重映射,但对于每个时钟寄存器的定义还是保持一致的,新板子的时钟树没有发生改变,所以此处无需修改。
3.env_init 主要初始化环境变量结构体,对硬件没有操作,因此不需修改。
4.init_baudrate 从环境变量里取出串口波特率,如没有初始化环境变量采用默认波特率。
5.serial_init
在新的设计中采用PSC1而不是PSC3,因此需要配置端口复用寄存器,首先对端口复用寄存器进行重映射
typedef struct ioctrl512x {
uint8_t io_control_mem; /* MEM pad ctrl reg */
uint8_t io_control_gb; /* GB pad ctrl reg */
uint8_t reserved1[2];
uint8_t io_control_lpc_clk; /* LPC_CLK pad ctrl reg */
uint8_t io_control_lpc_oe_b; /* LPC_OE pad ctrl reg */
uint8_t io_control_lpc_rwb; /* LPC_R/W pad ctrl reg */
uint8_t io_control_lpc_cs0_b; /* LPC_CS0 pad ctrl reg */
uint8_t io_control_lpc_ack_b; /* LPC_ACK pad ctrl reg */
uint8_t io_control_lpc_ax03; /* LPC_AX03 pad ctrl reg */
uint8_t io_control_emb_ax02; /* EMB_AX02 pad ctrl reg */
uint8_t io_control_emb_ax01; /* EMB_AX01 pad ctrl reg */
uint8_t io_control_emb_ax00; /* EMB_AX00 pad ctrl reg */
uint8_t io_control_emb_ad31; /* EMB_AD31 pad ctrl reg */
uint8_t io_control_emb_ad30; /* EMB_AD30 pad ctrl reg */
uint8_t io_control_emb_ad29; /* EMB_AD29 pad ctrl reg */
uint8_t io_control_emb_ad28; /* EMB_AD28 pad ctrl reg */
uint8_t io_control_emb_ad27; /* EMB_AD27 pad ctrl reg */
uint8_t io_control_emb_ad26; /* EMB_AD26 pad ctrl reg */
uint8_t io_control_emb_ad25; /* EMB_AD25 pad ctrl reg */
uint8_t io_control_emb_ad24; /* EMB_AD24 pad ctrl reg */
uint8_t io_control_emb_ad23; /* EMB_AD23 pad ctrl reg */
uint8_t io_control_emb_ad22; /* EMB_AD22 pad ctrl reg */
uint8_t io_control_emb_ad21; /* EMB_AD21 pad ctrl reg */
uint8_t io_control_emb_ad20; /* EMB_AD20 pad ctrl reg */
uint8_t io_control_emb_ad19; /* EMB_AD19 pad ctrl reg */
uint8_t io_control_emb_ad18; /* EMB_AD18 pad ctrl reg */
uint8_t io_control_emb_ad17; /* EMB_AD17 pad ctrl reg */
uint8_t io_control_emb_ad16; /* EMB_AD16 pad ctrl reg */
uint8_t io_control_emb_ad15; /* EMB_AD15 pad ctrl reg */
uint8_t io_control_emb_ad14; /* EMB_AD14 pad ctrl reg */
uint8_t io_control_emb_ad13; /* EMB_AD13 pad ctrl reg */
uint8_t io_control_emb_ad12; /* EMB_AD12 pad ctrl reg */
uint8_t io_control_emb_ad11; /* EMB_AD11 pad ctrl reg */
uint8_t io_control_emb_ad10; /* EMB_AD10 pad ctrl reg */
uint8_t io_control_emb_ad09; /* EMB_AD09 pad ctrl reg */
uint8_t io_control_emb_ad08; /* EMB_AD08 pad ctrl reg */
uint8_t io_control_emb_ad07; /* EMB_AD07 pad ctrl reg */
uint8_t io_control_emb_ad06; /* EMB_AD06 pad ctrl reg */
uint8_t io_control_emb_ad05; /* EMB_AD05 pad ctrl reg */
uint8_t io_control_emb_ad04; /* EMB_AD04 pad ctrl reg */
uint8_t io_control_emb_ad03; /* EMB_AD03 pad ctrl reg */
uint8_t io_control_emb_ad02; /* EMB_AD02 pad ctrl reg */
uint8_t io_control_emb_ad01; /* EMB_AD01 pad ctrl reg */
uint8_t io_control_emb_ad00; /* EMB_AD00 pad ctrl reg */
uint8_t io_control_nfc_ce0_b; /* NFC_CE0 pad ctrl reg */
uint8_t io_control_nfc_rb; /* NFC_RB pad ctrl reg */
uint8_t io_control_diu_clk;
uint8_t io_control_diu_de;
uint8_t io_control_diu_hsync;
uint8_t io_control_diu_vsync;
uint8_t io_control_diu_ld00;
uint8_t io_control_diu_ld01;
uint8_t io_control_diu_ld02;
uint8_t io_control_diu_ld03;
uint8_t io_control_diu_ld04;
uint8_t io_control_diu_ld05;
uint8_t io_control_diu_ld06;
uint8_t io_control_diu_ld07;
uint8_t io_control_diu_ld08;
uint8_t io_control_diu_ld09;
uint8_t io_control_diu_ld10;
uint8_t io_control_diu_ld11;
uint8_t io_control_diu_ld12;
uint8_t io_control_diu_ld13;
uint8_t io_control_diu_ld14;
uint8_t io_control_diu_ld15;
uint8_t io_control_diu_ld16;
uint8_t io_control_diu_ld17;
uint8_t io_control_diu_ld18;
uint8_t io_control_diu_ld19;
uint8_t io_control_diu_ld20;
uint8_t io_control_diu_ld21;
uint8_t io_control_diu_ld22;
uint8_t io_control_diu_ld23;
uint8_t io_control_i2c2_scl; /* i2c2_scl pad ctrl reg */
uint8_t io_control_i2c2_sda;
uint8_t io_control_can1_tx; /* CAN1_TX pad ctrl reg */
uint8_t io_control_can2_tx; /* CAN2_TX pad ctrl reg */
uint8_t io_control_i2c1_scl; /* I2C1_SCL pad ctrl reg */
uint8_t io_control_i2c1_sda; /* I2C1_SDA pad ctrl reg */
uint8_t io_control_fec1_txd_2;
uint8_t io_control_fec1_txd_3;
uint8_t io_control_fec1_rxd_2;
uint8_t io_control_fec1_rxd_3;
uint8_t io_control_fec1_crs;
uint8_t io_control_fec1_tx_er;
uint8_t io_control_fec1_rxd_1;
uint8_t io_control_fec1_txd_1;
uint8_t io_control_fec1_mdc;
uint8_t io_control_fec1_rx_er;
uint8_t io_control_fec1_mdio;
uint8_t io_control_fec1_rxd_0;
uint8_t io_control_fec1_txd_0;
uint8_t io_control_fec1_tx_clk;
uint8_t io_control_fec1_rx_clk;
uint8_t io_control_fec1_rx_dv;
uint8_t io_control_fec1_tx_en;
uint8_t io_control_fec1_col;
uint8_t io_control_usb1_data0;
uint8_t io_control_usb1_data1;
uint8_t io_control_usb1_data2;
uint8_t io_control_usb1_data3;
uint8_t io_control_usb1_data4;
uint8_t io_control_usb1_data5;
uint8_t io_control_usb1_data6;
uint8_t io_control_usb1_data7;
uint8_t io_control_usb1_stop;
uint8_t io_control_usb1_clk;
uint8_t io_control_usb1_next;
uint8_t io_control_usb1_dir;
uint8_t io_control_sdhc1_clk;
uint8_t io_control_sdhc1_cmd;
uint8_t io_control_sdhc1_d0;
uint8_t io_control_sdhc1_d1;
uint8_t io_control_sdhc1_d2;
uint8_t io_control_sdhc1_d3;
uint8_t io_control_psc_mclk_in; /* PSC_MCLK_IN pad ctrl reg */
uint8_t io_control_psc0_0; /* PSC0_0 pad ctrl reg */
uint8_t io_control_psc0_1; /* PSC0_1 pad ctrl reg */
uint8_t io_control_psc0_2; /* PSC0_2 pad ctrl reg */
uint8_t io_control_psc0_3; /* PSC0_3 pad ctrl reg */
uint8_t io_control_psc0_4; /* PSC0_4 pad ctrl reg */
uint8_t io_control_psc1_0; /* PSC1_0 pad ctrl reg */
uint8_t io_control_psc1_1; /* PSC1_1 pad ctrl reg */
uint8_t io_control_psc1_2; /* PSC1_2 pad ctrl reg */
uint8_t io_control_psc1_3; /* PSC1_3 pad ctrl reg */
uint8_t io_control_psc1_4; /* PSC1_4 pad ctrl reg */
uint8_t io_control_j1850_tx;
uint8_t io_control_j1850_rx;
u8 res1[0xF7E];
} ioctrl512x_t;
在serial_init中添加关于io_control的代码,
另外在myboard_v2.h中修改串口定义 #define CONFIG_PSC_CONSOLE 1 使用PSC1
对于mpc5125的psc模块的改动比较大,不仅基地址不一样,连寄存器的相应位也发生了改变。首先对寄存器进行重映射。
typedef struct {
volatile uint8_t MR1; //MBAR_PSC + 0x00
volatile uint8_t res0[3]; //MBAR_PSC + 0x01 -0x03
volatile uint8_t MR2; //MBAR_PSC + 0x04
volatile uint8_t res1[3]; //MBAR_PSC + 0x05 -0x07
volatile uint16_t SR; //MBAR_PSC + 0x08 -0x09
volatile uint8_t res2[2]; //MBAR_PSC + 0x0a -0x0b
volatile uint8_t CSR; //MBAR_PSC + 0x0c
volatile uint8_t res3[3]; //MBAR_PSC + 0x0d -0x0f
volatile uint8_t CR; //MBAR_PSC + 0x10
volatile uint8_t res4[3]; //MBAR_PSC + 0x11 -0x13
volatile uint8_t RB_TB[4]; //MBAR_PSC + 0x14 -0x17
volatile uint8_t IPCR; //MBAR_PSC + 0x18
volatile uint8_t res5[3]; //MBAR_PSC + 0x19 -0x1B
volatile uint8_t ACR; //MBAR_PSC + 0x1c
volatile uint8_t res6[3]; //MBAR_PSC + 0x1d -0x1f
volatile uint16_t ISR; //MBAR_PSC + 0x20 - 0x21
volatile uint8_t res7[2]; //MBAR_PSC + 0x22 -0x23
volatile uint16_t IMR; //MBAR_PSC + 0x24 - 0x25
volatile uint8_t res8[2]; //MBAR_PSC + 0x26 -0x27
volatile uint8_t CTUR; //MBAR_PSC + 0x28
volatile uint8_t res9[3]; //MBAR_PSC + 0x29 -0x2b
volatile uint8_t CTLR; //MBAR_PSC + 0x2c
volatile uint8_t res10[3]; //MBAR_PSC + 0x2d -0x2f
volatile uint32_t CCR; //MBAR_PSC + 0x30 -0x33
volatile uint32_t AC97slots; //MBAR_PSC + 0x34 -0x37
volatile uint32_t AC97CMD; //MBAR_PSC + 0x38 -0x3b
volatile uint32_t AC97DAT; //MBAR_PSC + 0x3c -0x3f
volatile uint8_t res11[4]; //MBAR_PSC + 0x40 -0x43
volatile uint8_t IP; //MBAR_PSC + 0x44
volatile uint8_t res12[3]; //MBAR_PSC + 0x45 -0x47
volatile uint8_t OP1; //MBAR_PSC + 0x48
volatile uint8_t res13[3]; //MBAR_PSC + 0x49 -0x4b
volatile uint8_t OP0; //MBAR_PSC + 0x4c
volatile uint8_t res14[3]; //MBAR_PSC + 0x4d -0x4f
volatile uint32_t SICR; //MBAR_PSC + 0x50 -0x53
volatile uint8_t res15[44]; //MBAR_PSC + 0x54 - 0x7f
volatile uint32_t tfcmd; /* PSC + 0x80 */
volatile uint32_t tfalarm; /* PSC + 0x84 */
volatile uint32_t tfstat; /* PSC + 0x88 */
volatile uint32_t tfintstat; /* PSC + 0x8C */
volatile uint32_t tfintmask; /* PSC + 0x90 */
volatile uint32_t tfcount; /* PSC + 0x94 */
volatile uint16_t tfwptr; /* PSC + 0x98 */
volatile uint16_t tfrptr; /* PSC + 0x9A */
volatile uint32_t tfsize; /* PSC + 0x9C */
volatile uint8_t res16[28];
union { /* PSC + 0xBC */
volatile uint8_t buffer_8;
volatile uint16_t buffer_16;
volatile uint32_t buffer_32;
} tfdata_buffer;
#define tfdata_8 tfdata_buffer.buffer_8
#define tfdata_16 tfdata_buffer.buffer_16
#define tfdata_32 tfdata_buffer.buffer_32
volatile uint32_t rfcmd; /* PSC + 0xC0 */
volatile uint32_t rfalarm; /* PSC + 0xC4 */
volatile uint32_t rfstat; /* PSC + 0xC8 */
volatile uint32_t rfintstat; /* PSC + 0xCC */
volatile uint32_t rfintmask; /* PSC + 0xD0 */
volatile uint32_t rfcount; /* PSC + 0xD4 */
volatile uint16_t rfwptr; /* PSC + 0xD8 */
volatile uint16_t rfrptr; /* PSC + 0xDA */
volatile uint32_t rfsize; /* PSC + 0xDC */
volatile uint8_t res17[28];
union { /* PSC + 0xFC */
volatile uint8_t buffer_8;
volatile uint16_t buffer_16;
volatile uint32_t buffer_32;
} rfdata_buffer;
#define rfdata_8 rfdata_buffer.buffer_8
#define rfdata_16 rfdata_buffer.buffer_16
#define rfdata_32 rfdata_buffer.buffer_32
} psc512x_t;
有些寄存器的名称也发生了改变,因此修改serial_init、serial_setbrg、serial_putc、serial_putc_raw、serial_setrts以及serial_getcts中的相应定义。
至此串口部分就移植完了。