From e19b0611d76d99b15586f4a584b754ab4d55e48a Mon Sep 17 00:00:00 2001 From: Dimitar Gamishev Date: Wed, 5 Dec 2018 11:52:01 +0200 Subject: [PATCH] Changes for MMC BSP 3.0 driver --- SOFTWARE/A64-TERES/u-boot_new/include/mmc.h | 51 ++++- .../A64-TERES/u-boot_new/include/spare_head.h | 213 ++++++++++-------- .../A64-TERES/u-boot_new/include/sys_config.h | 11 +- 3 files changed, 175 insertions(+), 100 deletions(-) diff --git a/SOFTWARE/A64-TERES/u-boot_new/include/mmc.h b/SOFTWARE/A64-TERES/u-boot_new/include/mmc.h index f5c5b11f..7c0a3126 100644 --- a/SOFTWARE/A64-TERES/u-boot_new/include/mmc.h +++ b/SOFTWARE/A64-TERES/u-boot_new/include/mmc.h @@ -33,6 +33,7 @@ #define MMC_VERSION_4_5 (MMC_VERSION_MMC | 0x405) #define MMC_VERSION_5_0 (MMC_VERSION_MMC | 0x500) #define MMC_VERSION_5_1 (MMC_VERSION_MMC | 0x501) +#define MMC_VERSION_NEW_VER (MMC_VERSION_MMC | 0xFFF) #define MMC_MODE_HS (1 << 0) /* can run at 26MHz -- DS26_SDR12*/ #define MMC_MODE_HS_52MHz (1 << 1) /* can run at 52MHz with SDR mode -- HSSDR52_SDR25 */ @@ -195,6 +196,9 @@ #define EXT_CSD_REV 192 /* RO */ #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ #define EXT_CSD_SECURE_REMOAL_TYPE 16 /* R/W */ +#define EXT_CSD_FFU_STATUS 26 /* RO */ +#define EXT_CSD_MODE_OPERATION_CODES 29 /* W */ +#define EXT_CSD_MODE_CONFIG 30 /* R/W */ #define EXT_CSD_FLUSH_CACHE 32 /* W */ #define EXT_CSD_CACHE_CTRL 33 /* R/W */ #define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ @@ -213,6 +217,7 @@ #define EXT_CSD_SANITIZE_START 165 /* W */ #define EXT_CSD_WR_REL_PARAM 166 /* RO */ #define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_FW_CONFIG 169 /* R/W */ #define EXT_CSD_BOOT_WP 173 /* R/W */ #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ #define EXT_CSD_PART_CONFIG 179 /* R/W */ @@ -249,10 +254,16 @@ #define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ #define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */ #define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */ +#define EXT_CSD_FIRMWARE_VERSION 254 /* 254-261, RO */ #define EXT_CSD_PRE_EOL_INFO 267 /* RO */ #define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A 268 /* RO */ #define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B 269 /* RO */ #define EXT_CSD_VENDOR_HEALTH_REPORT 270 /* 270-301, RO */ +#define EXT_CSD_NUM_OF_FW_SECTS_PROGRAMMED /* 302-305, RO */ +#define EXT_CSD_FFU_ARG 487 /* 487-490, RO */ +#define EXT_CSD_OPERATION_CODES_TIMEOUT 491 /* RO */ +#define EXT_CSD_FFU_FEATURES 492 /* RO */ +#define EXT_CSD_SUPPORTED_MODES 493 /* RO */ #define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */ #define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */ #define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */ @@ -324,6 +335,15 @@ #define EXT_CSD_SEC_GB_CL_EN (1U << 4) #define EXT_CSD_SEC_SANITIZE (1U << 6) /* v4.5 only */ +/* -- EXT_CSD[29] MODE_OPERATION_CODES */ +#define EXT_CSD_FFU_INSTALL (1U << 1) +#define EXT_CSD_FFU_ABORT (1U << 2) + +/* -- EXT_CSD[30] MODE_CONFIG */ +#define EXT_CSD_NORMAL_MODE (0) +#define EXT_CSD_FFU_MODE (1) +#define EXT_CSD_VENDOR_SPECIFIC_MODE (2) + /* MMC_SWITCH boot modes */ #define MMC_SWITCH_MMCPART_NOAVAILABLE (0xff) #define MMC_SWITCH_PART_ACCESS_MASK (0x7) @@ -475,7 +495,7 @@ struct tune_sdly { u32 tm4_sm4_f3210; u32 tm4_sm4_f7654; */ - u32 tm4_smx_fx[10]; + u32 tm4_smx_fx[12]; }; struct boot_mmc_cfg { @@ -498,6 +518,15 @@ struct boot_sdmmc_private_info_t { #define CARD_TYPE_MMC 0x8000000 #define CARD_TYPE_NULL 0xffffffff u32 card_type; /*0xffffffff: invalid; 0x8000000: mmc card; 0x8000001: sd card*/ + + #define EXT_PARA0_ID (0x55000000) + #define EXT_PARA0_TUNING_SUCCESS_FLAG (1U<<0) + u32 ext_para0; + + /* ext_para1/2/3 reseved for future */ + u32 ext_para1; + u32 ext_para2; + u32 ext_para3; }; #endif @@ -544,7 +573,8 @@ struct mmc_platform_caps { u8 tm4_tune_r_cycle; u8 tm4_tune_hs200_max_freq; u8 tm4_tune_hs400_max_freq; - u8 res[2]; + u8 tune_limit_kernel_timing; + u8 res[1]; /* bit31: valid; bit23~16: speed mode; bit15~8: freq id; bit7:0 freq value */ #define MAX_EXT_FREQ_POINT_NUM (4) @@ -562,6 +592,17 @@ struct mmc_platform_caps { u32 host_caps_mask; struct tune_sdly sdly; + + u32 force_boot_tuning; + + /* enable the flow of field firmware update(FFU) flow */ + u32 enable_ffu; + /* the byte length of emmc firmware, if it is 0, use the length get from toc0 header. if it is 0xffffffff, invalid len */ + u32 emmc_fw_byte_len; + /* emmc_fw_ver0[31:0] = ext_csd[257] | ext_csd[256] | ext_csd[255] | ext_csd[254] */ + u32 emmc_fw_ver0; + /* emmc_fw_ver1[31:0] = ext_csd[261] | ext_csd[260] | ext_csd[259] | ext_csd[258] */ + u32 emmc_fw_ver1; }; struct mmc_config { @@ -643,6 +684,7 @@ struct mmc { u32 pll_clock; u32 msglevel; u32 do_tuning; + u32 tuning_end; }; struct mmc_ext_csd { @@ -822,9 +864,14 @@ int mmc_send_manual_stop(struct mmc *mmc); int sunxi_need_rty(struct mmc *mmc); int sunxi_write_tuning(struct mmc *mmc); int sunxi_bus_tuning(struct mmc *mmc); +unsigned int sunxi_select_freq(struct mmc *mmc, int speed_md, int freq_index); int sunxi_switch_to_best_bus(struct mmc *mmc); +int sunxi_mmc_tuning_init(void); +int sunxi_mmc_tuning_exit(void); int mmc_init_product(struct mmc *mmc); int mmc_exit(void); +void mmc_update_config_for_sdly(struct mmc *mmc); +void mmc_update_config_for_dragonboard(int card_no); #endif /* _MMC_H_ */ diff --git a/SOFTWARE/A64-TERES/u-boot_new/include/spare_head.h b/SOFTWARE/A64-TERES/u-boot_new/include/spare_head.h index 0363665b..e60ed424 100644 --- a/SOFTWARE/A64-TERES/u-boot_new/include/spare_head.h +++ b/SOFTWARE/A64-TERES/u-boot_new/include/spare_head.h @@ -1,95 +1,115 @@ -/* - * (C) Copyright 2007-2013 - * Allwinner Technology Co., Ltd. - * Jerry Wang - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef __spare_head_h__ -#define __spare_head_h__ - -/* work mode */ -#define WORK_MODE_PRODUCT (1<<4) -#define WORK_MODE_UPDATE (1<<5) - +/* + * (C) Copyright 2007-2013 + * Allwinner Technology Co., Ltd. + * Jerry Wang + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef __spare_head_h__ +#define __spare_head_h__ + +/* work mode */ +#define WORK_MODE_PRODUCT (1<<4) +#define WORK_MODE_UPDATE (1<<5) + #define WORK_MODE_BOOT 0x00 //正常启动 #define WORK_MODE_USB_PRODUCT 0x10 //用于USB量产 #define WORK_MODE_CARD_PRODUCT 0x11 //用于卡量产 #define WORK_MODE_USB_DEBUG 0x12 //利用usb量产协议完成的测试 #define WORK_MODE_SPRITE_RECOVERY 0x13 //一键恢复 +#define WORK_MODE_CARD_UPDATE 0x14 //update firmware from sdcard #define WORK_MODE_USB_UPDATE 0x20 //用于USB升级 #define WORK_MODE_OUTER_UPDATE 0x21 //用于外部盘升级 #define WORK_MODE_USB_TOOL_PRODUCT 0x04 //用于量产 #define WORK_MODE_USB_TOOL_UPDATE 0x08 //用于升级 #define WORK_MODE_ERASE_KEY 0x20 //用于擦除key - -#define UBOOT_MAGIC "uboot" -#define STAMP_VALUE 0x5F0A6C39 -#define ALIGN_SIZE 16 * 1024 -#define MAGIC_SIZE 8 -#define STORAGE_BUFFER_SIZE (256) - -#define SUNXI_UPDATE_NEXT_ACTION_NORMAL (1) -#define SUNXI_UPDATE_NEXT_ACTION_REBOOT (2) -#define SUNXI_UPDATE_NEXT_ACTION_SHUTDOWN (3) -#define SUNXI_UPDATE_NEXT_ACTION_REUPDATE (4) -#define SUNXI_UPDATE_NEXT_ACTION_BOOT (5) + +#define UBOOT_MAGIC "uboot" +#define STAMP_VALUE 0x5F0A6C39 +#define ALIGN_SIZE 16 * 1024 +#define MAGIC_SIZE 8 +#define STORAGE_BUFFER_SIZE (256) + +#define SUNXI_UPDATE_NEXT_ACTION_NORMAL (1) +#define SUNXI_UPDATE_NEXT_ACTION_REBOOT (2) +#define SUNXI_UPDATE_NEXT_ACTION_SHUTDOWN (3) +#define SUNXI_UPDATE_NEXT_ACTION_REUPDATE (4) +#define SUNXI_UPDATE_NEXT_ACTION_BOOT (5) #define SUNXI_UPDATA_NEXT_ACTION_SPRITE_TEST (6) - -#define SUNXI_VBUS_UNKNOWN (0) -#define SUNXI_VBUS_EXIST (1) -#define SUNXI_VBUS_NOT_EXIST (2) - -#define BOOT0_SDMMC_START_ADDR (16) -#ifndef CONFIG_SUNXI_SECURE_SYSTEM -#define UBOOT_START_SECTOR_IN_SDMMC (38192) -#else -#define UBOOT_START_SECTOR_IN_SDMMC (32800) -#define UBOOT_START_SECTOR_PRE_IN_SDMMC (38192) -#endif - -#define SUNXI_NORMAL_MODE 0 -#define SUNXI_SECURE_MODE_WITH_SECUREOS 1 -#define SUNXI_SECURE_MODE_NO_SECUREOS 2 - -#define BOOT_FROM_SD0 0 -#define BOOT_FROM_SD2 2 -#define BOOT_FROM_NFC 1 -#define BOOT_FROM_SPI 3 - + +#define SUNXI_VBUS_UNKNOWN (0) +#define SUNXI_VBUS_EXIST (1) +#define SUNXI_VBUS_NOT_EXIST (2) + +#define BOOT0_SDMMC_START_ADDR (16) +#define BOOT0_SDMMC_BACKUP_START_ADDR (256) + +#define BOOT0_EMMC3_START_ADDR (384) +#define BOOT0_EMMC3_BACKUP_START_ADDR (512) + + +#ifndef CONFIG_SUNXI_SECURE_SYSTEM +#define UBOOT_START_SECTOR_IN_SDMMC (38192) +#else +#define UBOOT_START_SECTOR_IN_SDMMC (32800) +#define UBOOT_START_SECTOR_PRE_IN_SDMMC (38192) +#endif + + +#define SUNXI_NORMAL_MODE 0 +#define SUNXI_SECURE_MODE_WITH_SECUREOS 1 +#define SUNXI_SECURE_MODE_NO_SECUREOS 2 + +typedef enum _SUNXI_BOOT_FILE_MODE +{ + SUNXI_BOOT_FILE_NORMAL =0, + SUNXI_BOOT_FILE_TOC = 1, + SUNXI_BOOT_FILE_RES0 = 2, + SUNXI_BOOT_FILE_RES1 = 3, + SUNXI_BOOT_FILE_PKG = 4 +}SUNXI_BOOT_FILE_MODE; + + + +#define BOOT_FROM_SD0 0 +#define BOOT_FROM_SD2 2 +#define BOOT_FROM_NFC 1 +#define BOOT_FROM_SPI 3 + //#define TOC_MAIN_INFO_STATUS_ENCRYP_NOT_USED 0x00 //#define TOC_MAIN_INFO_STATUS_ENCRYP_SSK 0x01 //#define TOC_MAIN_INFO_STATUS_ENCRYP_BSSK 0x02 #define SUNXI_SECURE_MODE_USE_SEC_MONITOR 1 - -#define TOC_ITEM_ENTRY_STATUS_ENCRYP_NOT_USED 0x00 -#define TOC_ITEM_ENTRY_STATUS_ENCRYP_USED 0x01 - -#define TOC_ITEM_ENTRY_TYPE_NULL 0x00 -#define TOC_ITEM_ENTRY_TYPE_KEY_CERTIF 0x01 -#define TOC_ITEM_ENTRY_TYPE_BIN_CERTIF 0x02 -#define TOC_ITEM_ENTRY_TYPE_BIN 0x03 - -typedef struct _normal_gpio_cfg -{ + +#define TOC_ITEM_ENTRY_STATUS_ENCRYP_NOT_USED 0x00 +#define TOC_ITEM_ENTRY_STATUS_ENCRYP_USED 0x01 + +#define TOC_ITEM_ENTRY_TYPE_NULL 0x00 +#define TOC_ITEM_ENTRY_TYPE_KEY_CERTIF 0x01 +#define TOC_ITEM_ENTRY_TYPE_BIN_CERTIF 0x02 +#define TOC_ITEM_ENTRY_TYPE_BIN 0x03 +#define TOC_ITEM_ENTRY_TYPE_LOGO 0x04 + +typedef struct _normal_gpio_cfg +{ char port; //端口号 char port_num; //端口内编号 char mul_sel; //功能编号 @@ -97,34 +117,35 @@ typedef struct _normal_gpio_cfg char drv_level; //驱动驱动能力 char data; //输出电平 char reserved[2]; //保留位,保证对齐 -} -normal_gpio_cfg; - -typedef struct _special_gpio_cfg -{ - unsigned char port; //端口号 - unsigned char port_num; //端口内编号 - char mul_sel; //功能编号 - char data; //输出电平 -}special_gpio_cfg; +} +normal_gpio_cfg; + +typedef struct _special_gpio_cfg +{ + unsigned char port; //端口号 + unsigned char port_num; //端口内编号 + char mul_sel; //功能编号 + char data; //输出电平 +}special_gpio_cfg; //SD卡相关数据结构 -typedef struct sdcard_spare_info_t -{ +typedef struct sdcard_spare_info_t +{ int card_no[4]; //当前启动的卡控制器编号 int speed_mode[4]; //卡的速度模式,0:低速,其它:高速 int line_sel[4]; //卡的线制,0: 1线,其它,4线 int line_count[4]; //卡使用线的个数 -} -sdcard_spare_info; - +} +sdcard_spare_info; + typedef enum { STORAGE_NAND =0, STORAGE_SD, STORAGE_EMMC, - STORAGE_NOR + STORAGE_NOR, + STORAGE_EMMC3 }SUNXI_BOOT_STORAGE; - -#endif - - + +#endif + + diff --git a/SOFTWARE/A64-TERES/u-boot_new/include/sys_config.h b/SOFTWARE/A64-TERES/u-boot_new/include/sys_config.h index f36a64ae..1505e267 100644 --- a/SOFTWARE/A64-TERES/u-boot_new/include/sys_config.h +++ b/SOFTWARE/A64-TERES/u-boot_new/include/sys_config.h @@ -38,14 +38,21 @@ #define FDT_PATH_CARD0_BOOT_PARA "/soc/card0_boot_para" #define FDT_PATH_CARD2_BOOT_PARA "/soc/card2_boot_para" #define FDT_PATH_REGU "/soc/regu" +/* + * mmc2 and mmc3 can be use only one at same time on sun8iw10, so put mmc3's config at the same + * place with mmc2 to be compatile with other platforms. + */ +#define FDT_PATH_CARD3_BOOT_PARA "/soc/card2_boot_para" //for disp alias #define FDT_DISP_PATH "disp" #define FDT_HDMI_PATH "hdmi" #define FDT_LCD0_PATH "lcd0" #define FDT_LCD1_PATH "lcd1" +#define FDT_AC200_PATH "ac200" #define FDT_BOOT_DISP_PATH "boot_disp" - +#define FDT_TV0_PATH "tv0" +#define FDT_TV1_PATH "tv1" @@ -159,7 +166,7 @@ int fdt_get_one_gpio(const char* node_path, const char* prop_name,user_gpio_set_ int fdt_set_one_gpio(const char* node_path, const char* prop_name); //pin for use fdt //int fdt_get_pin_num(const char* node_path,const char* pinctrl_name); -//int fdt_get_all_pin(const char* node_path,const char* pinctrl_name,user_gpio_set_t* gpio_list); +int fdt_get_all_pin(int nodeoffset,const char* pinctrl_name,user_gpio_set_t* gpio_list); int fdt_set_all_pin(const char * node_path,const char * pinctrl_name); int fdt_set_all_pin_by_offset(int nodeoffset,const char* pinctrl_name); int fdt_set_pin_byname(user_gpio_set_t *pin_list,int pin_count, const char* pin_name);