Andrew Duggan | 052556f | 2014-04-16 11:32:30 -0700 | [diff] [blame] | 1 | /* |
| 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 Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 18 | #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 | |
| 26 | class RMI4Update |
| 27 | { |
| 28 | public: |
| 29 | RMI4Update(RMIDevice & device, FirmwareImage & firmwareImage) : m_device(device), |
| 30 | m_firmwareImage(firmwareImage) |
| 31 | {} |
Satoshi Noguchi | a0b675a | 2014-09-29 02:38:14 -0700 | [diff] [blame^] | 32 | int UpdateFirmware(bool force = false, bool performLockdown = false); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 33 | |
| 34 | private: |
| 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 | |
| 45 | private: |
| 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_ |