summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6/net/spidupd.h
blob: b97b0015e92c18a7ee085a83a72f1e45b0f769dc (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * /net/spidupd.h
 *
 * (C) Copyright 2008 SPiDCOM Technologies
 *
 * 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
 *
 * Author(s):
 * Drasko DRASKOVIC, drasko.draskovic@spidcom.com
 */

#ifndef __SPIDUPD_H__
#define __SPIDUPD_H__

/* mme part of eth message is always in little endian byteorder */
# define mmetohl(x)	__le32_to_cpu(x)
# define mmetohs(x)	__le16_to_cpu(x)
# define htommel(x)	__cpu_to_le32(x)
# define htommes(x)	__cpu_to_le16(x)

#define MAX_MME_SIZE       (PKTSIZE - MME_HDR_SIZE)

#define MME_MMV             1         /* Management Message Version       */

/*
 *	SPIDUPD operations
 */

/* SPIDUPD Messages */
#define VS_UPDATE_START     0xA064
#define VS_UPDATE_TRANSFER  0xA068
#define VS_UPDATE_END       0xA06C

/* information about REQ, CNF IND or RSP is held in two LSBs */
#define VS_UPDATE_START_REQ     (VS_UPDATE_START | 0x0)
#define VS_UPDATE_START_CNF     (VS_UPDATE_START | 0x1)
#define VS_UPDATE_TRANSFER_REQ  (VS_UPDATE_TRANSFER | 0x0)
#define VS_UPDATE_TRANSFER_CNF  (VS_UPDATE_TRANSFER | 0x1)
#define VS_UPDATE_END_REQ       (VS_UPDATE_END | 0x0)
#define VS_UPDATE_END_CNF       (VS_UPDATE_END | 0x1)
#define VS_UPDATE_END_IND       (VS_UPDATE_END | 0x2)

#define VS_UPDATE_RANGE(type)   ((type >= VS_UPDATE_START) && (type <= VS_UPDATE_END))

/*
 * SPIDUPD Primitive types
 */
typedef struct
{
    unsigned char       version[16];        /* version string of the fw to send */
    unsigned long       arch;               /* modem arch type; default: 0 (spc300) */
    unsigned long       upd_type;           /* update type; default: 0 for normal image */
} __attribute__ ((__packed__)) VsUpdStartReq_t;

typedef struct
{
    unsigned char       start_update;       /* 0 - success, 0x1..0x5 - error messages */
} __attribute__ ((__packed__)) VsUpdStartCnf_t;

typedef struct
{
    unsigned int        block_id;               /* block ID of data to be sent */
    unsigned int        length;                 /* length of data to be sent */
    unsigned char       data[MAX_MME_SIZE - 8]; /* padded data (for min size of eth packet) */
} __attribute__ ((__packed__)) VsUpdTransfReq_t;

typedef struct
{
    unsigned char       ack;                    /* 0 - success, 0x1 - failure */
    unsigned int        next_block;             /* next block ID that server expects */
} __attribute__ ((__packed__)) VsUpdTransfCnf_t;

typedef struct
{
    unsigned char   md5_sum[16];                /* 0 - success, 0x1 - failure */
} __attribute__ ((__packed__)) VsUpdEndReq_t;

typedef struct
{
    unsigned char       result;                 /* 0 - success, 0x1 - failure */
} __attribute__ ((__packed__)) VsUpdEndCnf_t;

typedef struct
{
    unsigned char       result;                 /* 0 - success, 0x1..0x2 - error messages */
} __attribute__ ((__packed__)) VsUpdEndInd_t;


/* Failure codes in server response */
/* start_cnf */
#define SPIDUPD_OK              0x00
#define SPIDUPD_BAD_VERSION     0x01
#define SPIDUPD_BAD_ARCH        0x02
#define SPIDUPD_BAD_UPD_TYPE    0x03
#define SPIDUPD_MODEM_BUSY      0x04

/* transfer_cnf and end_cnf */
#define SPIDUPD_SUCCESS         0x00
#define SPIDUPD_FAILURE         0x01

/* end_cnf */
#define SPIDUPD_MD5_ERROR           0x01
#define SPIDUPD_FLASH_WRITE_ERROR   0x02

/* end_ind */
#define SPIDUPD_TOUT                0x03



/**********************************************************************/
/*
 *	Global functions and variables.
 */

/* spidupd.c */
extern void SpidupdStart (void);        /* Begin SPIDUPD get */

/**********************************************************************/

#endif /* __SPIDUPD_H__ */