@@ -84,6 +84,16 @@ static char *firmware_file = ATMEL_PPP_FIRMWARE_NAME;
8484static char * configuration_file = ATMEL_QTM_CONF_NAME ;
8585static bool debug_mode ;
8686
87+ struct atmel_qtm_conf_header {
88+ u8 header_version_major ;
89+ u8 header_version_minor ;
90+ u32 header_size ;
91+ char * firmware_version ;
92+ char * tool_version ;
93+ char * date ;
94+ char * description ;
95+ };
96+
8797/* Depends on firmware version */
8898struct atmel_qtm_mailbox_map {
8999 unsigned int cmd_offset ;
@@ -114,7 +124,7 @@ struct atmel_qtm_mailbox_map {
114124 unsigned int touch_events_scroller_event_id ;
115125};
116126
117- static struct atmel_qtm_mailbox_map mailbox_map_v61 = {
127+ static struct atmel_qtm_mailbox_map mailbox_map_v63 = {
118128 .cmd_offset = 0x0 ,
119129 .cmd_id_offset = 0 ,
120130 .cmd_addr_offset = 2 ,
@@ -169,6 +179,7 @@ struct atmel_ptc {
169179 struct device * dev ;
170180 struct input_dev * buttons_input ;
171181 struct input_dev * scroller_input [ATMEL_PTC_MAX_SCROLLERS ];
182+ struct atmel_qtm_conf_header conf ;
172183 struct atmel_qtm_mailbox_map * mb_map ;
173184 const struct atmel_ptc_pins * pins ;
174185 bool * x_lines_requested ;
@@ -182,7 +193,7 @@ struct atmel_ptc {
182193 u32 button_event [ATMEL_PTC_MAX_NODES / 32 ];
183194 u32 button_state [ATMEL_PTC_MAX_NODES / 32 ];
184195 u32 scroller_event ;
185- u32 firmware_version ;
196+ char * firmware_version ;
186197};
187198
188199static void atmel_ppp_irq_enable (struct atmel_ptc * ptc , u8 mask )
@@ -738,6 +749,34 @@ static int atmel_ptc_conf_load(struct atmel_ptc *ptc)
738749 return ret ;
739750 }
740751
752+ ptc -> conf .header_version_major = conf -> data [0 ];
753+ ptc -> conf .header_version_minor = conf -> data [1 ];
754+ switch (ptc -> conf .header_version_major ) {
755+ case (1 ):
756+ ptc -> conf .header_size = 96 ;
757+ ptc -> conf .firmware_version = (char * ) conf -> data + 16 ;
758+ ptc -> conf .tool_version = (char * ) conf -> data + 32 ;
759+ ptc -> conf .date = (char * ) conf -> data + 48 ;
760+ ptc -> conf .description = (char * ) conf -> data + 64 ;
761+ break ;
762+ default :
763+ release_firmware (conf );
764+ dev_err (ptc -> dev , "Unsupported header version: %u.%u\n" ,
765+ ptc -> conf .header_version_major ,
766+ ptc -> conf .header_version_minor );
767+ return - EINVAL ;
768+ };
769+
770+ dev_info (ptc -> dev , "firmware version: %s, tool version: %s\n" ,
771+ ptc -> conf .firmware_version , ptc -> conf .tool_version );
772+ dev_info (ptc -> dev , "date: %s, description: %s\n" ,
773+ ptc -> conf .date , ptc -> conf .description );
774+
775+ /*
776+ * TODO: check the version of the firmware loaded vs the version of the
777+ * firmware needed by the configuration file.
778+ */
779+
741780 atmel_ppp_irq_enable (ptc , ATMEL_PPP_IRQ1 );
742781 atmel_ppp_irq_disable (ptc , ATMEL_PPP_IRQ2 | ATMEL_PPP_IRQ3 );
743782
@@ -746,7 +785,8 @@ static int atmel_ptc_conf_load(struct atmel_ptc *ptc)
746785
747786 dst = (char * )ptc -> qtm_mb ;
748787 /* Need to use _memcpy_toio, otherwise configuration is not well loaded. */
749- _memcpy_toio (dst , conf -> data + 64 , conf -> size - 64 ); /* Header size, cleanup needed. */
788+ _memcpy_toio (dst , conf -> data + ptc -> conf .header_size ,
789+ conf -> size - ptc -> conf .header_size );
750790
751791 key_count = atmel_qtm_get_key_count (ptc );
752792
@@ -771,7 +811,6 @@ static int atmel_ptc_conf_load(struct atmel_ptc *ptc)
771811static int atmel_ptc_fw_load (struct atmel_ptc * ptc )
772812{
773813 const struct firmware * fw ;
774- struct atmel_qtm_cmd cmd ;
775814 int ret ;
776815
777816 dev_dbg (ptc -> dev , "loading firmware: %s\n" , firmware_file );
@@ -781,16 +820,13 @@ static int atmel_ptc_fw_load(struct atmel_ptc *ptc)
781820 return ret ;
782821 }
783822
784- /* TODO */
785- ptc -> firmware_version = 61 ;
786- dev_dbg (ptc -> dev , "firmware version: %u\n" , ptc -> firmware_version );
823+ /* TODO: ptc->firmware_version = */
824+ ptc -> firmware_version = "PPP_VER_6.3" ;
787825
788- switch (ptc -> firmware_version ) {
789- case 61 :
790- ptc -> mb_map = & mailbox_map_v61 ;
791- break ;
792- default :
793- dev_err (ptc -> dev , "unsupported firmware version: %u\n" , ptc -> firmware_version );
826+ if (!strcmp (ptc -> firmware_version , "PPP_VER_6.3" )) {
827+ ptc -> mb_map = & mailbox_map_v63 ;
828+ } else {
829+ dev_err (ptc -> dev , "unsupported firmware version: %s\n" , ptc -> firmware_version );
794830 ret = - EINVAL ;
795831 goto out ;
796832 }
@@ -808,13 +844,6 @@ static int atmel_ptc_fw_load(struct atmel_ptc *ptc)
808844
809845 atmel_ppp_cmd_send (ptc , ATMEL_PPP_CMD_RUN );
810846
811- cmd .id = ATMEL_QTM_CMD_FIRM_VERSION ;
812- atmel_ptc_cmd_send (ptc , & cmd );
813- if (cmd .data != ptc -> firmware_version ) {
814- dev_err (ptc -> dev , "invalid firmware\n" );
815- ret = - EINVAL ;
816- }
817-
818847out :
819848 release_firmware (fw );
820849 return ret ;
0 commit comments