@@ -407,6 +407,62 @@ static void eep_9287_dump_power_info(struct atheepmgr *aem)
407
407
#undef PR_TARGET_POWER
408
408
}
409
409
410
+ static bool eep_9287_update_eeprom (struct atheepmgr * aem , int param ,
411
+ const void * data )
412
+ {
413
+ struct eep_9287_priv * emp = aem -> eepmap_priv ;
414
+ struct ar9287_eeprom * eep = & emp -> eep ;
415
+ uint16_t * buf = aem -> eep_buf ;
416
+ int data_pos , data_len = 0 , addr , el ;
417
+ uint16_t sum ;
418
+
419
+ switch (param ) {
420
+ case EEP_UPDATE_MAC :
421
+ data_pos = AR9287_DATA_START_LOC +
422
+ EEP_FIELD_OFFSET (baseEepHeader .macAddr );
423
+ data_len = EEP_FIELD_SIZE (baseEepHeader .macAddr );
424
+ memcpy (& buf [data_pos ], data , data_len * sizeof (uint16_t ));
425
+ break ;
426
+ #ifdef CONFIG_I_KNOW_WHAT_I_AM_DOING
427
+ case EEP_ERASE_CTL :
428
+ /* It is enough to erase the CTL index only */
429
+ data_pos = AR9287_DATA_START_LOC + EEP_FIELD_OFFSET (ctlIndex );
430
+ data_len = EEP_FIELD_SIZE (ctlIndex );
431
+ for (addr = data_pos ; addr < (data_pos + data_len ); ++ addr )
432
+ buf [addr ] = 0x0000 ;
433
+ break ;
434
+ #endif
435
+ default :
436
+ fprintf (stderr , "Internal error: unknown parameter Id\n" );
437
+ return false;
438
+ }
439
+
440
+ /* Store updated data */
441
+ for (addr = data_pos ; addr < (data_pos + data_len ); ++ addr ) {
442
+ if (!EEP_WRITE (addr , buf [addr ])) {
443
+ fprintf (stderr , "Unable to write EEPROM data at 0x%04x\n" ,
444
+ addr );
445
+ return false;
446
+ }
447
+ }
448
+
449
+ /* Update checksum if need it */
450
+ if (data_pos > AR9287_DATA_START_LOC ) {
451
+ el = eep -> baseEepHeader .length / sizeof (uint16_t );
452
+ if (el > AR9287_DATA_SZ )
453
+ el = AR9287_DATA_SZ ;
454
+ buf [AR9287_DATA_CSUM_LOC ] = 0xffff ;
455
+ sum = eep_calc_csum (& buf [AR9287_DATA_START_LOC ], el );
456
+ buf [AR9287_DATA_CSUM_LOC ] = sum ;
457
+ if (!EEP_WRITE (AR9287_DATA_CSUM_LOC , sum )) {
458
+ fprintf (stderr , "Unable to update EEPROM checksum\n" );
459
+ return false;
460
+ }
461
+ }
462
+
463
+ return true;
464
+ }
465
+
410
466
const struct eepmap eepmap_9287 = {
411
467
.name = "9287" ,
412
468
.desc = "AR9287 chip EEPROM map" ,
@@ -424,4 +480,10 @@ const struct eepmap eepmap_9287 = {
424
480
[EEP_SECT_MODAL ] = eep_9287_dump_modal_header ,
425
481
[EEP_SECT_POWER ] = eep_9287_dump_power_info ,
426
482
},
483
+ .update_eeprom = eep_9287_update_eeprom ,
484
+ .params_mask = BIT (EEP_UPDATE_MAC )
485
+ #ifdef CONFIG_I_KNOW_WHAT_I_AM_DOING
486
+ | BIT (EEP_ERASE_CTL )
487
+ #endif
488
+ ,
427
489
};
0 commit comments