blob: b59dfc95786f23b1bb42f4d003e239f9638a45be [file] [log] [blame]
Andrew Duggan052556f2014-04-16 11:32:30 -07001/*
2 * Copyright (C) 2014 Andrew Duggan
3 * Copyright (C) 2014 Synaptics Inc
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
Andrew Duggan4e811252014-04-03 15:17:57 -070018#ifndef _RMI4UPDATE_H_
19#define _RMI4UPDATE_H_
20
21#include "rmidevice.h"
22#include "firmware_image.h"
23
24#define RMI_BOOTLOADER_ID_SIZE 2
25
26class RMI4Update
27{
28public:
29 RMI4Update(RMIDevice & device, FirmwareImage & firmwareImage) : m_device(device),
30 m_firmwareImage(firmwareImage)
31 {}
32 int UpdateFirmware(bool force = false);
33
34private:
35 int FindUpdateFunctions();
36 int ReadF34Queries();
37 int ReadF34Controls();
38 int WriteBootloaderID();
39 int EnterFlashProgramming();
40 int WriteBlocks(unsigned char *block, unsigned short count, unsigned char cmd);
41 int WaitForIdle(int timeout_ms);
42 int GetFirmwareSize() { return m_blockSize * m_fwBlockCount; }
43 int GetConfigSize() { return m_blockSize * m_configBlockCount; }
44
45private:
46 RMIDevice & m_device;
47 FirmwareImage & m_firmwareImage;
48
49 RMIFunction m_f01;
50 RMIFunction m_f34;
51
52 unsigned char m_deviceStatus;
53 unsigned char m_bootloaderID[RMI_BOOTLOADER_ID_SIZE];
54
55 /* F34 Controls */
56 unsigned char m_f34Command;
57 unsigned char m_f34Status;
58 bool m_programEnabled;
59
60 /* F34 Query */
61 bool m_hasNewRegmap;
62 bool m_unlocked;
63 bool m_hasConfigID;
64 unsigned short m_blockSize;
65 unsigned short m_fwBlockCount;
66 unsigned short m_configBlockCount;
67
68 unsigned short m_f34StatusAddr;
69};
70
71#endif // _RMI4UPDATE_H_