b3828052e9a7796762077d13da6ac94c69e737ea
[openwrt/openwrt.git] /
1 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
2 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
3 @@ -76,6 +76,9 @@ struct rt2800_ops {
4 int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
5 __le32 *(*drv_get_txwi)(struct queue_entry *entry);
6 unsigned int (*drv_get_dma_done)(struct data_queue *queue);
7 + int (*hw_get_chippkg)(void);
8 + int (*hw_get_chipver)(void);
9 + int (*hw_get_chipeco)(void);
10 };
11
12 static inline u32 rt2800_register_read(struct rt2x00_dev *rt2x00dev,
13 @@ -184,6 +187,27 @@ static inline unsigned int rt2800_drv_ge
14 return rt2800ops->drv_get_dma_done(queue);
15 }
16
17 +static inline int rt2800_hw_get_chippkg(struct rt2x00_dev *rt2x00dev)
18 +{
19 + const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
20 +
21 + return rt2800ops->hw_get_chippkg();
22 +}
23 +
24 +static inline int rt2800_hw_get_chipver(struct rt2x00_dev *rt2x00dev)
25 +{
26 + const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
27 +
28 + return rt2800ops->hw_get_chipver();
29 +}
30 +
31 +static inline int rt2800_hw_get_chipeco(struct rt2x00_dev *rt2x00dev)
32 +{
33 + const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv;
34 +
35 + return rt2800ops->hw_get_chipeco();
36 +}
37 +
38 void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
39 const u8 command, const u8 token,
40 const u8 arg0, const u8 arg1);
41 --- a/drivers/net/wireless/ralink/rt2x00/rt2800pci.c
42 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800pci.c
43 @@ -286,6 +286,10 @@ static int rt2800pci_read_eeprom(struct
44 return retval;
45 }
46
47 +static int rt2800pci_get_chippkg(void) { return 0; }
48 +static int rt2800pci_get_chipver(void) { return 0; }
49 +static int rt2800pci_get_chipeco(void) { return 0; }
50 +
51 static const struct ieee80211_ops rt2800pci_mac80211_ops = {
52 .add_chanctx = ieee80211_emulate_add_chanctx,
53 .remove_chanctx = ieee80211_emulate_remove_chanctx,
54 @@ -333,6 +337,9 @@ static const struct rt2800_ops rt2800pci
55 .drv_init_registers = rt2800mmio_init_registers,
56 .drv_get_txwi = rt2800mmio_get_txwi,
57 .drv_get_dma_done = rt2800mmio_get_dma_done,
58 + .hw_get_chippkg = rt2800pci_get_chippkg,
59 + .hw_get_chipver = rt2800pci_get_chipver,
60 + .hw_get_chipeco = rt2800pci_get_chipeco,
61 };
62
63 static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
64 --- a/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
65 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800soc.c
66 @@ -27,6 +27,12 @@
67 #include "rt2800lib.h"
68 #include "rt2800mmio.h"
69
70 +/* Needed to probe CHIP_VER register on MT7620 */
71 +#ifdef CONFIG_SOC_MT7620
72 +#include <asm/mach-ralink/ralink_regs.h>
73 +#include <asm/mach-ralink/mt7620.h>
74 +#endif
75 +
76 /* Allow hardware encryption to be disabled. */
77 static bool modparam_nohwcrypt;
78 module_param_named(nohwcrypt, modparam_nohwcrypt, bool, 0444);
79 @@ -118,6 +124,27 @@ static int rt2800soc_write_firmware(stru
80 return 0;
81 }
82
83 +#ifdef CONFIG_SOC_MT7620
84 +static int rt2800soc_get_chippkg(void)
85 +{
86 + return mt7620_get_pkg();
87 +}
88 +
89 +static int rt2800soc_get_chipver(void)
90 +{
91 + return mt7620_get_chipver();
92 +}
93 +
94 +static int rt2800soc_get_chipeco(void)
95 +{
96 + return mt7620_get_eco();
97 +}
98 +#else
99 +static int rt2800soc_get_chippkg(void) { return 0; }
100 +static int rt2800soc_get_chipver(void) { return 0; }
101 +static int rt2800soc_get_chipeco(void) { return 0; }
102 +#endif
103 +
104 static const struct ieee80211_ops rt2800soc_mac80211_ops = {
105 .add_chanctx = ieee80211_emulate_add_chanctx,
106 .remove_chanctx = ieee80211_emulate_remove_chanctx,
107 @@ -165,6 +192,9 @@ static const struct rt2800_ops rt2800soc
108 .drv_init_registers = rt2800mmio_init_registers,
109 .drv_get_txwi = rt2800mmio_get_txwi,
110 .drv_get_dma_done = rt2800mmio_get_dma_done,
111 + .hw_get_chippkg = rt2800soc_get_chippkg,
112 + .hw_get_chipver = rt2800soc_get_chipver,
113 + .hw_get_chipeco = rt2800soc_get_chipeco,
114 };
115
116 static const struct rt2x00lib_ops rt2800soc_rt2x00_ops = {
117 --- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
118 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
119 @@ -628,6 +628,10 @@ static int rt2800usb_probe_hw(struct rt2
120 return 0;
121 }
122
123 +static int rt2800usb_get_chippkg(void) { return 0; }
124 +static int rt2800usb_get_chipver(void) { return 0; }
125 +static int rt2800usb_get_chipeco(void) { return 0; }
126 +
127 static const struct ieee80211_ops rt2800usb_mac80211_ops = {
128 .add_chanctx = ieee80211_emulate_add_chanctx,
129 .remove_chanctx = ieee80211_emulate_remove_chanctx,
130 @@ -676,6 +680,9 @@ static const struct rt2800_ops rt2800usb
131 .drv_init_registers = rt2800usb_init_registers,
132 .drv_get_txwi = rt2800usb_get_txwi,
133 .drv_get_dma_done = rt2800usb_get_dma_done,
134 + .hw_get_chippkg = rt2800usb_get_chippkg,
135 + .hw_get_chipver = rt2800usb_get_chipver,
136 + .hw_get_chipeco = rt2800usb_get_chipeco,
137 };
138
139 static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {