1 #include "mcu_command.h"
2 #include <asm/arch/packet.h>
3 #include <linux/string.h>
4 #include <asm/arch/sci_types.h>
5 #include <asm/arch/sc_reg.h>
7 #include <asm/arch/cmddef.h>
8 #include <asm/arch/mocor_boot_mode.h>
9 #include <asm/arch/chip.h>
11 #ifndef HWRST_STATUS_NORMAL
12 #define HWRST_STATUS_NORMAL (0X40)
16 typedef void (*BOOT_ENTRY) (void);
18 /*****************************************************************************/
19 // Description: This function Reset MCU
20 // Author: Haifeng.Yang
22 /*****************************************************************************/
25 // Set watchdog reset flag
26 BOOT_ResetHWVal (HWRST_STATUS_NORMAL);
27 BOOT_SetWDGHWFlag (TYPE_RESET, AUTO_TEST_MODE);
28 // Reset the system via watchdog timeout
33 /* Sorry, I don't know what this function is for.
35 * Ming.Zhang 2005-09-22
37 static void FDL_ResetMcuClock (void)
40 #define REG(r) (*((volatile unsigned int*)(r)))
42 REG (0x8b000018) |= 1 << 9; // write pll enable
43 REG (0x8b000024) = 0x1E05; // M/N = 5, so clock = 78M
44 REG (0x8b000018) &= ~ (1 << 9); // write pll disable
46 REG (GR_PCTL) = (unsigned int) (0x0A55);
47 #endif /* MCU_CLK_52M */
50 int FDL_McuResetBoot (PACKET_T *pakcet, void *arg)
53 BOOT_ENTRY boot_entry = (BOOT_ENTRY) 0; /* The address of ROM Code */
55 FDL_SendAckPacket (BSL_REP_ACK);
57 /* Wait until all characters are sent out. */
58 for (i=0; i<0x0A000; i++)
65 /* Jump to ROM code */
66 (*boot_entry) (); /*lint !e413*/
68 /* We should not go here */
72 int FDL_McuResetNormal (PACKET_T *packet, void *arg)
75 //BOOT_ENTRY boot_entry = (BOOT_ENTRY) 0x40000000; /* Start of internal RAM */
78 /* Copy NBL to internal RAM */
79 if (NAND_SUCCESS != nand_read_NBL ( (void *) boot_entry))
81 send_ack_packet (BSL_REP_OPERATION_FAILED);
86 FDL_SendAckPacket (BSL_REP_ACK);
88 /* Wait until all characters are sent out. */
89 for (i=0; i<0x0A000; i++)
97 /* We should not go here */
101 int FDL_McuReadChipType (PACKET_T *packet, void *arg)
106 id = * (unsigned int *) (0x4FFC);
108 if (0x660000B6 != id)
110 // @Richard We should check if we want to support 6600C
118 packet->packet_body.type = BSL_REP_READ_CHIP_TYPE;
119 packet->packet_body.size = 4;
120 memcpy (packet->packet_body.content, &id, sizeof (unsigned int));
122 FDL_SendPacket (packet);
125 /*unsigned int EndianModify (unsigned int value)
127 unsigned int nTmp = 0;
128 nTmp = (value >> 24 | value << 24);
129 nTmp |= ( (value >> 8) & 0x0000FF00);
130 nTmp |= ( (value << 8) & 0x00FF0000);
133 int FDL_McuReadMcpType (PACKET_T *packet, void *arg)
135 unsigned int pagesize;
136 unsigned int blocksize;
138 char temp[sizeof(struct MCP_TYPE)];
139 struct mtd_info *nand ;
140 struct MCP_TYPE mcp_type;
142 if ((nand_curr_device < 0) || (nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) {
143 printf("--->get curr nand device failed<---\n");
146 nand =&nand_info[nand_curr_device];
147 pagesize = nand->writesize;
148 blocksize = nand->erasesize;
150 mcp_type.pagesize = pagesize;
151 mcp_type.blocksize = blocksize;
152 size = sizeof(struct MCP_TYPE);
153 packet->packet_body.type = BSL_REP_READ_MCP_TYPE;
154 packet->packet_body.size = 12;
155 memcpy(packet->packet_body.content, &mcp_type,size);
156 for(i=0 ; i<size ;i++)
157 temp[i] = packet->packet_body.content[i];
158 for(i=0; i<size; i++){
161 packet->packet_body.content[i]=temp[--j];
163 FDL_SendPacket (packet);