Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cc2520: Add support for CC2591 amplifier.

The TI CC2521 is an RF power amplifier that is designed to interface
with the CC2520. Conveniently, it directly interfaces with the CC2520
and does not require any pins to be connected to a
microcontroller/processor. Adding a CC2591 increases the CC2520's range,
which is useful for border router and other wall-powered applications.

Using the CC2591 with the CC2520 requires configuring the CC2520 GPIOs
that are connected to the CC2591 to correctly set the CC2591 into TX and
RX modes. Further, TI recommends that the CC2520_TXPOWER and
CC2520_AGCCTRL1 registers are set differently to maximize the CC2591's
performance. These settings are covered in TI Application Note AN065.

This patch adds an optional `amplified` field to the cc2520 entry in the
device tree. If present, the CC2520 will be configured to operate with a
CC2591.

The expected pin mapping is:
CC2520 GPIO0 --> CC2591 EN
CC2520 GPIO5 --> CC2591 PAEN

Signed-off-by: Brad Campbell <bradjc5@gmail.com>
Acked-by: Varka Bhadram <varkabhadram@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Brad Campbell and committed by
Marcel Holtmann
f0b7d43c 0db055c9

+52 -8
+4
Documentation/devicetree/bindings/net/ieee802154/cc2520.txt
··· 13 13 - cca-gpio: GPIO spec for the CCA pin 14 14 - vreg-gpio: GPIO spec for the VREG pin 15 15 - reset-gpio: GPIO spec for the RESET pin 16 + Optional properties: 17 + - amplified: include if the CC2520 is connected to a CC2591 amplifier 18 + 16 19 Example: 17 20 cc2520@0 { 18 21 compatible = "ti,cc2520"; 19 22 reg = <0>; 20 23 spi-max-frequency = <4000000>; 24 + amplified; 21 25 pinctrl-names = "default"; 22 26 pinctrl-0 = <&cc2520_cape_pins>; 23 27 fifo-gpio = <&gpio1 18 0>;
+47 -8
drivers/net/ieee802154/cc2520.c
··· 738 738 pdata->vreg = of_get_named_gpio(np, "vreg-gpio", 0); 739 739 pdata->reset = of_get_named_gpio(np, "reset-gpio", 0); 740 740 741 + pdata->amplified = of_property_read_bool(np, "amplified"); 742 + 741 743 return 0; 742 744 } 743 745 ··· 748 746 u8 status = 0, state = 0xff; 749 747 int ret; 750 748 int timeout = 100; 749 + struct cc2520_platform_data pdata; 750 + 751 + ret = cc2520_get_platform_data(priv->spi, &pdata); 752 + if (ret) 753 + goto err_ret; 751 754 752 755 ret = cc2520_read_register(priv, CC2520_FSMSTAT1, &state); 753 756 if (ret) ··· 775 768 776 769 dev_vdbg(&priv->spi->dev, "oscillator brought up\n"); 777 770 778 - /* Registers default value: section 28.1 in Datasheet */ 779 - ret = cc2520_write_register(priv, CC2520_TXPOWER, 0xF7); 780 - if (ret) 781 - goto err_ret; 771 + /* If the CC2520 is connected to a CC2591 amplifier, we must both 772 + * configure GPIOs on the CC2520 to correctly configure the CC2591 773 + * and change a couple settings of the CC2520 to work with the 774 + * amplifier. See section 8 page 17 of TI application note AN065. 775 + * http://www.ti.com/lit/an/swra229a/swra229a.pdf 776 + */ 777 + if (pdata.amplified) { 778 + ret = cc2520_write_register(priv, CC2520_TXPOWER, 0xF9); 779 + if (ret) 780 + goto err_ret; 782 781 782 + ret = cc2520_write_register(priv, CC2520_AGCCTRL1, 0x16); 783 + if (ret) 784 + goto err_ret; 785 + 786 + ret = cc2520_write_register(priv, CC2520_GPIOCTRL0, 0x46); 787 + if (ret) 788 + goto err_ret; 789 + 790 + ret = cc2520_write_register(priv, CC2520_GPIOCTRL5, 0x47); 791 + if (ret) 792 + goto err_ret; 793 + 794 + ret = cc2520_write_register(priv, CC2520_GPIOPOLARITY, 0x1e); 795 + if (ret) 796 + goto err_ret; 797 + 798 + ret = cc2520_write_register(priv, CC2520_TXCTRL, 0xc1); 799 + if (ret) 800 + goto err_ret; 801 + } else { 802 + ret = cc2520_write_register(priv, CC2520_TXPOWER, 0xF7); 803 + if (ret) 804 + goto err_ret; 805 + 806 + ret = cc2520_write_register(priv, CC2520_AGCCTRL1, 0x11); 807 + if (ret) 808 + goto err_ret; 809 + } 810 + 811 + /* Registers default value: section 28.1 in Datasheet */ 783 812 ret = cc2520_write_register(priv, CC2520_CCACTRL0, 0x1A); 784 813 if (ret) 785 814 goto err_ret; ··· 837 794 goto err_ret; 838 795 839 796 ret = cc2520_write_register(priv, CC2520_FSCAL1, 0x2b); 840 - if (ret) 841 - goto err_ret; 842 - 843 - ret = cc2520_write_register(priv, CC2520_AGCCTRL1, 0x11); 844 797 if (ret) 845 798 goto err_ret; 846 799
+1
include/linux/spi/cc2520.h
··· 21 21 int sfd; 22 22 int reset; 23 23 int vreg; 24 + bool amplified; 24 25 }; 25 26 26 27 #endif