ar71xx: reorganize 4.1 patch directory layout
[openwrt.git] / target / linux / ar71xx / patches-4.1 / 613-MIPS-ath79-add-ath79_wmac_setup_ext_lna_gpio-helper.patch
1 --- a/arch/mips/ath79/dev-wmac.c
2 +++ b/arch/mips/ath79/dev-wmac.c
3 @@ -18,9 +18,11 @@
4  #include <linux/etherdevice.h>
5  #include <linux/platform_device.h>
6  #include <linux/ath9k_platform.h>
7 +#include <linux/gpio.h>
8  
9  #include <asm/mach-ath79/ath79.h>
10  #include <asm/mach-ath79/ar71xx_regs.h>
11 +#include "common.h"
12  #include "dev-wmac.h"
13  
14  static u8 ath79_wmac_mac[ETH_ALEN];
15 @@ -313,6 +315,51 @@ void __init ath79_wmac_set_tx_gain_buffa
16         ath79_wmac_data.tx_gain_buffalo = true;
17  }
18  
19 +static int ath79_request_ext_lna_gpio(unsigned chain, int gpio)
20 +{
21 +       char buf[32];
22 +       char *label;
23 +       int err;
24 +
25 +       scnprintf(buf, sizeof(buf), "external LNA%u", chain);
26 +       label = kstrdup(buf, GFP_KERNEL);
27 +
28 +       err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label);
29 +       if (err) {
30 +               pr_err("unable to request GPIO%d for external LNA%u\n",
31 +                       gpio, chain);
32 +               kfree(label);
33 +       }
34 +
35 +       return err;
36 +}
37 +
38 +static void ar934x_set_ext_lna_gpio(unsigned chain, int gpio)
39 +{
40 +       unsigned int sel;
41 +       int err;
42 +
43 +       if (WARN_ON(chain > 1))
44 +               return;
45 +
46 +       err = ath79_request_ext_lna_gpio(chain, gpio);
47 +       if (err)
48 +               return;
49 +
50 +       if (chain == 0)
51 +               sel = AR934X_GPIO_OUT_EXT_LNA0;
52 +       else
53 +               sel = AR934X_GPIO_OUT_EXT_LNA1;
54 +
55 +       ath79_gpio_output_select(gpio, sel);
56 +}
57 +
58 +void __init ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio)
59 +{
60 +       if (soc_is_ar934x())
61 +               ar934x_set_ext_lna_gpio(chain, gpio);
62 +}
63 +
64  void __init ath79_register_wmac(u8 *cal_data, u8 *mac_addr)
65  {
66         if (soc_is_ar913x())
67 --- a/arch/mips/ath79/dev-wmac.h
68 +++ b/arch/mips/ath79/dev-wmac.h
69 @@ -17,6 +17,7 @@ void ath79_register_wmac_simple(void);
70  void ath79_wmac_disable_2ghz(void);
71  void ath79_wmac_disable_5ghz(void);
72  void ath79_wmac_set_tx_gain_buffalo(void);
73 +void ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio);
74  
75  bool ar93xx_wmac_read_mac_address(u8 *dest);
76