fix hal module load msg
[openwrt/svn-archive/archive.git] / package / madwifi / patches-r3776 / 318-ifxmips_eeprom.patch
1 --- a/ath_hal/ah_os.c
2 +++ b/ath_hal/ah_os.c
3 @@ -917,9 +917,56 @@
4 * NB: see the comments in ah_osdep.h about byte-swapping register
5 * reads and writes to understand what's going on below.
6 */
7 +
8 +#ifdef CONFIG_IFXMIPS
9 +extern int ifxmips_has_brn_block(void);
10 +static int ifxmips_emulate = 0;
11 +#define EEPROM_EMULATION 1
12 +#endif
13 +
14 +#ifdef EEPROM_EMULATION
15 +static int ath_hal_eeprom(struct ath_hal *ah, unsigned long addr, int val, int write)
16 +{
17 + static int addrsel = 0;
18 + static int rc = 0;
19 +
20 + if (write) {
21 + if(addr == 0x6000) {
22 + addrsel = val * 2;
23 + rc = 0;
24 + }
25 + } else {
26 + switch(addr)
27 + {
28 + case 0x600c:
29 + if(rc++ < 2)
30 + val = 0x00000000;
31 + else
32 + val = 0x00000002;
33 + break;
34 + case 0x6004:
35 + val = cpu_to_le16(__raw_readw((u16 *) KSEG1ADDR(0xb07f0400 + addrsel)));
36 + /* this forces the regdomain to 0x00 (worldwide), as the original setting
37 + * causes issues with the HAL */
38 + if (addrsel == 0x17e)
39 + val = 0;
40 + break;
41 + }
42 + }
43 + return val;
44 +}
45 +#endif
46 +
47 void __ahdecl
48 ath_hal_reg_write(struct ath_hal *ah, u_int address, u_int32_t value)
49 {
50 +#ifdef EEPROM_EMULATION
51 + if((address >= 0x6000) && (address <= 0x6010) && ifxmips_emulate) {
52 + ath_hal_eeprom(ah, address, value, 1);
53 + return;
54 + }
55 +#endif
56 +
57 _trace_regop(ah, REGOP_WRITE, address, value);
58 _OS_REG_WRITE(ah, address, value);
59 }
60 @@ -929,7 +976,14 @@
61 u_int32_t __ahdecl
62 ath_hal_reg_read(struct ath_hal *ah, u_int address)
63 {
64 - u_int32_t val = _OS_REG_READ(ah, address);
65 + u_int32_t val;
66 +
67 +#ifdef EEPROM_EMULATION
68 + if((address >= 0x6000) && (address <= 0x6010) && ifxmips_emulate)
69 + val = ath_hal_eeprom(ah, address, 0, 0);
70 + else
71 +#endif
72 + val = _OS_REG_READ(ah, address);
73 _trace_regop(ah, REGOP_READ, address, val);
74 return val;
75 }
76 @@ -1123,6 +1177,9 @@
77 #ifdef MMIOTRACE
78 kmmio_logmsg = _kmmio_logmsg;
79 #endif
80 +#ifdef CONFIG_IFXMIPS
81 + ifxmips_emulate = ifxmips_has_brn_block();
82 +#endif
83
84 sep = "";
85 for (i = 0; ath_hal_buildopts[i] != NULL; i++) {