Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ |
| 2 | /* |
| 3 | * Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #ifndef __AML_MMC_H__ |
| 7 | #define __AML_MMC_H__ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <mmc.h> |
| 11 | |
| 12 | /* bootloader operation */ |
| 13 | #define AML_BL_USER (0x1 << 0) |
| 14 | #define AML_BL_BOOT0 (0x1 << 1) |
| 15 | #define AML_BL_BOOT1 (0x1 << 2) |
| 16 | #define AML_BL_BOOT (0x6) |
| 17 | #define AML_BL_ALL (0x7) |
| 18 | |
| 19 | /** For actually partitions with mask 8 store into bootinfo |
| 20 | * name: partition name. |
| 21 | * addr: sector addr of the partition |
| 22 | * size: sector cont of the partition |
| 23 | */ |
| 24 | struct part_property |
| 25 | { |
| 26 | char name[8]; |
| 27 | uint32_t addr; |
| 28 | uint32_t size; |
| 29 | }; |
| 30 | #define PART_PROPERTY_SIZE sizeof(struct part_property) |
| 31 | #define BOOTINFO_MAX_PARTITIONS (4) |
| 32 | #define BOOTINFO_PARTITIONS_SIZE (PART_PROPERTY_SIZE * BOOTINFO_MAX_PARTITIONS) |
| 33 | |
| 34 | |
| 35 | #define VPART_PROPERTY_SIZE sizeof(struct vpart_property) |
| 36 | struct vpart_property { |
| 37 | u32 addr; |
| 38 | u32 size; |
| 39 | }; |
| 40 | |
| 41 | /* |
| 42 | * sizeof(struct storage_emmc_boot_info) is strictly |
| 43 | * smaller than or equal to one sector. we will bind |
| 44 | * it in one sector with u-boot.bin together and |
| 45 | * write into boot loader area. |
| 46 | * @rsv_base_addr : the sector address of reserved area |
| 47 | * @dtb : the sector address and size of dtb property |
| 48 | * @ddr : the sector address and size of ddr property |
| 49 | */ |
| 50 | #define EMMC_BOOT_INFO_SIZE 512 |
| 51 | struct storage_emmc_boot_info { |
| 52 | u32 version; |
| 53 | u32 rsv_base_addr; |
| 54 | struct vpart_property dtb; |
| 55 | struct vpart_property ddr; |
| 56 | |
| 57 | struct part_property parts[BOOTINFO_MAX_PARTITIONS]; |
| 58 | uint8_t reserved[512 - 2 * VPART_PROPERTY_SIZE - BOOTINFO_PARTITIONS_SIZE - 12]; |
| 59 | u32 checksum; |
| 60 | }; |
| 61 | |
| 62 | int amlmmc_write_bootloader(int dev, int map, |
| 63 | unsigned int size, const void *src); |
| 64 | int amlmmc_erase_bootloader(int dev, int map); |
| 65 | |
| 66 | |
| 67 | /* interface on reserved area. */ |
| 68 | void mmc_write_cali_mattern(void *addr); |
| 69 | |
| 70 | /* dtb operation */ |
| 71 | int dtb_write(void *addr); |
| 72 | |
| 73 | /* emmc key operation */ |
| 74 | int mmc_key_read(unsigned char *buf, |
| 75 | unsigned int size, uint32_t *actual_length); |
| 76 | int mmc_key_write(unsigned char *buf, |
| 77 | unsigned int size, uint32_t *actual_length); |
| 78 | int mmc_key_erase(void); |
| 79 | |
| 80 | /* partition operation */ |
| 81 | int renew_partition_tbl(unsigned char *buffer); |
| 82 | int find_dev_num_by_partition_name (char const *name); |
| 83 | |
| 84 | #ifdef CONFIG_AML_PARTITION |
| 85 | int emmc_update_mbr(unsigned char *buffer); |
| 86 | #endif |
| 87 | |
| 88 | /*mmc ext_csd register operation*/ |
| 89 | int mmc_get_ext_csd(struct mmc *mmc, u8 *ext_csd); |
| 90 | int mmc_set_ext_csd(struct mmc *mmc, u8 index, u8 value); |
| 91 | |
| 92 | /* mmc caps quirks */ |
| 93 | int emmc_quirks(void); |
| 94 | #endif /* __AML_MMC_H__ */ |