Skip to content

Commit

Permalink
ath9k: Allow using the reset API for the external reset
Browse files Browse the repository at this point in the history
Allow using the reset API instead of a platform specific callback to
reset the device.

Signed-off-by: Alban Bedel <albeu@free.fr>
---
Changelog:
v2: * Fixed From/SoB to have my full name
  • Loading branch information
AlbanBedel committed Mar 24, 2018
1 parent aab2db9 commit 71668f9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
26 changes: 21 additions & 5 deletions drivers/net/wireless/ath/ath9k/hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/bitops.h>
#include <linux/etherdevice.h>
#include <linux/gpio.h>
#include <linux/reset.h>
#include <asm/unaligned.h>

#include "hw.h"
Expand Down Expand Up @@ -551,6 +552,24 @@ static int ath9k_hw_attach_ops(struct ath_hw *ah)
return 0;
}

static int ath9k_hw_external_reset(struct ath_hw *ah)
{
int ret = 0;

ath_dbg(ath9k_hw_common(ah), RESET,
"reset MAC via external reset\n");

if (ah->external_reset) {
ret = ah->external_reset();
} else if (ah->reset) {
ret = reset_control_assert(ah->reset);
if (!ret)
ret = reset_control_deassert(ah->reset);
}

return ret;
}

/* Called for all hardware families */
static int __ath9k_hw_init(struct ath_hw *ah)
{
Expand Down Expand Up @@ -1305,14 +1324,11 @@ static bool ath9k_hw_ar9330_reset_war(struct ath_hw *ah, int type)
break;
}

if (ah->external_reset &&
if ((ah->reset || ah->external_reset) &&
(npend || type == ATH9K_RESET_COLD)) {
int reset_err = 0;

ath_dbg(ath9k_hw_common(ah), RESET,
"reset MAC via external reset\n");

reset_err = ah->external_reset();
reset_err = ath9k_hw_external_reset(ah);
if (reset_err) {
ath_err(ath9k_hw_common(ah),
"External reset failed, err=%d\n",
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/ath/ath9k/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ struct ath_hw {
bool is_clk_25mhz;
int (*get_mac_revision)(void);
int (*external_reset)(void);
struct reset_control *reset;
bool disable_2ghz;
bool disable_5ghz;

Expand Down
10 changes: 10 additions & 0 deletions drivers/net/wireless/ath/ath9k/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/relay.h>
#include <linux/dmi.h>
#include <linux/clk.h>
#include <linux/reset.h>
#include <net/ieee80211_radiotap.h>

#include "ath9k.h"
Expand Down Expand Up @@ -752,6 +753,15 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
if (!is_valid_ether_addr(common->macaddr))
ath9k_get_nvmem_address(sc);

/* Try to get a reset controller */
ah->reset = devm_reset_control_get_optional(sc->dev, NULL);
if (IS_ERR(ah->reset)) {
if (PTR_ERR(ah->reset) != -ENOENT &&
PTR_ERR(ah->reset) != -ENOTSUPP)
return PTR_ERR(ah->reset);
ah->reset = NULL;
}

/* If the EEPROM hasn't been retrieved via firmware request
* use the nvmem API insted.
*/
Expand Down

0 comments on commit 71668f9

Please sign in to comment.