summaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2014-01-10 09:37:57 +0000
committerGabor Juhos <juhosg@openwrt.org>2014-01-10 09:37:57 +0000
commit182e8ef949e422b5b06bb8bf4d5b1bc36b496b21 (patch)
treeef55ac9f51948c1e9af4190657e4aa54bb575ecc /target
parent32aef686f7c8450b193ede200452a647471b9099 (diff)
downloadmtk-20170518-182e8ef949e422b5b06bb8bf4d5b1bc36b496b21.zip
mtk-20170518-182e8ef949e422b5b06bb8bf4d5b1bc36b496b21.tar.gz
mtk-20170518-182e8ef949e422b5b06bb8bf4d5b1bc36b496b21.tar.bz2
ar71xx: add a helper function for external LNA GPIO setup
The built-in wireless MAC of the AR934x SoC can handle external LNAs and the control signal of the LNAs can be routed to any GPIO line. Add a helper function which can be used to configure the GPIO lines. The helper function will be used for AR934x boards which are using externel LNAs to improve sensitivity. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> SVN-Revision: 39215
Diffstat (limited to 'target')
-rw-r--r--target/linux/ar71xx/patches-3.10/601-MIPS-ath79-add-more-register-defines.patch4
-rw-r--r--target/linux/ar71xx/patches-3.10/613-MIPS-ath79-add-ath79_wmac_setup_ext_lna_gpio-helper.patch76
2 files changed, 79 insertions, 1 deletions
diff --git a/target/linux/ar71xx/patches-3.10/601-MIPS-ath79-add-more-register-defines.patch b/target/linux/ar71xx/patches-3.10/601-MIPS-ath79-add-more-register-defines.patch
index 4812a62..81a997b 100644
--- a/target/linux/ar71xx/patches-3.10/601-MIPS-ath79-add-more-register-defines.patch
+++ b/target/linux/ar71xx/patches-3.10/601-MIPS-ath79-add-more-register-defines.patch
@@ -207,7 +207,7 @@
#define AR934X_GPIO_REG_FUNC 0x6c
#define AR71XX_GPIO_COUNT 16
-@@ -561,4 +664,146 @@
+@@ -561,4 +664,148 @@
#define AR934X_SRIF_DPLL2_OUTDIV_SHIFT 13
#define AR934X_SRIF_DPLL2_OUTDIV_MASK 0x7
@@ -284,6 +284,8 @@
+#define AR934X_GPIO_OUT_LED_LINK2 43
+#define AR934X_GPIO_OUT_LED_LINK3 44
+#define AR934X_GPIO_OUT_LED_LINK4 45
++#define AR934X_GPIO_OUT_EXT_LNA0 46
++#define AR934X_GPIO_OUT_EXT_LNA1 47
+
+/*
+ * MII_CTRL block
diff --git a/target/linux/ar71xx/patches-3.10/613-MIPS-ath79-add-ath79_wmac_setup_ext_lna_gpio-helper.patch b/target/linux/ar71xx/patches-3.10/613-MIPS-ath79-add-ath79_wmac_setup_ext_lna_gpio-helper.patch
new file mode 100644
index 0000000..83de7b1
--- /dev/null
+++ b/target/linux/ar71xx/patches-3.10/613-MIPS-ath79-add-ath79_wmac_setup_ext_lna_gpio-helper.patch
@@ -0,0 +1,76 @@
+--- a/arch/mips/ath79/dev-wmac.c
++++ b/arch/mips/ath79/dev-wmac.c
+@@ -18,9 +18,11 @@
+ #include <linux/etherdevice.h>
+ #include <linux/platform_device.h>
+ #include <linux/ath9k_platform.h>
++#include <linux/gpio.h>
+
+ #include <asm/mach-ath79/ath79.h>
+ #include <asm/mach-ath79/ar71xx_regs.h>
++#include "common.h"
+ #include "dev-wmac.h"
+
+ static u8 ath79_wmac_mac[ETH_ALEN];
+@@ -311,6 +313,51 @@ void __init ath79_wmac_set_tx_gain_buffa
+ ath79_wmac_data.tx_gain_buffalo = true;
+ }
+
++static int ath79_request_ext_lna_gpio(unsigned chain, int gpio)
++{
++ char buf[32];
++ char *label;
++ int err;
++
++ scnprintf(buf, sizeof(buf), "external LNA%u", chain);
++ label = kstrdup(buf, GFP_KERNEL);
++
++ err = gpio_request_one(gpio, GPIOF_DIR_OUT | GPIOF_INIT_LOW, label);
++ if (err) {
++ pr_err("unable to request GPIO%d for external LNA%u\n",
++ gpio, chain);
++ kfree(label);
++ }
++
++ return err;
++}
++
++static void ar934x_set_ext_lna_gpio(unsigned chain, int gpio)
++{
++ unsigned int sel;
++ int err;
++
++ if (WARN_ON(chain > 1))
++ return;
++
++ err = ath79_request_ext_lna_gpio(chain, gpio);
++ if (err)
++ return;
++
++ if (chain == 0)
++ sel = AR934X_GPIO_OUT_EXT_LNA0;
++ else
++ sel = AR934X_GPIO_OUT_EXT_LNA1;
++
++ ath79_gpio_output_select(gpio, sel);
++}
++
++void __init ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio)
++{
++ if (soc_is_ar934x())
++ ar934x_set_ext_lna_gpio(chain, gpio);
++}
++
+ void __init ath79_register_wmac(u8 *cal_data, u8 *mac_addr)
+ {
+ if (soc_is_ar913x())
+--- a/arch/mips/ath79/dev-wmac.h
++++ b/arch/mips/ath79/dev-wmac.h
+@@ -17,6 +17,7 @@ void ath79_register_wmac_simple(void);
+ void ath79_wmac_disable_2ghz(void);
+ void ath79_wmac_disable_5ghz(void);
+ void ath79_wmac_set_tx_gain_buffalo(void);
++void ath79_wmac_set_ext_lna_gpio(unsigned chain, int gpio);
+
+ bool ar93xx_wmac_read_mac_address(u8 *dest);
+