blob: eaad0f6dd756d6d1d0728e0312aa199cef342df4 [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),
Andrew Duggan83b0e1f2015-10-12 12:23:14 -070030 m_firmwareImage(firmwareImage), m_writeBlockWithCmd(true)
Andrew Duggan4e811252014-04-03 15:17:57 -070031 {}
Satoshi Noguchia0b675a2014-09-29 02:38:14 -070032 int UpdateFirmware(bool force = false, bool performLockdown = false);
Andrew Duggan4e811252014-04-03 15:17:57 -070033
34private:
Andrew Duggandc838552014-11-11 07:58:09 -080035 int DisableNonessentialInterupts();
Andrew Duggan4e811252014-04-03 15:17:57 -070036 int FindUpdateFunctions();
37 int ReadF34Queries();
38 int ReadF34Controls();
39 int WriteBootloaderID();
40 int EnterFlashProgramming();
41 int WriteBlocks(unsigned char *block, unsigned short count, unsigned char cmd);
Andrew Duggan83b0e1f2015-10-12 12:23:14 -070042 int WaitForIdle(int timeout_ms, bool readF34OnSucess = true);
Andrew Duggan4e811252014-04-03 15:17:57 -070043 int GetFirmwareSize() { return m_blockSize * m_fwBlockCount; }
44 int GetConfigSize() { return m_blockSize * m_configBlockCount; }
45
46private:
47 RMIDevice & m_device;
48 FirmwareImage & m_firmwareImage;
49
50 RMIFunction m_f01;
51 RMIFunction m_f34;
52
53 unsigned char m_deviceStatus;
54 unsigned char m_bootloaderID[RMI_BOOTLOADER_ID_SIZE];
Andrew Duggan83b0e1f2015-10-12 12:23:14 -070055 bool m_writeBlockWithCmd;
Andrew Duggan4e811252014-04-03 15:17:57 -070056
57 /* F34 Controls */
58 unsigned char m_f34Command;
59 unsigned char m_f34Status;
60 bool m_programEnabled;
61
62 /* F34 Query */
63 bool m_hasNewRegmap;
64 bool m_unlocked;
65 bool m_hasConfigID;
66 unsigned short m_blockSize;
67 unsigned short m_fwBlockCount;
68 unsigned short m_configBlockCount;
69
70 unsigned short m_f34StatusAddr;
71};
72
73#endif // _RMI4UPDATE_H_