summaryrefslogtreecommitdiff
path: root/drivers/media/platform/imx8/mcu_firmware.h
blob: de06baedd10fbc268137000c5a4501d76b421b35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _MCU_FIRMWARE_H
#define _MCU_FIRMWARE_H

/*   Local Defines */
#define MAX_BUF_LEN 2048

#define MAX_PAGES 			512
#define TOTAL_PAGES 		1536
#define NUM_ERASE_CYCLES	(TOTAL_PAGES / MAX_PAGES)

#define FLASH_START_ADDRESS 0x08000000
#define FLASH_SIZE 			192*1024
#define FLASH_READ_LEN		256

#define CR 13                   /*   Carriage return */
#define LF 10                   /*   Line feed */

/*MCU Buffer size increased - Fix for loading menu based controls */
#define MCU_BUFFER_SIZE 1024

/*   TODO: Only necessary commands added */
enum _i2c_cmds
{
        BL_GET_VERSION = 0x01,
        BL_GO = 0x21,
        BL_READ_MEM = 0x11,
        BL_WRITE_MEM = 0x31,
        BL_WRITE_MEM_NS = 0x32,
        BL_ERASE_MEM = 0x44,
        BL_ERASE_MEM_NS = 0x45,
};

enum _i2c_resp
{
        RESP_ACK = 0x79,
        RESP_NACK = 0x1F,
        RESP_BUSY = 0x76,
};

enum
{
	NUM_LANES_1 = 0x01,
	NUM_LANES_2 = 0x02,
	NUM_LANES_3 = 0x03,
	NUM_LANES_4 = 0x04,
	NUM_LANES_UNKWN = 0xFF,
};

enum _ihex_rectype
{
        /*   Normal data */
        REC_TYPE_DATA = 0x00,
        /*  End of File */
        REC_TYPE_EOF = 0x01,

        /*   Extended Segment Address */
        REC_TYPE_ESA = 0x02,
        /*   Start Segment Address */
        REC_TYPE_SSA = 0x03,

        /*   Extended Linear Address */
        REC_TYPE_ELA = 0x04,
        /*   Start Linear Address */
        REC_TYPE_SLA = 0x05,
};

typedef struct __attribute__ ((packed)) _ihex_rec {
        unsigned char datasize;
        unsigned short int addr;
        unsigned char rectype;
        unsigned char recdata[];
} IHEX_RECORD;

unsigned int g_bload_flashaddr = 0x0000;

uint8_t *fw_version = NULL;

/* MCU communication variables */
unsigned char mc_data[MCU_BUFFER_SIZE];
unsigned char mc_ret_data[MCU_BUFFER_SIZE];

/*   Buffer to Send Bootloader CMDs */
unsigned char g_bload_buf[MAX_BUF_LEN] = { 0 };

unsigned short int g_bload_crc16 = 0x0000;

const char g_mcu_fw_buf[] =
#include "ecam50_cam_fw.txt"
    ;

#endif                          //_MCU_FIRMWARE_H