]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/gdsys/p1022/sdhc_boot.c
2 * Copyright 2011 Freescale Semiconductor, Inc.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * The environment variables are written to just after the u-boot image
29 * on SDCard, so we must read the MBR to get the start address and code
30 * length of the u-boot image, then calculate the address of the env.
32 #define ESDHC_BOOT_IMAGE_SIZE 0x48
33 #define ESDHC_BOOT_IMAGE_ADDR 0x50
35 int mmc_get_env_addr(struct mmc
*mmc
, int copy
, u32
*env_addr
)
38 u32 blklen
, code_offset
, code_len
, n
;
40 blklen
= mmc
->read_bl_len
;
41 tmp_buf
= malloc(blklen
);
45 /* read out the first block, get the config data information */
46 n
= mmc
->block_dev
.block_read(mmc
->block_dev
.dev
, 0, 1, tmp_buf
);
52 /* Get the Source Address, from offset 0x50 */
53 code_offset
= *(u32
*)(tmp_buf
+ ESDHC_BOOT_IMAGE_ADDR
);
55 /* Get the code size from offset 0x48 */
56 code_len
= *(u32
*)(tmp_buf
+ ESDHC_BOOT_IMAGE_SIZE
);
58 *env_addr
= code_offset
+ code_len
;