blob: 6edf90bd84ef7a2d6e623f8f3aeb782af7b66d6f
1 | /* |
2 | * Copyright (C) 2017 Amlogic, Inc. All rights reserved. |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
12 | * more details. |
13 | * yonghui.yu@amlogic.com |
14 | */ |
15 | |
16 | |
17 | #ifndef __AML_MMC_H__ |
18 | #define __AML_MMC_H__ |
19 | |
20 | #include <common.h> |
21 | |
22 | /* bootloader operation */ |
23 | #define AML_BL_USER (0x1 << 0) |
24 | #define AML_BL_BOOT0 (0x1 << 1) |
25 | #define AML_BL_BOOT1 (0x1 << 2) |
26 | #define AML_BL_BOOT (0x6) |
27 | #define AML_BL_ALL (0x7) |
28 | |
29 | #define VPART_PROPERTY_SIZE sizeof(struct vpart_property) |
30 | struct vpart_property { |
31 | u32 addr; |
32 | u32 size; |
33 | }; |
34 | |
35 | /* |
36 | * sizeof(struct storage_emmc_boot_info) is strictly |
37 | * smaller than or equal to one sector. we will bind |
38 | * it in one sector with u-boot.bin together and |
39 | * write into boot loader area. |
40 | * @rsv_base_addr : the sector address of reserved area |
41 | * @dtb : the sector address and size of dtb property |
42 | * @ddr : the sector address and size of ddr property |
43 | */ |
44 | #define EMMC_BOOT_INFO_SIZE 512 |
45 | struct storage_emmc_boot_info { |
46 | u32 version; |
47 | u32 rsv_base_addr; |
48 | struct vpart_property dtb; |
49 | struct vpart_property ddr; |
50 | u8 reserved[512 - 2 * VPART_PROPERTY_SIZE - 12]; |
51 | u32 checksum; |
52 | }; |
53 | |
54 | int amlmmc_write_bootloader(int dev, int map, |
55 | unsigned int size, const void *src); |
56 | int amlmmc_erase_bootloader(int dev, int map); |
57 | |
58 | |
59 | /* interface on reserved area. */ |
60 | void mmc_write_cali_mattern(void *addr); |
61 | |
62 | /* dtb operation */ |
63 | int dtb_write(void *addr); |
64 | |
65 | /* emmc key operation */ |
66 | int mmc_key_read(unsigned char *buf, |
67 | unsigned int size, uint32_t *actual_lenth); |
68 | int mmc_key_write(unsigned char *buf, |
69 | unsigned int size, uint32_t *actual_lenth); |
70 | int mmc_key_erase(void); |
71 | |
72 | /* partition operation */ |
73 | int renew_partition_tbl(unsigned char *buffer); |
74 | int find_dev_num_by_partition_name (char *name); |
75 | |
76 | #ifdef CONFIG_AML_PARTITION |
77 | int emmc_update_mbr(unsigned char *buffer); |
78 | #endif |
79 | |
80 | /*mmc ext_csd register operation*/ |
81 | int mmc_get_ext_csd(struct mmc *mmc, u8 *ext_csd); |
82 | int mmc_set_ext_csd(struct mmc *mmc, u8 index, u8 value); |
83 | #endif /* __AML_MMC_H__ */ |
84 |