Skip to content

Commit f43f759

Browse files
committed
input: atmel_ptc: update for 6.4 firmware
Update for 6.4 firmware and rework firmware version checking. Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent 6c19cd7 commit f43f759

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

drivers/input/misc/atmel_ptc.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#define ATMEL_PTC_KEYCODE_BASE_OFFSET 0x100
3333

3434
/* ----- PPP ----- */
35-
#define ATMEL_PPP_FIRMWARE_NAME "atmel_ptc.bin"
35+
#define ATMEL_PPP_FW_NAME "atmel_ptc.bin"
36+
#define ATMEL_PPP_FW_FOOTER_SIZE 16
3637

3738
#define ATMEL_PPP_CONFIG 0x20
3839
#define ATMEL_PPP_CTRL 0x24
@@ -80,15 +81,15 @@
8081
#define ATMEL_QTM_SCROLLER_TYPE_SLIDER 0x0
8182
#define ATMEL_QTM_SCROLLER_TYPE_WHEEL 0x1
8283

83-
static char *firmware_file = ATMEL_PPP_FIRMWARE_NAME;
84+
static char *firmware_file = ATMEL_PPP_FW_NAME;
8485
static char *configuration_file = ATMEL_QTM_CONF_NAME;
8586
static bool debug_mode;
8687

8788
struct atmel_qtm_conf_header {
8889
u8 header_version_major;
8990
u8 header_version_minor;
9091
u32 header_size;
91-
char *firmware_version;
92+
char *fw_version;
9293
char *tool_version;
9394
char *date;
9495
char *description;
@@ -123,7 +124,7 @@ struct atmel_qtm_mailbox_map {
123124
unsigned int touch_events_scroller_event_id;
124125
};
125126

126-
static struct atmel_qtm_mailbox_map mailbox_map_v63 = {
127+
static struct atmel_qtm_mailbox_map mailbox_map_v64 = {
127128
.cmd_offset = 0x0,
128129
.cmd_id_offset = 0,
129130
.cmd_addr_offset = 2,
@@ -191,7 +192,7 @@ struct atmel_ptc {
191192
u32 button_event[ATMEL_PTC_MAX_NODES / 32];
192193
u32 button_state[ATMEL_PTC_MAX_NODES / 32];
193194
u32 scroller_event;
194-
char *firmware_version;
195+
char fw_version[ATMEL_PPP_FW_FOOTER_SIZE];
195196
};
196197

197198
static void atmel_ppp_irq_enable(struct atmel_ptc *ptc, u8 mask)
@@ -743,7 +744,7 @@ static int atmel_ptc_conf_load(struct atmel_ptc *ptc)
743744
switch (ptc->conf.header_version_major) {
744745
case (1):
745746
ptc->conf.header_size = 96;
746-
ptc->conf.firmware_version = (char *) conf->data + 16;
747+
ptc->conf.fw_version = (char *) conf->data + 16;
747748
ptc->conf.tool_version = (char *) conf->data + 32;
748749
ptc->conf.date = (char *) conf->data + 48;
749750
ptc->conf.description = (char *) conf->data + 64;
@@ -757,14 +758,17 @@ static int atmel_ptc_conf_load(struct atmel_ptc *ptc)
757758
};
758759

759760
dev_info(ptc->dev, "firmware version: %s, tool version: %s\n",
760-
ptc->conf.firmware_version, ptc->conf.tool_version);
761+
ptc->conf.fw_version, ptc->conf.tool_version);
761762
dev_info(ptc->dev, "date: %s, description: %s\n",
762763
ptc->conf.date, ptc->conf.description);
763764

764765
/*
765766
* TODO: check the version of the firmware loaded vs the version of the
766767
* firmware needed by the configuration file.
767768
*/
769+
if (strcmp(ptc->fw_version, ptc->conf.fw_version))
770+
dev_warn(ptc->dev, "be careful the configuration requires firmware %s, current firmware is %s\n",
771+
ptc->conf.fw_version, ptc->fw_version);
768772

769773
atmel_ppp_irq_enable(ptc, ATMEL_PPP_IRQ1);
770774
atmel_ppp_irq_disable(ptc, ATMEL_PPP_IRQ2 | ATMEL_PPP_IRQ3);
@@ -809,13 +813,14 @@ static int atmel_ptc_fw_load(struct atmel_ptc *ptc)
809813
return ret;
810814
}
811815

812-
/* TODO: ptc->firmware_version = */
813-
ptc->firmware_version = "PPP_VER_6.3";
816+
strncpy(ptc->fw_version, fw->data + fw->size - ATMEL_PPP_FW_FOOTER_SIZE,
817+
ATMEL_PPP_FW_FOOTER_SIZE);
818+
dev_dbg(ptc->dev, "version: %s\n", ptc->fw_version);
814819

815-
if (!strcmp(ptc->firmware_version, "PPP_VER_6.3")) {
816-
ptc->mb_map = &mailbox_map_v63;
820+
if (!strcmp(ptc->fw_version, "PPP_VER_006.004")) {
821+
ptc->mb_map = &mailbox_map_v64;
817822
} else {
818-
dev_err(ptc->dev, "unsupported firmware version: %s\n", ptc->firmware_version);
823+
dev_err(ptc->dev, "unsupported firmware version\n");
819824
ret = -EINVAL;
820825
goto out;
821826
}
@@ -1085,5 +1090,5 @@ MODULE_PARM_DESC(debug_mode, "The debug mode provides an interface to the mailbo
10851090
MODULE_AUTHOR("Ludovic Desroches <ludovic.desroches@microchip.com>");
10861091
MODULE_DESCRIPTION("Atmel PTC subsystem");
10871092
MODULE_LICENSE("GPL v2");
1088-
MODULE_FIRMWARE(ATMEL_PPP_FIRMWARE_NAME);
1093+
MODULE_FIRMWARE(ATMEL_PPP_FW_NAME);
10891094
MODULE_FIRMWARE(ATMEL_QTM_CONF_NAME);

0 commit comments

Comments
 (0)