source: trunk/package/madwifi/patches/354-ifxmips_eeprom.patch @ 27662

Last change on this file since 27662 was 27662, checked in by blogic, 5 years ago

better lantiq support in madwifi

Allow for each lantiq target (without wifi eeprom) to define where
wireless configuration data is on flash. Patch also adds support for
sx763 lantiq target.

Signed-off-by: Luka Perkov <openwrt@…>

File size: 2.3 KB
  • ath_hal/ah_os.c

    a b EXPORT_SYMBOL(ath_hal_func); 
    343343 * NB: see the comments in ah_osdep.h about byte-swapping register 
    344344 *     reads and writes to understand what's going on below. 
    345345 */ 
     346 
     347#ifdef CONFIG_LANTIQ 
     348extern int lantiq_emulate_madwifi_eep; 
     349extern unsigned long long lantiq_madwifi_eep_addr; 
     350#define EEPROM_EMULATION 1 
     351#endif 
     352 
     353#ifdef EEPROM_EMULATION 
     354static int ath_hal_eeprom(struct ath_hal *ah, unsigned long addr, int val, int write) 
     355{ 
     356        static int addrsel = 0; 
     357        static int rc = 0; 
     358 
     359        if (write) { 
     360                if(addr == 0x6000) { 
     361                        addrsel = val * 2; 
     362                        rc = 0; 
     363                } 
     364        } else { 
     365                switch(addr) 
     366                { 
     367                case 0x600c: 
     368                        if(rc++ < 2) 
     369                                val = 0x00000000; 
     370                        else 
     371                                val = 0x00000002; 
     372                        break; 
     373                case 0x6004: 
     374                        val = cpu_to_le16(__raw_readw((u16 *) KSEG1ADDR(lantiq_madwifi_eep_addr + addrsel))); 
     375                        /* this forces the regdomain to 0x00 (worldwide), as the original setting 
     376                         * causes issues with the HAL */ 
     377                        if (addrsel == 0x17e) 
     378                                val = 0; 
     379                        break; 
     380                } 
     381        } 
     382        return val; 
     383} 
     384#endif 
     385 
    346386void __ahdecl 
    347387ath_hal_reg_write(struct ath_hal *ah, u_int reg, u_int32_t val) 
    348388{ 
    ath_hal_reg_write(struct ath_hal *ah, u_ 
    351391                ath_hal_printf(ah, "%s: WRITE 0x%x <= 0x%x\n",  
    352392                                (ath_hal_func ?: "unknown"), reg, val); 
    353393#endif 
    354         _OS_REG_WRITE(ah, reg, val); 
     394#ifdef EEPROM_EMULATION 
     395        if((reg >= 0x6000) && (reg <= 0x6010) && lantiq_emulate_madwifi_eep) 
     396        { 
     397                val = ath_hal_eeprom(ah, reg, val, 1); 
     398        } else 
     399#endif 
     400                _OS_REG_WRITE(ah, reg, val); 
    355401} 
    356402EXPORT_SYMBOL(ath_hal_reg_write); 
    357403 
     404 
    358405/* This should only be called while holding the lock, sc->sc_hal_lock. */ 
    359406u_int32_t __ahdecl 
    360407ath_hal_reg_read(struct ath_hal *ah, u_int reg) 
    361408{ 
    362         u_int32_t val; 
     409        u_int32_t val; 
     410#ifdef EEPROM_EMULATION 
     411        if((reg >= 0x6000) && (reg <= 0x6010) && lantiq_emulate_madwifi_eep) 
     412        { 
     413                val = ath_hal_eeprom(ah, reg, 0, 0); 
     414        } else 
     415#endif 
     416                val = _OS_REG_READ(ah, reg); 
    363417 
    364         val = _OS_REG_READ(ah, reg); 
    365418#ifdef AH_DEBUG 
    366419        if (ath_hal_debug > 1) 
    367                 ath_hal_printf(ah, "%s: READ 0x%x => 0x%x\n",  
     420                ath_hal_printf(ah, "%s: READ 0x%x => 0x%x\n", 
    368421                                (ath_hal_func ?: "unknown"), reg, val); 
    369422#endif 
    370423        return val; 
    init_ath_hal(void) 
    581634{ 
    582635        const char *sep; 
    583636        int i; 
    584  
    585637        printk(KERN_INFO "%s: %s (", dev_info, ath_hal_version); 
    586638        sep = ""; 
    587639        for (i = 0; ath_hal_buildopts[i] != NULL; i++) { 
Note: See TracBrowser for help on using the repository browser.