1 /**
2   ******************************************************************************
3   * @file    rtl8721dlp_flashcfg.c
4   * @author
5   * @version V1.0.0
6   * @date    2018-09-12
7   * @brief   This file provides firmware functions to manage the following
8   *          functionalities:
9   *           - flash function config
10   ******************************************************************************
11   * @attention
12   *
13   * This module is a confidential and proprietary property of RealTek and
14   * possession or use of this module requires written permission of RealTek.
15   *
16   * Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
17   ******************************************************************************
18   */
19 
20 #include "ameba_soc.h"
21 
22 void flash_init_userdef(void);
23 
24 /**
25 * @brif Indicate the flash baudrate. It can be one of the following value:
26 *	0xFFFF: 80MHz
27 *	0x7FFF: 100MHz
28 *	0x3FFF: 67MHz
29 *	0x1FFF: 57MHz
30 *	0x0FFF: 50MHz
31 */
32 const u16 Flash_Speed = 0xFFFF;
33 
34 /**
35 * @brif Indicate the flash read I/O mode. It can be one of the following value:
36 *	0xFFFF: Read quad IO, Address & Data 4 bits mode
37 *	0x7FFF: Read quad O, Just data 4 bits mode
38 *	0x3FFF: Read dual IO, Address & Data 2 bits mode
39 *	0x1FFF: Read dual O, Just data 2 bits mode
40 *	0x0FFF: 1 bit mode
41 * @note If the configured read mode is not supported, other modes would be searched until find the appropriate mode.
42 */
43 const u16 Flash_ReadMode = 0xFFFF;
44 
45 
46 /**
47 * @brif Flash_AVL maintains the flash IC supported by SDK.
48 *	If users want to adpot new flash, add item in the following AVL.
49 *	Note that, if new flash can be classfied as one of the Realtek-defined categories according to Classification SPEC,
50 *	filling in the defined class index is necessary. Otherwise, FlashClassUser can be used to indicate new class.
51 */
52 const FlashInfo_TypeDef Flash_AVL[] = {
53 		/*flash_id,		flash_id_mask,	flash_class,		status_mask,	FlashInitHandler */
54 
55 		/* case1: Realtek defined class, any modification is not allowed */
56 		{0xEF,			0x000000FF,		FlashClass1,		0x000043FC,		NULL},	/* Winbond: MANUFACTURER_ID_WINBOND */
57 		{0xA1,			0x000000FF,		FlashClass1,		0x0000FFFC,		NULL}, 	/* Fudan Micro: MANUFACTURER_ID_FM */
58 		{0x0B,			0x000000FF,		FlashClass1,		0x000043FC,		NULL},	/* XTX */
59 		{0x0E,			0x000000FF,		FlashClass1,		0x000043FC,		NULL},	/* XTX(FT) */
60 		{0xC8,			0x000000FF,		FlashClass2,		0x000043FC,		NULL},	/* GD normal: MANUFACTURER_ID_GD */
61 		{0x28C2,		0x0000FFFF,		FlashClass6,		0x000200FC,		NULL},	/* MXIC wide-range VCC: MANUFACTURER_ID_MXIC */
62 		{0xC2,			0x000000FF,		FlashClass3,		0x000000FC,		NULL},	/* MXIC normal: MANUFACTURER_ID_BOHONG */
63 		{0x68,			0x000000FF,		FlashClass3,		0x000000FC,		NULL},	/* Hua Hong */
64 		{0x51,			0x000000FF,		FlashClass3,		0x000000FC,		NULL},	/* GD MD serial */
65 		{0x1C,			0x000000FF,		FlashClass4,		0x000000FC,		NULL},	/* ESMT: MANUFACTURER_ID_EON */
66 		{0x20,			0x000000FF,		FlashClass5,		0x000000FC,		NULL},	/* Microm: MANUFACTURER_ID_MICRON */
67 
68 		/* case2: new flash, ID is not included in case1 list, but specification is compatible with FlashClass1~FlashClass6 */
69 		//{0xXX,			0x0000XXXX,		FlashClassX,		0x0000XXXX,		NULL},
70 
71 		/* case3: new flash, ID is not included in case1 list, and specification is not compatible with FlashClass1~FlashClass6 */
72 		{0x00,			0x000000FF,		FlashClassUser,		0xFFFFFFFF,		&flash_init_userdef},
73 
74 		/* End */
75 		{0xFF,			0xFFFFFFFF,		FlashClassNone,		0xFFFFFFFF,		NULL},
76 };
77 
78 /**
79  * @brief  To adopt user defined class, need to initialize the parameters in the function below
80  *       with its default values according to flash Spec, and add additional config code if need.
81  * @param none.
82  * @retval none
83  * @note	The following parameter setting is an example of MXIC flash. For users reference.
84  */
flash_init_userdef(void)85 void flash_init_userdef(void)
86 {
87 	FLASH_InitTypeDef* FLASH_InitStruct = &flash_init_para;
88 
89 	/*1. Initialize CMD parameters */
90 
91 	FLASH_InitStruct->FLASH_Id = FLASH_ID_MXIC;
92 
93 	/*1.1 status bit define */
94 	FLASH_InitStruct->FLASH_QuadEn_bit = BIT(6);
95 	FLASH_InitStruct->FLASH_Busy_bit = BIT(0);
96 	FLASH_InitStruct->FLASH_WLE_bit = BIT(1);
97 	FLASH_InitStruct->FLASH_Status2_exist = 0;
98 
99 	/*1.2 dummy cycle */
100 	FLASH_InitStruct->FLASH_rd_dummy_cyle[0] = 0;
101 	FLASH_InitStruct->FLASH_rd_dummy_cyle[1] = 0x04;
102 	FLASH_InitStruct->FLASH_rd_dummy_cyle[2] = 0x06;
103 
104 	/*1.3 set 2bit mode cmd */
105 	FLASH_InitStruct->FLASH_rd_dual_io = 0xBB;
106 	FLASH_InitStruct->FLASH_rd_dual_o = 0x3B;
107 
108 	/*1.4 set 4bit mode cmd */
109 	FLASH_InitStruct->FLASH_rd_quad_io = 0xEB;
110 	FLASH_InitStruct->FLASH_rd_quad_o = 0x6B;
111 
112 	/*1.5 other flash commnad set */
113 	FLASH_InitStruct->FLASH_cmd_wr_en = 0x06;
114 	FLASH_InitStruct->FLASH_cmd_rd_id = 0x9F;
115 	FLASH_InitStruct->FLASH_cmd_rd_status = 0x05;
116 	FLASH_InitStruct->FLASH_cmd_rd_status2 = 0;
117 	FLASH_InitStruct->FLASH_cmd_wr_status = 0x01;
118 	FLASH_InitStruct->FLASH_cmd_wr_status2 = 0;
119 	FLASH_InitStruct->FLASH_cmd_chip_e = 0x60;
120 	FLASH_InitStruct->FLASH_cmd_block_e = 0xD8;
121 	FLASH_InitStruct->FLASH_cmd_sector_e = 0x20;
122 	FLASH_InitStruct->FLASH_cmd_pwdn_release = 0xAB;
123 	FLASH_InitStruct->FLASH_cmd_pwdn = 0xB9;
124 
125 	/*2. Add other configuration code here if needed for flash */
126 	//TODO
127 
128 }
129 
130 /******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
131