995-rt2x00-mt7620-introduce-accessors-for-CHIP_VER-register.patch 4.5 KB

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